Skip to content

Commit 07036cf

Browse files
willdeaconMarc Zyngier
authored andcommitted
KVM: arm64: Prevent re-finalisation of pKVM for a given CPU
__pkvm_prot_finalize() completes the deprivilege of the host when pKVM is in use by installing a stage-2 translation table for the calling CPU. Issuing the hypercall multiple times for a given CPU makes little sense, but in such a case just return early with -EPERM rather than go through the whole page-table dance again. Cc: Marc Zyngier <[email protected]> Cc: Quentin Perret <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2f2e1a5 commit 07036cf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ int __pkvm_prot_finalize(void)
123123
struct kvm_s2_mmu *mmu = &host_kvm.arch.mmu;
124124
struct kvm_nvhe_init_params *params = this_cpu_ptr(&kvm_init_params);
125125

126+
if (params->hcr_el2 & HCR_VM)
127+
return -EPERM;
128+
126129
params->vttbr = kvm_get_vttbr(mmu);
127130
params->vtcr = host_kvm.arch.vtcr;
128131
params->hcr_el2 |= HCR_VM;

0 commit comments

Comments
 (0)