From nobody Mon Nov 25 07:47:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1715598728; cv=none; d=zohomail.com; s=zohoarc; b=e+MV4fHwFeOj36tkw8i+iOTt//m+waEVE4mqT7JHNRY37n9Jhra4Dpqi4661E0BVKerthuPsGmtKrtDHK5wQsaQ/FZrEFsqHs/+eVV0I/ITSqNp4Na+lynhNxhcRP3K5jHPU7AGwN+a4h2Rxc67TN3IDDL470JYw0/oaI3TKCdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715598728; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZJrhmMV/WsLJjJ2b/S8Feij3BU9bNlhqRg9vQL1/RK0=; b=K77e7dIXEFqvxWT5UTLQU0L5gn4lOWkOVOOdgbav167yApdXoiFOo2DuO7Armc/MKVaxXVfuF6+Bmpsx9teL8wHg3ufk4LNLhLF/ITDdQAk/CbT9zDfMSMc9v0JnFh7UTfgUvxGYSkaj4P+qrHN+CdRO74+nFWd+7mvm/ynUa5I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1715598728302462.6140789459745; Mon, 13 May 2024 04:12:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.720808.1123762 (Exim 4.92) (envelope-from ) id 1s6Taw-0004D3-Gn; Mon, 13 May 2024 11:11:50 +0000 Received: by outflank-mailman (output) from mailman id 720808.1123762; Mon, 13 May 2024 11:11:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s6Taw-0004Cu-Dv; Mon, 13 May 2024 11:11:50 +0000 Received: by outflank-mailman (input) for mailman id 720808; Mon, 13 May 2024 11:11:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s6Tav-0003MC-9W for xen-devel@lists.xenproject.org; Mon, 13 May 2024 11:11:49 +0000 Received: from smtp-fw-52002.amazon.com (smtp-fw-52002.amazon.com [52.119.213.150]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 96e9b605-1119-11ef-909d-e314d9c70b13; Mon, 13 May 2024 13:11:48 +0200 (CEST) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-52002.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2024 11:11:46 +0000 Received: from EX19MTAUEB001.ant.amazon.com [10.0.44.209:62332] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.4.17:2525] with esmtp (Farcaster) id 0d4825d0-82ef-4415-bce3-98ee92835dc2; Mon, 13 May 2024 11:11:45 +0000 (UTC) Received: from EX19D008UEA001.ant.amazon.com (10.252.134.62) by EX19MTAUEB001.ant.amazon.com (10.252.135.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 13 May 2024 11:11:42 +0000 Received: from EX19MTAUWB001.ant.amazon.com (10.250.64.248) by EX19D008UEA001.ant.amazon.com (10.252.134.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 13 May 2024 11:11:42 +0000 Received: from dev-dsk-eliasely-1a-fd74790f.eu-west-1.amazon.com (10.253.91.118) by mail-relay.amazon.com (10.250.64.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28 via Frontend Transport; Mon, 13 May 2024 11:11:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 96e9b605-1119-11ef-909d-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1715598708; x=1747134708; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZJrhmMV/WsLJjJ2b/S8Feij3BU9bNlhqRg9vQL1/RK0=; b=Dr+pWSjzsuHSbbU8DvY6NanqzLZY6/Aqbhnb6fxlLgKy9em0bownbQFF XkVSkDz206yKhLB5H85kwIGsP6ZOIGB0GRncEKwN+ShJufpzGyKoPr10T ati6Uq51kcuJyIIdFIpk+EsmBBieiVoNwNyFEOCrFfINqOeuWQKo0NjFP A=; X-IronPort-AV: E=Sophos;i="6.08,158,1712620800"; d="scan'208";a="632473707" X-Farcaster-Flow-ID: 0d4825d0-82ef-4415-bce3-98ee92835dc2 From: Elias El Yandouzi To: CC: , , , Julien Grall , Elias El Yandouzi Subject: [PATCH V3 07/19] xen/x86: Add support for the PMAP Date: Mon, 13 May 2024 11:11:05 +0000 Message-ID: <20240513111117.68828-8-eliasely@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240513111117.68828-1-eliasely@amazon.com> References: <20240513111117.68828-1-eliasely@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1715598729904100005 Content-Type: text/plain; charset="utf-8" From: Julien Grall PMAP will be used in a follow-up patch to bootstrap map domain page infrastructure -- we need some way to map pages to setup the mapcache without a direct map. The functions pmap_{map, unmap} open code {set, clear}_fixmap to break the loop. Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi ---- The PMAP infrastructure was upstream separately for Arm since Hongyan sent the secret-free hypervisor series. So this is a new patch to plumb the feature on x86. Changes in v2: * Declare PMAP entries earlier in fixed_addresses * Reword the commit message diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index b4ec0e582e..56feb0c564 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -27,6 +27,7 @@ config X86 select HAS_PCI select HAS_PCI_MSI select HAS_PIRQ + select HAS_PMAP select HAS_SCHED_GRANULARITY select HAS_SECRET_HIDING select HAS_UBSAN diff --git a/xen/arch/x86/include/asm/fixmap.h b/xen/arch/x86/include/asm/f= ixmap.h index 516ec3fa6c..a7ac365fc6 100644 --- a/xen/arch/x86/include/asm/fixmap.h +++ b/xen/arch/x86/include/asm/fixmap.h @@ -21,6 +21,8 @@ =20 #include #include +#include + #include #include #include @@ -53,6 +55,8 @@ enum fixed_addresses { FIX_PV_CONSOLE, FIX_XEN_SHARED_INFO, #endif /* CONFIG_XEN_GUEST */ + FIX_PMAP_BEGIN, + FIX_PMAP_END =3D FIX_PMAP_BEGIN + NUM_FIX_PMAP, /* Everything else should go further down. */ FIX_APIC_BASE, FIX_IO_APIC_BASE_0, diff --git a/xen/arch/x86/include/asm/pmap.h b/xen/arch/x86/include/asm/pma= p.h new file mode 100644 index 0000000000..62746e191d --- /dev/null +++ b/xen/arch/x86/include/asm/pmap.h @@ -0,0 +1,25 @@ +#ifndef __ASM_PMAP_H__ +#define __ASM_PMAP_H__ + +#include + +static inline void arch_pmap_map(unsigned int slot, mfn_t mfn) +{ + unsigned long linear =3D (unsigned long)fix_to_virt(slot); + l1_pgentry_t *pl1e =3D &l1_fixmap[l1_table_offset(linear)]; + + ASSERT(!(l1e_get_flags(*pl1e) & _PAGE_PRESENT)); + + l1e_write_atomic(pl1e, l1e_from_mfn(mfn, PAGE_HYPERVISOR)); +} + +static inline void arch_pmap_unmap(unsigned int slot) +{ + unsigned long linear =3D (unsigned long)fix_to_virt(slot); + l1_pgentry_t *pl1e =3D &l1_fixmap[l1_table_offset(linear)]; + + l1e_write_atomic(pl1e, l1e_empty()); + flush_tlb_one_local(linear); +} + +#endif /* __ASM_PMAP_H__ */ --=20 2.40.1