x86/emul: Drop more redundant ctxt.event_pending checks
PATCH 1/1 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.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Julien Grall <[email protected]>
--- 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(-)
xen/arch/x86/hvm/emulate.c +2 -4
@@ -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 ; }
xen/arch/x86/hvm/hvm.c +1 -2
@@ -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);
xen/arch/x86/hvm/io.c +1 -2
@@ -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 ; }
xen/arch/x86/hvm/vmx/realmode.c +0 -15
@@ -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)) )
xen/arch/x86/mm/shadow/multi.c +1 -1
@@ -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
xen/arch/x86/traps.c +0 -9
@@ -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 ||
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 11 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 10 April 2017 13:15
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Tim (Xen.org) <[email protected]>; Paul Durrant <[email protected]>; Jun Nakajima <[email protected]>; Kevin Tian <[email protected]>; Julien Grall <[email protected]>
Subject: [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checks
Quoted 8 lines
Since c/s
92cf67888a,x86_emulate_wrapper()asserts stricter behaviour about
the relationship betweenX86EMUL_EXCEPTIONand 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...
Quoted 151 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Julien Grall <[email protected]>--- 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(-)xen/arch/x86/hvm/emulate.c +1
-2@@ -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);xen/arch/x86/hvm/emulate.c +1
-2@@ -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 ; }xen/arch/x86/hvm/hvm.c +1
-2@@ -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);xen/arch/x86/hvm/io.c +1
-2@@ -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 ; }xen/arch/x86/hvm/vmx/realmode.c +0
-15@@ -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)) )xen/arch/x86/mm/shadow/multi.c +1
-1@@ -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 xen/arch/x86/traps.c +0
-9@@ -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 ||
Quoted 2 lines
--
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines · Paul Durrant
Quoted 15 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 10 April 2017 13:15
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Tim (Xen.org) <[email protected]>; Paul Durrant <[email protected]>; Jun Nakajima <[email protected]>; Kevin Tian <[email protected]>; Julien Grall <[email protected]>
Subject: [PATCH for-4.9] x86/emul: Drop more redundant ctxt.event_pending checksSince c/s
92cf67888a,x86_emulate_wrapper()asserts stricter behaviour about
the relationship betweenX86EMUL_EXCEPTIONand ctxt.event_pending.
Quoted 7 lines
Quoted 4 lines
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 <[email protected]>
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
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 10.04.17 at 14:14, <[email protected]> wrote:
Since c/s
92cf67888a,x86_emulate_wrapper()asserts stricter behaviour about the relationship betweenX86EMUL_EXCEPTIONand 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 <[email protected]>
Interesting that I saw your and Paul's discussion half an hour before the patch arrived ...
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Tian, Kevin
Reviewed-byQuoted 10 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, April 10, 2017 9:30 PMQuoted 2 lines
Quoted 1 line
Quoted 1 line · On 10.04.17 at 14:14, <[email protected]> wrote:
Since c/s
92cf67888a,x86_emulate_wrapper()asserts stricter behaviourabout
Quoted 3 lines
the relationship between
X86EMUL_EXCEPTIONand ctxt.event_pending.These removals should have been included in the aforementioned
changeset, and
Quoted 9 lines
Quoted 3 lines
were only omitted due an oversight.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>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.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Andrew,
Quoted 7 lines · Andrew Cooper
Since c/s
92cf67888a,x86_emulate_wrapper()asserts stricter behaviour about the relationship betweenX86EMUL_EXCEPTIONand 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 <[email protected]>
Cheers,
Quoted 142 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Julien Grall <[email protected]>--- 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(-)xen/arch/x86/hvm/emulate.c +2
-4@@ -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 ; }xen/arch/x86/hvm/hvm.c +1
-2@@ -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);xen/arch/x86/hvm/io.c +1
-2@@ -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 ; }xen/arch/x86/hvm/vmx/realmode.c +0
-15@@ -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)) )xen/arch/x86/mm/shadow/multi.c +1
-1@@ -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 xen/arch/x86/traps.c +0
-9@@ -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 ||
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel