All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
@ 2017-04-10 12:14 Andrew Cooper
  2017-04-10 12:24 ` Paul Durrant
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrew Cooper @ 2017-04-10 12:14 UTC (permalink / raw)
  To: Xen-devel
  Cc: Kevin Tian, Jan Beulich, Andrew Cooper, Tim Deegan, Julien Grall,
	Paul Durrant, Jun Nakajima

Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour about
the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.

These removals should have been included in the aforementioned changeset, and
were only omitted due an oversight.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Paul Durrant <paul.durrant@citrix.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/x86/hvm/emulate.c      |  6 ++----
 xen/arch/x86/hvm/hvm.c          |  3 +--
 xen/arch/x86/hvm/io.c           |  3 +--
 xen/arch/x86/hvm/vmx/realmode.c | 15 ---------------
 xen/arch/x86/mm/shadow/multi.c  |  2 +-
 xen/arch/x86/traps.c            |  9 ---------
 6 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 06b8f1b..91e269f 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2035,8 +2035,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla)
         hvm_dump_emulation_state(XENLOG_G_WARNING "MMCFG", &ctxt);
         break;
     case X86EMUL_EXCEPTION:
-        if ( ctxt.ctxt.event_pending )
-            hvm_inject_event(&ctxt.ctxt.event);
+        hvm_inject_event(&ctxt.ctxt.event);
         /* fallthrough */
     default:
         hvm_emulate_writeback(&ctxt);
@@ -2095,8 +2094,7 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr,
         hvm_inject_hw_exception(trapnr, errcode);
         break;
     case X86EMUL_EXCEPTION:
-        if ( ctx.ctxt.event_pending )
-            hvm_inject_event(&ctx.ctxt.event);
+        hvm_inject_event(&ctx.ctxt.event);
         break;
     }
 
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index f50d15f..9ffe702 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3696,8 +3696,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
         hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
         break;
     case X86EMUL_EXCEPTION:
-        if ( ctxt.ctxt.event_pending )
-            hvm_inject_event(&ctxt.ctxt.event);
+        hvm_inject_event(&ctxt.ctxt.event);
         /* fall through */
     default:
         hvm_emulate_writeback(&ctxt);
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index 9e00409..67528d9 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -100,8 +100,7 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate)
         return false;
 
     case X86EMUL_EXCEPTION:
-        if ( ctxt.ctxt.event_pending )
-            hvm_inject_event(&ctxt.ctxt.event);
+        hvm_inject_event(&ctxt.ctxt.event);
         break;
     }
 
diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c
index 7b908c7..4eb4232 100644
--- a/xen/arch/x86/hvm/vmx/realmode.c
+++ b/xen/arch/x86/hvm/vmx/realmode.c
@@ -114,21 +114,6 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt)
 
     if ( rc == X86EMUL_EXCEPTION )
     {
-        if ( !hvmemul_ctxt->ctxt.event_pending )
-        {
-            unsigned long intr_info;
-
-            __vmread(VM_ENTRY_INTR_INFO, &intr_info);
-            __vmwrite(VM_ENTRY_INTR_INFO, 0);
-            if ( !(intr_info & INTR_INFO_VALID_MASK) )
-            {
-                gdprintk(XENLOG_ERR, "Exception pending but no info.\n");
-                goto fail;
-            }
-            hvmemul_ctxt->ctxt.event.vector = (uint8_t)intr_info;
-            hvmemul_ctxt->ctxt.event.insn_len = 0;
-        }
-
         if ( unlikely(curr->domain->debugger_attached) &&
              ((hvmemul_ctxt->ctxt.event.vector == TRAP_debug) ||
               (hvmemul_ctxt->ctxt.event.vector == TRAP_int3)) )
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 5195d61..2fb0125 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -3457,7 +3457,7 @@ static int sh_page_fault(struct vcpu *v,
 
     r = x86_emulate(&emul_ctxt.ctxt, emul_ops);
 
-    if ( r == X86EMUL_EXCEPTION && emul_ctxt.ctxt.event_pending )
+    if ( r == X86EMUL_EXCEPTION )
     {
         /*
          * This emulation covers writes to shadow pagetables.  We tolerate #PF
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index d69769f..ca0a04a 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -3185,15 +3185,9 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
     if ( IS_ERR_OR_NULL(state) )
     {
         if ( PTR_ERR(state) == -X86EMUL_EXCEPTION )
-        {
-            ASSERT(ctxt.ctxt.event_pending);
             pv_inject_event(&ctxt.ctxt.event);
-        }
         else
-        {
-            ASSERT(!ctxt.ctxt.event_pending);
             do_guest_trap(TRAP_gp_fault, regs);
-        }
         return;
     }
 
@@ -3234,13 +3228,10 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
 
     if ( rc == X86EMUL_EXCEPTION )
     {
-        ASSERT(ctxt.ctxt.event_pending);
         pv_inject_event(&ctxt.ctxt.event);
         return;
     }
 
-    ASSERT(!ctxt.ctxt.event_pending);
-
     if ( rc != X86EMUL_OKAY ||
          jump < 0 ||
          (opnd_sel & ~3) != regs->error_code ||
-- 
2.1.4


_______________________________________________
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 for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
  2017-04-10 12:14 [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks Andrew Cooper
@ 2017-04-10 12:24 ` Paul Durrant
  2017-04-10 12:26   ` Andrew Cooper
  2017-04-10 13:30 ` Jan Beulich
  2017-04-13  9:20 ` Julien Grall
  2 siblings, 1 reply; 6+ messages in thread
From: Paul Durrant @ 2017-04-10 12:24 UTC (permalink / raw)
  To: Xen-devel
  Cc: Kevin Tian, Jan Beulich, Andrew Cooper, Tim (Xen.org),
	Julien Grall, Jun Nakajima

> -----Original Message-----
> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com]
> Sent: 10 April 2017 13:15
> To: Xen-devel <xen-devel@lists.xen.org>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; Jan Beulich
> <JBeulich@suse.com>; Tim (Xen.org) <tim@xen.org>; Paul Durrant
> <Paul.Durrant@citrix.com>; Jun Nakajima <jun.nakajima@intel.com>; Kevin
> Tian <kevin.tian@intel.com>; Julien Grall <julien.grall@arm.com>
> Subject: [PATCH for-4.9] x86/emul: Drop more redundant
> ctxt.event_pending checks
> 
> Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour
> about
> the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.
> 
> These removals should have been included in the aforementioned
> changeset, and
> were only omitted due an oversight.
> 

As long as suitable assertions are in place...

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: Paul Durrant <paul.durrant@citrix.com>
> CC: Jun Nakajima <jun.nakajima@intel.com>
> CC: Kevin Tian <kevin.tian@intel.com>
> CC: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/x86/hvm/emulate.c      |  6 ++----
>  xen/arch/x86/hvm/hvm.c          |  3 +--
>  xen/arch/x86/hvm/io.c           |  3 +--
>  xen/arch/x86/hvm/vmx/realmode.c | 15 ---------------
>  xen/arch/x86/mm/shadow/multi.c  |  2 +-
>  xen/arch/x86/traps.c            |  9 ---------
>  6 files changed, 5 insertions(+), 33 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index 06b8f1b..91e269f 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2035,8 +2035,7 @@ int hvm_emulate_one_mmio(unsigned long mfn,
> unsigned long gla)
>          hvm_dump_emulation_state(XENLOG_G_WARNING "MMCFG", &ctxt);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          /* fallthrough */
>      default:
>          hvm_emulate_writeback(&ctxt);
> @@ -2095,8 +2094,7 @@ void hvm_emulate_one_vm_event(enum
> emul_kind kind, unsigned int trapnr,
>          hvm_inject_hw_exception(trapnr, errcode);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctx.ctxt.event_pending )
> -            hvm_inject_event(&ctx.ctxt.event);
> +        hvm_inject_event(&ctx.ctxt.event);
>          break;
>      }
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index f50d15f..9ffe702 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -3696,8 +3696,7 @@ void hvm_ud_intercept(struct cpu_user_regs
> *regs)
>          hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          /* fall through */
>      default:
>          hvm_emulate_writeback(&ctxt);
> diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
> index 9e00409..67528d9 100644
> --- a/xen/arch/x86/hvm/io.c
> +++ b/xen/arch/x86/hvm/io.c
> @@ -100,8 +100,7 @@ bool
> hvm_emulate_one_insn(hvm_emulate_validate_t *validate)
>          return false;
> 
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          break;
>      }
> 
> diff --git a/xen/arch/x86/hvm/vmx/realmode.c
> b/xen/arch/x86/hvm/vmx/realmode.c
> index 7b908c7..4eb4232 100644
> --- a/xen/arch/x86/hvm/vmx/realmode.c
> +++ b/xen/arch/x86/hvm/vmx/realmode.c
> @@ -114,21 +114,6 @@ void vmx_realmode_emulate_one(struct
> hvm_emulate_ctxt *hvmemul_ctxt)
> 
>      if ( rc == X86EMUL_EXCEPTION )
>      {
> -        if ( !hvmemul_ctxt->ctxt.event_pending )
> -        {
> -            unsigned long intr_info;
> -
> -            __vmread(VM_ENTRY_INTR_INFO, &intr_info);
> -            __vmwrite(VM_ENTRY_INTR_INFO, 0);
> -            if ( !(intr_info & INTR_INFO_VALID_MASK) )
> -            {
> -                gdprintk(XENLOG_ERR, "Exception pending but no info.\n");
> -                goto fail;
> -            }
> -            hvmemul_ctxt->ctxt.event.vector = (uint8_t)intr_info;
> -            hvmemul_ctxt->ctxt.event.insn_len = 0;
> -        }
> -
>          if ( unlikely(curr->domain->debugger_attached) &&
>               ((hvmemul_ctxt->ctxt.event.vector == TRAP_debug) ||
>                (hvmemul_ctxt->ctxt.event.vector == TRAP_int3)) )
> diff --git a/xen/arch/x86/mm/shadow/multi.c
> b/xen/arch/x86/mm/shadow/multi.c
> index 5195d61..2fb0125 100644
> --- a/xen/arch/x86/mm/shadow/multi.c
> +++ b/xen/arch/x86/mm/shadow/multi.c
> @@ -3457,7 +3457,7 @@ static int sh_page_fault(struct vcpu *v,
> 
>      r = x86_emulate(&emul_ctxt.ctxt, emul_ops);
> 
> -    if ( r == X86EMUL_EXCEPTION && emul_ctxt.ctxt.event_pending )
> +    if ( r == X86EMUL_EXCEPTION )
>      {
>          /*
>           * This emulation covers writes to shadow pagetables.  We tolerate #PF
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index d69769f..ca0a04a 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -3185,15 +3185,9 @@ static void emulate_gate_op(struct cpu_user_regs
> *regs)
>      if ( IS_ERR_OR_NULL(state) )
>      {
>          if ( PTR_ERR(state) == -X86EMUL_EXCEPTION )
> -        {
> -            ASSERT(ctxt.ctxt.event_pending);
>              pv_inject_event(&ctxt.ctxt.event);
> -        }
>          else
> -        {
> -            ASSERT(!ctxt.ctxt.event_pending);
>              do_guest_trap(TRAP_gp_fault, regs);
> -        }
>          return;
>      }
> 
> @@ -3234,13 +3228,10 @@ static void emulate_gate_op(struct
> cpu_user_regs *regs)
> 
>      if ( rc == X86EMUL_EXCEPTION )
>      {
> -        ASSERT(ctxt.ctxt.event_pending);
>          pv_inject_event(&ctxt.ctxt.event);
>          return;
>      }
> 
> -    ASSERT(!ctxt.ctxt.event_pending);
> -
>      if ( rc != X86EMUL_OKAY ||
>           jump < 0 ||
>           (opnd_sel & ~3) != regs->error_code ||
> --
> 2.1.4


_______________________________________________
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 for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
  2017-04-10 12:24 ` Paul Durrant
