[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 3/6] AMD-PVH: call hvm_emulate_one instead of handle_mmio



On 06/22/2015 12:37 PM, elena.ufimtseva@xxxxxxxxxx wrote:
From: Elena Ufimtseva <elena.ufimtseva@xxxxxxxxxx>

Certain IOIO instructions and CR access instructions like
lmsw/clts etc need to be emulated. handle_mmio is incorrectly called to
accomplish this. Create svm_emulate() to call hvm_emulate_one which is more
appropriate, and works for pvh as well. handle_mmio call is
forbidden for pvh.

Signed-off-by: Mukesh Rathor <mukesh.rathor@xxxxxxxxxx>
---
  xen/arch/x86/hvm/svm/svm.c | 27 +++++++++++++++++++++++----
  1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 28792fe..e7262c9 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2289,6 +2289,23 @@ static struct hvm_function_table __initdata 
svm_function_table = {
      .nhvm_hap_walk_L1_p2m = nsvm_hap_walk_L1_p2m,
  };
+static void svm_emulate(struct cpu_user_regs *regs)
+{
+    int rc;
+    struct hvm_emulate_ctxt ctxt;
+
+    hvm_emulate_prepare(&ctxt, regs);
+    rc = hvm_emulate_one(&ctxt);
+
+    if ( rc != X86EMUL_OKAY )
+    {
+       if ( ctxt.exn_pending )
+               hvm_inject_trap(&ctxt.trap);
+       else
+               hvm_inject_hw_exception(TRAP_gp_fault, 0);
+    }
+}
+
  void svm_vmexit_handler(struct cpu_user_regs *regs)
  {
      uint64_t exit_reason;
@@ -2555,16 +2572,16 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
              if ( handle_pio(port, bytes, dir) )
                  __update_guest_eip(regs, vmcb->exitinfo2 - vmcb->rip);
          }
-        else if ( !handle_mmio() )
-            hvm_inject_hw_exception(TRAP_gp_fault, 0);
+        else
+            svm_emulate(regs);
          break;
case VMEXIT_CR0_READ ... VMEXIT_CR15_READ:
      case VMEXIT_CR0_WRITE ... VMEXIT_CR15_WRITE:
          if ( cpu_has_svm_decode && (vmcb->exitinfo1 & (1ULL << 63)) )
              svm_vmexit_do_cr_access(vmcb, regs);
-        else if ( !handle_mmio() )
-            hvm_inject_hw_exception(TRAP_gp_fault, 0);
+        else
+            svm_emulate(regs);
          break;
case VMEXIT_INVLPG:
@@ -2575,6 +2592,8 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
          }
          else if ( !handle_mmio() )
              hvm_inject_hw_exception(TRAP_gp_fault, 0);
+       else
+            svm_emulate(regs);
          break;
case VMEXIT_INVLPGA:


handle_mmio() will pop the assertion on PVH ('ASSERT(!is_pvh_vcpu(curr))'). I think just calling svm_emulate() should be sufficient, just like it is for CR registers.

-boris

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.