Skip to contentSkip to conversation

x86/pv: Correctly fold vIOPL back into vcpu_guest_context

PATCH Applied Andrew Cooper 4 participants 4 messages Apr 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pv: Correctly fold vIOPL back into vcpu_guest_context

c/s f71ecb6 "x86: introduce a new VMASSIST for architectural behaviour of iopl" shifted the vcpu iopl field by 12, but didn't update the logic which reconstructs the guests eflags for migration.

Existing guest kernels set a vIOPL of 1, to prevent them from faulting when accessing IO ports. This bug manifests as a crash after migrate, as the vIOPL reverts back to the default of 0, and the guest suffers an unexpected #GP fault.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/domctl.c +1 -1
index cba1e37..6e709cb 100644
@@ -1512,7 +1512,7 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
 
         /* IOPL privileges are virtualised: merge back into returned eflags. */
         BUG_ON((c(user_regs.eflags) & X86_EFLAGS_IOPL) != 0);
-        c(user_regs.eflags |= v->arch.pv_vcpu.iopl << 12);
+        c(user_regs.eflags |= v->arch.pv_vcpu.iopl);
 
         if ( !compat )
         {
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrew Cooper

c/s f71ecb6 "x86: introduce a new VMASSIST for architectural behaviour of iopl" shifted the vcpu iopl field by 12, but didn't update the logic which reconstructs the guests eflags for migration.

Existing guest kernels set a vIOPL of 1, to prevent them from faulting when accessing IO ports. This bug manifests as a crash after migrate, as the vIOPL reverts back to the default of 0, and the guest suffers an unexpected #GP fault.

Quoted 4 lines

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

FWIW:

This is fine for 4.7.

Wei.

Quoted 20 lines
---
 xen/arch/x86/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/domctl.c +1 -1
index cba1e37..6e709cb 100644
@@ -1512,7 +1512,7 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
 
         /* IOPL privileges are virtualised: merge back into returned eflags. */
         BUG_ON((c(user_regs.eflags) & X86_EFLAGS_IOPL) != 0);
-        c(user_regs.eflags |= v->arch.pv_vcpu.iopl << 12);
+        c(user_regs.eflags |= v->arch.pv_vcpu.iopl);
 
         if ( !compat )
         {
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Tested-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 10 lines · Andrew Cooper

c/s f71ecb6 "x86: introduce a new VMASSIST for architectural behaviour of iopl" shifted the vcpu iopl field by 12, but didn't update the logic which reconstructs the guests eflags for migration.

Existing guest kernels set a vIOPL of 1, to prevent them from faulting when accessing IO ports. This bug manifests as a crash after migrate, as the vIOPL reverts back to the default of 0, and the guest suffers an unexpected #GP fault.

(save/restore was part of brokenness as well, obviously)

Quoted 12 lines

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

---
  xen/arch/x86/domctl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/domctl.c +0 -0
index cba1e37..6e709cb 100644

xen/arch/x86/domctl.c void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) · line 1518

Quoted 8 lines
xen/arch/x86/domctl.c +1 -1
@@ -1512,7 +1512,7 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
 
          /* IOPL privileges are virtualised: merge back into returned eflags. */
          BUG_ON((c(user_regs.eflags) & X86_EFLAGS_IOPL) != 0);
-        c(user_regs.eflags |= v->arch.pv_vcpu.iopl << 12);
+        c(user_regs.eflags |= v->arch.pv_vcpu.iopl);
 
          if ( !compat )
          {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Andrew Cooper

c/s f71ecb6 "x86: introduce a new VMASSIST for architectural behaviour of iopl" shifted the vcpu iopl field by 12, but didn't update the logic which reconstructs the guests eflags for migration.

Existing guest kernels set a vIOPL of 1, to prevent them from faulting when accessing IO ports. This bug manifests as a crash after migrate, as the vIOPL reverts back to the default of 0, and the guest suffers an unexpected #GP fault.

Quoted 5 lines
Quoted 1 line

(save/restore was part of brokenness as well, obviously)

Applied.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel