From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtIcN-0002Op-5q for qemu-devel@nongnu.org; Fri, 15 May 2015 12:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YtIcL-00018U-17 for qemu-devel@nongnu.org; Fri, 15 May 2015 12:37:47 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:36297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtIcK-00018M-QX for qemu-devel@nongnu.org; Fri, 15 May 2015 12:37:44 -0400 Received: by wizk4 with SMTP id k4so294141496wiz.1 for ; Fri, 15 May 2015 09:37:44 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 15 May 2015 18:37:03 +0200 Message-Id: <1431707823-51230-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1431707823-51230-1-git-send-email-pbonzini@redhat.com> References: <1431707823-51230-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 7/7] kvm-i386: register SMRAM regions with KVM_MEM_X86_SMRAM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, lersek@redhat.com, avi.kivity@gmail.com, kraxel@redhat.com This patch adds SMRAM regions to the KVM CPU address space. The /machine/smram container has KVM_MEM_X86_SMRAM set in the memory flags, and this flag is propagated to the memory slot. Signed-off-by: Paolo Bonzini --- target-i386/kvm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 09b4fc7..224f8db 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -87,6 +87,8 @@ static bool has_msr_xss; static bool has_msr_architectural_pmu; static uint32_t num_architectural_pmu_counters; +static Notifier smram_machine_done; + bool kvm_allows_irq0_override(void) { return !kvm_irqchip_in_kernel() || kvm_has_gsi_routing(); @@ -846,6 +848,25 @@ static int kvm_get_supported_msrs(KVMState *s) return ret; } +static void smram_notify(Notifier *n, void *unused) +{ + MemoryRegion *smram = + (MemoryRegion *) object_resolve_path("/machine/smram", NULL); + + if (!smram) { + return; + } + + /* Add the SMRAM regions to the KVM address space, so that they will + * be considered when adding memory slots. + * + * This requires that the chipsets *disables* regions in /machine/smram + * whenever SMRAM is opened. + */ + memory_region_add_subregion_overlap(&kvm_state->kvm_as_root, 0, smram, 10); + smram->kvm_mem_flags |= KVM_MEM_X86_SMRAM; +} + int kvm_arch_init(MachineState *ms, KVMState *s) { uint64_t identity_base = 0xfffbc000; @@ -904,6 +925,12 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return ret; } } + + if (kvm_check_extension(s, KVM_CAP_X86_SMM)) { + smram_machine_done.notify = smram_notify; + qemu_add_machine_init_done_notifier(&smram_machine_done); + } + return 0; } -- 1.8.3.1