Skip to content

Commit 6853a71

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Use correct accessor to parse stage-1 PTEs
hyp_get_page_state() is used with pKVM to retrieve metadata about a page by parsing a hypervisor stage-1 PTE. However, it incorrectly uses a helper which parses *stage-2* mappings. Ouch. Luckily, pkvm_getstate() only looks at the software bits, which happen to be in the same place for stage-1 and stage-2 PTEs, and this all ends up working correctly by accident. But clearly, we should do better. Fix hyp_get_page_state() to use the correct helper. Fixes: e82edcc ("KVM: arm64: Implement do_share() helper for sharing memory") Signed-off-by: Quentin Perret <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 247f34f commit 6853a71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kvm/hyp/nvhe/mem_protect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static enum pkvm_page_state hyp_get_page_state(kvm_pte_t pte)
516516
if (!kvm_pte_valid(pte))
517517
return PKVM_NOPAGE;
518518

519-
return pkvm_getstate(kvm_pgtable_stage2_pte_prot(pte));
519+
return pkvm_getstate(kvm_pgtable_hyp_pte_prot(pte));
520520
}
521521

522522
static int __hyp_check_page_state_range(u64 addr, u64 size,

0 commit comments

Comments
 (0)