Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: MMU: Make the definition of 'INVALID_GPA' common

KVM already has a 'GPA_INVALID' defined as (~(gpa_t)0) in kvm_types.h,
and it is used by ARM code. We do not need another definition of
'INVALID_GPA' for X86 specifically.

Instead of using the common 'GPA_INVALID' for X86, replace it with
'INVALID_GPA', and change the users of 'GPA_INVALID' so that the diff
can be smaller. Also because the name 'INVALID_GPA' tells the user we
are using an invalid GPA, while the name 'GPA_INVALID' is emphasizing
the GPA is an invalid one.

No functional change intended.

Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230105130127.866171-1-yu.c.zhang@linux.intel.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

authored by

Yu Zhang and committed by
Oliver Upton
cecafc0a 016cbbd2

+8 -10
+2 -2
arch/arm64/include/asm/kvm_host.h
··· 916 916 917 917 static inline void kvm_arm_pvtime_vcpu_init(struct kvm_vcpu_arch *vcpu_arch) 918 918 { 919 - vcpu_arch->steal.base = GPA_INVALID; 919 + vcpu_arch->steal.base = INVALID_GPA; 920 920 } 921 921 922 922 static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch) 923 923 { 924 - return (vcpu_arch->steal.base != GPA_INVALID); 924 + return (vcpu_arch->steal.base != INVALID_GPA); 925 925 } 926 926 927 927 void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);
+1 -1
arch/arm64/kvm/hypercalls.c
··· 198 198 break; 199 199 case ARM_SMCCC_HV_PV_TIME_ST: 200 200 gpa = kvm_init_stolen_time(vcpu); 201 - if (gpa != GPA_INVALID) 201 + if (gpa != INVALID_GPA) 202 202 val[0] = gpa; 203 203 break; 204 204 case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID:
+4 -4
arch/arm64/kvm/pvtime.c
··· 19 19 u64 steal = 0; 20 20 int idx; 21 21 22 - if (base == GPA_INVALID) 22 + if (base == INVALID_GPA) 23 23 return; 24 24 25 25 idx = srcu_read_lock(&kvm->srcu); ··· 40 40 switch (feature) { 41 41 case ARM_SMCCC_HV_PV_TIME_FEATURES: 42 42 case ARM_SMCCC_HV_PV_TIME_ST: 43 - if (vcpu->arch.steal.base != GPA_INVALID) 43 + if (vcpu->arch.steal.base != INVALID_GPA) 44 44 val = SMCCC_RET_SUCCESS; 45 45 break; 46 46 } ··· 54 54 struct kvm *kvm = vcpu->kvm; 55 55 u64 base = vcpu->arch.steal.base; 56 56 57 - if (base == GPA_INVALID) 57 + if (base == INVALID_GPA) 58 58 return base; 59 59 60 60 /* ··· 89 89 return -EFAULT; 90 90 if (!IS_ALIGNED(ipa, 64)) 91 91 return -EINVAL; 92 - if (vcpu->arch.steal.base != GPA_INVALID) 92 + if (vcpu->arch.steal.base != INVALID_GPA) 93 93 return -EEXIST; 94 94 95 95 /* Check the address is in a valid memslot */
-2
arch/x86/include/asm/kvm_host.h
··· 134 134 #define INVALID_PAGE (~(hpa_t)0) 135 135 #define VALID_PAGE(x) ((x) != INVALID_PAGE) 136 136 137 - #define INVALID_GPA (~(gpa_t)0) 138 - 139 137 /* KVM Hugepage definitions for x86 */ 140 138 #define KVM_MAX_HUGEPAGE_LEVEL PG_LEVEL_1G 141 139 #define KVM_NR_PAGE_SIZES (KVM_MAX_HUGEPAGE_LEVEL - PG_LEVEL_4K + 1)
+1 -1
include/linux/kvm_types.h
··· 40 40 typedef u64 gpa_t; 41 41 typedef u64 gfn_t; 42 42 43 - #define GPA_INVALID (~(gpa_t)0) 43 + #define INVALID_GPA (~(gpa_t)0) 44 44 45 45 typedef unsigned long hva_t; 46 46 typedef u64 hpa_t;