Re: [PATCH 07/18] KVM: arm64: Compute FGT masks from KVM's own FGT tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Ah, I missed that one earlier. Will fix.

> 
> 
> > 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?

So I ended up doing exactly what I threatened to do, which is to
completely get rid of the HFGxTR nonsense, and bring HFG{R,W}TR to
their full glory.

The diffstat is a bit annoying:

 arch/arm64/include/asm/el2_setup.h      |  14 +--
 arch/arm64/include/asm/kvm_arm.h        |   4 +-
 arch/arm64/include/asm/kvm_host.h       |   3 +-
 arch/arm64/kvm/emulate-nested.c         | 154 ++++++++++++-------------
 arch/arm64/kvm/hyp/include/hyp/switch.h |   4 +-
 arch/arm64/kvm/hyp/vgic-v3-sr.c         |   8 +-
 arch/arm64/kvm/nested.c                 |  42 +++----
 arch/arm64/kvm/sys_regs.c               |  20 ++--
 arch/arm64/tools/sysreg                 | 194 ++++++++++++++++++++------------
 9 files changed, 250 insertions(+), 193 deletions(-)

but at least it puts all registers in the same bucket, and we don't
assume anything anymore.

I'll repost the series on Monday, once I'm on holiday.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux