* [PATCH] ix86: fix types used in pgprot cachability flags translations
@ 2016-01-25 16:43 Jan Beulich
2016-01-25 16:59 ` Thomas Gleixner
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2016-01-25 16:43 UTC (permalink / raw)
To: mingo, tglx, hpa; +Cc: Juergen Gross, linux-kernel
For PAE kernels "unsigned long" is not suitable to hold page protection
flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
few W+X pages getting reported as insecure during boot (observed namely
for the entire initrd range).
Quite the other way around, "unsigned long" is inefficient for 64-bit
kernels when dealing with cachability flags alone - "unsigned int" is
sufficient here and allows for slightly smaller code to be generated.
Fixes: 281d4078be ("x86: Make page cache mode a real type")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/pgtable_types.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
--- 4.5-rc1/arch/x86/include/asm/pgtable_types.h
+++ 4.5-rc1-ix86-PAE-pgprot-xlat/arch/x86/include/asm/pgtable_types.h
@@ -357,9 +357,8 @@ static inline pgprot_t cachemode2pgprot(
}
static inline enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
{
- unsigned long masked;
+ unsigned int masked = pgprot_val(pgprot) & _PAGE_CACHE_MASK;
- masked = pgprot_val(pgprot) & _PAGE_CACHE_MASK;
if (likely(masked == 0))
return 0;
return __pte2cachemode_tbl[__pte2cm_idx(masked)];
@@ -367,9 +366,8 @@ static inline enum page_cache_mode pgpro
static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
{
pgprot_t new;
- unsigned long val;
+ pgprotval_t val = pgprot_val(pgprot);
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
return new;
@@ -377,9 +375,8 @@ static inline pgprot_t pgprot_4k_2_large
static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
{
pgprot_t new;
- unsigned long val;
+ pgprotval_t val = pgprot_val(pgprot);
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT_LARGE) >>
(_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ix86: fix types used in pgprot cachability flags translations
2016-01-25 16:43 [PATCH] ix86: fix types used in pgprot cachability flags translations Jan Beulich
@ 2016-01-25 16:59 ` Thomas Gleixner
2016-01-26 11:15 ` [PATCH v2] " Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2016-01-25 16:59 UTC (permalink / raw)
To: Jan Beulich; +Cc: mingo, hpa, Juergen Gross, linux-kernel
On Mon, 25 Jan 2016, Jan Beulich wrote:
> For PAE kernels "unsigned long" is not suitable to hold page protection
> flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
> few W+X pages getting reported as insecure during boot (observed namely
> for the entire initrd range).
>
> Quite the other way around, "unsigned long" is inefficient for 64-bit
> kernels when dealing with cachability flags alone - "unsigned int" is
> sufficient here and allows for slightly smaller code to be generated.
This part has nothing to do with the fix. Can you please avoid to mix fixes,
which require backporting and code enhancements?
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ix86: fix types used in pgprot cachability flags translations
2016-01-25 16:59 ` Thomas Gleixner
@ 2016-01-26 11:15 ` Jan Beulich
2016-01-26 11:20 ` Juergen Gross
2016-01-26 20:12 ` [tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability " tip-bot for Jan Beulich
0 siblings, 2 replies; 5+ messages in thread
From: Jan Beulich @ 2016-01-26 11:15 UTC (permalink / raw)
To: mingo, Thomas Gleixner, hpa; +Cc: Juergen Gross, linux-kernel
For PAE kernels "unsigned long" is not suitable to hold page protection
flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
few W+X pages getting reported as insecure during boot (observed namely
for the entire initrd range).
Fixes: 281d4078be ("x86: Make page cache mode a real type")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>
---
v2: Remove code enhancement part, as requested by tglx.
---
arch/x86/include/asm/pgtable_types.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
--- 4.5-rc1/arch/x86/include/asm/pgtable_types.h
+++ 4.5-rc1-ix86-PAE-pgprot-xlat/arch/x86/include/asm/pgtable_types.h
@@ -367,9 +367,8 @@ static inline enum page_cache_mode pgpro
static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
{
pgprot_t new;
- unsigned long val;
+ pgprotval_t val = pgprot_val(pgprot);
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
return new;
@@ -377,9 +376,8 @@ static inline pgprot_t pgprot_4k_2_large
static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
{
pgprot_t new;
- unsigned long val;
+ pgprotval_t val = pgprot_val(pgprot);
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT_LARGE) >>
(_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ix86: fix types used in pgprot cachability flags translations
2016-01-26 11:15 ` [PATCH v2] " Jan Beulich
@ 2016-01-26 11:20 ` Juergen Gross
2016-01-26 20:12 ` [tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability " tip-bot for Jan Beulich
1 sibling, 0 replies; 5+ messages in thread
From: Juergen Gross @ 2016-01-26 11:20 UTC (permalink / raw)
To: Jan Beulich, mingo, Thomas Gleixner, hpa; +Cc: linux-kernel
On 26/01/16 12:15, Jan Beulich wrote:
> For PAE kernels "unsigned long" is not suitable to hold page protection
> flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
> few W+X pages getting reported as insecure during boot (observed namely
> for the entire initrd range).
>
> Fixes: 281d4078be ("x86: Make page cache mode a real type")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Cc: Juergen Gross <jgross@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
> ---
> v2: Remove code enhancement part, as requested by tglx.
> ---
> arch/x86/include/asm/pgtable_types.h | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> --- 4.5-rc1/arch/x86/include/asm/pgtable_types.h
> +++ 4.5-rc1-ix86-PAE-pgprot-xlat/arch/x86/include/asm/pgtable_types.h
> @@ -367,9 +367,8 @@ static inline enum page_cache_mode pgpro
> static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
> {
> pgprot_t new;
> - unsigned long val;
> + pgprotval_t val = pgprot_val(pgprot);
>
> - val = pgprot_val(pgprot);
> pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
> ((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
> return new;
> @@ -377,9 +376,8 @@ static inline pgprot_t pgprot_4k_2_large
> static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
> {
> pgprot_t new;
> - unsigned long val;
> + pgprotval_t val = pgprot_val(pgprot);
>
> - val = pgprot_val(pgprot);
> pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
> ((val & _PAGE_PAT_LARGE) >>
> (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability flags translations
2016-01-26 11:15 ` [PATCH v2] " Jan Beulich
2016-01-26 11:20 ` Juergen Gross
@ 2016-01-26 20:12 ` tip-bot for Jan Beulich
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Jan Beulich @ 2016-01-26 20:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, JBeulich, jbeulich, hpa, linux-kernel, JGross, tglx
Commit-ID: 3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Gitweb: http://git.kernel.org/tip/3625c2c234ef66acf21a72d47a5ffa94f6c5ebf2
Author: Jan Beulich <JBeulich@suse.com>
AuthorDate: Tue, 26 Jan 2016 04:15:18 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 26 Jan 2016 21:05:36 +0100
x86/mm: Fix types used in pgprot cacheability flags translations
For PAE kernels "unsigned long" is not suitable to hold page protection
flags, since _PAGE_NX doesn't fit there. This is the reason for quite a
few W+X pages getting reported as insecure during boot (observed namely
for the entire initrd range).
Fixes: 281d4078be ("x86: Make page cache mode a real type")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <JGross@suse.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/56A7635602000078000CAFF1@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/include/asm/pgtable_types.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index a471cad..79c9185 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -363,20 +363,18 @@ static inline enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
}
static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
{
+ pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
- unsigned long val;
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
return new;
}
static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
{
+ pgprotval_t val = pgprot_val(pgprot);
pgprot_t new;
- unsigned long val;
- val = pgprot_val(pgprot);
pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
((val & _PAGE_PAT_LARGE) >>
(_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-26 20:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25 16:43 [PATCH] ix86: fix types used in pgprot cachability flags translations Jan Beulich
2016-01-25 16:59 ` Thomas Gleixner
2016-01-26 11:15 ` [PATCH v2] " Jan Beulich
2016-01-26 11:20 ` Juergen Gross
2016-01-26 20:12 ` [tip:x86/urgent] x86/mm: Fix types used in pgprot cacheability " tip-bot for Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.