On Fri, Apr 21, 2023 at 10:28:58AM +0100, Marc Zyngier wrote: [...] > So my conclusion is that after these two patches, data->phys should > never be updated, right? Yep, that's the intention. > Then I'd suggest an additional patch to constify a couple of things > and make sure we don't accidentally update them. Something like the > patch below (compile-tested only). I'm always a fan of more idiot proofing, especially when I am said idiot :) > From a2eb08ce793c1cf01c79df13a619815e9d7c1d41 Mon Sep 17 00:00:00 2001 > From: Marc Zyngier <maz@xxxxxxxxxx> > Date: Fri, 21 Apr 2023 10:18:34 +0100 > Subject: [PATCH] KVM: arm64: Constify start/end/phys fields of the pgtable > walker data > > As we are revamping the way the pgtable walker evaluates some of the > data, make it clear that we rely on somew of the fields to be constant > across the lifetime of a walk. > > For this, flag the start, end and pjys fields of the walk data as typo: phys > 'const', which will generate an error if we were to accidentally > update these fields again. > > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> Looks good. Reviewed-by: Oliver Upton <oliver.upton@xxxxxxxxx> Let's see if I've confused b4 into thinking I'm reviewing my own patches :-P > --- > arch/arm64/kvm/hyp/pgtable.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 356a3fd5220c..5282cb9ca4cf 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -58,9 +58,9 @@ > struct kvm_pgtable_walk_data { > struct kvm_pgtable_walker *walker; > > - u64 start; > + const u64 start; > u64 addr; > - u64 end; > + const u64 end; > }; > > static bool kvm_phys_is_valid(u64 phys) > @@ -352,7 +352,7 @@ int kvm_pgtable_get_leaf(struct kvm_pgtable *pgt, u64 addr, > } > > struct hyp_map_data { > - u64 phys; > + const u64 phys; > kvm_pte_t attr; > }; > > @@ -578,7 +578,7 @@ void kvm_pgtable_hyp_destroy(struct kvm_pgtable *pgt) > } > > struct stage2_map_data { > - u64 phys; > + const u64 phys; > kvm_pte_t attr; > u8 owner_id; > > -- > 2.34.1 > > -- > Without deviation from the norm, progress is not possible. -- Thanks, Oliver