1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

KVM: x86: Add a VALID_MASK for the flags in kvm_msr_filter_range

Add the mask KVM_MSR_FILTER_RANGE_VALID_MASK for the flags in the
struct kvm_msr_filter_range.  This simplifies checks that validate
these flags, and makes it easier to introduce new flags in the future.

No functional change intended.

Signed-off-by: Aaron Lewis <aaronlewis@google.com>
Message-Id: <20220921151525.904162-5-aaronlewis@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Aaron Lewis 2022-09-21 15:15:24 +00:00 committed by Paolo Bonzini
parent c1340fe359
commit 8aff460f21
2 changed files with 3 additions and 1 deletions

View file

@ -214,6 +214,8 @@ struct kvm_msr_list {
struct kvm_msr_filter_range { struct kvm_msr_filter_range {
#define KVM_MSR_FILTER_READ (1 << 0) #define KVM_MSR_FILTER_READ (1 << 0)
#define KVM_MSR_FILTER_WRITE (1 << 1) #define KVM_MSR_FILTER_WRITE (1 << 1)
#define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | \
KVM_MSR_FILTER_WRITE)
__u32 flags; __u32 flags;
__u32 nmsrs; /* number of msrs in bitmap */ __u32 nmsrs; /* number of msrs in bitmap */
__u32 base; /* MSR index the bitmap starts at */ __u32 base; /* MSR index the bitmap starts at */

View file

@ -6407,7 +6407,7 @@ static int kvm_add_msr_filter(struct kvm_x86_msr_filter *msr_filter,
if (!user_range->nmsrs) if (!user_range->nmsrs)
return 0; return 0;
if (user_range->flags & ~(KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE)) if (user_range->flags & ~KVM_MSR_FILTER_RANGE_VALID_MASK)
return -EINVAL; return -EINVAL;
if (!user_range->flags) if (!user_range->flags)