Fix and improvements to pvshim
cover Fix and improvements to pvshim
First batch of patches to fix problems I know of.
Wei Liu (9):
Update shim.config
libxl: remove whitespaces introduced in 62982da926 x86/guest: clean up guest/xen.h
Remove sched=null from shim cmdline and doc
x86: relocate pvh_info
Revert "x86/boot: Map more than the first 16MB"
libxl: lower shim related message to level info xen/consoled: discard NUL from guest x86/shim: pass through vcpu runstate to L0 Xen
docs/man/xl.cfg.pod.5.in | 2 +- tools/firmware/xen-dir/shim.config | 1 - tools/libxl/libxl_dom.c | 8 +++--- tools/libxl/libxl_internal.h | 2 +- xen/arch/x86/boot/Makefile | 7 ++++- xen/arch/x86/boot/build32.mk | 3 ++ xen/arch/x86/boot/defs.h | 3 ++ xen/arch/x86/boot/head.S | 25 +++++++++-------- xen/arch/x86/boot/reloc.c | 53 +++++++++++++++++++++++++++++++---- xen/arch/x86/boot/x86_64.S | 3 +- xen/common/domain.c | 10 +++++++ xen/drivers/char/consoled.c | 4 ++- xen/include/asm-x86/guest/hypercall.h | 7 +++++ xen/include/asm-x86/guest/xen.h | 12 +++++--- 14 files changed, 109 insertions(+), 31 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/9 Update shim.config
To avoid having it changed every time the shim is built.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- tools/firmware/xen-dir/shim.config | 1 - 1 file changed, 1 deletion(-)
tools/firmware/xen-dir/shim.config +0 -1
@@ -68,7 +68,6 @@ CONFIG_HAS_EHCI=y CONFIG_HAS_CPUFREQ=y CONFIG_HAS_PASSTHROUGH=y CONFIG_HAS_PCI=y -# CONFIG_VGA is not set CONFIG_DEFCONFIG_LIST="$ARCH_DEFCONFIG" CONFIG_ARCH_SUPPORTS_INT128=y
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/9] Update shim.config
Quoted 3 lines · Wei Liu
To avoid having it changed every time the shim is built.
Signed-off-by Wei Liu <[email protected]>
One downside of having a this config in-tree is that it needs regenerating every time the Kconfig logic changes.
OTOH, I did deliberately wire up all the config options, so
make -C tools/firmware/xen-dir shim-olddefconfig
or shim-menuconfig etc do work as expected.
Do we know why this line is disappearing? I presume it is some change in the Kconfig logic, but I can't spot which changeset.
~Andrew
Quoted 12 lines
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- tools/firmware/xen-dir/shim.config | 1 - 1 file changed, 1 deletion(-)tools/firmware/xen-dir/shim.config +0
-0
tools/firmware/xen-dir/shim.config CONFIG_HAS_EHCI=y · line 73
Quoted 7 lines
tools/firmware/xen-dir/shim.config +0
-1@@ -68,7 +68,6 @@ CONFIG_HAS_EHCI=y CONFIG_HAS_CPUFREQ=y CONFIG_HAS_PASSTHROUGH=y CONFIG_HAS_PCI=y -# CONFIG_VGA is not set CONFIG_DEFCONFIG_LIST="$ARCH_DEFCONFIG" CONFIG_ARCH_SUPPORTS_INT128=y
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/9] Update shim.config
Quoted 8 lines · Andrew Cooper
Quoted 3 lines · Wei Liu
To avoid having it changed every time the shim is built.
Signed-off-by Wei Liu <[email protected]>One downside of having a this config in-tree is that it needs regenerating every time the
Kconfiglogic changes.
Quoted 8 lines
OTOH, I did deliberately wire up all the config options, so
make -C
tools/firmware/xen-dirshim-olddefconfigor shim-menuconfig etc do work as expected.
Do we know why this line is disappearing? I presume it is some change in the
Kconfiglogic, but I can't spot which changeset.
I guess that's due to "xen/x86: make VGA support selectable".
The shim.config probably is generated before that patch.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/9] Update shim.config
Quoted 12 lines · Wei Liu
Quoted 11 lines · Andrew Cooper
Quoted 3 lines · Wei Liu
To avoid having it changed every time the shim is built.
Signed-off-by Wei Liu <[email protected]>One downside of having a this config in-tree is that it needs regenerating every time the
Kconfiglogic changes.OTOH, I did deliberately wire up all the config options, so
make -C
tools/firmware/xen-dirshim-olddefconfig
Quoted 7 lines
Quoted 4 lines
or shim-menuconfig etc do work as expected.
Do we know why this line is disappearing? I presume it is some change in the
Kconfiglogic, but I can't spot which changeset.I guess that's due to "xen/x86: make VGA support selectable".
The shim.config probably is generated before that patch.
Can you identify that in the commit message? With that, Reviewed-by:
Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Roger Pau Monné
Reviewed-byRe: [PATCH 1/9] Update shim.config
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Wei Liu
Quoted 13 lines · Andrew Cooper
Quoted 3 lines · Wei Liu
To avoid having it changed every time the shim is built.
Signed-off-by Wei Liu <[email protected]>One downside of having a this config in-tree is that it needs regenerating every time the
Kconfiglogic changes.OTOH, I did deliberately wire up all the config options, so
make -C
tools/firmware/xen-dirshim-olddefconfigor shim-menuconfig etc do work as expected.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Do we know why this line is disappearing? I presume it is some change in the
Kconfiglogic, but I can't spot which changeset.I guess that's due to "xen/x86: make VGA support selectable".
The shim.config probably is generated before that patch.
Can you identify that in the commit message? With that, Reviewed-by:
Andrew Cooper <[email protected]>
AFAICT this is because the Kconfig option for VGA contains:
bool "VGA support" if !PV_SHIM_EXCLUSIVE
So if PV_SHIM_EXCLUSIVE is selected this option is not even available.
With that fixed in the commit message:
Although possibly having to change this file every time there's a Kconfig change seems very annoying (and easy to miss).
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/9 libxl: remove whitespaces introduced in 62982da926
In reply to Wei Liu---
Cc: Ian Jackson <[email protected]>
--- tools/libxl/libxl_dom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom.c +2 -2
@@ -1069,7 +1069,7 @@ static int libxl__domain_firmware(libxl__gc *gc, } } } - +if (state->pv_ramdisk.path &&strlen (state->pv_ramdisk.path)) {if (state->pv_ramdisk.mapped) { rc = xc_dom_module_mem(dom, state->pv_ramdisk.data,
@@ -1183,7 +1183,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,xc_dom_loginit (ctx->xch); -/* +/* * If PVH and we have a shim override, use the shim cmdline. * If PVH and no shim override, use the pv cmdline. * If not PVH, use info->cmdline.
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/9] libxl: remove whitespaces introduced in 62982da926
Quoted 1 line · Wei Liu
Signed-off-by Wei Liu <[email protected]>
I would add to the commit message: "No functional change.", but I guess it's already clear from the subject.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/9 x86/guest: clean up guest/xen.h
In reply to Wei LiuRemove extraneous semicolon. Add blank lines.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/include/asm-x86/guest/xen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
xen/include/asm-x86/guest/xen.h +8 -4
@@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);#define xen_guest 0#define pv_console 0 -static inline void probe_hypervisor (void ) {}; +static inline void probe_hypervisor (void ) {} +static inline void hypervisor_setup (void ) {ASSERT_UNREACHABLE ();
@@ -63,20 +64,23 @@ static inline void hypervisor_fixup_e820(struct e820map *e820) {ASSERT_UNREACHABLE (); } +static inline const unsigned long *hypervisor_reserved_pages (unsigned int *size) {ASSERT_UNREACHABLE ();return NULL ; -}; +} +static inline uint32_t hypervisor_cpuid_base (void ) {ASSERT_UNREACHABLE ();return 0 ; -}; +} +static inline void hypervisor_resume (void ) {ASSERT_UNREACHABLE (); -}; +}#endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/9] x86/guest: clean up guest/xen.h
Quoted 3 lines · Wei Liu
Remove extraneous semicolon. Add blank lines.
Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/9] x86/guest: clean up guest/xen.h
In reply to Wei LiuQuoted 38 lines · Wei Liu
Remove extraneous semicolon. Add blank lines.
Signed-off-by Wei Liu <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- xen/include/asm-x86/guest/xen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)xen/include/asm-x86/guest/xen.h +5
-2@@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);#define xen_guest 0#define pv_console 0 -static inline void probe_hypervisor (void ) {}; +static inline void probe_hypervisor (void ) {} +static inline void hypervisor_setup (void ) {ASSERT_UNREACHABLE ();@@ -63,20 +64,23 @@ static inline void hypervisor_fixup_e820(struct e820map *e820) {ASSERT_UNREACHABLE (); } +static inline const unsigned long *hypervisor_reserved_pages (unsigned int *size) {ASSERT_UNREACHABLE ();return NULL ; -}; +} +static inline uint32_t hypervisor_cpuid_base (void ) {
xen/include/asm-x86/guest/xen.h static inline void hypervisor_fixup_e820(struct e820map *e820) · line 83
Quoted 10 lines
xen/include/asm-x86/guest/xen.h +3
-2ASSERT_UNREACHABLE ();return 0 ; -}; +} +static inline void hypervisor_resume (void ) {ASSERT_UNREACHABLE (); -}; +}
AFAICT hypervisor_cpuid_base and hypervisor_resume could be removed, because those are only called from shim code, and it's not even possible to compile the shim code without having Xen guest support enabled.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/9] x86/guest: clean up guest/xen.h
Quoted 46 lines · Roger Pau Monné
Quoted 45 lines · Wei Liu
Remove extraneous semicolon. Add blank lines.
Signed-off-by Wei Liu <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- xen/include/asm-x86/guest/xen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)xen/include/asm-x86/guest/xen.h +7
-3@@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);#define xen_guest 0#define pv_console 0 -static inline void probe_hypervisor (void ) {}; +static inline void probe_hypervisor (void ) {} +static inline void hypervisor_setup (void ) {ASSERT_UNREACHABLE ();@@ -63,20 +64,23 @@ static inline void hypervisor_fixup_e820(struct e820map *e820) {ASSERT_UNREACHABLE (); } +static inline const unsigned long *hypervisor_reserved_pages (unsigned int *size) {ASSERT_UNREACHABLE ();return NULL ; -}; +} +static inline uint32_t hypervisor_cpuid_base (void ) {ASSERT_UNREACHABLE ();return 0 ; -}; +} +static inline void hypervisor_resume (void ) {
Quoted 8 lines
xen/include/asm-x86/guest/xen.h static inline void hypervisor_fixup_e820(struct e820map *e820) · line 72
Quoted 3 lines
xen/include/asm-x86/guest/xen.h +1
-1ASSERT_UNREACHABLE (); -}; +}AFAICT
hypervisor_cpuid_baseandhypervisor_resumecould be removed, because those are only called from shim code, and it's not even possible to compile the shim code without having Xen guest support enabled.
They need to stay. This header is included by the shim code itself.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/9] x86/guest: clean up guest/xen.h
Quoted 56 lines · Wei Liu
Quoted 46 lines · Roger Pau Monné
Quoted 45 lines · Wei Liu
Remove extraneous semicolon. Add blank lines.
Signed-off-by Wei Liu <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- xen/include/asm-x86/guest/xen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)xen/include/asm-x86/guest/xen.h +7
-3@@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);#define xen_guest 0#define pv_console 0 -static inline void probe_hypervisor (void ) {}; +static inline void probe_hypervisor (void ) {} +static inline void hypervisor_setup (void ) {ASSERT_UNREACHABLE ();@@ -63,20 +64,23 @@ static inline void hypervisor_fixup_e820(struct e820map *e820) {ASSERT_UNREACHABLE (); } +static inline const unsigned long *hypervisor_reserved_pages (unsigned int *size) {ASSERT_UNREACHABLE ();return NULL ; -}; +} +static inline uint32_t hypervisor_cpuid_base (void ) {ASSERT_UNREACHABLE ();return 0 ; -}; +} +static inline void hypervisor_resume (void ) {Quoted 8 lines
xen/include/asm-x86/guest/xen.h static inline void hypervisor_fixup_e820(struct e820map *e820) · line 72
Quoted 3 lines
xen/include/asm-x86/guest/xen.h +1
-1ASSERT_UNREACHABLE (); -}; +}AFAICT
hypervisor_cpuid_baseandhypervisor_resumecould be removed, because those are only called from shim code, and it's not even possible to compile the shim code without having Xen guest support enabled.
Quoted 1 line
They need to stay. This header is included by the shim code itself.
But the shim code never sees those, instead it should see the function prototypes above (inside the #ifdef CONFIG_XEN_GUEST guard).
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/9] x86/guest: clean up guest/xen.h
Quoted 57 lines · Roger Pau Monné
Quoted 56 lines · Wei Liu
Quoted 54 lines · Roger Pau Monné
Quoted 38 lines · Wei Liu
Remove extraneous semicolon. Add blank lines.
Signed-off-by Wei Liu <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>--- xen/include/asm-x86/guest/xen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)xen/include/asm-x86/guest/xen.h +5
-2@@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);#define xen_guest 0#define pv_console 0 -static inline void probe_hypervisor (void ) {}; +static inline void probe_hypervisor (void ) {} +static inline void hypervisor_setup (void ) {ASSERT_UNREACHABLE ();@@ -63,20 +64,23 @@ static inline void hypervisor_fixup_e820(struct e820map *e820) {ASSERT_UNREACHABLE (); } +static inline const unsigned long *hypervisor_reserved_pages (unsigned int *size) {ASSERT_UNREACHABLE ();return NULL ; -}; +} +static inline uint32_t hypervisor_cpuid_base (void ) {xen/include/asm-x86/guest/xen.h static inline void hypervisor_fixup_e820(struct e820map *e820) · line 83
Quoted 10 lines
xen/include/asm-x86/guest/xen.h +3
-2ASSERT_UNREACHABLE ();return 0 ; -}; +} +static inline void hypervisor_resume (void ) {ASSERT_UNREACHABLE (); -}; +}AFAICT
hypervisor_cpuid_baseandhypervisor_resumecould be removed, because those are only called from shim code, and it's not even possible to compile the shim code without having Xen guest support enabled.
Quoted 4 lines
Quoted 1 line
They need to stay. This header is included by the shim code itself.
But the shim code never sees those, instead it should see the function prototypes above (inside the #ifdef
CONFIG_XEN_GUESTguard).
I see. You mean removing the !CONFIG_PVH_GUEST static inline functions. That would be fine by me.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/9 Remove sched=null from shim cmdline and doc
In reply to Wei LiuWe use the default scheduler (credit1 as of writing). The NULL scheduler still has bugs to fix.
---
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- docs/man/xl.cfg.pod.5.in | 2 +- tools/libxl/libxl_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
docs/man/xl.cfg.pod.5.in +1 -1
@@ -531,7 +531,7 @@ Ignored if pvhsim is false. =item B<pvshim_cmdline="STRING"> Command line for the shim. -Default is "pv-shim console=xen,pv sched=null". +Default is "pv-shim console=xen,pv". Ignored if pvhsim is false. =item B<pvshim_extra="STRING">
tools/libxl/libxl_internal.h +1 -1
@@ -119,7 +119,7 @@#define DOMID_XS_PATH "domid"#define INVALID_DOMID ~0#define PVSHIM_BASENAME "xen-shim" -#define PVSHIM_CMDLINE "pv-shim console=xen,pv sched=null" +#define PVSHIM_CMDLINE "pv-shim console=xen,pv"/* Size macros. */ #define __AC (X ,Y ) (X##Y)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/9] Remove sched=null from shim cmdline and doc
Quoted 4 lines · Wei Liu
We use the default scheduler (credit1 as of writing). The NULL scheduler still has bugs to fix.
Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/9] Remove sched=null from shim cmdline and doc
In reply to Wei LiuQuoted 4 lines · Wei Liu
We use the default scheduler (credit1 as of writing). The NULL scheduler still has bugs to fix.
Signed-off-by Wei Liu <[email protected]>
This is AFAICT missing the change to shim.config, because the shim in staging is still being built with:
CONFIG_SCHED_NULL_DEFAULT=yCONFIG_SCHED_DEFAULT="null"
This however doesn't seem to be the case for the 4.10.0-shim-comet branch, where it's built with:
CONFIG_SCHED_CREDIT_DEFAULT=yCONFIG_SCHED_DEFAULT="credit"
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/9] Remove sched=null from shim cmdline and doc
Quoted 9 lines · Roger Pau Monné
Quoted 4 lines · Wei Liu
We use the default scheduler (credit1 as of writing). The NULL scheduler still has bugs to fix.
Signed-off-by Wei Liu <[email protected]>This is AFAICT missing the change to shim.config, because the shim in staging is still being built with:
Quoted 9 lines
CONFIG_SCHED_NULL_DEFAULT=yCONFIG_SCHED_DEFAULT="null"This however doesn't seem to be the case for the 4.10.0-shim-comet branch, where it's built with:
CONFIG_SCHED_CREDIT_DEFAULT=yCONFIG_SCHED_DEFAULT="credit"
-ETOOMANYBRANCHES
I thought this branch (forward-ported version of 4.10.0-shim-comet) had this in. I probably ported a stale branch.
I will fix this up in next version.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 5/9 x86: relocate pvh_info
In reply to Wei LiuModify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/arch/x86/boot/Makefile | 7 +++++- xen/arch/x86/boot/build32.mk | 3 +++ xen/arch/x86/boot/defs.h | 3 +++ xen/arch/x86/boot/head.S | 25 ++++++++++++--------- xen/arch/x86/boot/reloc.c | 53 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 73 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +6 -1
@@ -7,10 +7,15 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \ $(BASEDIR)/include/xen/multiboot2.h +ifeq ($(CONFIG_PVH_GUEST),y) +RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h +RELOC_EXTRA = CONFIG_PVH_GUEST=y +endif + head.o: cmdline.S reloc.S cmdline.S: cmdline.c $(CMDLINE_DEPS) $(MAKE) -f build32.mk $@ CMDLINE_DEPS="$(CMDLINE_DEPS)" reloc.S: reloc.c $(RELOC_DEPS) - $(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)" + $(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)" $(RELOC_EXTRA)
xen/arch/x86/boot/build32.mk +3 -0
@@ -36,5 +36,8 @@ CFLAGS := $(filter-out -flto,$(CFLAGS)) cmdline.o: cmdline.c $(CMDLINE_DEPS) reloc.o: reloc.c $(RELOC_DEPS) +ifeq ($(CONFIG_PVH_GUEST),y) +reloc.o: CFLAGS += -DCONFIG_PVH_GUEST +endif .PRECIOUS: %.bin %.lnk
xen/arch/x86/boot/defs.h +3 -0
@@ -51,6 +51,9 @@ typedef unsigned short u16;typedef unsigned int u32 ;typedef unsigned long long u64 ;typedef unsigned int size_t ; +typedef u8 uint8_t ; +typedef u32 uint32_t ; +typedef u64 uint64_t ;#define U16_MAX ((u16)(~0U))#define UINT_MAX (~0U)
xen/arch/x86/boot/head.S +14 -11
@@ -414,6 +414,7 @@ __pvh_start: /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA 0 */ movw $0x1000, sym_esi(trampoline_phys) + xor %eax, %eax /* Needed by reloc.c */ jmp trampoline_setup #endif /* CONFIG_PVH_GUEST */
@@ -578,18 +579,20 @@ trampoline_setup: /* Get bottom-most low-memory stack address. */ add $TRAMPOLINE_SPACE,%ecx -#ifdef CONFIG_PVH_GUEST - cmpb $0, sym_fs(pvh_boot) - jne 1f -#endif - - /* Save the Multiboot info struct (after relocation) for later use. */ + /* Save Multiboot / PVH info struct (after relocation) for later use. */ push %ecx /* Bottom-most low-memory stack address. */ - push %ebx /* Multiboot information address. */ - push %eax /* Multiboot magic. */ + push %ebx /* Multiboot / PVH information address. */ + push %eax /* Magic number. */ call reloc - mov %eax,sym_fs(multiboot_ptr) +#ifdef CONFIG_PVH_GUEST + cmp $0,sym_fs(pvh_boot) + je 1f + mov %eax,sym_fs(pvh_start_info_pa) + jmp 2f +#endif 1: + mov %eax,sym_fs(multiboot_ptr) +2: /* * Now trampoline_phys points to the following structure (lowest address
@@ -598,12 +601,12 @@ trampoline_setup: * +------------------------+ * | TRAMPOLINE_STACK_SPACE | * +------------------------+ - * | mbi data | + * | Data (MBI / PVH) | * +- - - - - - - - - - - - + * | TRAMPOLINE_SPACE | * +------------------------+ * - * mbi data grows downwards from the highest address of TRAMPOLINE_SPACE + * Data grows downwards from the highest address of TRAMPOLINE_SPACE * region to the end of the trampoline. The rest of TRAMPOLINE_SPACE is * reserved for trampoline code and data. */
xen/arch/x86/boot/reloc.c +47 -6
81 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] x86: relocate pvh_info
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.01.18 at 19:16, <[email protected]> wrote:
Modify early boot code to relocate pvh info as well, so that we can be sure
__vain__start_xenworks.Signed-off-by Wei Liu <[email protected]>
with one cosmetic request:
xen/arch/x86/boot/reloc.c asm ( · line 34
Quoted 7 lines
xen/arch/x86/boot/reloc.c +3
-0@@ -29,6 +29,10 @@ asm (#include "../../../include/xen/multiboot.h" #include "../../../include/xen/multiboot2.h" +#ifdef CONFIG_PVH_GUEST +#include <public/arch-x86/hvm/start_info.h> +#endif
Would you mind moving the #include ...
xen/arch/x86/boot/reloc.c static u32 copy_string(u32 src) · line 79
Quoted 6 lines
xen/arch/x86/boot/reloc.c +2
-0@@ -71,6 +75,38 @@ static u32 copy_string(u32 src)return copy_mem (src, p - src +1 ); } +#ifdef CONFIG_PVH_GUEST +static struct hvm_start_info *pvh_info_reloc (u32 in)
... above this line, to avoid the duplicate #ifdef?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] x86: relocate pvh_info
In reply to Wei LiuQuoted 4 lines · Wei Liu
Modify early boot code to relocate pvh info as well, so that we can be sure
__vain__start_xenworks.Signed-off-by Wei Liu <[email protected]>
:(
It was a fear of code like this which caused me to go with the gross hack in the short term.
Let me see if I can clean it up somewhat.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] x86: relocate pvh_info
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 19.01.18 at 11:10, <[email protected]> wrote:
Quoted 3 lines · Wei Liu
Modify early boot code to relocate pvh info as well, so that we can be sure
__vain__start_xenworks.
Quoted 8 lines
Quoted 1 line
Signed-off-by Wei Liu <[email protected]>:(
It was a fear of code like this which caused me to go with the gross hack in the short term.
Let me see if I can clean it up somewhat.
Is it really that bad, i.e. that much worse than the other relocation code?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] x86: relocate pvh_info
In reply to Wei Liuxen/arch/x86/boot/head.S __pvh_start: · line 417
Quoted 9 lines · Wei Liu
xen/arch/x86/boot/head.S +1
-0@@ -414,6 +414,7 @@ __pvh_start: /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA 0 */ movw $0x1000, sym_esi(trampoline_phys) + xor %eax, %eax /* Needed by reloc.c */
I would rather do:
movl $XEN_HVM_START_MAGIC_VALUE,%eax
Or:
mov (%ebx),%eax
So that...
xen/arch/x86/boot/head.S __pvh_start:
Quoted 9 lines
xen/arch/x86/boot/head.S +3
-3-multiboot_info_t __stdcall *reloc(u32 mb_magic, u32 mbi_in, u32 trampoline) +void __stdcall *reloc(u32 magic, u32 in, u32 trampoline) { alloc = trampoline; - if ( mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC ) - return mbi2_reloc(mbi_in); +#ifdef CONFIG_PVH_GUEST + if ( magic == 0 )
... here you can do magic == XEN_HVM_START_MAGIC_VALUE.
xen/arch/x86/boot/head.S
Quoted 8 lines
xen/arch/x86/boot/head.S +6
-1+ return pvh_info_reloc(in); + else +#endif + if ( magic == MULTIBOOT2_BOOTLOADER_MAGIC ) + return mbi2_reloc(in); else - return mbi_reloc(mbi_in); + return mbi_reloc(in);
A 'switch ( magic )' would be better here IMHO.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] x86: relocate pvh_info
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 19.01.18 at 11:53, <[email protected]> wrote:
xen/arch/x86/boot/head.S __pvh_start: · line 415
Quoted 7 lines · Wei Liu
xen/arch/x86/boot/head.S +0
-0@@ -414,6 +414,7 @@ __pvh_start: /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA0 */
xen/arch/x86/boot/head.S __pvh_start: · line 417
Quoted 2 lines
xen/arch/x86/boot/head.S +1
-0movw $0x1000, sym_esi(trampoline_phys) + xor %eax, %eax /* Needed by reloc.c */I would rather do:
movl $XEN_HVM_START_MAGIC_VALUE,%eax
Or:
mov (%ebx),%eax
So that...
xen/arch/x86/boot/head.S __pvh_start:
Quoted 9 lines
xen/arch/x86/boot/head.S +3
-3-multiboot_info_t __stdcall *reloc(u32 mb_magic, u32 mbi_in, u32 trampoline) +void __stdcall *reloc(u32 magic, u32 in, u32 trampoline) { alloc = trampoline; - if ( mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC ) - return mbi2_reloc(mbi_in); +#ifdef CONFIG_PVH_GUEST + if ( magic == 0 )... here you can do magic ==
XEN_HVM_START_MAGIC_VALUE.xen/arch/x86/boot/head.S
Quoted 8 lines
xen/arch/x86/boot/head.S +6
-1+ return pvh_info_reloc(in); + else +#endif + if ( magic == MULTIBOOT2_BOOTLOADER_MAGIC ) + return mbi2_reloc(in); else - return mbi_reloc(mbi_in); + return mbi_reloc(in);
Quoted 1 line
A 'switch ( magic )' would be better here IMHO.
Ah, indeed, that's better.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 6/9 Revert "x86/boot: Map more than the first 16MB"
In reply to Wei LiuThis reverts commit 7d6f958d9d18c54017f5ef6e299a08037f035747.
Now we have PVH info relocation support, this change is no longer needed.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/arch/x86/boot/x86_64.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/boot/x86_64.S +2 -1
@@ -114,10 +114,11 @@ GLOBAL(__page_tables_start) GLOBAL(l2_identmap) .quad sym_offs(l1_identmap) + __PAGE_HYPERVISOR idx = 1 - .rept 4 * L2_PAGETABLE_ENTRIES - 1 + .rept 7 .quad (idx << L2_PAGETABLE_SHIFT) | PAGE_HYPERVISOR | _PAGE_PSE idx = idx + 1 .endr + .fill 4 * L2_PAGETABLE_ENTRIES - 8, 8, 0 .size l2_identmap, . - l2_identmap /*
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 6/9] Revert "x86/boot: Map more than the first 16MB"
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 18.01.18 at 19:16, <[email protected]> wrote:
This reverts commit
7d6f958d9d18c54017f5ef6e299a08037f035747.Now we have PVH info relocation support, this change is no longer needed.
Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 7/9 libxl: lower shim related message to level info
In reply to Wei Liu---
Cc: Ian Jackson <[email protected]>
--- tools/libxl/libxl_dom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom.c +2 -2
@@ -1035,7 +1035,7 @@ static int libxl__domain_firmware(libxl__gc *gc,/* We've loaded the shim, so load the kernel as a secondary module */ if (state->pv_kernel.mapped) { -LOG (WARN ,"xc_dom_module_mem, cmdline %s" , +LOG (INFO ,"xc_dom_module_mem, cmdline %s" , state->pv_cmdline); rc =xc_dom_module_mem (dom, state->pv_kernel.data, state->pv_kernel.size, state->pv_cmdline);
@@ -1044,7 +1044,7 @@ static int libxl__domain_firmware(libxl__gc *gc, goto out; } }else { -LOG (WARN ,"xc_dom_module_file, path %s cmdline %s" , +LOG (INFO ,"xc_dom_module_file, path %s cmdline %s" , state->pv_kernel.path, state->pv_cmdline); rc =xc_dom_module_file (dom, state->pv_kernel.path, state->pv_cmdline);if (rc) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 7/9] libxl: lower shim related message to level info
Quoted 1 line · Wei Liu
Signed-off-by Wei Liu <[email protected]>
I would even make them DEBUG in fact. Feel free to keep the RB if you turn them into DEBUG.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 8/9 xen/consoled: discard NUL from guest
In reply to Wei LiuAccording to [0], some program sends NUL for padding purpose. We can discard them.
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_mono/termcap.html#SEC7
---
Cc: Sarah Newman <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
A bit RFC. Awaiting test results.
--- xen/drivers/char/consoled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/drivers/char/consoled.c +3 -1
@@ -72,7 +72,9 @@ size_t consoled_guest_rx(void) {char c = cons_ring->out[MASK_XENCONS_IDX (cons++, cons_ring->out)]; - buf[idx++] = c; +/* Discard NUL. See the "Padding" section of termcap manual. */ +if ( c !='\0' ) + buf[idx++] = c; recv++;if ( idx >=BUF_SZ )
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 8/9] xen/consoled: discard NUL from guest
Quoted 7 lines · Wei Liu
According to [0], some program sends NUL for padding purpose. We can discard them.
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_mono/termcap.html#SEC7
Reported-by Sarah Newman <[email protected]>Signed-off-by Wei Liu <[email protected]>
Although I have a suggestion below.
Quoted 16 lines
---
Cc: Sarah Newman <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>A bit RFC. Awaiting test results.
--- xen/drivers/char/consoled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/drivers/char/consoled.c +0
-0
xen/drivers/char/consoled.c size_t consoled_guest_rx(void) · line 73
Quoted 2 lines
xen/drivers/char/consoled.c +0
-0@@ -72,7 +72,9 @@ size_t consoled_guest_rx(void) {char c = cons_ring->out[MASK_XENCONS_IDX (cons++, cons_ring->out)];
You could also do:
if ( c == '\0' )
continue;
recv AFAICT it's just a cosmetic return value that's not consumed by the caller. This avoids checking the "idx >= BUF_SZ" condition with the same idx value.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 8/9] xen/consoled: discard NUL from guest
Quoted 34 lines · Roger Pau Monné
Quoted 7 lines · Wei Liu
According to [0], some program sends NUL for padding purpose. We can discard them.
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_mono/termcap.html#SEC7
Reported-by Sarah Newman <[email protected]>Signed-off-by Wei Liu <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>Although I have a suggestion below.
Quoted 16 lines
---
Cc: Sarah Newman <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>A bit RFC. Awaiting test results.
--- xen/drivers/char/consoled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/drivers/char/consoled.c +0
-0xen/drivers/char/consoled.c size_t consoled_guest_rx(void) · line 73
Quoted 2 lines
xen/drivers/char/consoled.c +0
-0@@ -72,7 +72,9 @@ size_t consoled_guest_rx(void) {char c = cons_ring->out[MASK_XENCONS_IDX (cons++, cons_ring->out)];You could also do:
Quoted 7 lines
if ( c == '\0' )
continue;recv AFAICT it's just a cosmetic return value that's not consumed by the caller. This avoids checking the "idx >=
BUF_SZ" condition with the same idx value.
I would like to keep the increment of recv but I like the idea of not repeatedly checking idx. I will rearrange the code a bit.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 9/9 x86/shim: pass through vcpu runstate to L0 Xen
In reply to Wei LiuSo that we can have accurate stolen time accounting. Idea taken from Vixen work from Amazon.
---
Cc: Roger Pau Monné <[email protected]>
Cc: Anthony Liguori <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/common/domain.c | 10 ++++++++++ xen/include/asm-x86/guest/hypercall.h | 7 +++++++ 2 files changed, 17 insertions(+)
xen/common/domain.c +10 -0
@@ -45,6 +45,7 @@#ifdef CONFIG_X86 #include <asm/guest.h> +#include <asm/guest/hypercall.h> #endif /* Linux config option: propageted to domain0 */
@@ -1425,6 +1426,15 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)if ( !guest_handle_okay (area.addr.h,1 ) )break ; +#if CONFIG_X86 +if ( pv_shim ) + { + rc =xen_hypercall_vcpu_op (VCPUOP_register_runstate_memory_area, + vcpuid, &area); +break ; + } +#endif + rc =0 ;runstate_guest (v) = area.addr.h;
xen/include/asm-x86/guest/hypercall.h +7 -0
@@ -192,6 +192,13 @@ static inline long xen_hypercall_shutdown(unsigned int reason)return 0 ; } +static inline int xen_hypercall_vcpu_op (unsigned int cmd,unsigned int vcpu, +void *arg) +{ +ASSERT_UNREACHABLE (); +return 0 ; +} +#endif /* CONFIG_XEN_GUEST */ #endif /* __X86_XEN_HYPERCALL_H__ */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 9/9] x86/shim: pass through vcpu runstate to L0 Xen
Quoted 14 lines · Wei Liu
xen/common/domain.c +1
-0@@ -45,6 +45,7 @@#ifdef CONFIG_X86 #include <asm/guest.h> +#include <asm/guest/hypercall.h> #endif /* Linux config option: propageted to domain0 */ @@ -1425,6 +1426,15 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)if ( !guest_handle_okay (area.addr.h,1 ) )
xen/common/domain.c long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) · line 1436
Quoted 10 lines
xen/common/domain.c +8
-0break ; +#if CONFIG_X86 +if ( pv_shim ) + { + rc =xen_hypercall_vcpu_op (VCPUOP_register_runstate_memory_area, + vcpuid, &area); +break ; + } +#endif
This only fixes VCPUOP_register_runstate_memory_area, but VCPUOP_get_runstate_info will still report wrong information. I've also wondered whether simply returning L0 information is correct. To get the exact information the shim should actually return the L0 information plus whatever time it steals from the guest.
Also, before adding more hooks to do_vcpu_op I would attempt to add a pv_shim_do_vcpu_op helper and patch the hypercall table, in order to avoid modifying more common code. AFAICT this doesn't require adding much compat code to the shim implementation.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 9/9] x86/shim: pass through vcpu runstate to L0 Xen
Quoted 17 lines · Roger Pau Monné
Quoted 16 lines · Wei Liu
xen/common/domain.c +1
-0@@ -45,6 +45,7 @@#ifdef CONFIG_X86 #include <asm/guest.h> +#include <asm/guest/hypercall.h> #endif /* Linux config option: propageted to domain0 */ @@ -1425,6 +1426,15 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)if ( !guest_handle_okay (area.addr.h,1 ) )break ;
Quoted 11 lines
xen/common/domain.c long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) · line 1436
Quoted 8 lines
xen/common/domain.c +8
-0+#if CONFIG_X86 +if ( pv_shim ) + { + rc =xen_hypercall_vcpu_op (VCPUOP_register_runstate_memory_area, + vcpuid, &area); +break ; + } +#endif This only fixes
VCPUOP_register_runstate_memory_area, butVCPUOP_get_runstate_infowill still report wrong information. I've
Yes, it appears that we should passthrough that call as well.
Quoted 4 lines
also wondered whether simply returning L0 information is correct. To get the exact information the shim should actually return the L0 information plus whatever time it steals from the guest.
I think that should be mostly correct. The error margin in the shim should be very small.
Quoted 5 lines
Also, before adding more hooks to
do_vcpu_opI would attempt to add apv_shim_do_vcpu_ophelper and patch the hypercall table, in order to avoid modifying more common code. AFAICT this doesn't require adding much compat code to the shim implementation.
Good idea.
I'm going to revisit this idea next week when I have more time. In the mean time I will repost the fixes patches I have.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel