Re: [PATCH 10/12] KVM: selftests: Move EPT-specific init outside nested_create_pte()

Jim Mattson
2025-10-13T18:52:51Z

On Wed, Oct 1, 2025 at 8:06 AM Yosry Ahmed <yosry.ahmed@linux.dev> wrote:
>
> From: Yosry Ahmed <yosryahmed@google.com>
>
> Refactor the EPT specific initialization into nested_ept_create_pte(),
> in preparation for making nested_create_pte() NPT-friendly.
>
> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> ---
> tools/testing/selftests/kvm/lib/x86/vmx.c | 71 ++++++++++++++---------
> 1 file changed, 43 insertions(+), 28 deletions(-)
>
> ...
> +
> + /*
> + * For now mark these as accessed and dirty because the only
> + * testcase we have needs that. Can be reconsidered later.
> + */
> + epte->accessed = *leaf;
> + epte->dirty = *leaf;

Not your change, but it seems strange to set the 'accessed' bit only
at the leaf. The CPU will set the 'accessed' bits from the PGD down as
it does the walk. So, to only have an accessed bit set on the leaf
requires the existence of some software agent to clear the higher
levels.

Reviewed-by: Jim Mattson <jmattson@google.com>