From: Andrew Cooper Date: Wed, 29 Apr 2015 16:31:43 +0000 (+0100) Subject: HVM 32 and 64bit environment X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d98030256819a530d18cba772684b55bdd469bb6;p=people%2Froyger%2Fxen-test-framework.git HVM 32 and 64bit environment Signed-off-by: Andrew Cooper --- diff --git a/README b/README index c4f4192..5cee405 100644 --- 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 index 0000000..dfdfa1e --- /dev/null +++ b/arch/x86/boot/head_hvm.S @@ -0,0 +1,76 @@ +#include + +#include +#include +#include +#include + + .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) diff --git a/config/common.mk b/config/common.mk index 89fc75e..f1ad103 100644 --- a/config/common.mk +++ b/config/common.mk @@ -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 diff --git a/include/arch/x86/config.h b/include/arch/x86/config.h index a99619b..b0eb933 100644 --- a/include/arch/x86/config.h +++ b/include/arch/x86/config.h @@ -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 */