Skip to content

Commit 5398ddc

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Pass walk flags to kvm_pgtable_stage2_mkyoung
kvm_pgtable_stage2_mkyoung currently assumes that it is being called from a 'shared' walker, which will not be true once called from pKVM. To allow for the re-use of that function, make the walk flags one of its parameters. Tested-by: Fuad Tabba <[email protected]> Reviewed-by: Fuad Tabba <[email protected]> Signed-off-by: Quentin Perret <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent e94a7de commit 5398ddc

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

arch/arm64/include/asm/kvm_pgtable.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,15 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size);
669669
* kvm_pgtable_stage2_mkyoung() - Set the access flag in a page-table entry.
670670
* @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*().
671671
* @addr: Intermediate physical address to identify the page-table entry.
672+
* @flags: Flags to control the page-table walk (ex. a shared walk)
672673
*
673674
* The offset of @addr within a page is ignored.
674675
*
675676
* If there is a valid, leaf page-table entry used to translate @addr, then
676677
* set the access flag in that entry.
677678
*/
678-
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr);
679+
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr,
680+
enum kvm_pgtable_walk_flags flags);
679681

680682
/**
681683
* kvm_pgtable_stage2_test_clear_young() - Test and optionally clear the access

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,14 +1245,13 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size)
12451245
NULL, NULL, 0);
12461246
}
12471247

1248-
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr)
1248+
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr,
1249+
enum kvm_pgtable_walk_flags flags)
12491250
{
12501251
int ret;
12511252

12521253
ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0,
1253-
NULL, NULL,
1254-
KVM_PGTABLE_WALK_HANDLE_FAULT |
1255-
KVM_PGTABLE_WALK_SHARED);
1254+
NULL, NULL, flags);
12561255
if (!ret)
12571256
dsb(ishst);
12581257
}

arch/arm64/kvm/mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,13 +1718,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17181718
/* Resolve the access fault by making the page young again. */
17191719
static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
17201720
{
1721+
enum kvm_pgtable_walk_flags flags = KVM_PGTABLE_WALK_HANDLE_FAULT | KVM_PGTABLE_WALK_SHARED;
17211722
struct kvm_s2_mmu *mmu;
17221723

17231724
trace_kvm_access_fault(fault_ipa);
17241725

17251726
read_lock(&vcpu->kvm->mmu_lock);
17261727
mmu = vcpu->arch.hw_mmu;
1727-
kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa);
1728+
kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa, flags);
17281729
read_unlock(&vcpu->kvm->mmu_lock);
17291730
}
17301731

0 commit comments

Comments
 (0)