mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-20 02:34:23 +08:00
KVM: introduce module parameter for ignoring unknown MSRs accesses
KVM will inject a #GP into the guest if that tries to access unhandled MSRs. This will crash many guests. Although it would be the correct way to actually handle these MSRs, we introduce a runtime switchable module param called "ignore_msrs" (defaults to 0). If this is Y, unknown MSR reads will return 0, while MSR writes are simply dropped. In both cases we print a message to dmesg to inform the user about that. You can change the behaviour at any time by saying: # echo 1 > /sys/modules/kvm/parameters/ignore_msrs Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
1fdbd48c24
commit
ed85c06853
@ -83,6 +83,9 @@ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
|
|||||||
struct kvm_x86_ops *kvm_x86_ops;
|
struct kvm_x86_ops *kvm_x86_ops;
|
||||||
EXPORT_SYMBOL_GPL(kvm_x86_ops);
|
EXPORT_SYMBOL_GPL(kvm_x86_ops);
|
||||||
|
|
||||||
|
int ignore_msrs = 0;
|
||||||
|
module_param_named(ignore_msrs, ignore_msrs, bool, S_IRUGO | S_IWUSR);
|
||||||
|
|
||||||
struct kvm_stats_debugfs_item debugfs_entries[] = {
|
struct kvm_stats_debugfs_item debugfs_entries[] = {
|
||||||
{ "pf_fixed", VCPU_STAT(pf_fixed) },
|
{ "pf_fixed", VCPU_STAT(pf_fixed) },
|
||||||
{ "pf_guest", VCPU_STAT(pf_guest) },
|
{ "pf_guest", VCPU_STAT(pf_guest) },
|
||||||
@ -930,8 +933,15 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
|
|||||||
"0x%x data 0x%llx\n", msr, data);
|
"0x%x data 0x%llx\n", msr, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n", msr, data);
|
if (!ignore_msrs) {
|
||||||
return 1;
|
pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n",
|
||||||
|
msr, data);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n",
|
||||||
|
msr, data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1078,8 +1088,14 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
|
|||||||
case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
|
case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
|
||||||
return get_msr_mce(vcpu, msr, pdata);
|
return get_msr_mce(vcpu, msr, pdata);
|
||||||
default:
|
default:
|
||||||
pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
|
if (!ignore_msrs) {
|
||||||
return 1;
|
pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
pr_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr);
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
*pdata = data;
|
*pdata = data;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user