[PATCH] kvm: arm64: correctly align nVHE percpu data

Jamie Iles jamie at nuviainc.com
Thu Nov 12 19:31:43 EST 2020


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.  This manifests as one of the CPUs getting lost when
running kvm-unit-tests on EL2 entry and subsequent soft lockup.

Fixes: 30c953911c43 ("kvm: arm64: Set up hyp percpu data for nVHE")
Cc: David Brazdil <dbrazdil at google.com>
Cc: Marc Zyngier <maz at kernel.org>
Cc: Will Deacon <will at kernel.org>
Signed-off-by: Jamie Iles <jamie at nuviainc.com>
---
 arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S
index bb2d986ff696..84edca959893 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S
+++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S
@@ -13,6 +13,7 @@
 
 SECTIONS {
 	HYP_SECTION(.text)
+	. = ALIGN(PAGE_SIZE);
 	HYP_SECTION_NAME(.data..percpu) : {
 		PERCPU_INPUT(L1_CACHE_BYTES)
 	}
-- 
2.27.0




More information about the linux-arm-kernel mailing list