Browse Source

KVM: MMU: cleanup for error mask set while walk guest page table

Small cleanup for set page fault error code

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Xiao Guangrong 14 years ago
parent
commit
20bd40dc64
1 changed files with 7 additions and 10 deletions
  1. 7 10
      arch/x86/kvm/paging_tmpl.h

+ 7 - 10
arch/x86/kvm/paging_tmpl.h

@@ -224,9 +224,7 @@ walk:
 			    is_cpuid_PSE36())
 			    is_cpuid_PSE36())
 				gfn += pse36_gfn_delta(pte);
 				gfn += pse36_gfn_delta(pte);
 
 
-			access |= write_fault ? PFERR_WRITE_MASK : 0;
-			access |= fetch_fault ? PFERR_FETCH_MASK : 0;
-			access |= user_fault  ? PFERR_USER_MASK  : 0;
+			access |= write_fault | fetch_fault | user_fault;
 
 
 			real_gpa = mmu->translate_gpa(vcpu, gfn_to_gpa(gfn),
 			real_gpa = mmu->translate_gpa(vcpu, gfn_to_gpa(gfn),
 						      access);
 						      access);
@@ -268,10 +266,9 @@ error:
 	walker->error_code = 0;
 	walker->error_code = 0;
 	if (present)
 	if (present)
 		walker->error_code |= PFERR_PRESENT_MASK;
 		walker->error_code |= PFERR_PRESENT_MASK;
-	if (write_fault)
-		walker->error_code |= PFERR_WRITE_MASK;
-	if (user_fault)
-		walker->error_code |= PFERR_USER_MASK;
+
+	walker->error_code |= write_fault | user_fault;
+
 	if (fetch_fault && mmu->nx)
 	if (fetch_fault && mmu->nx)
 		walker->error_code |= PFERR_FETCH_MASK;
 		walker->error_code |= PFERR_FETCH_MASK;
 	if (rsvd_fault)
 	if (rsvd_fault)
@@ -673,9 +670,9 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access,
 	int r;
 	int r;
 
 
 	r = FNAME(walk_addr)(&walker, vcpu, vaddr,
 	r = FNAME(walk_addr)(&walker, vcpu, vaddr,
-			     !!(access & PFERR_WRITE_MASK),
-			     !!(access & PFERR_USER_MASK),
-			     !!(access & PFERR_FETCH_MASK));
+			     access & PFERR_WRITE_MASK,
+			     access & PFERR_USER_MASK,
+			     access & PFERR_FETCH_MASK);
 
 
 	if (r) {
 	if (r) {
 		gpa = gfn_to_gpa(walker.gfn);
 		gpa = gfn_to_gpa(walker.gfn);