xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.8] x86/emul: Move CPUID Faulting fault generation into the emulator
@ 2016-10-26 11:09 Andrew Cooper
  2016-10-26 12:26 ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2016-10-26 11:09 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

In hindsight, this is a better position for it, as it avoids opencoding
hvmemul_inject_hw_exception() in hvmemul_cpuid(), and reduces the requirements
on other ops->cpuid() hooks wanting to implement cpuid faulting in the future.

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/hvm/emulate.c             | 11 -----------
 xen/arch/x86/x86_emulate/x86_emulate.c | 10 +++++++++-
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 70c8d44..5b408f8 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -1556,18 +1556,7 @@ static int hvmemul_cpuid(
      */
     if ( ctxt->opcode == X86EMUL_OPC(0x0f, 0xa2) &&
          hvm_check_cpuid_faulting(current) )
-    {
-        struct hvm_emulate_ctxt *hvmemul_ctxt =
-            container_of(ctxt, struct hvm_emulate_ctxt, ctxt);
-
-        hvmemul_ctxt->exn_pending = 1;
-        hvmemul_ctxt->trap.vector = TRAP_gp_fault;
-        hvmemul_ctxt->trap.type = X86_EVENTTYPE_HW_EXCEPTION;
-        hvmemul_ctxt->trap.error_code = 0;
-        hvmemul_ctxt->trap.insn_len = 0;
-
         return X86EMUL_EXCEPTION;
-    }
 
     hvm_funcs.cpuid_intercept(eax, ebx, ecx, edx);
     return X86EMUL_OKAY;
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index a1821d5..0f8d252 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -5011,8 +5011,16 @@ x86_emulate(
         unsigned int eax = _regs.eax, ebx = _regs.ebx;
         unsigned int ecx = _regs.ecx, edx = _regs.edx;
         fail_if(ops->cpuid == NULL);
-        if ( (rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt)) != 0 )
+        switch ( rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt) )
+        {
+        case X86EMUL_OKAY:
+            break;
+        case X86EMUL_EXCEPTION: /* CPUID Faulting active. */
+            generate_exception_if(true, EXC_GP, 0);
+            /* unreachable */
+        default:
             goto done;
+        }
         _regs.eax = eax; _regs.ebx = ebx;
         _regs.ecx = ecx; _regs.edx = edx;
         break;
-- 
2.1.4


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

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

end of thread, other threads:[~2016-10-26 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26 11:09 [PATCH for-4.8] x86/emul: Move CPUID Faulting fault generation into the emulator Andrew Cooper
2016-10-26 12:26 ` Jan Beulich
2016-10-26 12:58   ` [PATCH v2 " Andrew Cooper
2016-10-26 13:05     ` Wei Liu
2016-10-26 13:40     ` Jan Beulich

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).