From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 7/7] target-i386: register a separate KVM address space including SMRAM regions
Date: Mon, 18 May 2015 17:28:40 +0200 [thread overview]
Message-ID: <1431962920-47525-8-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1431962920-47525-1-git-send-email-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target-i386/kvm.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 09b4fc7..19ccc08 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -22,7 +22,7 @@
#include "qemu-common.h"
#include "sysemu/sysemu.h"
-#include "sysemu/kvm.h"
+#include "sysemu/kvm_int.h"
#include "kvm_i386.h"
#include "cpu.h"
#include "exec/gdbstub.h"
@@ -846,6 +846,39 @@ static int kvm_get_supported_msrs(KVMState *s)
return ret;
}
+static Notifier smram_machine_done;
+static KVMMemoryListener smram_listener;
+static AddressSpace smram_address_space;
+static MemoryRegion smram_as_root;
+static MemoryRegion smram_as_mem;
+
+static void register_smram_listener(Notifier *n, void *unused)
+{
+ MemoryRegion *smram =
+ (MemoryRegion *) object_resolve_path("/machine/smram", NULL);
+
+ /* Outer container... */
+ memory_region_init(&smram_as_root, OBJECT(kvm_state), "mem-container-smram", ~0ull);
+ memory_region_set_enabled(&smram_as_root, true);
+
+ /* ... with two regions inside: normal system memory with low
+ * priority, and...
+ */
+ memory_region_init_alias(&smram_as_mem, OBJECT(kvm_state), "mem-smram",
+ get_system_memory(), 0, ~0ull);
+ memory_region_add_subregion_overlap(&smram_as_root, 0, &smram_as_mem, 0);
+ memory_region_set_enabled(&smram_as_mem, true);
+
+ if (smram) {
+ memory_region_add_subregion_overlap(&smram_as_root, 0, smram, 10);
+ memory_region_set_enabled(smram, true);
+ }
+
+ address_space_init(&smram_address_space, &smram_as_root, "KVM-SMRAM");
+ kvm_memory_listener_register(kvm_state, &smram_listener,
+ &smram_address_space, 1);
+}
+
int kvm_arch_init(MachineState *ms, KVMState *s)
{
uint64_t identity_base = 0xfffbc000;
@@ -904,6 +937,11 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
return ret;
}
}
+
+ if (kvm_check_extension(s, KVM_CAP_X86_SMM)) {
+ smram_machine_done.notify = register_smram_listener;
+ qemu_add_machine_init_done_notifier(&smram_machine_done);
+ }
return 0;
}
--
1.8.3.1
prev parent reply other threads:[~2015-05-18 15:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 15:28 [Qemu-devel] [PATCH 0/7] kvm-i386: QEMU support for SMRAM Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 1/7] kvm-all: put kvm_mem_flags to more work Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 2/7] kvm-all: remove useless typedef Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 3/7] kvm-all: move internal types to kvm_int.h Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 4/7] kvm-all: make KVM's memory listener more generic Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 5/7] kvm-all: add support for multiple address spaces Paolo Bonzini
2015-05-18 15:28 ` [Qemu-devel] [PATCH 6/7] kvm-all: kvm_irqchip_create is not expected to fail Paolo Bonzini
2015-05-18 15:28 ` 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=1431962920-47525-8-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).