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 <jan.kiszka@siemens.com>
parent 2b8250ae
......@@ -3090,9 +3090,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
u64 old_msr_data = msr->data;
msr->data = data;
if (msr - vmx->guest_msrs < vmx->save_nmsrs) {
unsigned long flags;
preempt_disable();
flags = hard_cond_local_irq_save();
__ipipe_enter_vm(&vcpu->ipipe_notifier);
ret = kvm_set_shared_msr(msr->index, msr->data,
msr->mask);
hard_cond_local_irq_restore(flags);
preempt_enable();
if (ret)
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