Skip to content

Commit 66421c1

Browse files
Wanpeng Lirkrcmar
authored andcommitted
KVM: X86: Introduce kvm_get_msr_feature()
Introduce kvm_get_msr_feature() to handle the msrs which are supported by different vendors and sharing the same emulation logic. Cc: Paolo Bonzini <[email protected]> Cc: Radim Krčmář <[email protected]> Cc: Liran Alon <[email protected]> Cc: Nadav Amit <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Tom Lendacky <[email protected]> Signed-off-by: Wanpeng Li <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Signed-off-by: Radim Krčmář <[email protected]>
1 parent d1d93fa commit 66421c1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

arch/x86/kvm/x86.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,13 +1059,25 @@ static u32 msr_based_features[] = {
10591059

10601060
static unsigned int num_msr_based_features;
10611061

1062+
static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
1063+
{
1064+
switch (msr->index) {
1065+
default:
1066+
if (kvm_x86_ops->get_msr_feature(msr))
1067+
return 1;
1068+
}
1069+
return 0;
1070+
}
1071+
10621072
static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
10631073
{
10641074
struct kvm_msr_entry msr;
1075+
int r;
10651076

10661077
msr.index = index;
1067-
if (kvm_x86_ops->get_msr_feature(&msr))
1068-
return 1;
1078+
r = kvm_get_msr_feature(&msr);
1079+
if (r)
1080+
return r;
10691081

10701082
*data = msr.data;
10711083

@@ -4522,7 +4534,7 @@ static void kvm_init_msr_list(void)
45224534
struct kvm_msr_entry msr;
45234535

45244536
msr.index = msr_based_features[i];
4525-
if (kvm_x86_ops->get_msr_feature(&msr))
4537+
if (kvm_get_msr_feature(&msr))
45264538
continue;
45274539

45284540
if (j < i)

0 commit comments

Comments
 (0)