Skip to content

Commit 7bab16a

Browse files
Jamie IlesMarc Zyngier
authored andcommitted
KVM: arm64: Correctly align nVHE percpu data
The nVHE percpu data is partially linked but the nVHE linker script did not align the percpu section. The PERCPU_INPUT macro would then align the data to a page boundary: #define PERCPU_INPUT(cacheline) \ __per_cpu_start = .; \ *(.data..percpu..first) \ . = ALIGN(PAGE_SIZE); \ *(.data..percpu..page_aligned) \ . = ALIGN(cacheline); \ *(.data..percpu..read_mostly) \ . = ALIGN(cacheline); \ *(.data..percpu) \ *(.data..percpu..shared_aligned) \ PERCPU_DECRYPTED_SECTION \ __per_cpu_end = .; but then when the final vmlinux linking happens the hypervisor percpu data is included after page alignment and so the offsets potentially don't match. On my build I saw that the .hyp.data..percpu section was at address 0x20 and then the percpu data would begin at 0x1000 (because of the page alignment in PERCPU_INPUT), but when linked into vmlinux, everything would be shifted down by 0x20 bytes. This manifests as one of the CPUs getting lost when running kvm-unit-tests or starting any VM and subsequent soft lockup on a Cortex A72 device. Fixes: 30c9539 ("kvm: arm64: Set up hyp percpu data for nVHE") Signed-off-by: Jamie Iles <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Acked-by: David Brazdil <[email protected]> Cc: David Brazdil <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ed4ffaf commit 7bab16a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/arm64/kvm/hyp/nvhe/hyp.lds.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
SECTIONS {
1515
HYP_SECTION(.text)
16+
/*
17+
* .hyp..data..percpu needs to be page aligned to maintain the same
18+
* alignment for when linking into vmlinux.
19+
*/
20+
. = ALIGN(PAGE_SIZE);
1621
HYP_SECTION_NAME(.data..percpu) : {
1722
PERCPU_INPUT(L1_CACHE_BYTES)
1823
}

0 commit comments

Comments
 (0)