On Wed, Feb 13, 2013 at 03:46:59PM +0000, Marc Zyngier wrote: > As we carry on deconstructing stage2_set_pte(), introduce a method > to write a pte at a given location. > > Make the prototype similar to the kernel set_pte_at(), so the properties > are not completely surprising. Convert stage2_set_pte() to make use > of stage_set_pte_at(). > > Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx> > --- > arch/arm/kvm/mmu.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c > index cb2b42e..ab35906 100644 > --- a/arch/arm/kvm/mmu.c > +++ b/arch/arm/kvm/mmu.c > @@ -444,10 +444,24 @@ static pte_t *stage2_get_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache > return pte_offset_kernel(pmd, addr); > } > > +static void stage2_set_pte_at(struct kvm *kvm, phys_addr_t addr, > + pte_t *pte, const pte_t pteval) > +{ > + pte_t old_pte; > + > + /* Create 2nd stage page table mapping - Level 3 */ > + old_pte = *pte; > + kvm_set_pte(pte, pteval); > + if (pte_present(old_pte)) > + kvm_tlb_flush_vmid_ipa(kvm, addr); > + else > + get_page(virt_to_page(pte)); > +} what's the reason between this level of indirection? We already have quite a few xxx_set_pte_xxx functions, ... > + > static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, > phys_addr_t addr, const pte_t *new_pte, bool iomap) > { > - pte_t *pte, old_pte; > + pte_t *pte; > > pte = stage2_get_pte(kvm, cache, addr); > if (!pte) > @@ -456,13 +470,7 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, > if (iomap && pte_present(*pte)) > return -EFAULT; > > - /* Create 2nd stage page table mapping - Level 3 */ > - old_pte = *pte; > - kvm_set_pte(pte, *new_pte); > - if (pte_present(old_pte)) > - kvm_tlb_flush_vmid_ipa(kvm, addr); > - else > - get_page(virt_to_page(pte)); > + stage2_set_pte_at(kvm, addr, pte, *new_pte); > > return 0; > } > -- > 1.8.1.2 > > > > _______________________________________________ > kvmarm mailing list > kvmarm@xxxxxxxxxxxxxxxxxxxxx > https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm