All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection
@ 2020-02-03 12:19 Roger Pau Monne
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used Roger Pau Monne
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Roger Pau Monne @ 2020-02-03 12:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Jun Nakajima, Wei Liu, Andrew Cooper, Ian Jackson,
	Roger Pau Monne

Hello,

The following series contain fixes for nested interrupt injection.

Thanks, Roger.

Roger Pau Monne (4):
  x86/vvmx: fix virtual interrupt injection when Ack on exit control is
    used
  x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling
  x86/vvmx: don't enable interrupt window when using virt intr delivery
  Revert "tools/libxc: disable x2APIC when using nested virtualization"

 tools/libxc/xc_cpuid_x86.c  | 11 -----------
 xen/arch/x86/hvm/vmx/intr.c |  2 +-
 xen/arch/x86/hvm/vmx/vvmx.c | 13 ++++++++++---
 3 files changed, 11 insertions(+), 15 deletions(-)

-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used
  2020-02-03 12:19 [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection Roger Pau Monne
@ 2020-02-03 12:19 ` Roger Pau Monne
  2020-02-04  1:35   ` Tian, Kevin
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling Roger Pau Monne
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Roger Pau Monne @ 2020-02-03 12:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Jun Nakajima, Wei Liu, Andrew Cooper, Roger Pau Monne

When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM)
interrupts shouldn't be injected using the virtual interrupt delivery
mechanism unless the Ack on exit vmexit control bit isn't set in the
nested vmcs.

Gate the call to nvmx_update_apicv helper on whether the nested vmcs
has the Ack on exit bit set in the vmexit control field.

Note that this fixes the usage of x2APIC by the L1 VMM, at least when
the L1 VMM is Xen.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - Call nvmx_update_apicv if the "Ack on exit" vmexit control bit
   isn't set.
---
 xen/arch/x86/hvm/vmx/vvmx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index d8ab167d62..3d97a293b2 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -1393,7 +1393,12 @@ static void virtual_vmexit(struct cpu_user_regs *regs)
     /* updating host cr0 to sync TS bit */
     __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0);
 
-    if ( cpu_has_vmx_virtual_intr_delivery )
+    if ( cpu_has_vmx_virtual_intr_delivery &&
+         /*
+          * Only inject the vector if the Ack on exit bit is not set, else the
+          * interrupt will be signaled in the vmcs VM_EXIT_INTR_INFO field.
+          */
+         !(get_vvmcs(v, VM_EXIT_CONTROLS) & VM_EXIT_ACK_INTR_ON_EXIT) )
         nvmx_update_apicv(v);
 
     nvcpu->nv_vmswitch_in_progress = 0;
-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling
  2020-02-03 12:19 [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection Roger Pau Monne
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used Roger Pau Monne
@ 2020-02-03 12:19 ` Roger Pau Monne
  2020-02-04  1:39   ` Tian, Kevin
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery Roger Pau Monne
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 4/4] Revert "tools/libxc: disable x2APIC when using nested virtualization" Roger Pau Monne
  3 siblings, 1 reply; 12+ messages in thread
From: Roger Pau Monne @ 2020-02-03 12:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Jun Nakajima, Wei Liu, Andrew Cooper, Roger Pau Monne

When VM_EXIT_ACK_INTR_ON_EXIT is set in the vmexit control vmcs
register the bit 31 of VM_EXIT_INTR_INFO must be 0, in order to denote
that the field doesn't contain any interrupt information. This is not
currently acknowledged as the field always get filled with valid
interrupt information, regardless of whether VM_EXIT_ACK_INTR_ON_EXIT
is set.

Fix this and only fill VM_EXIT_INTR_INFO when VM_EXIT_ACK_INTR_ON_EXIT
is not set. Note that this requires one minor change in
nvmx_update_apicv in order to obtain the interrupt information from
the internal state rather than the nested vmcs register.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - New in this version.
---
 xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index 3d97a293b2..47eee1e5b9 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -1283,6 +1283,7 @@ static void load_vvmcs_host_state(struct vcpu *v)
 static void sync_exception_state(struct vcpu *v)
 {
     struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
+    uint32_t exit_ctrl = get_vvmcs(v, VM_EXIT_CONTROLS);
 
     if ( !(nvmx->intr.intr_info & INTR_INFO_VALID_MASK) )
         return;
@@ -1294,7 +1295,8 @@ static void sync_exception_state(struct vcpu *v)
         set_vvmcs(v, VM_EXIT_REASON, EXIT_REASON_EXTERNAL_INTERRUPT);
         set_vvmcs(v, EXIT_QUALIFICATION, 0);
         set_vvmcs(v, VM_EXIT_INTR_INFO,
-                    nvmx->intr.intr_info);
+                  (exit_ctrl & VM_EXIT_ACK_INTR_ON_EXIT) ? nvmx->intr.intr_info
+                                                         : 0);
         break;
 
     case X86_EVENTTYPE_HW_EXCEPTION:
@@ -1320,7 +1322,7 @@ static void nvmx_update_apicv(struct vcpu *v)
 {
     struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
     unsigned long reason = get_vvmcs(v, VM_EXIT_REASON);
-    uint32_t intr_info = get_vvmcs(v, VM_EXIT_INTR_INFO);
+    uint32_t intr_info = nvmx->intr.intr_info;
 
     if ( reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
          nvmx->intr.source == hvm_intsrc_lapic &&
-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery
  2020-02-03 12:19 [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection Roger Pau Monne
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used Roger Pau Monne
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling Roger Pau Monne
@ 2020-02-03 12:19 ` Roger Pau Monne
  2020-02-04  1:40   ` Tian, Kevin
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 4/4] Revert "tools/libxc: disable x2APIC when using nested virtualization" Roger Pau Monne
  3 siblings, 1 reply; 12+ messages in thread
From: Roger Pau Monne @ 2020-02-03 12:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Jun Nakajima, Wei Liu, Andrew Cooper, Roger Pau Monne

If virtual interrupt delivery is used to inject the interrupt to the
guest the interrupt window shouldn't be enabled, as the interrupt is
already injected using the GUEST_INTR_STATUS vmcs field.

Reported-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - New in this version.
---
 xen/arch/x86/hvm/vmx/intr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/intr.c b/xen/arch/x86/hvm/vmx/intr.c
index 2eaf3f8d36..49a1295f09 100644
--- a/xen/arch/x86/hvm/vmx/intr.c
+++ b/xen/arch/x86/hvm/vmx/intr.c
@@ -209,7 +209,7 @@ static int nvmx_intr_intercept(struct vcpu *v, struct hvm_intack intack)
                 if ( unlikely(intack.source != hvm_intsrc_none) )
                     vmx_enable_intr_window(v, intack);
             }
-            else
+            else if ( !cpu_has_vmx_virtual_intr_delivery )
                 vmx_enable_intr_window(v, intack);
 
             return 1;
-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Xen-devel] [PATCH v2 4/4] Revert "tools/libxc: disable x2APIC when using nested virtualization"
  2020-02-03 12:19 [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection Roger Pau Monne
                   ` (2 preceding siblings ...)
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery Roger Pau Monne
@ 2020-02-03 12:19 ` Roger Pau Monne
  3 siblings, 0 replies; 12+ messages in thread
From: Roger Pau Monne @ 2020-02-03 12:19 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Wei Liu, Roger Pau Monne

This reverts commit 7b3c5b70a32303b46d0d051e695f18d72cce5ed0 and
re-enables the usage of x2APIC with nested virtualization.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/xc_cpuid_x86.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index ac38c1406e..2540aa1e1c 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -653,17 +653,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
         p->extd.itsc = true;
         p->basic.vmx = true;
         p->extd.svm = true;
-
-        /*
-         * BODGE: don't announce x2APIC mode when using nested virtualization,
-         * as it doesn't work properly. This should be removed once the
-         * underlying bug(s) are fixed.
-         */
-        rc = xc_hvm_param_get(xch, domid, HVM_PARAM_NESTEDHVM, &val);
-        if ( rc )
-            goto out;
-        if ( val )
-            p->basic.x2apic = false;
     }
 
     rc = x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves);
-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used Roger Pau Monne
@ 2020-02-04  1:35   ` Tian, Kevin
  2020-02-04  9:23     ` Roger Pau Monné
  0 siblings, 1 reply; 12+ messages in thread
