Skip to content

Commit 4202bca

Browse files
committed
KVM: arm64: Use mtree_empty() to determine if SMCCC filter configured
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent d34b764 commit 4202bca

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,8 @@ struct kvm_arch {
239239
#define KVM_ARCH_FLAG_VM_COUNTER_OFFSET 5
240240
/* Timer PPIs made immutable */
241241
#define KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE 6
242-
/* SMCCC filter initialized for the VM */
243-
#define KVM_ARCH_FLAG_SMCCC_FILTER_CONFIGURED 7
244242
/* Initial ID reg values loaded */
245-
#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 8
243+
#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 7
246244
unsigned long flags;
247245

248246
/* VM-wide vCPU feature set */

arch/arm64/kvm/hypercalls.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int kvm_smccc_filter_insert_reserved(struct kvm *kvm)
164164

165165
static bool kvm_smccc_filter_configured(struct kvm *kvm)
166166
{
167-
return test_bit(KVM_ARCH_FLAT_SMCCC_FILTER_CONFIGURED, &kvm->arch.flags);
167+
return !mtree_empty(&kvm->arch.smccc_filter);
168168
}
169169

170170
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
201201

202202
r = mtree_insert_range(&kvm->arch.smccc_filter, start, end,
203203
xa_mk_value(filter.action), GFP_KERNEL_ACCOUNT);
204-
if (r)
205-
goto out_unlock;
206-
207-
set_bit(KVM_ARCH_FLAG_SMCCC_FILTER_CONFIGURED, &kvm->arch.flags);
208-
209204
out_unlock:
210205
mutex_unlock(&kvm->arch.config_lock);
211206
return r;

0 commit comments

Comments
 (0)