[Xen-devel] [PATCH] x86/vvmx: Fix the use of RDTSCP when it is intercepted at L0

Andrew Cooper posted 1 patch 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20191003104736.32259-1-andrew.cooper3@citrix.com
xen/arch/x86/hvm/vmx/vvmx.c | 3 +++
1 file changed, 3 insertions(+)

[Xen-devel] [PATCH] x86/vvmx: Fix the use of RDTSCP when it is intercepted at L0

Posted by Andrew Cooper 1 week ago
Linux has started using RDTSCP as of v5.1.  This has highlighted a bug in Xen,
where virtual vmexit simply gives up.

  (XEN) d1v1 Unhandled nested vmexit: reason 51
  (XEN) domain_crash called from vvmx.c:2671
  (XEN) Domain 1 (vcpu#1) crashed on cpu#2:

Handle RDTSCP in the virtual vmexit hander in the same was as RDTSC
intercepts.

Reported-by: Sarah Newman <srn@prgmr.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Chris Brannon <cmb@prgmr.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Juergen Gross <jgross@suse.com>

This probably wants backporting to all stable trees, even though nested virt
isn't supported, and therefore ought to qualify for 4.13 at this point.
---
 xen/arch/x86/hvm/vmx/vvmx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index fdf449bfd1..6696bd6240 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -2491,6 +2491,7 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,
             nvcpu->nv_vmexit_pending = 1;
         break;
     case EXIT_REASON_RDTSC:
+    case EXIT_REASON_RDTSCP:
         ctrl = __n2_exec_control(v);
         if ( ctrl & CPU_BASED_RDTSC_EXITING )
             nvcpu->nv_vmexit_pending = 1;
@@ -2501,6 +2502,8 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,
              * avoiding changing guest_tsc and messing up timekeeping in L1
              */
             msr_split(regs, hvm_get_guest_tsc(v) + get_vvmcs(v, TSC_OFFSET));
+            if ( exit_reason == EXIT_REASON_RDTSCP )
+                regs->rcx = v->arch.msrs->tsc_aux;
             update_guest_eip();
 
             return 1;
-- 
2.11.0


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

Re: [Xen-devel] [PATCH] x86/vvmx: Fix the use of RDTSCP when it is intercepted at L0

Posted by Wei Liu 1 week ago
On Thu, Oct 03, 2019 at 11:47:36AM +0100, Andrew Cooper wrote:
> Linux has started using RDTSCP as of v5.1.  This has highlighted a bug in Xen,
> where virtual vmexit simply gives up.
> 
>   (XEN) d1v1 Unhandled nested vmexit: reason 51
>   (XEN) domain_crash called from vvmx.c:2671
>   (XEN) Domain 1 (vcpu#1) crashed on cpu#2:
> 
> Handle RDTSCP in the virtual vmexit hander in the same was as RDTSC
> intercepts.
> 
> Reported-by: Sarah Newman <srn@prgmr.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Tested-by: Chris Brannon <cmb@prgmr.com>

Reviewed-by: Wei Liu <wl@xen.org>

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

Re: [Xen-devel] [PATCH] x86/vvmx: Fix the use of RDTSCP when it is intercepted at L0

Posted by Jürgen Groß 1 week ago
On 03.10.19 12:47, Andrew Cooper wrote:
> Linux has started using RDTSCP as of v5.1.  This has highlighted a bug in Xen,
> where virtual vmexit simply gives up.
> 
>    (XEN) d1v1 Unhandled nested vmexit: reason 51
>    (XEN) domain_crash called from vvmx.c:2671
>    (XEN) Domain 1 (vcpu#1) crashed on cpu#2:
> 
> Handle RDTSCP in the virtual vmexit hander in the same was as RDTSC
> intercepts.
> 
> Reported-by: Sarah Newman <srn@prgmr.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Tested-by: Chris Brannon <cmb@prgmr.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen

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