From: Tian, Kevin @ 2020-02-04  1:35 UTC (permalink / raw)
  To: Roger Pau Monne, xen-devel; +Cc: Andrew Cooper, Wei Liu, Nakajima, Jun

> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: Monday, February 3, 2020 8:19 PM
> 
> When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM)
> interrupts shouldn't be injected using the virtual interrupt delivery
> mechanism unless the Ack on exit vmexit control bit isn't set in the
> nested vmcs.
> 
> Gate the call to nvmx_update_apicv helper on whether the nested vmcs
> has the Ack on exit bit set in the vmexit control field.
> 
> Note that this fixes the usage of x2APIC by the L1 VMM, at least when
> the L1 VMM is Xen.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>, with a small comment:

> ---
> Changes since v1:
>  - Call nvmx_update_apicv if the "Ack on exit" vmexit control bit
>    isn't set.
> ---
>  xen/arch/x86/hvm/vmx/vvmx.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> index d8ab167d62..3d97a293b2 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -1393,7 +1393,12 @@ static void virtual_vmexit(struct cpu_user_regs
> *regs)
>      /* updating host cr0 to sync TS bit */
>      __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0);
> 
> -    if ( cpu_has_vmx_virtual_intr_delivery )
> +    if ( cpu_has_vmx_virtual_intr_delivery &&
> +         /*
> +          * Only inject the vector if the Ack on exit bit is not set, else the
> +          * interrupt will be signaled in the vmcs VM_EXIT_INTR_INFO field.
> +          */
> +         !(get_vvmcs(v, VM_EXIT_CONTROLS) & VM_EXIT_ACK_INTR_ON_EXIT) )

It's a bit odd to put comment between code lines. Can you move it to
the line before 'if'?

>          nvmx_update_apicv(v);
> 
>      nvcpu->nv_vmswitch_in_progress = 0;
> --
> 2.25.0

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling Roger Pau Monne
@ 2020-02-04  1:39   ` Tian, Kevin
  2020-02-04  9:26     ` Roger Pau Monné
  0 siblings, 1 reply; 12+ messages in thread
From: Tian, Kevin @ 2020-02-04  1:39 UTC (permalink / raw)
  To: Roger Pau Monne, xen-devel; +Cc: Andrew Cooper, Wei Liu, Nakajima, Jun

> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: Monday, February 3, 2020 8:19 PM
> 
> When VM_EXIT_ACK_INTR_ON_EXIT is set in the vmexit control vmcs

set->cleared

> register the bit 31 of VM_EXIT_INTR_INFO must be 0, in order to denote
> that the field doesn't contain any interrupt information. This is not
> currently acknowledged as the field always get filled with valid
> interrupt information, regardless of whether VM_EXIT_ACK_INTR_ON_EXIT
> is set.
> 
> Fix this and only fill VM_EXIT_INTR_INFO when VM_EXIT_ACK_INTR_ON_EXIT
> is not set. Note that this requires one minor change in

not set -> set

> nvmx_update_apicv in order to obtain the interrupt information from
> the internal state rather than the nested vmcs register.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

with above fixed, 

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> ---
> Changes since v1:
>  - New in this version.
> ---
>  xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> index 3d97a293b2..47eee1e5b9 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -1283,6 +1283,7 @@ static void load_vvmcs_host_state(struct vcpu *v)
>  static void sync_exception_state(struct vcpu *v)
>  {
>      struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
> +    uint32_t exit_ctrl = get_vvmcs(v, VM_EXIT_CONTROLS);
> 
>      if ( !(nvmx->intr.intr_info & INTR_INFO_VALID_MASK) )
>          return;
> @@ -1294,7 +1295,8 @@ static void sync_exception_state(struct vcpu *v)
>          set_vvmcs(v, VM_EXIT_REASON, EXIT_REASON_EXTERNAL_INTERRUPT);
>          set_vvmcs(v, EXIT_QUALIFICATION, 0);
>          set_vvmcs(v, VM_EXIT_INTR_INFO,
> -                    nvmx->intr.intr_info);
> +                  (exit_ctrl & VM_EXIT_ACK_INTR_ON_EXIT) ? nvmx->intr.intr_info
> +                                                         : 0);
>          break;
> 
>      case X86_EVENTTYPE_HW_EXCEPTION:
> @@ -1320,7 +1322,7 @@ static void nvmx_update_apicv(struct vcpu *v)
>  {
>      struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
>      unsigned long reason = get_vvmcs(v, VM_EXIT_REASON);
> -    uint32_t intr_info = get_vvmcs(v, VM_EXIT_INTR_INFO);
> +    uint32_t intr_info = nvmx->intr.intr_info;
> 
>      if ( reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
>           nvmx->intr.source == hvm_intsrc_lapic &&
> --
> 2.25.0

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery
  2020-02-03 12:19 ` [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery Roger Pau Monne
@ 2020-02-04  1:40   ` Tian, Kevin
  0 siblings, 0 replies; 12+ messages in thread
From: Tian, Kevin @ 2020-02-04  1:40 UTC (permalink / raw)
  To: Roger Pau Monne, xen-devel; +Cc: Andrew Cooper, Wei Liu, Nakajima, Jun

> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: Monday, February 3, 2020 8:19 PM
> 
> If virtual interrupt delivery is used to inject the interrupt to the
> guest the interrupt window shouldn't be enabled, as the interrupt is
> already injected using the GUEST_INTR_STATUS vmcs field.
> 
> Reported-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used
  2020-02-04  1:35   ` Tian, Kevin
@ 2020-02-04  9:23     ` Roger Pau Monné
  2020-02-04  9:49       ` Jan Beulich
  0 siblings, 1 reply; 12+ messages in thread
From: Roger Pau Monné @ 2020-02-04  9:23 UTC (permalink / raw)
  To: Tian, Kevin; +Cc: xen-devel, Wei Liu, Jan Beulich, Nakajima, Jun, Andrew Cooper

On Tue, Feb 04, 2020 at 01:35:05AM +0000, Tian, Kevin wrote:
> > From: Roger Pau Monne <roger.pau@citrix.com>
> > Sent: Monday, February 3, 2020 8:19 PM
> > 
> > When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM)
> > interrupts shouldn't be injected using the virtual interrupt delivery
> > mechanism unless the Ack on exit vmexit control bit isn't set in the
> > nested vmcs.
> > 
> > Gate the call to nvmx_update_apicv helper on whether the nested vmcs
> > has the Ack on exit bit set in the vmexit control field.
> > 
> > Note that this fixes the usage of x2APIC by the L1 VMM, at least when
> > the L1 VMM is Xen.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>, with a small comment:
> 
> > ---
> > Changes since v1:
> >  - Call nvmx_update_apicv if the "Ack on exit" vmexit control bit
> >    isn't set.
> > ---
> >  xen/arch/x86/hvm/vmx/vvmx.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> > index d8ab167d62..3d97a293b2 100644
> > --- a/xen/arch/x86/hvm/vmx/vvmx.c
> > +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> > @@ -1393,7 +1393,12 @@ static void virtual_vmexit(struct cpu_user_regs
> > *regs)
> >      /* updating host cr0 to sync TS bit */
> >      __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0);
> > 
> > -    if ( cpu_has_vmx_virtual_intr_delivery )
> > +    if ( cpu_has_vmx_virtual_intr_delivery &&
> > +         /*
> > +          * Only inject the vector if the Ack on exit bit is not set, else the
> > +          * interrupt will be signaled in the vmcs VM_EXIT_INTR_INFO field.
> > +          */
> > +         !(get_vvmcs(v, VM_EXIT_CONTROLS) & VM_EXIT_ACK_INTR_ON_EXIT) )
> 
> It's a bit odd to put comment between code lines. Can you move it to
> the line before 'if'?

I usually try to keep the comments as close to the code it references
as possible, even if that means adding them in the middle of an if
condition.

I don't mind moving it, but maybe the committer can do it at commit
time?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling
  2020-02-04  1:39   ` Tian, Kevin
@ 2020-02-04  9:26     ` Roger Pau Monné
  0 siblings, 0 replies; 12+ messages in thread
From: Roger Pau Monné @ 2020-02-04  9:26 UTC (permalink / raw)
  To: Tian, Kevin; +Cc: xen-devel, Wei Liu, Jan Beulich, Nakajima, Jun, Andrew Cooper

On Tue, Feb 04, 2020 at 01:39:44AM +0000, Tian, Kevin wrote:
> > From: Roger Pau Monne <roger.pau@citrix.com>
> > Sent: Monday, February 3, 2020 8:19 PM
> > 
> > When VM_EXIT_ACK_INTR_ON_EXIT is set in the vmexit control vmcs
> 
> set->cleared
> 
> > register the bit 31 of VM_EXIT_INTR_INFO must be 0, in order to denote
> > that the field doesn't contain any interrupt information. This is not
> > currently acknowledged as the field always get filled with valid
> > interrupt information, regardless of whether VM_EXIT_ACK_INTR_ON_EXIT
> > is set.
> > 
> > Fix this and only fill VM_EXIT_INTR_INFO when VM_EXIT_ACK_INTR_ON_EXIT
> > is not set. Note that this requires one minor change in
> 
> not set -> set
> 
> > nvmx_update_apicv in order to obtain the interrupt information from
> > the internal state rather than the nested vmcs register.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> with above fixed, 

Ouch yes, I've inverted the conditions. Thanks for noticing.

> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>

To whoever picks this patch for committing: let me know if you would
like me to resend with the commit log fixed.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used
  2020-02-04  9:23     ` Roger Pau Monné
@ 2020-02-04  9:49       ` Jan Beulich
  2020-02-04 10:05         ` Tian, Kevin
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Beulich @ 2020-02-04  9:49 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: xen-devel, Tian, Kevin, Wei Liu, Nakajima, Jun, Andrew Cooper

On 04.02.2020 10:23, Roger Pau Monné wrote:
> On Tue, Feb 04, 2020 at 01:35:05AM +0000, Tian, Kevin wrote:
>>> From: Roger Pau Monne <roger.pau@citrix.com>
>>> Sent: Monday, February 3, 2020 8:19 PM
>>>
>>> When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM)
>>> interrupts shouldn't be injected using the virtual interrupt delivery
>>> mechanism unless the Ack on exit vmexit control bit isn't set in the
>>> nested vmcs.
>>>
>>> Gate the call to nvmx_update_apicv helper on whether the nested vmcs
>>> has the Ack on exit bit set in the vmexit control field.
>>>
>>> Note that this fixes the usage of x2APIC by the L1 VMM, at least when
>>> the L1 VMM is Xen.
>>>
>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>>
>> Reviewed-by: Kevin Tian <kevin.tian@intel.com>, with a small comment:
>>
>>> ---
>>> Changes since v1:
>>>  - Call nvmx_update_apicv if the "Ack on exit" vmexit control bit
>>>    isn't set.
>>> ---
>>>  xen/arch/x86/hvm/vmx/vvmx.c | 7 ++++++-
>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
>>> index d8ab167d62..3d97a293b2 100644
>>> --- a/xen/arch/x86/hvm/vmx/vvmx.c
>>> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
>>> @@ -1393,7 +1393,12 @@ static void virtual_vmexit(struct cpu_user_regs
>>> *regs)
>>>      /* updating host cr0 to sync TS bit */
>>>      __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0);
>>>
>>> -    if ( cpu_has_vmx_virtual_intr_delivery )
>>> +    if ( cpu_has_vmx_virtual_intr_delivery &&
>>> +         /*
>>> +          * Only inject the vector if the Ack on exit bit is not set, else the
>>> +          * interrupt will be signaled in the vmcs VM_EXIT_INTR_INFO field.
>>> +          */
>>> +         !(get_vvmcs(v, VM_EXIT_CONTROLS) & VM_EXIT_ACK_INTR_ON_EXIT) )
>>
>> It's a bit odd to put comment between code lines. Can you move it to
>> the line before 'if'?
> 
> I usually try to keep the comments as close to the code it references
> as possible, even if that means adding them in the middle of an if
> condition.
> 
> I don't mind moving it, but maybe the committer can do it at commit
> time?

