Commit ba6f5a46 authored by Jan Kiszka's avatar Jan Kiszka

x86/ipipe: kvm: Harden kvm_set_shared_msr in vmx_set_msr

vmx_set_msr may be called without a ipipe notifier registered, i.e.
outside of vcpu_run. In that case, shared MSRs may be set to guest state
while I-pipe will have no chance to restore them when interrupting
afterwards. Register the notifier and move the whole thing under hard
irq protection.

This fixes crashes when calling "info registers" from the QEMU console a
number times.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent 2b8250ae
...@@ -3090,9 +3090,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) ...@@ -3090,9 +3090,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
u64 old_msr_data = msr->data; u64 old_msr_data = msr->data;
msr->data = data; msr->data = data;
if (msr - vmx->guest_msrs < vmx->save_nmsrs) { if (msr - vmx->guest_msrs < vmx->save_nmsrs) {
unsigned long flags;
preempt_disable(); preempt_disable();
flags = hard_cond_local_irq_save();
ret = kvm_set_shared_msr(msr->index, msr->data, ret = kvm_set_shared_msr(msr->index, msr->data,
msr->mask); msr->mask);
preempt_enable(); preempt_enable();
if (ret) if (ret)
msr->data = old_msr_data; msr->data = old_msr_data;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment