Skip to contentSkip to conversation

KVM: arm64: Transfer the hyp stack pages out of the host stage-2

PATCH Applied Mark Bundschuh 2 participants 2 messages Oct 29 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: Transfer the hyp stack pages out of the host stage-2

From: Fuad Tabba <[email protected]>

[ Upstream commit 3a8c562892b96f35bba1e00d5e455a15963bbb92 ]

fix_host_ownership() walks only the linear-map alias of each memblock region, and the per-CPU hyp stack, mapped in the private VA range for its guard page, has none.

Walk each stack's VA range with the same walker.

[ 38f9e4b905a0 ("arm64: kvm: Introduce nvhe stack size constants") is
not backported because it converts nvhe stack code in eight files to NVHE_STACK_SIZE, and the hyp stack here is one page, so PAGE_SIZE replaces it. ]

Assisted-by LLM
---
 arch/arm64/kvm/hyp/nvhe/setup.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/kvm/hyp/nvhe/setup.c +10 -0
index e8d4ea2fcfa09..89dbe4cb8394b 100644
@@ -255,6 +255,16 @@ static int finalize_host_mappings(void)
 			return ret;
 	}
 
+	/* The stacks sit in the private VA range, not the linear map. */
+	for (i = 0; i < hyp_nr_cpus; i++) {
+		struct kvm_nvhe_init_params *params = per_cpu_ptr(&kvm_init_params, i);
+		u64 start = params->stack_hyp_va - PAGE_SIZE;
+
+		ret = kvm_pgtable_walk(&pkvm_pgtable, start, PAGE_SIZE, &walker);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 

base-commit: 79807e970724c1f90cee1316361d61b80db4eef6

Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 4 lines

[ 38f9e4b905a0 ("arm64: kvm: Introduce nvhe stack size constants") is
not backported because it converts nvhe stack code in eight files to NVHE_STACK_SIZE, and the hyp stack here is one page, so PAGE_SIZE replaces it. ]

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha