xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context
@ 2016-04-11  9:03 Andrew Cooper
  2016-04-11  9:45 ` Wei Liu
  2016-04-11 14:08 ` Boris Ostrovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2016-04-11  9:03 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

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.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index cba1e37..6e709cb 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -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 )
         {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context
  2016-04-11  9:03 [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context Andrew Cooper
@ 2016-04-11  9:45 ` Wei Liu
  2016-04-11 14:08 ` Boris Ostrovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-04-11  9:45 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Jan Beulich, Xen-devel

On Mon, Apr 11, 2016 at 10:03:55AM +0100, Andrew Cooper wrote:
> 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.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>

FWIW:

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

This is fine for 4.7.

Wei.

> ---
>  xen/arch/x86/domctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index cba1e37..6e709cb 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -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 )
>          {
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context
  2016-04-11  9:03 [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context Andrew Cooper
  2016-04-11  9:45 ` Wei Liu
@ 2016-04-11 14:08 ` Boris Ostrovsky
  2016-04-11 14:22   ` Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 4+ messages in thread
From: Boris Ostrovsky @ 2016-04-11 14:08 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel; +Cc: Wei Liu, Jan Beulich

On 04/11/2016 05:03 AM, Andrew Cooper wrote:
> 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> ---
>   xen/arch/x86/domctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index cba1e37..6e709cb 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context
  2016-04-11 14:08 ` Boris Ostrovsky
@ 2016-04-11 14:22   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-04-11 14:22 UTC (permalink / raw)
  To: Boris Ostrovsky; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Xen-devel

On Mon, Apr 11, 2016 at 10:08:58AM -0400, Boris Ostrovsky wrote:
> On 04/11/2016 05:03 AM, Andrew Cooper wrote:
> >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.
> >
> >Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
> (save/restore was part of brokenness as well, obviously)

Applied.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-04-11 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-11  9:03 [PATCH for-4.7] x86/pv: Correctly fold vIOPL back into vcpu_guest_context Andrew Cooper
2016-04-11  9:45 ` Wei Liu
2016-04-11 14:08 ` Boris Ostrovsky
2016-04-11 14:22   ` Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).