SVM: Plumb NPT error-code bits into nested-fault access_X arguments.
authorTim Deegan <tim@xen.org>
Tue, 24 Jan 2012 16:46:17 +0000 (16:46 +0000)
committerTim Deegan <tim@xen.org>
Tue, 24 Jan 2012 16:46:17 +0000 (16:46 +0000)
Signed-off-by: Tim Deegan <tim@xen.org>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/hvm.h

index b163ed0f01b403f5b42484a52316c4a9b11ee08b..8847b499ecb7df158c8c73b882cf22d1e25d2518 100644 (file)
@@ -1185,7 +1185,6 @@ void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2)
 int hvm_hap_nested_page_fault(unsigned long gpa,
                               bool_t gla_valid,
                               unsigned long gla,
-                              bool_t access_valid,
                               bool_t access_r,
                               bool_t access_w,
                               bool_t access_x)
@@ -1234,7 +1233,7 @@ int hvm_hap_nested_page_fault(unsigned long gpa,
     mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_guest, NULL);
 
     /* Check access permissions first, then handle faults */
-    if ( access_valid && (mfn_x(mfn) != INVALID_MFN) )
+    if ( mfn_x(mfn) != INVALID_MFN )
     {
         int violation = 0;
         /* If the access is against the permissions, then send to mem_event */
index e4b41c44705f5a7aa103f206d1756c79bf222bcd..b5a5933f46f83df3c0c9b1ba96a565b1b380a495 100644 (file)
@@ -1143,7 +1143,7 @@ struct hvm_function_table * __init start_svm(void)
 }
 
 static void svm_do_nested_pgfault(struct vcpu *v,
-    struct cpu_user_regs *regs, paddr_t gpa)
+    struct cpu_user_regs *regs, uint32_t npfec, paddr_t gpa)
 {
     int ret;
     unsigned long gfn = gpa >> PAGE_SHIFT;
@@ -1152,7 +1152,10 @@ static void svm_do_nested_pgfault(struct vcpu *v,
     p2m_access_t p2ma;
     struct p2m_domain *p2m = NULL;
 
-    ret = hvm_hap_nested_page_fault(gpa, 0, ~0ul, 0, 0, 0, 0);
+    ret = hvm_hap_nested_page_fault(gpa, 0, ~0ul, 
+                                    1, /* All NPFs count as reads */
+                                    npfec & PFEC_write_access, 
+                                    npfec & PFEC_insn_fetch);
 
     if ( tb_init_done )
     {
@@ -1181,7 +1184,7 @@ static void svm_do_nested_pgfault(struct vcpu *v,
     case -1:
         ASSERT(nestedhvm_enabled(v->domain) && nestedhvm_vcpu_in_guestmode(v));
         /* inject #VMEXIT(NPF) into guest. */
-        nestedsvm_vmexit_defer(v, VMEXIT_NPF, regs->error_code, gpa);
+        nestedsvm_vmexit_defer(v, VMEXIT_NPF, npfec, gpa);
         return;
     }
 
@@ -2198,10 +2201,9 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
 
     case VMEXIT_NPF:
         perfc_incra(svmexits, VMEXIT_NPF_PERFC);
-        regs->error_code = vmcb->exitinfo1;
         if ( cpu_has_svm_decode )
             v->arch.hvm_svm.cached_insn_len = vmcb->guest_ins_len & 0xf;
-        svm_do_nested_pgfault(v, regs, vmcb->exitinfo2);
+        svm_do_nested_pgfault(v, regs, vmcb->exitinfo1, vmcb->exitinfo2);
         v->arch.hvm_svm.cached_insn_len = 0;
         break;
 
index 81e8b82ca5bd1d9286a7061dc19cb7d0cdba27e0..d2bb64a6f260965eacb7bf889c7bf6c3a1dea2a6 100644 (file)
@@ -2106,7 +2106,6 @@ static void ept_handle_violation(unsigned long qualification, paddr_t gpa)
                                    qualification & EPT_GLA_VALID       ? 1 : 0,
                                    qualification & EPT_GLA_VALID
                                      ? __vmread(GUEST_LINEAR_ADDRESS) : ~0ull,
-                                   1, /* access types are as follows */
                                    qualification & EPT_READ_VIOLATION  ? 1 : 0,
                                    qualification & EPT_WRITE_VIOLATION ? 1 : 0,
                                    qualification & EPT_EXEC_VIOLATION  ? 1 : 0) )
index 826cb3302cab51610ece3a9ccc732190b58171c2..1a113f2bf97457dbfcf53ffb9649c2e0685f05d1 100644 (file)
@@ -409,7 +409,6 @@ int hvm_debug_op(struct vcpu *v, int32_t op);
 
 int hvm_hap_nested_page_fault(unsigned long gpa,
                               bool_t gla_valid, unsigned long gla,
-                              bool_t access_valid, 
                               bool_t access_r,
                               bool_t access_w,
                               bool_t access_x);