Message ID | 20240604143507.1041901-1-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kvm-unit-tests] realmode: load above stack | expand |
On 04/06/2024 16.35, Paolo Bonzini wrote: > The bottom 32K of memory are generally reserved for use by the BIOS; > for example, traditionally the boot loader is placed at 0x7C00 and > the stack grows below that address. > > It turns out that with some versions of clang, realmode.flat has > become big enough that it overlaps the stack used by the multiboot > option ROM loader. The result is that a couple instructions are > overwritten. Typically one or two tests fail and that's it... > > Move the code above the forbidden region, in real 90s style. > > Reported-by: Thomas Huth <thuth@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > x86/realmode.lds | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/x86/realmode.lds b/x86/realmode.lds > index 0ed3063b..e4782a98 100644 > --- a/x86/realmode.lds > +++ b/x86/realmode.lds > @@ -1,6 +1,6 @@ > SECTIONS > { > - . = 16K; > + . = 32K; > stext = .; > .text : { *(.init) *(.text) } > . = ALIGN(4K); This fails for me with: ld -m elf_i386 -nostdlib -o x86/realmode.elf \ -T /home/thuth/devel/kvm-unit-tests/x86/realmode.lds x86/realmode.o x86/realmode.o: in function `init_inregs': /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0x79): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0x82): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0x8b): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0x94): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0x9d): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0xa6): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0xaf): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0xb8): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0xc1): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:176:(.text+0xca): relocation truncated to fit: R_386_16 against `.bss' /home/thuth/devel/kvm-unit-tests/x86/realmode.c:180:(.text+0xda): additional relocation overflows omitted from the output make: *** [/home/thuth/devel/kvm-unit-tests/x86/Makefile.common:107: x86/realmode.elf] Error 1 Thomas
On Tue, Jun 4, 2024 at 4:40 PM Thomas Huth <thuth@redhat.com> wrote:
> This fails for me with:
Ok... I'll try building a fully relocated binary and copying it to the
right address.
Paolo
diff --git a/x86/realmode.lds b/x86/realmode.lds index 0ed3063b..e4782a98 100644 --- a/x86/realmode.lds +++ b/x86/realmode.lds @@ -1,6 +1,6 @@ SECTIONS { - . = 16K; + . = 32K; stext = .; .text : { *(.init) *(.text) } . = ALIGN(4K);
The bottom 32K of memory are generally reserved for use by the BIOS; for example, traditionally the boot loader is placed at 0x7C00 and the stack grows below that address. It turns out that with some versions of clang, realmode.flat has become big enough that it overlaps the stack used by the multiboot option ROM loader. The result is that a couple instructions are overwritten. Typically one or two tests fail and that's it... Move the code above the forbidden region, in real 90s style. Reported-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- x86/realmode.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)