2008-01-16 02:42:04

by Pallipadi, Venkatesh

[permalink] [raw]
Subject: [patch 2/4] x86: PAT followup - Remove KERNPG_TABLE from pte entry

KERNPG_TABLE was a bug in earlier patch. Remove it from pte.
pte_val() check is redundant as this routine is called immediately after a
ptepage is allocated afresh.

Signed-off-by: Venkatesh Pallipadi <[email protected]>
Signed-off-by: Suresh Siddha <[email protected]>

Index: linux-2.6.git/arch/x86/mm/init_64.c
===================================================================
--- linux-2.6.git.orig/arch/x86/mm/init_64.c 2008-01-15 11:02:23.000000000 -0800
+++ linux-2.6.git/arch/x86/mm/init_64.c 2008-01-15 11:06:37.000000000 -0800
@@ -541,9 +541,6 @@
if (address >= end)
break;

- if (pte_val(*pte))
- continue;
-
/* Nothing to map. Map the null page */
if (!(address & (~PAGE_MASK)) &&
(address + PAGE_SIZE <= end) &&
@@ -561,9 +558,9 @@
}

if (exec)
- entry = _PAGE_NX|_KERNPG_TABLE|_PAGE_GLOBAL|address;
+ entry = _PAGE_NX|_PAGE_GLOBAL|address;
else
- entry = _KERNPG_TABLE|_PAGE_GLOBAL|address;
+ entry = _PAGE_GLOBAL|address;
entry &= __supported_pte_mask;
set_pte(pte, __pte(entry));
}

--


2008-01-16 08:45:01

by Mika Penttilä

[permalink] [raw]
Subject: Re: [patch 2/4] x86: PAT followup - Remove KERNPG_TABLE from pte entry

[email protected] kirjoitti:
> KERNPG_TABLE was a bug in earlier patch. Remove it from pte.
> pte_val() check is redundant as this routine is called immediately after a
> ptepage is allocated afresh.
>
> Signed-off-by: Venkatesh Pallipadi <[email protected]>
> Signed-off-by: Suresh Siddha <[email protected]>
>
> Index: linux-2.6.git/arch/x86/mm/init_64.c
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/mm/init_64.c 2008-01-15 11:02:23.000000000 -0800
> +++ linux-2.6.git/arch/x86/mm/init_64.c 2008-01-15 11:06:37.000000000 -0800
> @@ -541,9 +541,6 @@
> if (address >= end)
> break;
>
> - if (pte_val(*pte))
> - continue;
> -
> /* Nothing to map. Map the null page */
> if (!(address & (~PAGE_MASK)) &&
> (address + PAGE_SIZE <= end) &&
> @@ -561,9 +558,9 @@
> }
>
> if (exec)
> - entry = _PAGE_NX|_KERNPG_TABLE|_PAGE_GLOBAL|address;
> + entry = _PAGE_NX|_PAGE_GLOBAL|address;
> else
> - entry = _KERNPG_TABLE|_PAGE_GLOBAL|address;
> + entry = _PAGE_GLOBAL|address;
> entry &= __supported_pte_mask;
> set_pte(pte, __pte(entry));
> }
>
>

Hmm then what's the point of mapping not present 4k pages for valid mem
here?

--Mika

2008-01-16 18:17:26

by Pallipadi, Venkatesh

[permalink] [raw]
Subject: RE: [patch 2/4] x86: PAT followup - Remove KERNPG_TABLE from pte entry

