Clear .bss for VP guests
Subsystems (3)
Boris Ostrovsky
reviewerv3 cover Clear .bss for VP guests
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
v3:
* Use existing macros for selecting mode-appropriate instructions/registers
* Use 32-bit registers in XOR
* Split removal of mode-selecting ifdefs into a separate patch
Boris Ostrovsky (2):
xen/x86: Zero out .bss for PV guests xen/x86: Drop mode-selecting ifdefs in startup_xen()
arch/x86/xen/xen-head.S | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.0
Boris Ostrovsky
reviewerPATCH v3 1/2 xen/x86: Zero out .bss for PV guests
Baremetal kernels clear .bss early in the boot but Xen PV guests don't execute that code. They have been able to run without problems because Xen domain builder happens to give out zeroed pages. However, since this is not really guaranteed, .bss should be explicitly cleared.
--- arch/x86/xen/xen-head.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/xen/xen-head.S +14 -0
@@ -38,6 +38,20 @@ __INIT ENTRY(startup_xen) cld + +#ifdef CONFIG_X86_32 +#define WSIZE_SHIFT 2 +#else +#define WSIZE_SHIFT 3 +#endif + /* Clear .bss */ + xor %eax,%eax + mov $__bss_start, %__ASM_REG(di) + mov $__bss_stop, %__ASM_REG(cx) + sub %__ASM_REG(di), %__ASM_REG(cx) + shr $WSIZE_SHIFT, %__ASM_REG(cx) + rep __ASM_SIZE(stos) + #ifdef CONFIG_X86_32 mov %esi,xen_start_info mov $init_thread_union+THREAD_SIZE,%esp
Signature · 1 line
2.1.0
Re: [PATCH v3 1/2] xen/x86: Zero out .bss for PV guests
Quoted 26 lines · Boris Ostrovsky
Baremetal kernels clear .bss early in the boot but Xen PV guests don't execute that code. They have been able to run without problems because Xen domain builder happens to give out zeroed pages. However, since this is not really guaranteed, .bss should be explicitly cleared.
Signed-off-by Boris Ostrovsky <[email protected]>--- arch/x86/xen/xen-head.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/x86/xen/xen-head.S +7
-0@@ -38,6 +38,20 @@ __INIT ENTRY(startup_xen) cld + +#ifdef CONFIG_X86_32 +#define WSIZE_SHIFT 2 +#else +#define WSIZE_SHIFT 3 +#endif + /* Clear .bss */
arch/x86/xen/xen-head.S line 57
Quoted 10 lines
arch/x86/xen/xen-head.S +7
-0+ xor %eax,%eax + mov $__bss_start, %__ASM_REG(di) + mov $__bss_stop, %__ASM_REG(cx) + sub %__ASM_REG(di), %__ASM_REG(cx) + shr $WSIZE_SHIFT, %__ASM_REG(cx) + rep __ASM_SIZE(stos) + #ifdef CONFIG_X86_32 mov %esi,xen_start_info mov $init_thread_union+THREAD_SIZE,%esp
Better, but can still be improved. Replace WSIZE_SHIFT with __ASM_SEL(2, 3), and use the macros for the registers (ie. __ASM_DI).
--
Brian Gerst
Re: [PATCH v3 1/2] xen/x86: Zero out .bss for PV guests
In reply to Boris OstrovskyQuoted 26 lines · Boris Ostrovsky
Baremetal kernels clear .bss early in the boot but Xen PV guests don't execute that code. They have been able to run without problems because Xen domain builder happens to give out zeroed pages. However, since this is not really guaranteed, .bss should be explicitly cleared.
Signed-off-by Boris Ostrovsky <[email protected]>--- arch/x86/xen/xen-head.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/x86/xen/xen-head.S +7
-0@@ -38,6 +38,20 @@ __INIT ENTRY(startup_xen) cld + +#ifdef CONFIG_X86_32 +#define WSIZE_SHIFT 2 +#else +#define WSIZE_SHIFT 3 +#endif + /* Clear .bss */
arch/x86/xen/xen-head.S line 57
Quoted 10 lines
arch/x86/xen/xen-head.S +7
-0+ xor %eax,%eax + mov $__bss_start, %__ASM_REG(di) + mov $__bss_stop, %__ASM_REG(cx) + sub %__ASM_REG(di), %__ASM_REG(cx) + shr $WSIZE_SHIFT, %__ASM_REG(cx) + rep __ASM_SIZE(stos) + #ifdef CONFIG_X86_32 mov %esi,xen_start_info mov $init_thread_union+THREAD_SIZE,%esp
Better, but can still be improved. Replace WSIZE_SHIFT with __ASM_SEL(2, 3), and use the macros for the registers (ie. __ASM_DI).
--
Brian Gerst
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerPATCH v3 1/2 xen/x86: Zero out .bss for PV guests
In reply to Boris OstrovskyBaremetal kernels clear .bss early in the boot but Xen PV guests don't execute that code. They have been able to run without problems because Xen domain builder happens to give out zeroed pages. However, since this is not really guaranteed, .bss should be explicitly cleared.
--- arch/x86/xen/xen-head.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/xen/xen-head.S +14 -0
@@ -38,6 +38,20 @@ __INIT ENTRY(startup_xen) cld + +#ifdef CONFIG_X86_32 +#define WSIZE_SHIFT 2 +#else +#define WSIZE_SHIFT 3 +#endif + /* Clear .bss */ + xor %eax,%eax + mov $__bss_start, %__ASM_REG(di) + mov $__bss_stop, %__ASM_REG(cx) + sub %__ASM_REG(di), %__ASM_REG(cx) + shr $WSIZE_SHIFT, %__ASM_REG(cx) + rep __ASM_SIZE(stos) + #ifdef CONFIG_X86_32 mov %esi,xen_start_info mov $init_thread_union+THREAD_SIZE,%esp
Signature · 7 lines
2.1.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerPATCH v3 2/2 xen/x86: Drop mode-selecting ifdefs in startup_xen()
In reply to Boris OstrovskyUse asm/asm.h macros instead.
--- arch/x86/xen/xen-head.S | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/x86/xen/xen-head.S +3 -7
@@ -52,13 +52,9 @@ ENTRY(startup_xen) shr $WSIZE_SHIFT, %__ASM_REG(cx) rep __ASM_SIZE(stos) -#ifdef CONFIG_X86_32 - mov %esi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%esp -#else - mov %rsi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%rsp -#endif + mov %__ASM_REG(si), xen_start_info + mov $init_thread_union+THREAD_SIZE, %__ASM_REG(sp) + jmp xen_start_kernel __FINIT
Signature · 7 lines
2.1.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerPATCH v3 2/2 xen/x86: Drop mode-selecting ifdefs in startup_xen()
In reply to Boris OstrovskyUse asm/asm.h macros instead.
--- arch/x86/xen/xen-head.S | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/x86/xen/xen-head.S +3 -7
@@ -52,13 +52,9 @@ ENTRY(startup_xen) shr $WSIZE_SHIFT, %__ASM_REG(cx) rep __ASM_SIZE(stos) -#ifdef CONFIG_X86_32 - mov %esi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%esp -#else - mov %rsi,xen_start_info - mov $init_thread_union+THREAD_SIZE,%rsp -#endif + mov %__ASM_REG(si), xen_start_info + mov $init_thread_union+THREAD_SIZE, %__ASM_REG(sp) + jmp xen_start_kernel __FINIT
Signature · 1 line
2.1.0
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but elf_load_image (in libelf-loader.c) seems to be able to clear segments (it will zero the memory between p_paddr + p_filesz and p_paddr + p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.
Roger.
Boris Ostrovsky
reviewerQuoted 8 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.
Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerQuoted 8 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.
Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
-boris
Quoted 17 lines · Boris Ostrovsky
Quoted 11 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
Quoted 6 lines
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
It does it on bare metal because bzImage is a raw binary image, not ELF.
--
Brian Gerst
Boris Ostrovsky
reviewerQuoted 15 lines · Brian Gerst
Quoted 13 lines · Boris Ostrovsky
Quoted 8 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
Quoted 7 lines
Quoted 6 lines
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerQuoted 15 lines · Brian Gerst
Quoted 13 lines · Boris Ostrovsky
Quoted 8 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
Quoted 7 lines
Quoted 6 lines
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
-boris
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Brian Gerst
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.
Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I'm going to apply it once you post a final version with the last suggestion from Brian.
I'll drop the tag for stable though.
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Brian Gerst
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.
Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I'm going to apply it once you post a final version with the last suggestion from Brian.
I'll drop the tag for stable though.
David
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 27 lines · Brian Gerst
Quoted 26 lines
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.
Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because elf_load_image explicitly zeroes the space between p_filesz and p_memsz in ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.
I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
Roger.
Quoted 47 lines · Roger Pau Monné
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 27 lines · Brian Gerst
Quoted 26 lines
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
Quoted 8 lines
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because
elf_load_imageexplicitly zeroes the space betweenp_fileszandp_memszin ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
The tools support loading bzImages, not just ELF images.
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 47 lines · Roger Pau Monné
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 27 lines · Brian Gerst
Quoted 26 lines
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
Quoted 8 lines
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because
elf_load_imageexplicitly zeroes the space betweenp_fileszandp_memszin ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
The tools support loading bzImages, not just ELF images.
David
Boris Ostrovsky
reviewerQuoted 2 lines · David Vrabel
The tools support loading bzImages, not just ELF images.
We load them as ELF images though, I believe, after uncompressing. E.g.:
static int xc_dom_load_bzimage_kernel(struct xc_dom_image *dom)
{
return elf_loader.loader(dom);
}-boris
Boris Ostrovsky
reviewerQuoted 2 lines · David Vrabel
The tools support loading bzImages, not just ELF images.
We load them as ELF images though, I believe, after uncompressing. E.g.:
static int xc_dom_load_bzimage_kernel(struct xc_dom_image *dom)
{
return elf_loader.loader(dom);
}-boris
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Boris Ostrovsky
reviewerQuoted 41 lines · Roger Pau Monné
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 23 lines · Brian Gerst
Quoted 22 lines
Quoted 20 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
Quoted 7 lines
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because
elf_load_imageexplicitly zeroes the space betweenp_fileszandp_memszin ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.
That's what I meant --- that the builder/loader gives out zeroed pages, not that Xen's allocator clears them in general. I'll update the commit message.
Quoted 4 lines
I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
Maybe NetBSD should drive carefully then ;-)
-boris
Boris Ostrovsky
reviewerQuoted 41 lines · Roger Pau Monné
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 23 lines · Brian Gerst
Quoted 22 lines
Quoted 20 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
Quoted 7 lines
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because
elf_load_imageexplicitly zeroes the space betweenp_fileszandp_memszin ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.
That's what I meant --- that the builder/loader gives out zeroed pages, not that Xen's allocator clears them in general. I'll update the commit message.
Quoted 4 lines
I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
Maybe NetBSD should drive carefully then ;-)
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
El 26/2/16 a les 16:10, Boris Ostrovsky ha escrit:
Quoted 27 lines · Brian Gerst
Quoted 26 lines
Quoted 24 lines · Boris Ostrovsky
Quoted 10 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed
to be cleared by Xen's domain builderI guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be
zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in
principle it can be anything.The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader
to do so.And since kernel does it explicitly on baremetal path I think it's a good
idea for PV to do the same.
Quoted 6 lines
Quoted 1 line
It does it on bare metal because bzImage is a raw binary image, not ELF.
OK, I didn't think about this.
But nevertheless, is it guaranteed that .bss is cleared by the loader? My reading of the spec is that it's not.
I think this is very blur in general. The copy of the spec I have says:
"the system initializes the data with zeros when the program begins to run"
What is "the system" here, Xen or the guest kernel?
Just to be clear, I'm not opposing to this change in any way, but the message in patch 1/2 needs to be fixed:
"They have been able to run without problems because Xen domain builder happens to give out zeroed pages."
This is wrong IMHO, .bss is not cleared because we are using zeroed pages, but because elf_load_image explicitly zeroes the space between p_filesz and p_memsz in ELF program headers (which is were .bss resides on properly arranged ELF binaries) when loading them.
I'm quite sure NetBSD also relies on this, so I would say it's intrinsically part of the Xen boot ABI now, and this change just adds seatbelts to Linux.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 17 lines · Boris Ostrovsky
Quoted 11 lines · Roger Pau Monné
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 3 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but
elf_load_image(inlibelf-loader.c) seems to be able to clear segments (it will zero the memory betweenp_paddr+p_fileszandp_paddr+p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.Right, but I don't think this is guaranteed. It's uninitialized data so in principle it can be anything.
Quoted 6 lines
The ELF spec says "the system initializes the data with zero when the program begins to run" which I read as it's up to runtime and not the loader to do so.
And since kernel does it explicitly on baremetal path I think it's a good idea for PV to do the same.
It does it on bare metal because bzImage is a raw binary image, not ELF.
--
Brian Gerst
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
El 25/2/16 a les 16:16, Boris Ostrovsky ha escrit:
Quoted 2 lines
PV guests need to have their .bss zeroed out since it is not guaranteed to be cleared by Xen's domain builder
I guess I'm missing something, but elf_load_image (in libelf-loader.c) seems to be able to clear segments (it will zero the memory between p_paddr + p_filesz and p_paddr + p_memsz) while loading the ELF into memory, so if the program headers are correctly setup the .bss should be zeroed out AFAICT.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel