[PATCH 3/5] KVM: arm64: Only return attributes from stage2_update_leaf_attrs()

Marc Zyngier maz at kernel.org
Wed Jan 11 00:52:25 PST 2023


[+ Suzuki and Zenghui who are missing from the Cc list]

On Wed, 11 Jan 2023 00:02:58 +0000,
Oliver Upton <oliver.upton at linux.dev> wrote:
> 
> Returning a single PTE from stage2_update_leaf_attrs() doesn't make a
> great deal of sense given that the function could be used to apply a
> change to a range of PTEs. Instead, return a bitwise OR of attributes
> from all the visited PTEs.

I find this amalgamation of attributes quite confusing, and I have a
hard time attaching semantics to the resulting collection of bits.

It also means that you cannot reason about a particular attribute
being 0 if any of the neighbour PTEs has this bit set.

> 
> As the walker is no longer returning the full PTE, drop the check for a
> valid PTE in kvm_age_gfn().

But then what does it mean to check for a potentially invalid PTE?

The helpers explicitly say:

/*
 * The following only work if pte_present(). Undefined behaviour otherwise.
 */
#define pte_present(pte)	(!!(pte_val(pte) & (PTE_VALID | PTE_PROT_NONE)))
#define pte_young(pte)		(!!(pte_val(pte) & PTE_AF))

and you seem to be violating this requirement.

Thanks,

	M.

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



More information about the linux-arm-kernel mailing list