x86/wakeup: Fix code generation for bogus_saved_magic
PATCH 1/1 x86/wakeup: Fix code generation for bogus_saved_magic
bogus_saved_magic() is in a .code64 section but invokved in 32bit mode. This causes a real encoding difference.
Before:
66 c7 04 25 14 80 0b 00 53 0e movw $0xe53,0xb8014(,%eiz,1)
After:
66 c7 05 14 80 0b 00 53 0e movw $0xe53,0xb8014
The differnce happens to be benign, but move the logic back into a .code32 for sanity sake. Annotate it with ELF metadata while doing so.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
This issue dates back to the very introduction of S3 support in Xen, in 2007.
--- xen/arch/x86/boot/wakeup.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
xen/arch/x86/boot/wakeup.S +5 -4
@@ -153,15 +153,16 @@ wakeup_32: /* Now in compatibility mode. Long-jump to 64-bit mode */ ljmp $BOOT_CS64, $bootsym_rel(wakeup_64,6) +FUNC_LOCAL(bogus_saved_magic, 0) + movw $0x0e00 + 'S', 0xb8014 + jmp bogus_saved_magic +END(bogus_saved_magic) + .code64 wakeup_64: /* Jump to high mappings and the higher-level wakeup code. */ movabs $s3_resume, %rbx jmp *%rbx -bogus_saved_magic: - movw $0x0e00 + 'S', 0xb8014 - jmp bogus_saved_magic - /* Stack for wakeup: rest of first trampoline page. */ ENTRY(wakeup_stack_start)
Signature · 1 line
2.39.5
Quoted 2 lines · Andrew Cooper
bogus_saved_magic()is in a .code64 section but invokved in 32bit mode. This
Typo: invoked
Quoted 9 lines
causes a real encoding difference.
Before:
66 c7 04 25 14 80 0b 00 53 0e movw $0xe53,0xb8014(,%eiz,1)After:
66 c7 05 14 80 0b 00 53 0e movw $0xe53,0xb8014The differnce happens to be benign, but move the logic back into a .code32 for
Typo: difference
Quoted 28 lines
sanity sake. Annotate it with ELF metadata while doing so.
Fixes d8c8fef09054 ("Provide basic Xen PM infrastructure")Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>This issue dates back to the very introduction of S3 support in Xen, in 2007.
--- xen/arch/x86/boot/wakeup.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)xen/arch/x86/boot/wakeup.S +5
-0@@ -153,15 +153,16 @@ wakeup_32: /* Now in compatibility mode. Long-jump to 64-bit mode */ ljmp $BOOT_CS64, $bootsym_rel(wakeup_64,6) +FUNC_LOCAL(bogus_saved_magic, 0) + movw $0x0e00 + 'S', 0xb8014 + jmp bogus_saved_magic +END(bogus_saved_magic) + .code64 wakeup_64:
xen/arch/x86/boot/wakeup.S wakeup_32: · line 168
Quoted 10 lines
xen/arch/x86/boot/wakeup.S +0
-4/* Jump to high mappings and the higher-level wakeup code. */ movabs $s3_resume, %rbx jmp *%rbx -bogus_saved_magic: - movw $0x0e00 + 'S', 0xb8014 - jmp bogus_saved_magic - /* Stack for wakeup: rest of first trampoline page. */ ENTRY(wakeup_stack_start)
Hi,
I agree with the code move, it's supposed to be 32 bit so it should
be in the 32 bit section.
Does the ELF annotation help with debug information? Maybe worth adding to the comment.
OT: If I understood correctly, the code is writing a character on screen in a tight loop. Maybe an hlt instruction could be helpful?
BTW
Frediano
Quoted 6 lines · Frediano Ziglio
Quoted 1 line · Andrew Cooper
bogus_saved_magic()is in a .code64 section but invokved in 32bit mode. ThisTypo: invoked
Quoted 2 lines
causes a real encoding difference.
Quoted 8 lines
Quoted 7 lines
Before:
66 c7 04 25 14 80 0b 00 53 0e movw $0xe53,0xb8014(,%eiz,1)After:
66 c7 05 14 80 0b 00 53 0e movw $0xe53,0xb8014The differnce happens to be benign, but move the logic back into a .code32 for
Typo: difference
Thanks. I'd noticed and fixed up locally.
Quoted 33 lines
Quoted 33 lines
sanity sake. Annotate it with ELF metadata while doing so.
Fixes d8c8fef09054 ("Provide basic Xen PM infrastructure")Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>This issue dates back to the very introduction of S3 support in Xen, in 2007.
--- xen/arch/x86/boot/wakeup.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)xen/arch/x86/boot/wakeup.S +5
-0@@ -153,15 +153,16 @@ wakeup_32: /* Now in compatibility mode. Long-jump to 64-bit mode */ ljmp $BOOT_CS64, $bootsym_rel(wakeup_64,6) +FUNC_LOCAL(bogus_saved_magic, 0) + movw $0x0e00 + 'S', 0xb8014 + jmp bogus_saved_magic +END(bogus_saved_magic) + .code64 wakeup_64: /* Jump to high mappings and the higher-level wakeup code. */ movabs $s3_resume, %rbx jmp *%rbx
Quoted 11 lines
xen/arch/x86/boot/wakeup.S wakeup_32: · line 168
Quoted 6 lines
xen/arch/x86/boot/wakeup.S +0
-4-bogus_saved_magic: - movw $0x0e00 + 'S', 0xb8014 - jmp bogus_saved_magic - /* Stack for wakeup: rest of first trampoline page. */ ENTRY(wakeup_stack_start)Hi,
I agree with the code move, it's supposed to be 32 bit so it should
be in the 32 bit section.
Does the ELF annotation help with debug information? Maybe worth adding to the comment.
As said in the commit message, it's simply ELF metadata (symbol type and size).
It doesn't interact with debug symbols, so far as I'm aware.
It's mainly for livepatching (the ELF metadata is how changes are identified), but we're applying it uniformly to all assembly as a cleanup activity.
Quoted 2 lines
OT: If I understood correctly, the code is writing a character on screen in a tight loop. Maybe an hlt instruction could be helpful?
Yeah, it's not exactly great code, but it needs more adjustments than just a hlt.
It ought to know about CONFIG_VIDEO, and ideally video=none.
Quoted 1 line
Reviewed-by Frediano Ziglio <[email protected]>
Thanks.
~Andrew
Quoted 64 lines · Andrew Cooper
Quoted 6 lines · Frediano Ziglio
Quoted 1 line · Andrew Cooper
bogus_saved_magic()is in a .code64 section but invokved in 32bit mode. ThisTypo: invoked
Quoted 2 lines
causes a real encoding difference.
Quoted 8 lines
Quoted 7 lines
Before:
66 c7 04 25 14 80 0b 00 53 0e movw $0xe53,0xb8014(,%eiz,1)After:
66 c7 05 14 80 0b 00 53 0e movw $0xe53,0xb8014The differnce happens to be benign, but move the logic back into a .code32 for
Typo: difference
Thanks. I'd noticed and fixed up locally.
Quoted 33 lines
Quoted 33 lines
sanity sake. Annotate it with ELF metadata while doing so.
Fixes d8c8fef09054 ("Provide basic Xen PM infrastructure")Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>This issue dates back to the very introduction of S3 support in Xen, in 2007.
--- xen/arch/x86/boot/wakeup.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)xen/arch/x86/boot/wakeup.S +5
-0@@ -153,15 +153,16 @@ wakeup_32: /* Now in compatibility mode. Long-jump to 64-bit mode */ ljmp $BOOT_CS64, $bootsym_rel(wakeup_64,6) +FUNC_LOCAL(bogus_saved_magic, 0) + movw $0x0e00 + 'S', 0xb8014 + jmp bogus_saved_magic +END(bogus_saved_magic) + .code64 wakeup_64: /* Jump to high mappings and the higher-level wakeup code. */ movabs $s3_resume, %rbx jmp *%rbxQuoted 11 lines
xen/arch/x86/boot/wakeup.S wakeup_32: · line 168
Quoted 6 lines
xen/arch/x86/boot/wakeup.S +0
-4-bogus_saved_magic: - movw $0x0e00 + 'S', 0xb8014 - jmp bogus_saved_magic - /* Stack for wakeup: rest of first trampoline page. */ ENTRY(wakeup_stack_start)Hi,
I agree with the code move, it's supposed to be 32 bit so it should
be in the 32 bit section.
Does the ELF annotation help with debug information? Maybe worth adding to the comment.
Quoted 9 lines
As said in the commit message, it's simply ELF metadata (symbol type and size).
It doesn't interact with debug symbols, so far as I'm aware.
It's mainly for livepatching (the ELF metadata is how changes are identified), but we're applying it uniformly to all assembly as a cleanup activity.
I don't think livepatching this code would be so easy. That code is copied to low memory and discarded (.init section) later, so patching the code in the current ELF code would corrupt Xen memory.
Quoted 8 lines
Quoted 2 lines
OT: If I understood correctly, the code is writing a character on screen in a tight loop. Maybe an hlt instruction could be helpful?
Yeah, it's not exactly great code, but it needs more adjustments than just a hlt.
It ought to know about
CONFIG_VIDEO, and ideally video=none.
In head.S we write messages in both VGA (if possible) and serial. Anyway... out of scope here.
Quoted 5 lines
Quoted 1 line
Reviewed-by Frediano Ziglio <[email protected]>Thanks.
~Andrew
Frediano
Quoted 48 lines · Frediano Ziglio
Quoted 48 lines
Quoted 32 lines
Quoted 32 lines
sanity sake. Annotate it with ELF metadata while doing so.
Fixes d8c8fef09054 ("Provide basic Xen PM infrastructure")Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>This issue dates back to the very introduction of S3 support in Xen, in 2007.
--- xen/arch/x86/boot/wakeup.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)xen/arch/x86/boot/wakeup.S +5
-0@@ -153,15 +153,16 @@ wakeup_32: /* Now in compatibility mode. Long-jump to 64-bit mode */ ljmp $BOOT_CS64, $bootsym_rel(wakeup_64,6) +FUNC_LOCAL(bogus_saved_magic, 0) + movw $0x0e00 + 'S', 0xb8014 + jmp bogus_saved_magic +END(bogus_saved_magic) + .code64 wakeup_64: /* Jump to high mappings and the higher-level wakeup code. */ movabs $s3_resume, %rbx jmp *%rbxQuoted 11 lines
xen/arch/x86/boot/wakeup.S wakeup_32: · line 168
Quoted 6 lines
xen/arch/x86/boot/wakeup.S +0
-4-bogus_saved_magic: - movw $0x0e00 + 'S', 0xb8014 - jmp bogus_saved_magic - /* Stack for wakeup: rest of first trampoline page. */ ENTRY(wakeup_stack_start)Hi,
I agree with the code move, it's supposed to be 32 bit so it should
be in the 32 bit section.
Does the ELF annotation help with debug information? Maybe worth adding to the comment.As said in the commit message, it's simply ELF metadata (symbol type and size).
It doesn't interact with debug symbols, so far as I'm aware.
Quoted 7 lines
Quoted 4 lines
It's mainly for livepatching (the ELF metadata is how changes are identified), but we're applying it uniformly to all assembly as a cleanup activity.
I don't think livepatching this code would be so easy. That code is copied to low memory and discarded (.init section) later, so patching the code in the current ELF code would corrupt Xen memory.
Indeed. This specific code is out of scope for livepatching.
But, we are (slowly) cleaning up all assembly code to use proper ELF metadata.
~Andrew
Quoted 6 lines · Andrew Cooper
bogus_saved_magic()is in a .code64 section but invokved in 32bit mode. This causes a real encoding difference.Before:
66 c7 04 25 14 80 0b 00 53 0e movw $0xe53,0xb8014(,%eiz,1)
Quoted 8 lines
After:
66 c7 05 14 80 0b 00 53 0e movw $0xe53,0xb8014The differnce happens to be benign, but move the logic back into a .code32 for sanity sake. Annotate it with ELF metadata while doing so.
Fixes d8c8fef09054 ("Provide basic Xen PM infrastructure")Signed-off-by Andrew Cooper <[email protected]>