|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86: introduce using_{svm,vmx}() helpers
commit 3f7efa20e4f31601657b16e32d1289002aa8ee25
Author: Sergiy Kibrik <Sergiy_Kibrik@xxxxxxxx>
AuthorDate: Thu Aug 1 13:55:39 2024 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Aug 1 13:55:39 2024 +0200
x86: introduce using_{svm,vmx}() helpers
As we now have AMD_SVM/INTEL_VMX config options for enabling/disabling these
features completely in the build, we need some build-time checks to ensure
that
vmx/svm code can be used and things compile. Macros cpu_has_{svm,vmx} used
to be
doing such checks at runtime, however they do not check if SVM/VMX support
is
enabled in the build.
Also cpu_has_{svm,vmx} can potentially be called from non-{VMX,SVM} build
yet running on {VMX,SVM}-enabled CPU, so would correctly indicate that
VMX/SVM
is indeed supported by CPU, but code to drive it can't be used.
New routines using_{vmx,svm}() indicate that both CPU _and_ build provide
corresponding technology support, while cpu_has_{vmx,svm} still remains for
informational runtime purpose, just as their naming suggests.
These new helpers are used right away in several sites, namely guard calls
to
start_nested_{svm,vmx} and start_{svm,vmx} to fix a build when INTEL_VMX=n
or
AMD_SVM=n.
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@xxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 4 ++--
xen/arch/x86/hvm/nestedhvm.c | 4 ++--
xen/arch/x86/include/asm/hvm/hvm.h | 10 ++++++++++
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d7f195ba9a..9f37db494d 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -155,9 +155,9 @@ static int __init cf_check hvm_enable(void)
{
const struct hvm_function_table *fns = NULL;
- if ( cpu_has_vmx )
+ if ( using_vmx() )
fns = start_vmx();
- else if ( cpu_has_svm )
+ else if ( using_svm() )
fns = start_svm();
if ( fns == NULL )
diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c
index d895a73844..bddd77d810 100644
--- a/xen/arch/x86/hvm/nestedhvm.c
+++ b/xen/arch/x86/hvm/nestedhvm.c
@@ -155,9 +155,9 @@ static int __init cf_check nestedhvm_setup(void)
* done, so that if (for example) HAP is disabled, nested virt is
* disabled as well.
*/
- if ( cpu_has_vmx )
+ if ( using_vmx() )
start_nested_vmx(&hvm_funcs);
- else if ( cpu_has_svm )
+ else if ( using_svm() )
start_nested_svm(&hvm_funcs);
return 0;
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h
b/xen/arch/x86/include/asm/hvm/hvm.h
index 34824af6df..518ba5319b 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -363,6 +363,16 @@ int hvm_copy_context_and_params(struct domain *dst, struct
domain *src);
int hvm_get_param(struct domain *d, uint32_t index, uint64_t *value);
+static inline bool using_vmx(void)
+{
+ return IS_ENABLED(CONFIG_INTEL_VMX) && cpu_has_vmx;
+}
+
+static inline bool using_svm(void)
+{
+ return IS_ENABLED(CONFIG_AMD_SVM) && cpu_has_svm;
+}
+
#ifdef CONFIG_HVM
#define hvm_get_guest_tsc(v) hvm_get_guest_tsc_fixed(v, 0)
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |