Skip to contentSkip to conversation

kvm,ept: pass error code to handler

PATCH In review Lai Jiangshan 2 participants 2 messages Jun 11, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kvm,ept: pass error code to handler

handle_ept_violation() does not pass error code to the handler tdp_page_fault().

It means tdp_page_fault() handles the page fault with ignoring the error code, It will not handle the page fault completely correctly, and may causes endless page fault.

{
But because there is another bad code in the kvm, This endless page faulting never occur. The bad code: kvm always set pte writable.

negative * negative = positive, WTF!!

Next patch will fix this bad code.
}

---

arch/x86/kvm/vmx.c +1 -1
index c7565ea..6362dcc 100644
@@ -3470,7 +3470,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
 
 	gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
 	trace_kvm_page_fault(gpa, exit_qualification);
-	return kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, 0);
+	return kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, exit_qualification);
 }
 
 static u64 ept_rsvd_mask(u64 spte, int level)
#1 lore raw
Quoted 23 lines · Lai Jiangshan

handle_ept_violation() does not pass error code to the handler tdp_page_fault().

It means tdp_page_fault() handles the page fault with ignoring the error code, It will not handle the page fault completely correctly, and may causes endless page fault.

{
But because there is another bad code in the kvm, This endless page faulting never occur. The bad code: kvm always set pte writable.

negative * negative = positive, WTF!!

Next patch will fix this bad code.
}

---

arch/x86/kvm/vmx.c +0 -0
index c7565ea..6362dcc 100644

arch/x86/kvm/vmx.c static int handle_ept_violation(struct kvm_vcpu *vcpu) · line 3473

Quoted 5 lines
arch/x86/kvm/vmx.c +1 -1
@@ -3470,7 +3470,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
 
 	gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
 	trace_kvm_page_fault(gpa, exit_qualification);
-	return kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, 0);
+	return kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, exit_qualification);

exit_qualification & 0x2, because bit 1 (write fault) of exit qualification is the only one that matches x86's pagefault error codes.