>-----Original Message-----
>From: Mika Penttil? [mailto:[email protected]]
>Sent: Wednesday, January 16, 2008 12:14 AM
>To: Pallipadi, Venkatesh
>Cc: [email protected]; [email protected]; [email protected];
>[email protected]; [email protected];
>[email protected]; [email protected]; [email protected];
>[email protected]; [email protected]; [email protected];
>[email protected]; Barnes, Jesse; [email protected];
>[email protected]; Siddha, Suresh B
>Subject: Re: [patch 2/4] x86: PAT followup - Remove
>KERNPG_TABLE from pte entry
>
>[email protected] kirjoitti:
>> KERNPG_TABLE was a bug in earlier patch. Remove it from pte.
>> pte_val() check is redundant as this routine is called
>immediately after a
>> ptepage is allocated afresh.
>>
>> Signed-off-by: Venkatesh Pallipadi <[email protected]>
>> Signed-off-by: Suresh Siddha <[email protected]>
>>
>> Index: linux-2.6.git/arch/x86/mm/init_64.c
>> ===================================================================
>> --- linux-2.6.git.orig/arch/x86/mm/init_64.c 2008-01-15
>11:02:23.000000000 -0800
>> +++ linux-2.6.git/arch/x86/mm/init_64.c 2008-01-15
>11:06:37.000000000 -0800
>> @@ -541,9 +541,6 @@
>> if (address >= end)
>> break;
>>
>> - if (pte_val(*pte))
>> - continue;
>> -
>> /* Nothing to map. Map the null page */
>> if (!(address & (~PAGE_MASK)) &&
>> (address + PAGE_SIZE <= end) &&
>> @@ -561,9 +558,9 @@
>> }
>>
>> if (exec)
>> - entry =
>_PAGE_NX|_KERNPG_TABLE|_PAGE_GLOBAL|address;
>> + entry = _PAGE_NX|_PAGE_GLOBAL|address;
>> else
>> - entry = _KERNPG_TABLE|_PAGE_GLOBAL|address;
>> + entry = _PAGE_GLOBAL|address;
>> entry &= __supported_pte_mask;
>> set_pte(pte, __pte(entry));
>> }
>>
>>
>
>Hmm then what's the point of mapping not present 4k pages for
>valid mem
>here?
>

My bad... Thanks for the catch.
I had to replace KERNPG_TABLE by PAGE_KERNEL here.

Thanks,
Venki

2008-01-17 00:18:35

by Pallipadi, Venkatesh

[permalink] [raw]
Subject: Re: [patch 2/4] x86: PAT followup - Remove KERNPG_TABLE from pte entry

On Wed, Jan 16, 2008 at 10:14:00AM +0200, Mika Penttil? wrote:
> [email protected] kirjoitti:
> >KERNPG_TABLE was a bug in earlier patch. Remove it from pte.
> >pte_val() check is redundant as this routine is called immediately after a
> >ptepage is allocated afresh.
> >
> >Signed-off-by: Venkatesh Pallipadi <[email protected]>
> >Signed-off-by: Suresh Siddha <[email protected]>
> >
> >Index: linux-2.6.git/arch/x86/mm/init_64.c
> >===================================================================
> >--- linux-2.6.git.orig/arch/x86/mm/init_64.c 2008-01-15
> >11:02:23.000000000 -0800
> >+++ linux-2.6.git/arch/x86/mm/init_64.c 2008-01-15
> >11:06:37.000000000 -0800
> >@@ -541,9 +541,6 @@
> > if (address >= end)
> > break;
> >
> >- if (pte_val(*pte))
> >- continue;
> >-
> > /* Nothing to map. Map the null page */
> > if (!(address & (~PAGE_MASK)) &&
> > (address + PAGE_SIZE <= end) &&
> >@@ -561,9 +558,9 @@
> > }
> >
> > if (exec)
> >- entry = _PAGE_NX|_KERNPG_TABLE|_PAGE_GLOBAL|address;
> >+ entry = _PAGE_NX|_PAGE_GLOBAL|address;
> > else
> >- entry = _KERNPG_TABLE|_PAGE_GLOBAL|address;
> >+ entry = _PAGE_GLOBAL|address;
> > entry &= __supported_pte_mask;
> > set_pte(pte, __pte(entry));
> > }
> >
> >
>
> Hmm then what's the point of mapping not present 4k pages for valid mem
> here?
>

Ingo,

Below incremental patch fixes this pte entry setting correctly. Thanks to
Mika for catching this.

Signed-off-by: Venkatesh Pallipadi <[email protected]>

Index: linux-2.6.git/arch/x86/mm/init_64.c
===================================================================
--- linux-2.6.git.orig/arch/x86/mm/init_64.c 2008-01-16 03:38:32.000000000 -0800
+++ linux-2.6.git/arch/x86/mm/init_64.c 2008-01-16 03:51:34.000000000 -0800
@@ -515,9 +515,9 @@
}

if (exec)
- entry = _PAGE_NX|_PAGE_GLOBAL|address;
+ entry = __PAGE_KERNEL_EXEC | _PAGE_GLOBAL | address;
else
- entry = _PAGE_GLOBAL|address;
+ entry = __PAGE_KERNEL | _PAGE_GLOBAL | address;
entry &= __supported_pte_mask;
set_pte(pte, __pte(entry));
}