Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64d60670 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

KVM: x86: stubs for SMM support



This patch adds the interface between x86.c and the emulator: the
SMBASE register, a new emulator flag, the RSM instruction.  It also
adds a new request bit that will be used by the KVM_SMI ioctl.

Reviewed-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f077825a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -193,6 +193,8 @@ struct x86_emulate_ops {
	int (*cpl)(struct x86_emulate_ctxt *ctxt);
	int (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest);
	int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value);
	u64 (*get_smbase)(struct x86_emulate_ctxt *ctxt);
	void (*set_smbase)(struct x86_emulate_ctxt *ctxt, u64 smbase);
	int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data);
	int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata);
	int (*check_pmc)(struct x86_emulate_ctxt *ctxt, u32 pmc);
@@ -264,6 +266,8 @@ enum x86emul_mode {

/* These match some of the HF_* flags defined in kvm_host.h  */
#define X86EMUL_GUEST_MASK           (1 << 5) /* VCPU is in guest-mode */
#define X86EMUL_SMM_MASK             (1 << 6)
#define X86EMUL_SMM_INSIDE_NMI_MASK  (1 << 7)

struct x86_emulate_ctxt {
	const struct x86_emulate_ops *ops;
+1 −0
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@ struct kvm_vcpu_arch {
	int32_t apic_arb_prio;
	int mp_state;
	u64 ia32_misc_enable_msr;
	u64 smbase;
	bool tpr_access_reporting;
	u64 ia32_xss;

+9 −1
Original line number Diff line number Diff line
@@ -2259,6 +2259,14 @@ static int em_lseg(struct x86_emulate_ctxt *ctxt)
	return rc;
}

static int em_rsm(struct x86_emulate_ctxt *ctxt)
{
	if ((ctxt->emul_flags & X86EMUL_SMM_MASK) == 0)
		return emulate_ud(ctxt);

	return X86EMUL_UNHANDLEABLE;
}

static void
setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
			struct desc_struct *cs, struct desc_struct *ss)
@@ -4197,7 +4205,7 @@ static const struct opcode twobyte_table[256] = {
	F(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N,
	/* 0xA8 - 0xAF */
	I(Stack | Src2GS, em_push_sreg), I(Stack | Src2GS, em_pop_sreg),
	DI(ImplicitOps, rsm),
	II(No64 | EmulateOnUD | ImplicitOps, em_rsm, rsm),
	F(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts),
	F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd),
	F(DstMem | SrcReg | Src2CL | ModRM, em_shrd),
+3 −1
Original line number Diff line number Diff line
@@ -808,7 +808,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
		break;

	case APIC_DM_SMI:
		apic_debug("Ignoring guest SMI\n");
		result = 1;
		kvm_make_request(KVM_REQ_SMI, vcpu);
		kvm_vcpu_kick(vcpu);
		break;

	case APIC_DM_NMI:
+1 −0
Original line number Diff line number Diff line
@@ -3394,6 +3394,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = {
	[SVM_EXIT_MWAIT]			= mwait_interception,
	[SVM_EXIT_XSETBV]			= xsetbv_interception,
	[SVM_EXIT_NPF]				= pf_interception,
	[SVM_EXIT_RSM]                          = emulate_on_interception,
};

static void dump_vmcb(struct kvm_vcpu *vcpu)
Loading