@ 2017-04-10 12:26   ` Andrew Cooper
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cooper @ 2017-04-10 12:26 UTC (permalink / raw)
  To: Paul Durrant, Xen-devel
  Cc: Kevin Tian, Julien Grall, Tim (Xen.org), Jun Nakajima, Jan Beulich

On 10/04/17 13:24, Paul Durrant wrote:
>> -----Original Message-----
>> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com]
>> Sent: 10 April 2017 13:15
>> To: Xen-devel <xen-devel@lists.xen.org>
>> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; Jan Beulich
>> <JBeulich@suse.com>; Tim (Xen.org) <tim@xen.org>; Paul Durrant
>> <Paul.Durrant@citrix.com>; Jun Nakajima <jun.nakajima@intel.com>; Kevin
>> Tian <kevin.tian@intel.com>; Julien Grall <julien.grall@arm.com>
>> Subject: [PATCH for-4.9] x86/emul: Drop more redundant
>> ctxt.event_pending checks
>>
>> Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour
>> about
>> the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.
>>
>> These removals should have been included in the aforementioned
>> changeset, and
>> were only omitted due an oversight.
>>
> As long as suitable assertions are in place...
>
> Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

The assertion in question is

ASSERT(ctxt->event_pending == (rc == X86EMUL_EXCEPTION));

in x86_emulate_wrapper() which transparently replaces x86_emulate() in
debug builds.

~Andrew

_______________________________________________
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 for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
  2017-04-10 12:14 [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks Andrew Cooper
  2017-04-10 12:24 ` Paul Durrant
@ 2017-04-10 13:30 ` Jan Beulich
  2017-04-11  5:32   ` Tian, Kevin
  2017-04-13  9:20 ` Julien Grall
  2 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2017-04-10 13:30 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Kevin Tian, Tim Deegan, Xen-devel, Julien Grall, Paul Durrant,
	Jun Nakajima

>>> On 10.04.17 at 14:14, <andrew.cooper3@citrix.com> wrote:
> Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour about
> the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.
> 
> These removals should have been included in the aforementioned changeset, and
> were only omitted due an oversight.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Interesting that I saw your and Paul's discussion half an hour before
the patch arrived ...

Jan


_______________________________________________
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 for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
  2017-04-10 13:30 ` Jan Beulich
@ 2017-04-11  5:32   ` Tian, Kevin
  0 siblings, 0 replies; 6+ messages in thread
From: Tian, Kevin @ 2017-04-11  5:32 UTC (permalink / raw)
  To: Jan Beulich, Andrew Cooper
  Cc: Julien Grall, Paul Durrant, Tim Deegan, Nakajima, Jun, Xen-devel

> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: Monday, April 10, 2017 9:30 PM
> 
> >>> On 10.04.17 at 14:14, <andrew.cooper3@citrix.com> wrote:
> > Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour
> about
> > the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.
> >
> > These removals should have been included in the aforementioned
> changeset, and
> > were only omitted due an oversight.
> >
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Interesting that I saw your and Paul's discussion half an hour before
> the patch arrived ...
> 

me too. this patch came 10min later than discussion in my side.

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

_______________________________________________
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 for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
  2017-04-10 12:14 [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks Andrew Cooper
  2017-04-10 12:24 ` Paul Durrant
  2017-04-10 13:30 ` Jan Beulich
@ 2017-04-13  9:20 ` Julien Grall
  2 siblings, 0 replies; 6+ messages in thread
