From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933452AbcAYQnX (ORCPT ); Mon, 25 Jan 2016 11:43:23 -0500 Received: from prv-mh.provo.novell.com ([137.65.248.74]:33465 "EHLO prv-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932887AbcAYQnU convert rfc822-to-8bit (ORCPT ); Mon, 25 Jan 2016 11:43:20 -0500 Message-Id: <56A65EB502000078000CAC72@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Mon, 25 Jan 2016 09:43:17 -0700 From: "Jan Beulich" To: , , Cc: "Juergen Gross" , Subject: [PATCH] ix86: fix types used in pgprot cachability flags translations Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Juergen Gross --- 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));