Skip to content

Commit 95df55e

Browse files
Binbin Wusean-jc
authored andcommitted
KVM: x86: Remove kvm_vcpu_is_illegal_gpa()
Remove kvm_vcpu_is_illegal_gpa() and use !kvm_vcpu_is_legal_gpa() instead. The "illegal" helper actually predates the "legal" helper, the only reason the "illegal" variant wasn't removed by commit 4bda0e9 ("KVM: x86: Add a helper to check for a legal GPA") was to avoid code churn. Now that CR3 has a dedicated helper, there are fewer callers, and so the code churn isn't that much of a deterrent. No functional change intended. Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Tested-by: Xuelian Guo <xuelian.guo@intel.com> Link: https://lore.kernel.org/r/20230913124227.12574-8-binbin.wu@linux.intel.com [sean: provide a bit of history in the changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 82ba716 commit 95df55e

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

arch/x86/kvm/cpuid.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ static inline bool kvm_vcpu_is_legal_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
4747
return !(gpa & vcpu->arch.reserved_gpa_bits);
4848
}
4949

50-
static inline bool kvm_vcpu_is_illegal_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
51-
{
52-
return !kvm_vcpu_is_legal_gpa(vcpu, gpa);
53-
}
54-
5550
static inline bool kvm_vcpu_is_legal_aligned_gpa(struct kvm_vcpu *vcpu,
5651
gpa_t gpa, gpa_t alignment)
5752
{

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,7 @@ static bool nested_vmx_check_eptp(struct kvm_vcpu *vcpu, u64 new_eptp)
27172717
}
27182718

27192719
/* Reserved bits should not be set */
2720-
if (CC(kvm_vcpu_is_illegal_gpa(vcpu, new_eptp) || ((new_eptp >> 7) & 0x1f)))
2720+
if (CC(!kvm_vcpu_is_legal_gpa(vcpu, new_eptp) || ((new_eptp >> 7) & 0x1f)))
27212721
return false;
27222722

27232723
/* AD, if set, should be supported */

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5782,7 +5782,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
57825782
* would also use advanced VM-exit information for EPT violations to
57835783
* reconstruct the page fault error code.
57845784
*/
5785-
if (unlikely(allow_smaller_maxphyaddr && kvm_vcpu_is_illegal_gpa(vcpu, gpa)))
5785+
if (unlikely(allow_smaller_maxphyaddr && !kvm_vcpu_is_legal_gpa(vcpu, gpa)))
57865786
return kvm_emulate_instruction(vcpu, 0);
57875787

57885788
return kvm_mmu_page_fault(vcpu, gpa, error_code, NULL, 0);

0 commit comments

Comments
 (0)