]> www.infradead.org Git - users/hch/configfs.git/commitdiff
KVM: arm64: Use mtree_empty() to determine if SMCCC filter configured
authorOliver Upton <oliver.upton@linux.dev>
Wed, 4 Oct 2023 23:49:47 +0000 (23:49 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Thu, 5 Oct 2023 09:33:15 +0000 (09:33 +0000)
The smccc_filter maple tree is only populated if userspace attempted to
configure it. Use the state of the maple tree to determine if the filter
has been configured, eliminating the VM flag.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20231004234947.207507-4-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hypercalls.c

index af06ccb7ee343304535c30b8855d6de8d8b1f4fc..feb63db7a5cf44ed57074657d2b9ec321dfbe338 100644 (file)
@@ -239,10 +239,8 @@ struct kvm_arch {
 #define KVM_ARCH_FLAG_VM_COUNTER_OFFSET                        5
        /* Timer PPIs made immutable */
 #define KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE             6
-       /* SMCCC filter initialized for the VM */
-#define KVM_ARCH_FLAG_SMCCC_FILTER_CONFIGURED          7
        /* Initial ID reg values loaded */
-#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED              8
+#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED              7
        unsigned long flags;
 
        /* VM-wide vCPU feature set */
index 20a878c64ba7d3b978bac27668f899fb0223c504..a61213786e5fcfd81b3c4b9580a97f554ca35116 100644 (file)
@@ -164,7 +164,7 @@ out_destroy:
 
 static bool kvm_smccc_filter_configured(struct kvm *kvm)
 {
-       return test_bit(KVM_ARCH_FLAT_SMCCC_FILTER_CONFIGURED, &kvm->arch.flags);
+       return !mtree_empty(&kvm->arch.smccc_filter);
 }
 
 static int kvm_smccc_set_filter(struct kvm *kvm, struct kvm_smccc_filter __user *uaddr)
@@ -201,11 +201,6 @@ static int kvm_smccc_set_filter(struct kvm *kvm, struct kvm_smccc_filter __user
 
        r = mtree_insert_range(&kvm->arch.smccc_filter, start, end,
                               xa_mk_value(filter.action), GFP_KERNEL_ACCOUNT);
-       if (r)
-               goto out_unlock;
-
-       set_bit(KVM_ARCH_FLAG_SMCCC_FILTER_CONFIGURED, &kvm->arch.flags);
-
 out_unlock:
        mutex_unlock(&kvm->arch.config_lock);
        return r;