From: Julien Grall @ 2017-04-13  9:20 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel
  Cc: Kevin Tian, Paul Durrant, Tim Deegan, Jun Nakajima, Jan Beulich

Hi Andrew,

On 10/04/17 13:14, Andrew Cooper wrote:
> Since c/s 92cf67888a, x86_emulate_wrapper() asserts stricter behaviour about
> the relationship between X86EMUL_EXCEPTION and ctxt.event_pending.
>
> These removals should have been included in the aforementioned changeset, and
> were only omitted due an oversight.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Release-acked-by: Julien Grall <julien.grall@arm.com>

Cheers,

> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: Paul Durrant <paul.durrant@citrix.com>
> CC: Jun Nakajima <jun.nakajima@intel.com>
> CC: Kevin Tian <kevin.tian@intel.com>
> CC: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/x86/hvm/emulate.c      |  6 ++----
>  xen/arch/x86/hvm/hvm.c          |  3 +--
>  xen/arch/x86/hvm/io.c           |  3 +--
>  xen/arch/x86/hvm/vmx/realmode.c | 15 ---------------
>  xen/arch/x86/mm/shadow/multi.c  |  2 +-
>  xen/arch/x86/traps.c            |  9 ---------
>  6 files changed, 5 insertions(+), 33 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index 06b8f1b..91e269f 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2035,8 +2035,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla)
>          hvm_dump_emulation_state(XENLOG_G_WARNING "MMCFG", &ctxt);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          /* fallthrough */
>      default:
>          hvm_emulate_writeback(&ctxt);
> @@ -2095,8 +2094,7 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr,
>          hvm_inject_hw_exception(trapnr, errcode);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctx.ctxt.event_pending )
> -            hvm_inject_event(&ctx.ctxt.event);
> +        hvm_inject_event(&ctx.ctxt.event);
>          break;
>      }
>
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index f50d15f..9ffe702 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -3696,8 +3696,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
>          hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          /* fall through */
>      default:
>          hvm_emulate_writeback(&ctxt);
> diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
> index 9e00409..67528d9 100644
> --- a/xen/arch/x86/hvm/io.c
> +++ b/xen/arch/x86/hvm/io.c
> @@ -100,8 +100,7 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate)
>          return false;
>
>      case X86EMUL_EXCEPTION:
> -        if ( ctxt.ctxt.event_pending )
> -            hvm_inject_event(&ctxt.ctxt.event);
> +        hvm_inject_event(&ctxt.ctxt.event);
>          break;
>      }
>
> diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c
> index 7b908c7..4eb4232 100644
> --- a/xen/arch/x86/hvm/vmx/realmode.c
> +++ b/xen/arch/x86/hvm/vmx/realmode.c
> @@ -114,21 +114,6 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt)
>
>      if ( rc == X86EMUL_EXCEPTION )
>      {
> -        if ( !hvmemul_ctxt->ctxt.event_pending )
> -        {
> -            unsigned long intr_info;
> -
> -            __vmread(VM_ENTRY_INTR_INFO, &intr_info);
> -            __vmwrite(VM_ENTRY_INTR_INFO, 0);
> -            if ( !(intr_info & INTR_INFO_VALID_MASK) )
> -            {
> -                gdprintk(XENLOG_ERR, "Exception pending but no info.\n");
> -                goto fail;
> -            }
> -            hvmemul_ctxt->ctxt.event.vector = (uint8_t)intr_info;
> -            hvmemul_ctxt->ctxt.event.insn_len = 0;
> -        }
> -
>          if ( unlikely(curr->domain->debugger_attached) &&
>               ((hvmemul_ctxt->ctxt.event.vector == TRAP_debug) ||
>                (hvmemul_ctxt->ctxt.event.vector == TRAP_int3)) )
> diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
> index 5195d61..2fb0125 100644
> --- a/xen/arch/x86/mm/shadow/multi.c
> +++ b/xen/arch/x86/mm/shadow/multi.c
> @@ -3457,7 +3457,7 @@ static int sh_page_fault(struct vcpu *v,
>
>      r = x86_emulate(&emul_ctxt.ctxt, emul_ops);
>
> -    if ( r == X86EMUL_EXCEPTION && emul_ctxt.ctxt.event_pending )
> +    if ( r == X86EMUL_EXCEPTION )
>      {
>          /*
>           * This emulation covers writes to shadow pagetables.  We tolerate #PF
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index d69769f..ca0a04a 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -3185,15 +3185,9 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
>      if ( IS_ERR_OR_NULL(state) )
>      {
>          if ( PTR_ERR(state) == -X86EMUL_EXCEPTION )
> -        {
> -            ASSERT(ctxt.ctxt.event_pending);
>              pv_inject_event(&ctxt.ctxt.event);
> -        }
>          else
> -        {
> -            ASSERT(!ctxt.ctxt.event_pending);
>              do_guest_trap(TRAP_gp_fault, regs);
> -        }
>          return;
>      }
>
> @@ -3234,13 +3228,10 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
>
>      if ( rc == X86EMUL_EXCEPTION )
>      {
> -        ASSERT(ctxt.ctxt.event_pending);
>          pv_inject_event(&ctxt.ctxt.event);
>          return;
>      }
>
> -    ASSERT(!ctxt.ctxt.event_pending);
> -
>      if ( rc != X86EMUL_OKAY ||
>           jump < 0 ||
>           (opnd_sel & ~3) != regs->error_code ||
>

-- 
Julien Grall

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

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

end of thread, other threads:[~2017-04-13  9:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 12:14 [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks Andrew Cooper
2017-04-10 12:24 ` Paul Durrant
2017-04-10 12:26   ` Andrew Cooper
2017-04-10 13:30 ` Jan Beulich
2017-04-11  5:32   ` Tian, Kevin
2017-04-13  9:20 ` Julien Grall

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.