]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
HVM 32 and 64bit environment
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 29 Apr 2015 16:31:43 +0000 (17:31 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Sep 2015 13:55:01 +0000 (14:55 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
README
arch/x86/boot/head_hvm.S [new file with mode: 0644]
config/common.mk
include/arch/x86/config.h

diff --git a/README b/README
index c4f4192ffc4f604024edb964665fda3546f3006c..5cee40501680d0b3d2d4a7a8b30166417b4e97f3 100644 (file)
--- a/README
+++ b/README
@@ -11,13 +11,12 @@ machine.
 
 ## The framework consists of:
 
-* PV 32 and 64 bit entry points
+* PV and HVM, 32 and 64 bit entry points
 * Hypercall interface
 * PV console driver (output)
 
 ## TODO List:
 
 * More introductory text
-* Entry points for 32 and 64bit HVM guests
 * Common reporting framework
 * Tests
diff --git a/arch/x86/boot/head_hvm.S b/arch/x86/boot/head_hvm.S
new file mode 100644 (file)
index 0000000..dfdfa1e
--- /dev/null
@@ -0,0 +1,76 @@
+#include <xtf/asm_macros.h>
+
+#include <arch/x86/page.h>
+#include <arch/x86/processor.h>
+#include <arch/x86/msr-index.h>
+#include <arch/x86/segment.h>
+
+        .code32 /* Always starts in 32bit flat mode. */
+
+
+/* HVM common setup for pae paging. */
+GLOBAL(_start)
+
+        /* CR4.PAE = 1 */
+        mov $X86_CR4_PAE, %eax
+        mov %eax, %cr4
+
+        /* CR3 = l?_???map */
+#ifdef __x86_64__
+        mov $l4_identmap, %eax
+#else
+        mov $l3_paemap, %eax
+#endif
+        mov %eax, %cr3
+
+#ifdef __x86_64__
+        /* EFER.LME = 1 */
+        mov $MSR_EFER, %ecx
+        rdmsr
+        bts $_EFER_LME, %eax
+        wrmsr
+#endif
+
+        /* CR0.{PG,PE} = 1 */
+        mov %cr0, %eax
+        or $(X86_CR0_PG | X86_CR0_PE), %eax
+        mov %eax, %cr0
+
+        lgdt gdt_ptr
+
+        /* Load code segment. */
+        ljmp $__KERN_CS, $1f
+#ifdef __x86_64__
+        .code64
+#endif
+
+        /* Load data segments. */
+1:      mov $__KERN_DS, %eax
+        mov %eax, %ds
+        mov %eax, %es
+        mov %eax, %fs
+        mov %eax, %gs
+        mov %eax, %ss
+
+        /* Move onto the boot stack. */
+        mov $boot_stack + PAGE_SIZE, %esp
+
+        /* Reset flags. */
+        push $X86_EFLAGS_MBS
+        popf
+
+        call xtf_main
+
+        /* panic() if xtf_main manages to return. */
+#ifdef __x86_64__
+        lea main_err_msg(%rip), %rdi
+#else
+        push $main_err_msg
+#endif
+        call panic
+SIZE(_start)
+
+.section .rodata.str1, "aMS", @progbits, 1
+
+main_err_msg: .asciz "xtf_main() returned\n"
+SIZE(main_err_msg)
index 89fc75e756ccb1bf8da68d9fda600c0c51f23146..f1ad103477213f6b9737060b22654e19dd362ec0 100644 (file)
@@ -2,10 +2,13 @@ ROOT := $(abspath $(CURDIR)/../..)
 DESTDIR ?= $(ROOT)/dist/
 
 PV_ENVIRONMENTS  := pv64 pv32
-ALL_ENVIRONMENTS := $(PV_ENVIRONMENTS)
+HVM_ENVIRONMENTS := hvm64 hvm32
+ALL_ENVIRONMENTS := $(PV_ENVIRONMENTS) $(HVM_ENVIRONMENTS)
 
 pv64_arch  := x86_64
 pv32_arch  := x86_32
+hvm64_arch := x86_64
+hvm32_arch := x86_32
 
 COMMON_FLAGS := -pipe -I$(ROOT)/include -MMD -MP
 
@@ -23,6 +26,8 @@ COMMON_CFLAGS-x86_64 := -m64
 
 head-pv64  := $(ROOT)/arch/x86/boot/head_pv64.o
 head-pv32  := $(ROOT)/arch/x86/boot/head_pv32.o
+head-hvm64 := $(ROOT)/arch/x86/boot/head_hvm64.o
+head-hvm32 := $(ROOT)/arch/x86/boot/head_hvm32.o
 
 obj-perarch :=
 obj-perenv  :=
@@ -52,6 +57,11 @@ ifneq ($(findstring $(1),$(PV_ENVIRONMENTS)),)
 %/head_$(1).o: %/head_pv.S
        $$(CC) $$(AFLAGS_$(1)) -c $$< -o $$@
 endif
+ifneq ($(findstring $(1),$(HVM_ENVIRONMENTS)),)
+# HVM guests generate head_hvm64.o and head_hvm32.o from head_hvm.S
+%/head_$(1).o: %/head_hvm.S
+       $$(CC) $$(AFLAGS_$(1)) -c $$< -o $$@
+endif
 
 # Generate .lds with approprate flags
 %/link-$(1).lds: %/link.lds.S
index a99619bbb90fcd93762d96fc695f1e32105da421..b0eb93364e7052d28d8dc552136e3996986fd752 100644 (file)
@@ -3,6 +3,8 @@
 
 #if defined(CONFIG_ENV_pv64) || defined(CONFIG_ENV_pv32)
 # define CONFIG_ENV_pv
+#elif defined(CONFIG_ENV_hvm64) || defined(CONFIG_ENV_hvm32)
+# define CONFIG_ENV_hvm
 #endif
 
 #endif /* XTF_X86_CONFIG_H */