diff mbox series

x86: fix pgprotval_t format string

Message ID 20180410084424.2935759-1-arnd@arndb.de
State New
Headers show
Series x86: fix pgprotval_t format string | expand

Commit Message

Arnd Bergmann April 10, 2018, 8:43 a.m. UTC
On 32-bit builds, pgprotval_t can be either 32-bit or 64-bit wide depending
on the page table layout. In the latter case, we now get a build warning:

In file included from arch/x86/include/asm/bug.h:83,
                 from include/linux/bug.h:5,
                 from include/linux/crypto.h:23,
                 from arch/x86/kernel/asm-offsets.c:9:
arch/x86/include/asm/pgtable.h: In function 'check_pgprot':
arch/x86/include/asm/pgtable.h:536:5: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'pgprotval_t' {aka 'long long unsigned int'} [-Werror=format=]

To work around the problem, we can always print the value as a u64,
and add the respective cast.

Fixes: 64c80759408f ("x86/mm: Do not auto-massage page protections")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 arch/x86/include/asm/pgtable.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.9.0

Comments

Dave Hansen April 10, 2018, 8 p.m. UTC | #1
On 04/10/2018 01:43 AM, Arnd Bergmann wrote:
> --- a/arch/x86/include/asm/pgtable.h

> +++ b/arch/x86/include/asm/pgtable.h

> @@ -533,11 +533,11 @@ static inline pgprotval_t check_pgprot(pgprot_t pgprot)

>  	/* mmdebug.h can not be included here because of dependencies */

>  #ifdef CONFIG_DEBUG_VM

>  	WARN_ONCE(pgprot_val(pgprot) != massaged_val,

> -		  "attempted to set unsupported pgprot: %016lx "

> -		  "bits: %016lx supported: %016lx\n",

> -		  pgprot_val(pgprot),

> -		  pgprot_val(pgprot) ^ massaged_val,

> -		  __supported_pte_mask);

> +		  "attempted to set unsupported pgprot: %016llx "

> +		  "bits: %016llx supported: %016llx\n",

> +		  (u64)pgprot_val(pgprot),

> +		  (u64)pgprot_val(pgprot) ^ massaged_val,

> +		  (u64)__supported_pte_mask);

>  #endif


Whoops, I just sent a similar patch.  I just used 'unsigned long long'
instead of u64.  I'm fine with this as well, and don't prefer one over
the other, so:

Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 50b207289ae1..5f49b4ff0c24 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -533,11 +533,11 @@  static inline pgprotval_t check_pgprot(pgprot_t pgprot)
 	/* mmdebug.h can not be included here because of dependencies */
 #ifdef CONFIG_DEBUG_VM
 	WARN_ONCE(pgprot_val(pgprot) != massaged_val,
-		  "attempted to set unsupported pgprot: %016lx "
-		  "bits: %016lx supported: %016lx\n",
-		  pgprot_val(pgprot),
-		  pgprot_val(pgprot) ^ massaged_val,
-		  __supported_pte_mask);
+		  "attempted to set unsupported pgprot: %016llx "
+		  "bits: %016llx supported: %016llx\n",
+		  (u64)pgprot_val(pgprot),
+		  (u64)pgprot_val(pgprot) ^ massaged_val,
+		  (u64)__supported_pte_mask);
 #endif
 
 	return massaged_val;