Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: entry: Don't assume tramp_vectors is the start of the vectors

The tramp_ventry macro uses tramp_vectors as the address of the vectors
when calculating which ventry in the 'full fat' vectors to branch to.

While there is one set of tramp_vectors, this will be true.
Adding multiple sets of vectors will break this assumption.

Move the generation of the vectors to a macro, and pass the start
of the vectors as an argument to tramp_ventry.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>

+15 -13
+15 -13
arch/arm64/kernel/entry.S
··· 652 652 sub \dst, \dst, PAGE_SIZE 653 653 .endm 654 654 655 - .macro tramp_ventry, regsize = 64 655 + .macro tramp_ventry, vector_start, regsize 656 656 .align 7 657 657 1: 658 658 .if \regsize == 64 ··· 675 675 ldr x30, =vectors 676 676 #endif 677 677 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM 678 - prfm plil1strm, [x30, #(1b - tramp_vectors)] 678 + prfm plil1strm, [x30, #(1b - \vector_start)] 679 679 alternative_else_nop_endif 680 680 msr vbar_el1, x30 681 - add x30, x30, #(1b - tramp_vectors + 4) 681 + add x30, x30, #(1b - \vector_start + 4) 682 682 isb 683 683 ret 684 684 .org 1b + 128 // Did we overflow the ventry slot? ··· 697 697 sb 698 698 .endm 699 699 700 - .align 11 701 - SYM_CODE_START_NOALIGN(tramp_vectors) 700 + .macro generate_tramp_vector 701 + .Lvector_start\@: 702 702 .space 0x400 703 703 704 - tramp_ventry 705 - tramp_ventry 706 - tramp_ventry 707 - tramp_ventry 704 + .rept 4 705 + tramp_ventry .Lvector_start\@, 64 706 + .endr 707 + .rept 4 708 + tramp_ventry .Lvector_start\@, 32 709 + .endr 710 + .endm 708 711 709 - tramp_ventry 32 710 - tramp_ventry 32 711 - tramp_ventry 32 712 - tramp_ventry 32 712 + .align 11 713 + SYM_CODE_START_NOALIGN(tramp_vectors) 714 + generate_tramp_vector 713 715 SYM_CODE_END(tramp_vectors) 714 716 715 717 SYM_CODE_START(tramp_exit_native)