summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheng Yang <sheng@linux.intel.com>2009-07-21 10:42:49 +0800
committerMarcelo Tosatti <mtosatti@redhat.com>2009-07-21 13:55:13 -0300
commitbf85573cb6a0d5bb72b0558e3aa56c153098422e (patch)
tree5537377e1c536e94f3f19c941f05d9e9506c2fd3 /qemu-kvm-x86.c
parentAdd MCE simulation support to qemu/kvm (diff)
downloadqemu-kvm-bf85573cb6a0d5bb72b0558e3aa56c153098422e.tar.gz
qemu-kvm-bf85573cb6a0d5bb72b0558e3aa56c153098422e.tar.bz2
qemu-kvm-bf85573cb6a0d5bb72b0558e3aa56c153098422e.zip
kvm: allow qemu to set EPT identity mapping address
If we use larger BIOS image than current 256KB, we would need move reserved TSS and EPT identity mapping pages. Currently TSS support this, but not EPT. (change from v1, use parameter address instead of value for ioctl) Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'qemu-kvm-x86.c')
-rw-r--r--qemu-kvm-x86.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index df40aaee8..d2c8abe1f 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -73,6 +73,47 @@ static int kvm_init_tss(kvm_context_t kvm)
return 0;
}
+static int kvm_set_identity_map_addr(kvm_context_t kvm, unsigned long addr)
+{
+#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR
+ int r;
+
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_IDENTITY_MAP_ADDR);
+ if (r > 0) {
+ r = ioctl(kvm->vm_fd, KVM_SET_IDENTITY_MAP_ADDR, &addr);
+ if (r == -1) {
+ fprintf(stderr, "kvm_set_identity_map_addr: %m\n");
+ return -errno;
+ }
+ return 0;
+ }
+#endif
+ return -ENOSYS;
+}
+
+static int kvm_init_identity_map_page(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR
+ int r;
+
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_IDENTITY_MAP_ADDR);
+ if (r > 0) {
+ /*
+ * this address is 4 pages before the bios, and the bios should present
+ * as unavaible memory
+ */
+ r = kvm_set_identity_map_addr(kvm, 0xfffbc000);
+ if (r < 0) {
+ fprintf(stderr, "kvm_init_identity_map_page: "
+ "unable to set identity mapping addr\n");
+ return r;
+ }
+
+ }
+#endif
+ return 0;
+}
+
static int kvm_create_pit(kvm_context_t kvm)
{
#ifdef KVM_CAP_PIT
@@ -104,6 +145,10 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
if (r < 0)
return r;
+ r = kvm_init_identity_map_page(kvm);
+ if (r < 0)
+ return r;
+
r = kvm_create_pit(kvm);
if (r < 0)
return r;