Skip to content

Commit f9a4d62

Browse files
committed
KVM: x86: introduce complete_emulated_msr callback
This will be used by SEV-ES to inject MSR failure via the GHCB. Reviewed-by: Tom Lendacky <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8b47442 commit f9a4d62

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ struct kvm_x86_ops {
12851285

12861286
void (*migrate_timers)(struct kvm_vcpu *vcpu);
12871287
void (*msr_filter_changed)(struct kvm_vcpu *vcpu);
1288+
int (*complete_emulated_msr)(struct kvm_vcpu *vcpu, int err);
12881289
};
12891290

12901291
struct kvm_x86_nested_ops {

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,6 +4306,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
43064306
.apic_init_signal_blocked = svm_apic_init_signal_blocked,
43074307

43084308
.msr_filter_changed = svm_msr_filter_changed,
4309+
.complete_emulated_msr = kvm_complete_insn_gp,
43094310
};
43104311

43114312
static struct kvm_x86_init_ops svm_init_ops __initdata = {

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7701,6 +7701,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
77017701
.migrate_timers = vmx_migrate_timers,
77027702

77037703
.msr_filter_changed = vmx_msr_filter_changed,
7704+
.complete_emulated_msr = kvm_complete_insn_gp,
77047705
.cpu_dirty_log_size = vmx_cpu_dirty_log_size,
77057706
};
77067707

arch/x86/kvm/x86.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,12 +1642,12 @@ static int complete_emulated_rdmsr(struct kvm_vcpu *vcpu)
16421642
kvm_rdx_write(vcpu, vcpu->run->msr.data >> 32);
16431643
}
16441644

1645-
return kvm_complete_insn_gp(vcpu, err);
1645+
return kvm_x86_ops.complete_emulated_msr(vcpu, err);
16461646
}
16471647

16481648
static int complete_emulated_wrmsr(struct kvm_vcpu *vcpu)
16491649
{
1650-
return kvm_complete_insn_gp(vcpu, vcpu->run->msr.error);
1650+
return kvm_x86_ops.complete_emulated_msr(vcpu, vcpu->run->msr.error);
16511651
}
16521652

16531653
static u64 kvm_msr_reason(int r)
@@ -1719,7 +1719,7 @@ int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu)
17191719
trace_kvm_msr_read_ex(ecx);
17201720
}
17211721

1722-
return kvm_complete_insn_gp(vcpu, r);
1722+
return kvm_x86_ops.complete_emulated_msr(vcpu, r);
17231723
}
17241724
EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr);
17251725

@@ -1745,7 +1745,7 @@ int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu)
17451745
else
17461746
trace_kvm_msr_write_ex(ecx, data);
17471747

1748-
return kvm_complete_insn_gp(vcpu, r);
1748+
return kvm_x86_ops.complete_emulated_msr(vcpu, r);
17491749
}
17501750
EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr);
17511751

0 commit comments

Comments
 (0)