Virtual GIF
v2 cover Virtual GIF
On AMD family 17h processors, there is a feature called virtual GIF. This allows a nested hypervisor to preform a CLGI or STGI without needing to be intercepted by the host hypervisor. For more information about it please see:
AMD64 Architecture Programmer’s Manual Volume 2: System Programming
http://support.amd.com/TechDocs/24593.pdf
Section: Virtual GIF (Section 15.33.2)
This patch series adds support to check for and enable the virtual GIF features if available.
These patches were tested on a AMD family 17h (EPYC 7401) system.
Brian Woods (2):
x86/svm: Add virtual GIF feature definition
x86/svm: Add virtual GIF support
xen/arch/x86/hvm/svm/nestedsvm.c | 7 ++++++- xen/arch/x86/hvm/svm/svm.c | 1 + xen/arch/x86/hvm/svm/vmcb.c | 12 ++++++++++++ xen/include/asm-x86/hvm/svm/svm.h | 2 ++ xen/include/asm-x86/hvm/svm/vmcb.h | 6 ++++-- 5 files changed, 25 insertions(+), 3 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 1/2 x86/svm: Add virtual GIF feature definition
Add support for enabling the virtual GIF feature.
--- xen/include/asm-x86/hvm/svm/svm.h | 2 ++ xen/include/asm-x86/hvm/svm/vmcb.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
xen/include/asm-x86/hvm/svm/svm.h +2 -0
@@ -64,6 +64,7 @@ extern u32 svm_feature_flags;#define SVM_FEATURE_FLUSHBYASID 6/* TLB flush by ASID support */ #define SVM_FEATURE_DECODEASSISTS 7/* Decode assists support */ #define SVM_FEATURE_PAUSEFILTER 10/* Pause intercept filter support */ +#define SVM_FEATURE_VGIF 16/* Virtual GIF */ #define cpu_has_svm_feature (f) test_bit(f, &svm_feature_flags)#define cpu_has_svm_npt cpu_has_svm_feature(SVM_FEATURE_NPT)
@@ -72,6 +73,7 @@ extern u32 svm_feature_flags;#define cpu_has_svm_nrips cpu_has_svm_feature(SVM_FEATURE_NRIPS)#define cpu_has_svm_cleanbits cpu_has_svm_feature(SVM_FEATURE_VMCBCLEAN)#define cpu_has_svm_decode cpu_has_svm_feature(SVM_FEATURE_DECODEASSISTS) +#define cpu_has_svm_vgif cpu_has_svm_feature(SVM_FEATURE_VGIF)#define cpu_has_pause_filter cpu_has_svm_feature(SVM_FEATURE_PAUSEFILTER)#define cpu_has_tsc_ratio cpu_has_svm_feature(SVM_FEATURE_TSCRATEMSR)
xen/include/asm-x86/hvm/svm/vmcb.h +4 -2
@@ -325,12 +325,14 @@ typedef union { u64 tpr: 8; u64 irq: 1; - u64 rsvd0: 7; + u64 vgif: 1; + u64 rsvd0: 6; u64 prio: 4; u64 ign_tpr: 1; u64 rsvd1: 3; u64 intr_masking: 1; - u64 rsvd2: 7; + u64 vgif_enable: 1; + u64 rsvd2: 6; u64 vector: 8; u64 rsvd3: 24; } fields;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition
Quoted 7 lines · Brian Woods
Add support for enabling the virtual GIF feature.
Signed-off-by Brian Woods <[email protected]>--- xen/include/asm-x86/hvm/svm/svm.h | 2 ++ xen/include/asm-x86/hvm/svm/vmcb.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
The patch says 'v2', but I don't see anything having changed here.
Usually one adds comments in here (right after ---) with something to the effect of:
v1: New version
v2: Nothing new.
Or if something did change (like in second patch), you say exactly what changed.
Thanks!
Quoted 50 lines
xen/include/asm-x86/hvm/svm/svm.h +2
-0@@ -64,6 +64,7 @@ extern u32 svm_feature_flags;#define SVM_FEATURE_FLUSHBYASID 6/* TLB flush by ASID support */ #define SVM_FEATURE_DECODEASSISTS 7/* Decode assists support */ #define SVM_FEATURE_PAUSEFILTER 10/* Pause intercept filter support */ +#define SVM_FEATURE_VGIF 16/* Virtual GIF */ #define cpu_has_svm_feature (f) test_bit(f, &svm_feature_flags)#define cpu_has_svm_npt cpu_has_svm_feature(SVM_FEATURE_NPT)@@ -72,6 +73,7 @@ extern u32 svm_feature_flags;#define cpu_has_svm_nrips cpu_has_svm_feature(SVM_FEATURE_NRIPS)#define cpu_has_svm_cleanbits cpu_has_svm_feature(SVM_FEATURE_VMCBCLEAN)#define cpu_has_svm_decode cpu_has_svm_feature(SVM_FEATURE_DECODEASSISTS) +#define cpu_has_svm_vgif cpu_has_svm_feature(SVM_FEATURE_VGIF)#define cpu_has_pause_filter cpu_has_svm_feature(SVM_FEATURE_PAUSEFILTER)#define cpu_has_tsc_ratio cpu_has_svm_feature(SVM_FEATURE_TSCRATEMSR)xen/include/asm-x86/hvm/svm/vmcb.h +4
-2@@ -325,12 +325,14 @@ typedef union { u64 tpr: 8; u64 irq: 1; - u64 rsvd0: 7; + u64 vgif: 1; + u64 rsvd0: 6; u64 prio: 4; u64 ign_tpr: 1; u64 rsvd1: 3; u64 intr_masking: 1; - u64 rsvd2: 7; + u64 vgif_enable: 1; + u64 rsvd2: 6; u64 vector: 8; u64 rsvd3: 24; } fields;Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition
Quoted 11 lines · Konrad Rzeszutek Wilk
The patch says 'v2', but I don't see anything having changed here.
Usually one adds comments in here (right after ---) with something to the effect of:
v1: New version
v2: Nothing new.Or if something did change (like in second patch), you say exactly what changed.
Thanks!
Sorry about forgetting that. I'll make sure to do that in the future.
The change log for this one was:
- Change the test condition from if it had the vgif feature to if it's enabled in the vmcb
- Update for the use of C99 bool type
There was some discussion in the irc channel so I'm not sure if there's going be another version soon or not. I need to fix the style error I have with the else anyway.
Thank you for the feedback.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 2/2 x86/svm: Add virtual GIF support
In reply to Brian WoodsThis patch detects and enables Virtual GIF if available. This allows a nested hypervisor to perform STGIs and CLGIs without having to be intercepted by host hypervisor.
--- xen/arch/x86/hvm/svm/nestedsvm.c | 7 ++++++- xen/arch/x86/hvm/svm/svm.c | 1 + xen/arch/x86/hvm/svm/vmcb.c | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/svm/nestedsvm.c +6 -1
@@ -1597,8 +1597,13 @@ bool_t nestedsvm_gif_isset(struct vcpu *v) {struct nestedsvm *svm = &vcpu_nestedsvm (v); +struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -return (!!svm->ns_gif); +/* get the vmcb gif value if using vgif */ +if ( vmcb->_vintr.fields.vgif_enable ) +return vmcb->_vintr.fields.vgif; +else +return svm->ns_gif; }void svm_vmexit_do_stgi (struct cpu_user_regs *regs,struct vcpu *v)
xen/arch/x86/hvm/svm/svm.c +1 -0
@@ -1669,6 +1669,7 @@ const struct hvm_function_table * __init start_svm(void)P (cpu_has_svm_nrips,"Next-RIP Saved on #VMEXIT" );P (cpu_has_svm_cleanbits,"VMCB Clean Bits" );P (cpu_has_svm_decode,"DecodeAssists" ); +P (cpu_has_svm_vgif,"Virtual GIF" );P (cpu_has_pause_filter,"Pause-Intercept Filter" );P (cpu_has_tsc_ratio,"TSC Rate MSR" );#undef P
xen/arch/x86/hvm/svm/vmcb.c +12 -0
@@ -206,6 +206,18 @@ static int construct_vmcb(struct vcpu *v) vmcb->_exception_intercepts |= (1U << TRAP_page_fault); } +/* if available, enable and configure virtual gif */ +if ( cpu_has_svm_vgif ) + { + vmcb->_vintr.fields.vgif =1 ; + vmcb->_vintr.fields.vgif_enable =1 ; + vmcb->_general2_intercepts &= ~GENERAL2_INTERCEPT_STGI ; + vmcb->_general2_intercepts &= ~GENERAL2_INTERCEPT_CLGI ; + } +else { + vmcb->_vintr.fields.vgif_enable =0 ; + } +if ( cpu_has_pause_filter ) { vmcb->_pause_filter_count =SVM_PAUSEFILTER_INIT ;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 18 lines · Brian Woods
On AMD family 17h processors, there is a feature called virtual GIF. This allows a nested hypervisor to preform a CLGI or STGI without needing to be intercepted by the host hypervisor. For more information about it please see:
AMD64 Architecture Programmer’s Manual Volume 2: System Programming
http://support.amd.com/TechDocs/24593.pdf
Section: Virtual GIF (Section 15.33.2)This patch series adds support to check for and enable the virtual GIF features if available.
These patches were tested on a AMD family 17h (EPYC 7401) system.
Brian Woods (2):
x86/svm: Add virtual GIF feature definition
x86/svm: Add virtual GIF support
Quoted 7 lines
xen/arch/x86/hvm/svm/nestedsvm.c | 7 ++++++- xen/arch/x86/hvm/svm/svm.c | 1 + xen/arch/x86/hvm/svm/vmcb.c | 12 ++++++++++++ xen/include/asm-x86/hvm/svm/svm.h | 2 ++ xen/include/asm-x86/hvm/svm/vmcb.h | 6 ++++-- 5 files changed, 25 insertions(+), 3 deletions(-)
(with or without 'else' style changes in the second patch)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel