* [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition
2017-11-16 17:19 [PATCH v2 0/2] Virtual GIF Brian Woods
@ 2017-11-16 17:19 ` Brian Woods
2017-11-16 17:44 ` Konrad Rzeszutek Wilk
2017-11-16 17:19 ` [PATCH v2 2/2] x86/svm: Add virtual GIF support Brian Woods
2017-11-16 19:17 ` [PATCH v2 0/2] Virtual GIF Boris Ostrovsky
2 siblings, 1 reply; 6+ messages in thread
From: Brian Woods @ 2017-11-16 17:19 UTC (permalink / raw)
To: xen-devel
Cc: Andrew Cooper, Boris Ostrovsky, Brian Woods, Jan Beulich,
Suravee Suthikulpanit
Add support for enabling the virtual GIF feature.
Signed-off-by: Brian Woods <brian.woods@amd.com>
---
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(-)
diff --git a/xen/include/asm-x86/hvm/svm/svm.h b/xen/include/asm-x86/hvm/svm/svm.h
index 0956f860ef..ec1eda6a3e 100644
--- a/xen/include/asm-x86/hvm/svm/svm.h
+++ b/xen/include/asm-x86/hvm/svm/svm.h
@@ -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)
diff --git a/xen/include/asm-x86/hvm/svm/vmcb.h b/xen/include/asm-x86/hvm/svm/vmcb.h
index 01ce20b0bd..595cfcf57b 100644
--- a/xen/include/asm-x86/hvm/svm/vmcb.h
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -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;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition
2017-11-16 17:19 ` [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition Brian Woods
@ 2017-11-16 17:44 ` Konrad Rzeszutek Wilk
2017-11-16 18:01 ` Brian Woods
0 siblings, 1 reply; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2017-11-16 17:44 UTC (permalink / raw)
To: Brian Woods
Cc: Andrew Cooper, Boris Ostrovsky, Suravee Suthikulpanit,
Jan Beulich, xen-devel
On Thu, Nov 16, 2017 at 11:19:38AM -0600, Brian Woods wrote:
> Add support for enabling the virtual GIF feature.
>
> Signed-off-by: Brian Woods <brian.woods@amd.com>
> ---
> 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!
>
> diff --git a/xen/include/asm-x86/hvm/svm/svm.h b/xen/include/asm-x86/hvm/svm/svm.h
> index 0956f860ef..ec1eda6a3e 100644
> --- a/xen/include/asm-x86/hvm/svm/svm.h
> +++ b/xen/include/asm-x86/hvm/svm/svm.h
> @@ -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)
>
> diff --git a/xen/include/asm-x86/hvm/svm/vmcb.h b/xen/include/asm-x86/hvm/svm/vmcb.h
> index 01ce20b0bd..595cfcf57b 100644
> --- a/xen/include/asm-x86/hvm/svm/vmcb.h
> +++ b/xen/include/asm-x86/hvm/svm/vmcb.h
> @@ -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;
> --
> 2.11.0
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition
2017-11-16 17:44 ` Konrad Rzeszutek Wilk
@ 2017-11-16 18:01 ` Brian Woods
0 siblings, 0 replies; 6+ messages in thread
From: Brian Woods @ 2017-11-16 18:01 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: Jan Beulich, Andrew Cooper, xen-devel, Suravee Suthikulpanit,
Boris Ostrovsky, Brian Woods
On Thu, Nov 16, 2017 at 12:44:27PM -0500, Konrad Rzeszutek Wilk wrote:
> 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.
--
Brian Woods
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] x86/svm: Add virtual GIF support
2017-11-16 17:19 [PATCH v2 0/2] Virtual GIF Brian Woods
2017-11-16 17:19 ` [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition Brian Woods
@ 2017-11-16 17:19 ` Brian Woods
2017-11-16 19:17 ` [PATCH v2 0/2] Virtual GIF Boris Ostrovsky
2 siblings, 0 replies; 6+ messages in thread
From: Brian Woods @ 2017-11-16 17:19 UTC (permalink / raw)
To: xen-devel
Cc: Andrew Cooper, Boris Ostrovsky, Brian Woods, Jan Beulich,
Suravee Suthikulpanit
This 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.
Signed-off-by: Brian Woods <brian.woods@amd.com>
---
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(-)
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 1de896e456..0705cf9cb8 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -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)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index b9cf423fd9..6b7a462fcb 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -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
diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c
index 997e7597e0..ce656dcbce 100644
--- a/xen/arch/x86/hvm/svm/vmcb.c
+++ b/xen/arch/x86/hvm/svm/vmcb.c
@@ -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;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 0/2] Virtual GIF
2017-11-16 17:19 [PATCH v2 0/2] Virtual GIF Brian Woods
2017-11-16 17:19 ` [PATCH v2 1/2] x86/svm: Add virtual GIF feature definition Brian Woods
2017-11-16 17:19 ` [PATCH v2 2/2] x86/svm: Add virtual GIF support Brian Woods
@ 2017-11-16 19:17 ` Boris Ostrovsky
2 siblings, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2017-11-16 19:17 UTC (permalink / raw)
To: Brian Woods, xen-devel; +Cc: Andrew Cooper, Jan Beulich, Suravee Suthikulpanit
On 11/16/2017 12:19 PM, Brian Woods wrote:
> 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(-)
>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
(with or without 'else' style changes in the second patch)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread