From: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
To: xen-devel@lists.xenproject.org
Cc: "Sergiy Kibrik" <Sergiy_Kibrik@epam.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Xenia Ragiadakou" <xenia.ragiadakou@amd.com>,
"Tamas K Lengyel" <tamas@tklengyel.com>
Subject: [XEN PATCH v2 06/15] x86/p2m: guard altp2m code with CONFIG_ALTP2M option
Date: Wed, 15 May 2024 12:10:16 +0300 [thread overview]
Message-ID: <7a6980b1c67dedb306985f73afb23db359771e8f.1715761386.git.Sergiy_Kibrik@epam.com> (raw)
In-Reply-To: <cover.1715761386.git.Sergiy_Kibrik@epam.com>
Instead of using generic CONFIG_HVM option switch to a bit more specific
CONFIG_ALTP2M option for altp2m support. Also guard altp2m routines, so that
they can be disabled completely in the build -- when target platform does not
actually support altp2m (AMD-V & ARM as of now).
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
CC: Tamas K Lengyel <tamas@tklengyel.com>
---
changes in v2:
- use separate CONFIG_ALTP2M option instead of CONFIG_VMX
---
xen/arch/x86/include/asm/altp2m.h | 5 ++++-
xen/arch/x86/include/asm/hvm/hvm.h | 2 +-
xen/arch/x86/include/asm/p2m.h | 17 ++++++++++++++++-
xen/arch/x86/mm/Makefile | 2 +-
4 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/altp2m.h
index e5e59cbd68..092b13e231 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -7,7 +7,7 @@
#ifndef __ASM_X86_ALTP2M_H
#define __ASM_X86_ALTP2M_H
-#ifdef CONFIG_HVM
+#ifdef CONFIG_ALTP2M
#include <xen/types.h>
#include <xen/sched.h> /* for struct vcpu, struct domain */
@@ -38,7 +38,10 @@ static inline bool altp2m_active(const struct domain *d)
}
/* Only declaration is needed. DCE will optimise it out when linking. */
+void altp2m_vcpu_initialise(struct vcpu *v);
+void altp2m_vcpu_destroy(struct vcpu *v);
uint16_t altp2m_vcpu_idx(const struct vcpu *v);
+int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn);
void altp2m_vcpu_disable_ve(struct vcpu *v);
#endif
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index 0c9e6f1564..4f03dd7af8 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -670,7 +670,7 @@ static inline bool hvm_hap_supported(void)
/* returns true if hardware supports alternate p2m's */
static inline bool hvm_altp2m_supported(void)
{
- return hvm_funcs.caps.altp2m;
+ return IS_ENABLED(CONFIG_ALTP2M) && hvm_funcs.caps.altp2m;
}
/* Returns true if we have the minimum hardware requirements for nested virt */
diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 111badf89a..855e69d24a 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -581,9 +581,9 @@ static inline gfn_t mfn_to_gfn(const struct domain *d, mfn_t mfn)
return _gfn(mfn_x(mfn));
}
-#ifdef CONFIG_HVM
#define AP2MGET_prepopulate true
#define AP2MGET_query false
+#ifdef CONFIG_ALTP2M
/*
* Looks up altp2m entry. If the entry is not found it looks up the entry in
@@ -593,6 +593,15 @@ static inline gfn_t mfn_to_gfn(const struct domain *d, mfn_t mfn)
int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn,
p2m_type_t *t, p2m_access_t *a,
bool prepopulate);
+#else
+static inline int altp2m_get_effective_entry(struct p2m_domain *ap2m,
+ gfn_t gfn, mfn_t *mfn,
+ p2m_type_t *t, p2m_access_t *a,
+ bool prepopulate)
+{
+ ASSERT_UNREACHABLE();
+ return -EOPNOTSUPP;
+}
#endif
/* Init the datastructures for later use by the p2m code */
@@ -909,8 +918,14 @@ static inline bool p2m_set_altp2m(struct vcpu *v, unsigned int idx)
/* Switch alternate p2m for a single vcpu */
bool p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx);
+#ifdef CONFIG_ALTP2M
/* Check to see if vcpu should be switched to a different p2m. */
void p2m_altp2m_check(struct vcpu *v, uint16_t idx);
+#else
+static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
+{
+}
+#endif
/* Flush all the alternate p2m's for a domain */
void p2m_flush_altp2m(struct domain *d);
diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile
index 0128ca7ab6..d7d57b8190 100644
--- a/xen/arch/x86/mm/Makefile
+++ b/xen/arch/x86/mm/Makefile
@@ -1,7 +1,7 @@
obj-y += shadow/
obj-$(CONFIG_HVM) += hap/
-obj-$(CONFIG_HVM) += altp2m.o
+obj-$(CONFIG_ALTP2M) += altp2m.o
obj-$(CONFIG_HVM) += guest_walk_2.o guest_walk_3.o guest_walk_4.o
obj-$(CONFIG_SHADOW_PAGING) += guest_walk_4.o
obj-$(CONFIG_MEM_ACCESS) += mem_access.o
--
2.25.1
next prev parent reply other threads:[~2024-05-15 9:10 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 8:57 [XEN PATCH v2 00/15] x86: make cpu virtualization support configurable Sergiy Kibrik
2024-05-15 8:59 ` [XEN PATCH v2 01/15] x86: introduce AMD-V and Intel VT-x Kconfig options Sergiy Kibrik
2024-05-16 10:09 ` Jan Beulich
2024-05-15 9:01 ` [XEN PATCH v2 02/15] x86/monitor: guard altp2m usage Sergiy Kibrik
2024-05-16 0:29 ` Stefano Stabellini
2024-05-16 10:20 ` Jan Beulich
2024-05-15 9:03 ` [XEN PATCH v2 03/15] x86/p2m: guard altp2m routines Sergiy Kibrik
2024-05-16 0:31 ` Stefano Stabellini
2024-05-16 10:26 ` Jan Beulich
2024-05-15 9:06 ` [XEN PATCH v2 04/15] x86/p2m: move altp2m-related code to separate file Sergiy Kibrik
2024-05-16 0:35 ` Stefano Stabellini
2024-05-16 11:46 ` Jan Beulich
2024-05-16 10:37 ` Jan Beulich
2024-05-15 9:08 ` [XEN PATCH v2 05/15] x86: introduce CONFIG_ALTP2M Kconfig option Sergiy Kibrik
2024-05-16 0:33 ` Stefano Stabellini
2024-05-16 10:41 ` Jan Beulich
2024-05-18 1:07 ` Tamas K Lengyel
2024-05-15 9:10 ` Sergiy Kibrik [this message]
2024-05-16 0:38 ` [XEN PATCH v2 06/15] x86/p2m: guard altp2m code with CONFIG_ALTP2M option Stefano Stabellini
2024-05-16 10:55 ` Jan Beulich
2024-05-16 11:01 ` Jan Beulich
2024-05-23 10:44 ` Sergiy Kibrik
2024-05-23 14:43 ` Jan Beulich
2024-05-15 9:12 ` [XEN PATCH v2 07/15] x86: guard cpu_has_{svm/vmx} macros with CONFIG_{SVM/VMX} Sergiy Kibrik
2024-05-16 0:38 ` Stefano Stabellini
2024-05-16 11:12 ` Jan Beulich
2024-05-23 13:07 ` Sergiy Kibrik
2024-05-23 14:50 ` Jan Beulich
2024-05-23 23:36 ` Stefano Stabellini
2024-05-24 6:49 ` Jan Beulich
2024-05-27 10:27 ` Sergiy Kibrik
2024-05-27 10:49 ` Jan Beulich
2024-05-15 9:14 ` [XEN PATCH v2 08/15] x86/vpmu: guard vmx/svm calls with cpu_has_{vmx,svm} Sergiy Kibrik
2024-05-16 0:44 ` Stefano Stabellini
2024-05-16 7:25 ` Jan Beulich
2024-05-16 11:23 ` Jan Beulich
2024-06-03 9:02 ` Sergiy Kibrik
2024-05-15 9:16 ` [XEN PATCH v2 09/15] x86/traps: clean up superfluous #idef-s Sergiy Kibrik
2024-05-16 0:45 ` Stefano Stabellini
2024-05-15 9:18 ` [XEN PATCH v2 10/15] x86/domain: " Sergiy Kibrik
2024-05-16 0:46 ` Stefano Stabellini
2024-05-15 9:20 ` [XEN PATCH v2 11/15] x86/oprofile: guard svm specific symbols with CONFIG_SVM Sergiy Kibrik
2024-05-15 9:22 ` [XEN PATCH v2 12/15] x86/vmx: guard access to cpu_has_vmx_* in common code Sergiy Kibrik
2024-05-16 0:50 ` Stefano Stabellini
2024-05-16 7:32 ` Jan Beulich
2024-05-29 10:58 ` Sergiy Kibrik
2024-05-29 12:16 ` Jan Beulich
2024-05-15 9:24 ` [XEN PATCH v2 13/15] x86/ioreq: guard VIO_realmode_completion with CONFIG_VMX Sergiy Kibrik
2024-05-16 0:51 ` Stefano Stabellini
2024-05-16 12:11 ` Jan Beulich
2024-05-31 8:05 ` Sergiy Kibrik
2024-05-31 8:31 ` Jan Beulich
2024-05-31 8:06 ` [XEN PATCH RFC] ioreq: make arch_vcpu_ioreq_completion() an optional callback Sergiy Kibrik
2024-05-15 9:26 ` [XEN PATCH v2 14/15] iommu/vt-d: guard vmx_pi_hooks_* calls with cpu_has_vmx Sergiy Kibrik
2024-05-16 0:54 ` Stefano Stabellini
2024-05-16 7:37 ` Jan Beulich
2024-05-16 23:41 ` Stefano Stabellini
2024-05-16 12:15 ` Jan Beulich
2024-06-03 9:34 ` Sergiy Kibrik
2024-05-15 9:28 ` [XEN PATCH v2 15/15] x86/hvm: make AMD-V and Intel VT-x support configurable Sergiy Kibrik
2024-05-16 0:54 ` Stefano Stabellini
2024-05-16 12:17 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7a6980b1c67dedb306985f73afb23db359771e8f.1715761386.git.Sergiy_Kibrik@epam.com \
--to=sergiy_kibrik@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--cc=xen-devel@lists.xenproject.org \
--cc=xenia.ragiadakou@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).