]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/mm: Unexport __cachemode2pte_tbl
authorChristoph Hellwig <hch@lst.de>
Wed, 8 Apr 2020 15:27:45 +0000 (17:27 +0200)
committerBorislav Petkov <bp@suse.de>
Thu, 23 Apr 2020 09:34:31 +0000 (11:34 +0200)
Exporting the raw data for a table is generally a bad idea. Move
cachemode2protval() out of line given that it isn't really used in the
fast path, and then mark __cachemode2pte_tbl static.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200408152745.1565832-5-hch@lst.de
arch/x86/include/asm/pgtable_types.h
arch/x86/mm/init.c
arch/x86/mm/pat/set_memory.c

index a3b78d84b26aa02e428a7604a5bbfc9c68ba595e..567abdbd64d31b19af766d8f810ad09026d7f009 100644 (file)
@@ -467,8 +467,6 @@ static inline pteval_t pte_flags(pte_t pte)
        return native_pte_val(pte) & PTE_FLAGS_MASK;
 }
 
-extern uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM];
-
 #define __pte2cm_idx(cb)                               \
        ((((cb) >> (_PAGE_BIT_PAT - 2)) & 4) |          \
         (((cb) >> (_PAGE_BIT_PCD - 1)) & 2) |          \
@@ -478,16 +476,8 @@ extern uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM];
         (((i) & 2) << (_PAGE_BIT_PCD - 1)) |           \
         (((i) & 1) << _PAGE_BIT_PWT))
 
-static inline unsigned long cachemode2protval(enum page_cache_mode pcm)
-{
-       if (likely(pcm == 0))
-               return 0;
-       return __cachemode2pte_tbl[pcm];
-}
-static inline pgprot_t cachemode2pgprot(enum page_cache_mode pcm)
-{
-       return __pgprot(cachemode2protval(pcm));
-}
+unsigned long cachemode2protval(enum page_cache_mode pcm);
+
 static inline unsigned long protval_4k_2_large(unsigned long val)
 {
        return (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
index 4a55d687c24689b8b7752cf11fede314c464f0bc..71720dd8f28ada6c3e5cd7f1628d727019ae6e59 100644 (file)
@@ -49,7 +49,7 @@
  *   Index into __pte2cachemode_tbl[] are the caching attribute bits of the pte
  *   (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
  */
-uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
+static uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
        [_PAGE_CACHE_MODE_WB      ]     = 0         | 0        ,
        [_PAGE_CACHE_MODE_WC      ]     = 0         | _PAGE_PCD,
        [_PAGE_CACHE_MODE_UC_MINUS]     = 0         | _PAGE_PCD,
@@ -57,7 +57,14 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
        [_PAGE_CACHE_MODE_WT      ]     = 0         | _PAGE_PCD,
        [_PAGE_CACHE_MODE_WP      ]     = 0         | _PAGE_PCD,
 };
-EXPORT_SYMBOL(__cachemode2pte_tbl);
+
+unsigned long cachemode2protval(enum page_cache_mode pcm)
+{
+       if (likely(pcm == 0))
+               return 0;
+       return __cachemode2pte_tbl[pcm];
+}
+EXPORT_SYMBOL(cachemode2protval);
 
 static uint8_t __pte2cachemode_tbl[8] = {
        [__pte2cm_idx( 0        | 0         | 0        )] = _PAGE_CACHE_MODE_WB,
index 59eca6a94ce7961ace4cd6588a4f7cc5df48294b..a28f0c345303bebff0ae2f55d21fa573f9423921 100644 (file)
@@ -68,6 +68,11 @@ static DEFINE_SPINLOCK(cpa_lock);
 #define CPA_PAGES_ARRAY 4
 #define CPA_NO_CHECK_ALIAS 8 /* Do not search for aliases */
 
+static inline pgprot_t cachemode2pgprot(enum page_cache_mode pcm)
+{
+       return __pgprot(cachemode2protval(pcm));
+}
+
 #ifdef CONFIG_PROC_FS
 static unsigned long direct_pages_count[PG_LEVEL_NUM];