This should be easy enough, but - Kevin, I agree with Roger that
the chose placement is better than what you suggest. You're the
maintainer of the file, so if you really think the comment should
be moved - so be it. But please re-confirm one or the other way.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used
  2020-02-04  9:49       ` Jan Beulich
@ 2020-02-04 10:05         ` Tian, Kevin
  0 siblings, 0 replies; 12+ messages in thread
From: Tian, Kevin @ 2020-02-04 10:05 UTC (permalink / raw)
  To: Jan Beulich, Roger Pau Monné
  Cc: xen-devel, Nakajima, Jun, Wei Liu, Andrew Cooper

> From: Jan Beulich
> Sent: Tuesday, February 4, 2020 5:50 PM
> 
> On 04.02.2020 10:23, Roger Pau Monné wrote:
> > On Tue, Feb 04, 2020 at 01:35:05AM +0000, Tian, Kevin wrote:
> >>> From: Roger Pau Monne <roger.pau@citrix.com>
> >>> Sent: Monday, February 3, 2020 8:19 PM
> >>>
> >>> When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM)
> >>> interrupts shouldn't be injected using the virtual interrupt delivery
> >>> mechanism unless the Ack on exit vmexit control bit isn't set in the
> >>> nested vmcs.
> >>>
> >>> Gate the call to nvmx_update_apicv helper on whether the nested vmcs
> >>> has the Ack on exit bit set in the vmexit control field.
> >>>
> >>> Note that this fixes the usage of x2APIC by the L1 VMM, at least when
> >>> the L1 VMM is Xen.
> >>>
> >>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> >>
> >> Reviewed-by: Kevin Tian <kevin.tian@intel.com>, with a small comment:
> >>
> >>> ---
> >>> Changes since v1:
> >>>  - Call nvmx_update_apicv if the "Ack on exit" vmexit control bit
> >>>    isn't set.
> >>> ---
> >>>  xen/arch/x86/hvm/vmx/vvmx.c | 7 ++++++-
> >>>  1 file changed, 6 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c
> b/xen/arch/x86/hvm/vmx/vvmx.c
> >>> index d8ab167d62..3d97a293b2 100644
> >>> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> >>> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> >>> @@ -1393,7 +1393,12 @@ static void virtual_vmexit(struct
> cpu_user_regs
> >>> *regs)
> >>>      /* updating host cr0 to sync TS bit */
> >>>      __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0);
> >>>
> >>> -    if ( cpu_has_vmx_virtual_intr_delivery )
> >>> +    if ( cpu_has_vmx_virtual_intr_delivery &&
> >>> +         /*
> >>> +          * Only inject the vector if the Ack on exit bit is not set, else the
> >>> +          * interrupt will be signaled in the vmcs VM_EXIT_INTR_INFO field.
> >>> +          */
> >>> +         !(get_vvmcs(v, VM_EXIT_CONTROLS) &
> VM_EXIT_ACK_INTR_ON_EXIT) )
> >>
> >> It's a bit odd to put comment between code lines. Can you move it to
> >> the line before 'if'?
> >
> > I usually try to keep the comments as close to the code it references
> > as possible, even if that means adding them in the middle of an if
> > condition.
> >
> > I don't mind moving it, but maybe the committer can do it at commit
> > time?
> 
> This should be easy enough, but - Kevin, I agree with Roger that
> the chose placement is better than what you suggest. You're the
> maintainer of the file, so if you really think the comment should
> be moved - so be it. But please re-confirm one or the other way.
> 

Then leave it as it is. I'm not strong on this request.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-02-04 10:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 12:19 [Xen-devel] [PATCH v2 0/4] x86/vvmx: fixes to interrupt injection Roger Pau Monne
2020-02-03 12:19 ` [Xen-devel] [PATCH v2 1/4] x86/vvmx: fix virtual interrupt injection when Ack on exit control is used Roger Pau Monne
2020-02-04  1:35   ` Tian, Kevin
2020-02-04  9:23     ` Roger Pau Monné
2020-02-04  9:49       ` Jan Beulich
2020-02-04 10:05         ` Tian, Kevin
2020-02-03 12:19 ` [Xen-devel] [PATCH v2 2/4] x86/vvmx: fix VM_EXIT_ACK_INTR_ON_EXIT handling Roger Pau Monne
2020-02-04  1:39   ` Tian, Kevin
2020-02-04  9:26     ` Roger Pau Monné
2020-02-03 12:19 ` [Xen-devel] [PATCH v2 3/4] x86/vvmx: don't enable interrupt window when using virt intr delivery Roger Pau Monne
2020-02-04  1:40   ` Tian, Kevin
2020-02-03 12:19 ` [Xen-devel] [PATCH v2 4/4] Revert "tools/libxc: disable x2APIC when using nested virtualization" Roger Pau Monne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.