Commit 264b82f
x86/decompressor: Don't rely on upper 32 bits of GPRs being preserved
The 4-to-5 level mode switch trampoline disables long mode and paging in
order to be able to flick the LA57 bit. According to section 3.4.1.1 of
the x86 architecture manual [0], 64-bit GPRs might not retain the upper
32 bits of their contents across such a mode switch.
Given that RBP, RBX and RSI are live at this point, preserve them on the
stack, along with the return address that might be above 4G as well.
[0] Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1: Basic Architecture
"Because the upper 32 bits of 64-bit general-purpose registers are
undefined in 32-bit modes, the upper 32 bits of any general-purpose
register are not preserved when switching from 64-bit mode to a 32-bit
mode (to protected mode or compatibility mode). Software must not
depend on these bits to maintain a value after a 64-bit to 32-bit
mode switch."
Fixes: 194a974 ("x86/boot/compressed/64: Handle 5-level paging boot if kernel is above 4G")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230807162720.545787-2-ardb@kernel.org1 parent bee6cf1 commit 264b82f
1 file changed
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
462 | 474 | | |
463 | | - | |
464 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
465 | 478 | | |
466 | 479 | | |
| 480 | + | |
467 | 481 | | |
468 | 482 | | |
469 | 483 | | |
470 | 484 | | |
471 | 485 | | |
472 | 486 | | |
473 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
474 | 493 | | |
475 | 494 | | |
476 | 495 | | |
| |||
582 | 601 | | |
583 | 602 | | |
584 | 603 | | |
585 | | - | |
| 604 | + | |
586 | 605 | | |
587 | 606 | | |
588 | 607 | | |
| |||
592 | 611 | | |
593 | 612 | | |
594 | 613 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | 614 | | |
599 | 615 | | |
600 | 616 | | |
| |||
671 | 687 | | |
672 | 688 | | |
673 | 689 | | |
674 | | - | |
| 690 | + | |
675 | 691 | | |
676 | 692 | | |
677 | 693 | | |
| |||
0 commit comments