Re: [PATCH 1/4] x86/mm/pat: Handle no-GBPAGES case correctly in populate_pud

From: Ard Biesheuvel
Date: Wed Mar 04 2020 - 14:22:51 EST


On Wed, 4 Mar 2020 at 20:10, Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:
>
> On Wed, Mar 04, 2020 at 08:04:04PM +0100, Ard Biesheuvel wrote:
> > On Wed, 4 Mar 2020 at 19:50, Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:
> > >
> > > On Wed, Mar 04, 2020 at 07:44:50PM +0100, Ard Biesheuvel wrote:
> > > >
> > > > I've tried a couple of different ways, but I can't seem to get my
> > > > memory map organized in the way that will trigger the error.
> > >
> > > What does yours look like? efi_merge_regions doesn't merge everything
> > > that will eventually be mapped the same way, so if there are some
> > > non-conventional memory regions scattered over the address space, it
> > > might be breaking up the mappings to the point where this doesn't
> > > trigger.
> >
> > I have a region
> >
> > [ 0.000000] efi: mem07: [Conventional Memory| | | | | | | |
> > | |WB|WT|WC|UC] range=[0x0000000001400000-0x00000000b9855fff]
> > (2948MB)
> >
> > which gets covered correctly
> >
> > [ 0.401766] 0x0000000000a00000-0x0000000040000000 1014M
> > RW PSE NX pmd
> > [ 0.403436] 0x0000000040000000-0x0000000080000000 1G
> > RW PSE NX pud
> > [ 0.404645] 0x0000000080000000-0x00000000b9800000 920M
> > RW PSE NX pmd
> > [ 0.405844] 0x00000000b9800000-0x00000000b9a00000 2M
> > RW NX pte
> > [ 0.407436] 0x00000000b9a00000-0x00000000baa00000 16M
> > ro PSE x pmd
> > [ 0.408591] 0x00000000baa00000-0x00000000bbe00000 20M
> > RW PSE NX pmd
> > [ 0.409751] 0x00000000bbe00000-0x00000000bc000000 2M
> > RW NX pte
> > [ 0.410821] 0x00000000bc000000-0x00000000be600000 38M
> > RW PSE NX pmd
> >
> > However, the fact that you can provide a case where it does fail
> > should be sufficient justification for taking this patch. I was just
> > trying to give more than a regression-tested-by
>
> No, this case is exactly one that should break. But I think you're
> running on a processor model that _does_ support GB pages, as shown by
> the "pud" mapping there for the 1G-2G range.
>
> At least for my version of qemu, -cpu Haswell does not enable the
> pdpe1gb feature. Which cpu did you specify?
>

The wrong one, obviously :-)

With Haswell, I get [before]

[ 0.368541] 0x0000000000900000-0x0000000000a00000 1M
RW NX pte
[ 0.369118] 0x0000000000a00000-0x0000000080000000 2038M
RW PSE NX pmd
[ 0.369592] 0x0000000080000000-0x00000000b9800000 920M
pmd
[ 0.370177] 0x00000000b9800000-0x00000000b9856000 344K
pte
[ 0.370649] 0x00000000b9856000-0x00000000b9a00000 1704K
RW NX pte
[ 0.371066] 0x00000000b9a00000-0x00000000baa00000 16M
ro PSE x pmd

and after

[ 0.349577] 0x0000000000a00000-0x0000000080000000 2038M
RW PSE NX pmd
[ 0.350049] 0x0000000080000000-0x00000000b9800000 920M
pmd
[ 0.350514] 0x00000000b9800000-0x00000000b9856000 344K
pte
[ 0.351013] 0x00000000b9856000-0x00000000b9a00000 1704K
RW NX pte

so i'm still doing something wrong, I think?