From: Ladi Prosek <lprosek@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com
Subject: [PATCH v3 2/6] KVM: x86: introduce ISA specific smi_allowed callback
Date: Mon, 25 Sep 2017 10:09:00 +0200 [thread overview]
Message-ID: <20170925080904.24850-3-lprosek@redhat.com> (raw)
In-Reply-To: <20170925080904.24850-1-lprosek@redhat.com>
Similar to NMI, there may be ISA specific reasons why an SMI cannot be
injected into the guest. This commit adds a new smi_allowed callback to
be implemented in following commits.
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/svm.c | 6 ++++++
arch/x86/kvm/vmx.c | 6 ++++++
arch/x86/kvm/x86.c | 2 +-
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 596f2e826327..2445b2ba26f9 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1062,6 +1062,7 @@ struct kvm_x86_ops {
void (*setup_mce)(struct kvm_vcpu *vcpu);
+ int (*smi_allowed)(struct kvm_vcpu *vcpu);
int (*prep_enter_smm)(struct kvm_vcpu *vcpu, char *smstate);
int (*post_leave_smm)(struct kvm_vcpu *vcpu, u64 smbase);
};
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index cdbbf9537111..1d8dd364ead0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5393,6 +5393,11 @@ static void svm_setup_mce(struct kvm_vcpu *vcpu)
vcpu->arch.mcg_cap &= 0x1ff;
}
+static int svm_smi_allowed(struct kvm_vcpu *vcpu)
+{
+ return 1;
+}
+
static int svm_prep_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
{
/* TODO: Implement */
@@ -5516,6 +5521,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.update_pi_irte = svm_update_pi_irte,
.setup_mce = svm_setup_mce,
+ .smi_allowed = svm_smi_allowed,
.prep_enter_smm = svm_prep_enter_smm,
.post_leave_smm = svm_post_leave_smm,
};
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 10f5526f1069..5ddd092fb140 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11946,6 +11946,11 @@ static void vmx_setup_mce(struct kvm_vcpu *vcpu)
~FEATURE_CONTROL_LMCE;
}
+static int vmx_smi_allowed(struct kvm_vcpu *vcpu)
+{
+ return 1;
+}
+
static int vmx_prep_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
{
/* TODO: Implement */
@@ -12084,6 +12089,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
.setup_mce = vmx_setup_mce,
+ .smi_allowed = vmx_smi_allowed,
.prep_enter_smm = vmx_prep_enter_smm,
.post_leave_smm = vmx_post_leave_smm,
};
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8007a6ec2e5b..5c4c49e8e660 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6434,7 +6434,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
}
kvm_x86_ops->queue_exception(vcpu);
- } else if (vcpu->arch.smi_pending && !is_smm(vcpu)) {
+ } else if (vcpu->arch.smi_pending && !is_smm(vcpu) && kvm_x86_ops->smi_allowed(vcpu)) {
vcpu->arch.smi_pending = false;
enter_smm(vcpu);
} else if (vcpu->arch.nmi_pending && kvm_x86_ops->nmi_allowed(vcpu)) {
--
2.13.5
next prev parent reply other threads:[~2017-09-25 8:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-25 8:08 [PATCH v3 0/6] KVM: nested virt SMM fixes Ladi Prosek
2017-09-25 8:08 ` [PATCH v3 1/6] KVM: x86: introduce ISA specific SMM entry/exit callbacks Ladi Prosek
2017-09-25 8:09 ` Ladi Prosek [this message]
2017-09-25 8:09 ` [PATCH v3 3/6] KVM: nVMX: fix SMI injection in guest mode Ladi Prosek
2017-09-25 8:09 ` [PATCH v3 4/6] KVM: nVMX: treat CR4.VMXE as reserved in SMM Ladi Prosek
2017-09-25 8:09 ` [PATCH v3 5/6] KVM: nSVM: refactor nested_svm_vmrun Ladi Prosek
2017-09-25 8:09 ` [PATCH v3 6/6] KVM: nSVM: fix SMI injection in guest mode Ladi Prosek
2017-10-03 19:53 ` Radim Krčmář
2017-10-04 10:10 ` Ladi Prosek
2017-10-04 14:42 ` Radim Krčmář
2017-10-10 8:03 ` Ladi Prosek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170925080904.24850-3-lprosek@redhat.com \
--to=lprosek@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox