Re: [PATCH v4 21/21] KVM: selftests: Test READ=>WRITE dirty logging behavior for shadow MMU

Sean Christopherson
2026-01-08T20:29:11Z

On Thu, Jan 08, 2026, Yosry Ahmed wrote:
> On Thu, Jan 08, 2026 at 10:31:22AM -0800, Sean Christopherson wrote:
> > On Thu, Jan 08, 2026, Yosry Ahmed wrote:
> > > > /*
> > > > - * Add an identity map for GVA range [0xc0000000, 0xc0002000). This
> > > > + * Add an identity map for GVA range [0xc0000000, 0xc0004000). This
> > > > * affects both L1 and L2. However...
> > > > */
> > > > - virt_map(vm, GUEST_TEST_MEM, GUEST_TEST_MEM, TEST_MEM_PAGES);
> > > > + virt_map(vm, TEST_MEM_BASE, TEST_MEM_BASE, TEST_MEM_PAGES);
> > > >
> > > > /*
> > > > - * ... pages in the L2 GPA range [0xc0001000, 0xc0003000) will map to
> > > > - * 0xc0000000.
> > > > + * ... pages in the L2 GPA ranges [0xc0001000, 0xc0002000) and
> > > > + * [0xc0003000, 0xc0004000) will map to 0xc0000000 and 0xc0001000
> > > > + * respectively.
> > >
> > > Are these ranges correct? I thought L2 GPA range [0xc0002000,
> > > 0xc0004000) will map to [0xc0000000, 0xc0002000).
> >
> > Gah, no. I looked at the comments after changing things around, but my eyes had
> > glazed over by that point.
> >
> > > Also, perhaps it's better to express those in terms of the macros?
> > >
> > > L2 GPA range [TEST_MEM_ALIAS_BASE, TEST_MEM_ALIAS_BASE + 2*PAGE_SIZE)
> > > will map to [TEST_MEM_BASE, TEST_MEM_BASE + 2*PAGE_SIZE)?
> >
> > Hmm, no, at some point we need to concretely state the addresses, so that people
> > debugging this know what to expect, i.e. don't have to manually compute the
> > addresses from the macros in order to debug.
>
> I was trying to avoid a situation where the comment gets out of sync
> with the macros in a way that gets confusing. Maybe reference both if
> it's not too verbose?
>
> /*
> * ... pages in the L2 GPA range [0xc0002000, 0xc0004000) at
> * TEST_MEM_ALIAS_BASE will map to [[0xc0000000, 0xc0002000) at
> * TEST_MEM_BASE.
> */

Heh, your solution to a mitigate a comment getting out of sync is to add more
things to the comment that can get out of sync :-D

Unless you feel very strongly about having the names of the macros in the comments,
I'd prefer to keep just the raw addresses.