[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220311005742.1060992-6-ira.weiny@intel.com>
Date: Thu, 10 Mar 2022 16:57:42 -0800
From: ira.weiny@...el.com
To: Dave Hansen <dave.hansen@...ux.intel.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Cc: Ira Weiny <ira.weiny@...el.com>,
"Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] x86/pkeys: Standardize on u8 for pkey type
From: Ira Weiny <ira.weiny@...el.com>
The number of pkeys supported on x86 and powerpc are much smaller than a
u16 value can hold. It is desirable to standardize on the type for
pkeys. powerpc currently supports the most pkeys at 32. u8 is plenty
large for that.
Standardize on the pkey types by changing u16 to u8.
To: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.ibm.com>
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
arch/x86/include/asm/pgtable.h | 4 ++--
arch/x86/include/asm/pkru.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 8a9432fb3802..cb89f1224d8a 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1357,7 +1357,7 @@ static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd)
}
#endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */
-static inline u16 pte_flags_pkey(unsigned long pte_flags)
+static inline u8 pte_flags_pkey(unsigned long pte_flags)
{
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
/* ifdef to avoid doing 59-bit shift on 32-bit values */
@@ -1367,7 +1367,7 @@ static inline u16 pte_flags_pkey(unsigned long pte_flags)
#endif
}
-static inline bool __pkru_allows_pkey(u16 pkey, bool write)
+static inline bool __pkru_allows_pkey(u8 pkey, bool write)
{
u32 pkru = read_pkru();
diff --git a/arch/x86/include/asm/pkru.h b/arch/x86/include/asm/pkru.h
index 74f0a2d34ffd..06d088f06229 100644
--- a/arch/x86/include/asm/pkru.h
+++ b/arch/x86/include/asm/pkru.h
@@ -16,13 +16,13 @@ extern u32 init_pkru_value;
#define pkru_get_init_value() 0
#endif
-static inline bool __pkru_allows_read(u32 pkru, u16 pkey)
+static inline bool __pkru_allows_read(u32 pkru, u8 pkey)
{
int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY;
return !(pkru & (PKRU_AD_BIT << pkru_pkey_bits));
}
-static inline bool __pkru_allows_write(u32 pkru, u16 pkey)
+static inline bool __pkru_allows_write(u32 pkru, u8 pkey)
{
int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY;
/*
--
2.35.1
Powered by blists - more mailing lists