Re: [PATCH] arm64: Clear VTCR_EL2 in __init_el2_stage2()
From: Marc Zyngier
Date: Fri Mar 13 2026 - 04:08:22 EST
On Fri, 13 Mar 2026 07:54:04 +0000,
Anshuman Khandual <anshuman.khandual@xxxxxxx> wrote:
>
> On 13/03/26 12:55 PM, Marc Zyngier wrote:
> > On Fri, 13 Mar 2026 05:38:57 +0000,
> > Anshuman Khandual <anshuman.khandual@xxxxxxx> wrote:
> >>
> >> Clear VTCR_EL2 along with VTTBR_EL2 register in __init_el2_stage2(), which
> >> ensures that MMU stage-2 translation remain disabled. Although clearing out
> >> VTTBR_EL2 probably should have been sufficient but adding VTCR_EL2 improves
> >> overall safety.
> >
> > This serves no purpose whatsoever. Even the write to VTTBR_EL2 is
> > pointless, and writing 0 is no better than writing *any* other value.
> > > The only thing that matters at this stage is HCR_EL2.VM, which
> > actually controls stage-2 translation (contrary to your above
> > assertion). This of course is not captured by this macro.
> >
> > So what are you *really* trying to achieve?
>
> To keep VTTBR_EL2 and VTCR_EL2 cleared (and prepared) if and when
> HCR_EL2_VM gets enabled.
How does that prepare anything? Zero is not even a valid value for
VTCR_EL2!
> But it can be argued that these registers
> need not have to be cleared now and can just be initialised before
> setting up HCR_EL2_VM itself. In which case should we drop
> __init_el2_stage2() entirely ?
I really like how you argue one thing and its opposite in two adjacent
sentences.
"If it ain't broke, don't fix it".
M.
--
Jazz isn't dead. It just smells funny.