On Tue, 04 Mar 2025 16:55:50 +0000, Fuad Tabba <tabba@xxxxxxxxxx> wrote: > > Hi Marc, > > On Mon, 10 Feb 2025 at 18:42, Marc Zyngier <maz@xxxxxxxxxx> wrote: > > > > In the process of decoupling KVM's view of the FGT bits from the > > wider architectural state, use KVM's own FGT tables to build > > a synthitic view of what is actually known. > > synthitic -> synthetic > > > > This allows for some checking along the way. > > > > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> > > --- > > arch/arm64/include/asm/kvm_arm.h | 4 ++ > > arch/arm64/include/asm/kvm_host.h | 14 ++++ > > arch/arm64/kvm/emulate-nested.c | 102 ++++++++++++++++++++++++++++++ > > 3 files changed, 120 insertions(+) > > > > diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h > > index 8d94a6c0ed5c4..e424085f2aaca 100644 > > --- a/arch/arm64/include/asm/kvm_arm.h > > +++ b/arch/arm64/include/asm/kvm_arm.h > > @@ -359,6 +359,10 @@ > > #define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0)) > > #define __HAFGRTR_EL2_nMASK ~(__HAFGRTR_EL2_RES0 | __HAFGRTR_EL2_MASK) > > > > +/* Because the sysreg file mixes R and W... */ > > +#define HFGRTR_EL2_RES0 HFGxTR_EL2_RES0 (0) > > +#define HFGWTR_EL2_RES0 (HFGRTR_EL2_RES0 | __HFGRTR_ONLY_MASK) > > __HFGRTR_ONLY_MASK is a hand-crafted bitmask. The only bit remaining > in HFGxTR_EL2 that is RES0 is bit 51. If that were to be used as an > HFGRTR-only bit without __HFGRTR_ONLY_MASK getting updated, then > aggregate_fgt() below would set its bit in hfgwtr_masks. Could this be > a problem if this happens and the polarity of this bit ends up being > negative, thereby setting the corresponding nmask bit? This could become a problem indeed. But the only fix for that is to kill the HFGxTR stupidity and describe all the bits as needed so that we stop assuming things. I'm half tempted to do that next. Thanks, M. -- Without deviation from the norm, progress is not possible.