[PATCH v15 7/8] KVM: arm64: use CAST instruction for swapping guest descriptor

Yeoreum Yun yeoreum.yun at arm.com
Fri Mar 13 02:59:43 PDT 2026


Hi Catalin,

> On Fri, Feb 27, 2026 at 03:17:04PM +0000, Yeoreum Yun wrote:
> > +static int __lsui_swap_desc(u64 __user *ptep, u64 old, u64 new)
> > +{
> > +	u64 tmp = old;
> > +	int ret = 0;
> > +
> > +	/*
> > +	 * FEAT_LSUI is supported since Armv9.6, where FEAT_PAN is mandatory.
> > +	 * However, this assumption may not always hold:
> > +	 *
> > +	 *   - Some CPUs advertise FEAT_LSUI but lack FEAT_PAN.
> > +	 *   - Virtualisation or ID register overrides may expose invalid
> > +	 *     feature combinations.
> > +	 *
> > +	 * Rather than disabling FEAT_LSUI when FEAT_PAN is absent, wrap LSUI
> > +	 * instructions with uaccess_ttbr0_enable()/disable() when
> > +	 * ARM64_SW_TTBR0_PAN is enabled.
> > +	 */
> > +	uaccess_ttbr0_enable();
> > +
> > +	asm volatile(__LSUI_PREAMBLE
>
> I haven't tried, so just asking. Does the toolchain complain if it does
> not support LSUI or is this path eliminated (due to
> cpucap_is_possible()) before being handed over to gas? It's probably
> fine but worth checking.

Yes I did with clang-19 and that's one of v14's modification:
  - https://lore.kernel.org/all/20260225182708.3225211-1-yeoreum.yun@arm.com/


--
Sincerely,
Yeoreum Yun



More information about the linux-arm-kernel mailing list