KVM: MMU: Make the definition of 'INVALID_GPA' common
authorYu Zhang <yu.c.zhang@linux.intel.com>
Thu, 5 Jan 2023 13:01:27 +0000 (21:01 +0800)
committerOliver Upton <oliver.upton@linux.dev>
Thu, 19 Jan 2023 21:48:38 +0000 (21:48 +0000)
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>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hypercalls.c
arch/arm64/kvm/pvtime.c
arch/x86/include/asm/kvm_host.h
include/linux/kvm_types.h

index 35a159d131b5f862c16b52842ef6b0ba8088fb00..37766e57c8f2cc8c2b66066af86d912bd1c9b32a 100644 (file)
@@ -916,12 +916,12 @@ void kvm_arm_vmid_clear_active(void);
 
 static inline void kvm_arm_pvtime_vcpu_init(struct kvm_vcpu_arch *vcpu_arch)
 {
-       vcpu_arch->steal.base = GPA_INVALID;
+       vcpu_arch->steal.base = INVALID_GPA;
 }
 
 static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch)
 {
-       return (vcpu_arch->steal.base != GPA_INVALID);
+       return (vcpu_arch->steal.base != INVALID_GPA);
 }
 
 void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);
index c9f401fa01a93c00ac20a3f6d9e2146a5592a12a..64c086c02c603167ddffa612f59b43daa2d9830f 100644 (file)
@@ -198,7 +198,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
                break;
        case ARM_SMCCC_HV_PV_TIME_ST:
                gpa = kvm_init_stolen_time(vcpu);
-               if (gpa != GPA_INVALID)
+               if (gpa != INVALID_GPA)
                        val[0] = gpa;
                break;
        case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID:
index 78a09f7a66373bfeb6b61b325a6830cb6249b5b3..4ceabaa4c30bddace82026253d84b0e89fe62a0c 100644 (file)
@@ -19,7 +19,7 @@ void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
        u64 steal = 0;
        int idx;
 
-       if (base == GPA_INVALID)
+       if (base == INVALID_GPA)
                return;
 
        idx = srcu_read_lock(&kvm->srcu);
@@ -40,7 +40,7 @@ long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
        switch (feature) {
        case ARM_SMCCC_HV_PV_TIME_FEATURES:
        case ARM_SMCCC_HV_PV_TIME_ST:
-               if (vcpu->arch.steal.base != GPA_INVALID)
+               if (vcpu->arch.steal.base != INVALID_GPA)
                        val = SMCCC_RET_SUCCESS;
                break;
        }
@@ -54,7 +54,7 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
        struct kvm *kvm = vcpu->kvm;
        u64 base = vcpu->arch.steal.base;
 
-       if (base == GPA_INVALID)
+       if (base == INVALID_GPA)
                return base;
 
        /*
@@ -89,7 +89,7 @@ int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
                return -EFAULT;
        if (!IS_ALIGNED(ipa, 64))
                return -EINVAL;
-       if (vcpu->arch.steal.base != GPA_INVALID)
+       if (vcpu->arch.steal.base != INVALID_GPA)
                return -EEXIST;
 
        /* Check the address is in a valid memslot */
index f35f1ff4427bb85273abab37fe40a9154bf11cd9..46e50cb6c9caea93a116abd98cfdd8c70d3aa41a 100644 (file)
 #define INVALID_PAGE (~(hpa_t)0)
 #define VALID_PAGE(x) ((x) != INVALID_PAGE)
 
-#define INVALID_GPA (~(gpa_t)0)
-
 /* KVM Hugepage definitions for x86 */
 #define KVM_MAX_HUGEPAGE_LEVEL PG_LEVEL_1G
 #define KVM_NR_PAGE_SIZES      (KVM_MAX_HUGEPAGE_LEVEL - PG_LEVEL_4K + 1)
index 76de36e56cdfe828e17b46f88a6d60f14a7f0bc2..2728d49bbdf6d34cf6cf94dc9adebf2480ddbe22 100644 (file)
@@ -40,7 +40,7 @@ typedef unsigned long  gva_t;
 typedef u64            gpa_t;
 typedef u64            gfn_t;
 
-#define GPA_INVALID    (~(gpa_t)0)
+#define INVALID_GPA    (~(gpa_t)0)
 
 typedef unsigned long  hva_t;
 typedef u64            hpa_t;