Skip to content

Commit 7075f16

Browse files
committed
KVM: x86: Refactor kvm_get_feature_msr() to avoid struct kvm_msr_entry
Refactor kvm_get_feature_msr() to take the components of kvm_msr_entry as separate parameters, along with a vCPU pointer, i.e. to give it the same prototype as kvm_{g,s}et_msr_ignored_check(). This will allow using a common inner helper for handling accesses to "regular" and feature MSRs. No functional change intended. Link: https://lore.kernel.org/r/20240802181935.292540-7-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b848f24 commit 7075f16

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

arch/x86/kvm/x86.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,39 +1659,38 @@ static u64 kvm_get_arch_capabilities(void)
16591659
return data;
16601660
}
16611661

1662-
static int kvm_get_feature_msr(struct kvm_msr_entry *msr)
1662+
static int kvm_get_feature_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data,
1663+
bool host_initiated)
16631664
{
1664-
switch (msr->index) {
1665+
WARN_ON_ONCE(!host_initiated);
1666+
1667+
switch (index) {
16651668
case MSR_IA32_ARCH_CAPABILITIES:
1666-
msr->data = kvm_get_arch_capabilities();
1669+
*data = kvm_get_arch_capabilities();
16671670
break;
16681671
case MSR_IA32_PERF_CAPABILITIES:
1669-
msr->data = kvm_caps.supported_perf_cap;
1672+
*data = kvm_caps.supported_perf_cap;
16701673
break;
16711674
case MSR_IA32_UCODE_REV:
1672-
rdmsrl_safe(msr->index, &msr->data);
1675+
rdmsrl_safe(index, data);
16731676
break;
16741677
default:
1675-
return kvm_x86_call(get_feature_msr)(msr->index, &msr->data);
1678+
return kvm_x86_call(get_feature_msr)(index, data);
16761679
}
16771680
return 0;
16781681
}
16791682

16801683
static int do_get_feature_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
16811684
{
1682-
struct kvm_msr_entry msr;
16831685
int r;
16841686

16851687
/* Unconditionally clear the output for simplicity */
1686-
msr.data = 0;
1687-
msr.index = index;
1688-
r = kvm_get_feature_msr(&msr);
1688+
*data = 0;
1689+
r = kvm_get_feature_msr(vcpu, index, data, true);
16891690

16901691
if (r == KVM_MSR_RET_UNSUPPORTED && kvm_msr_ignored_check(index, 0, false))
16911692
r = 0;
16921693

1693-
*data = msr.data;
1694-
16951694
return r;
16961695
}
16971696

@@ -7378,11 +7377,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
73787377

73797378
static void kvm_probe_feature_msr(u32 msr_index)
73807379
{
7381-
struct kvm_msr_entry msr = {
7382-
.index = msr_index,
7383-
};
7380+
u64 data;
73847381

7385-
if (kvm_get_feature_msr(&msr))
7382+
if (kvm_get_feature_msr(NULL, msr_index, &data, true))
73867383
return;
73877384

73887385
msr_based_features[num_msr_based_features++] = msr_index;

0 commit comments

Comments
 (0)