From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, bsd@redhat.com
Subject: [PATCH 12/12] KVM: x86: advertise KVM_CAP_X86_SMM
Date: Fri, 8 May 2015 13:20:34 +0200 [thread overview]
Message-ID: <1431084034-8425-13-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1431084034-8425-1-git-send-email-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
--
RFC->v1: depend on support for real mode CS base above 1M
---
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 | 15 +++++++++++++++
4 files changed, 28 insertions(+)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3caefa4be90b..1c3e68a571c7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -700,6 +700,7 @@ struct kvm_x86_ops {
int (*hardware_setup)(void); /* __init */
void (*hardware_unsetup)(void); /* __exit */
bool (*cpu_has_accelerated_tpr)(void);
+ bool (*cpu_has_high_real_mode_segbase)(void);
void (*cpuid_update)(struct kvm_vcpu *vcpu);
/* Create, but do not attach this VCPU */
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1422dd945b85..c8c4430222c3 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -4080,6 +4080,11 @@ static bool svm_cpu_has_accelerated_tpr(void)
return false;
}
+static bool svm_has_high_real_mode_segbase(void)
+{
+ return true;
+}
+
static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
{
return 0;
@@ -4353,6 +4358,7 @@ static struct kvm_x86_ops svm_x86_ops = {
.hardware_enable = svm_hardware_enable,
.hardware_disable = svm_hardware_disable,
.cpu_has_accelerated_tpr = svm_cpu_has_accelerated_tpr,
+ .cpu_has_high_real_mode_segbase = svm_has_high_real_mode_segbase,
.vcpu_create = svm_create_vcpu,
.vcpu_free = svm_free_vcpu,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d29f751ea10d..c547b20e7438 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -8142,6 +8142,11 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu)
local_irq_enable();
}
+static bool vmx_has_high_real_mode_segbase(void)
+{
+ return enable_unrestricted_guest || emulate_invalid_guest_state;
+}
+
static bool vmx_mpx_supported(void)
{
return (vmcs_config.vmexit_ctrl & VM_EXIT_CLEAR_BNDCFGS) &&
@@ -10299,6 +10304,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
.hardware_enable = hardware_enable,
.hardware_disable = hardware_disable,
.cpu_has_accelerated_tpr = report_flexpriority,
+ .cpu_has_high_real_mode_segbase = vmx_has_high_real_mode_segbase,
.vcpu_create = vmx_create_vcpu,
.vcpu_free = vmx_free_vcpu,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ce36aca2276d..c4dd64377c19 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2836,6 +2836,17 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
#endif
r = 1;
break;
+ case KVM_CAP_X86_SMM:
+ /* SMBASE is usually relocated above 1M on modern chipsets,
+ * and SMM handlers might indeed rely on 4G segment limits,
+ * so do not report SMM to be available if real mode is
+ * emulated via vm86 mode. Still, do not go to great lengths
+ * to avoid userspace's usage of the feature, because it is a
+ * fringe case that is not enabled except via specific settings
+ * of the module parameters.
+ */
+ r = kvm_x86_ops->cpu_has_high_real_mode_segbase();
+ break;
case KVM_CAP_COALESCED_MMIO:
r = KVM_COALESCED_MMIO_PAGE_OFFSET;
break;
@@ -4229,6 +4240,10 @@ static void kvm_init_msr_list(void)
for (i = j = 0; i < ARRAY_SIZE(emulated_msrs); i++) {
switch (emulated_msrs[i]) {
+ case MSR_IA32_SMBASE:
+ if (!kvm_x86_ops->cpu_has_high_real_mode_segbase())
+ continue;
+ break;
default:
break;
}
--
1.8.3.1
prev parent reply other threads:[~2015-05-08 11:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 11:20 [PATCH 00/12] KVM: x86: SMM support Paolo Bonzini
2015-05-08 11:20 ` [PATCH 01/12] KVM: export __gfn_to_pfn_memslot, drop gfn_to_pfn_async Paolo Bonzini
2015-05-08 11:20 ` [PATCH 02/12] KVM: x86: introduce num_emulated_msrs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 03/12] KVM: remove unnecessary arg from mark_page_dirty_in_slot, export it Paolo Bonzini
2015-05-08 11:20 ` [PATCH 04/12] KVM: x86: pass host_initiated to functions that read MSRs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 05/12] KVM: x86: pass the whole hflags field to emulator and back Paolo Bonzini
2015-05-08 11:20 ` [PATCH 06/12] KVM: x86: API changes for SMM support Paolo Bonzini
2015-05-21 14:49 ` Radim Krčmář
2015-05-21 14:59 ` Paolo Bonzini
2015-05-21 16:26 ` Radim Krčmář
2015-05-21 21:21 ` Paolo Bonzini
2015-05-08 11:20 ` [PATCH 07/12] KVM: x86: stubs " Paolo Bonzini
2015-05-21 14:55 ` Radim Krčmář
2015-05-08 11:20 ` [PATCH 08/12] KVM: x86: save/load state on SMM switch Paolo Bonzini
2015-05-21 16:20 ` Radim Krčmář
2015-05-21 16:21 ` Paolo Bonzini
2015-05-21 16:33 ` Radim Krčmář
2015-05-21 20:24 ` Paolo Bonzini
2015-05-22 13:13 ` Radim Krčmář
2015-05-21 16:23 ` Paolo Bonzini
2015-05-21 17:00 ` Radim Krčmář
2015-05-21 21:21 ` Paolo Bonzini
2015-05-22 14:17 ` Radim Krčmář
2015-05-25 12:46 ` Paolo Bonzini
2015-05-08 11:20 ` [PATCH 09/12] KVM: x86: add vcpu-specific functions to read/write/translate GFNs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 10/12] KVM: x86: add SMM to the MMU role Paolo Bonzini
2015-05-08 11:20 ` [PATCH 11/12] KVM: x86: add KVM_MEM_X86_SMRAM memory slot flag Paolo Bonzini
2015-05-26 18:45 ` Avi Kivity
2015-05-27 9:26 ` Paolo Bonzini
2015-05-08 11:20 ` Paolo Bonzini [this message]
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=1431084034-8425-13-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=bsd@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).