Skip to content

Commit 51de815

Browse files
agrafbonzini
authored andcommitted
KVM: x86: Add infrastructure for MSR filtering
In the following commits we will add pieces of MSR filtering. To ensure that code compiles even with the feature half-merged, let's add a few stubs and struct definitions before the real patches start. Signed-off-by: Alexander Graf <graf@amazon.com> Message-Id: <20200925143422.21718-4-graf@amazon.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 1ae0995 commit 51de815

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ struct kvm_x86_ops {
12351235
int (*enable_direct_tlbflush)(struct kvm_vcpu *vcpu);
12361236

12371237
void (*migrate_timers)(struct kvm_vcpu *vcpu);
1238+
void (*msr_filter_changed)(struct kvm_vcpu *vcpu);
12381239
};
12391240

12401241
struct kvm_x86_nested_ops {

arch/x86/include/uapi/asm/kvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ struct kvm_msr_list {
192192
__u32 indices[0];
193193
};
194194

195+
#define KVM_MSR_FILTER_READ (1 << 0)
196+
#define KVM_MSR_FILTER_WRITE (1 << 1)
195197

196198
struct kvm_cpuid_entry {
197199
__u32 function;

arch/x86/kvm/x86.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,12 @@ void kvm_enable_efer_bits(u64 mask)
14881488
}
14891489
EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
14901490

1491+
bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type)
1492+
{
1493+
return true;
1494+
}
1495+
EXPORT_SYMBOL_GPL(kvm_msr_allowed);
1496+
14911497
/*
14921498
* Write @data into the MSR specified by @index. Select MSR specific fault
14931499
* checks are bypassed if @host_initiated is %true.

arch/x86/kvm/x86.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu);
374374
int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r,
375375
struct x86_exception *e);
376376
int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva);
377+
bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
377378

378379
#define KVM_MSR_RET_INVALID 2
379380

0 commit comments

Comments
 (0)