Skip to content

Commit de17a37

Browse files
Christoph Hellwigsuryasaimadhu
authored andcommitted
x86/mm: Unexport __cachemode2pte_tbl
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 <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d073569 commit de17a37

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

arch/x86/include/asm/pgtable_types.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,6 @@ static inline pteval_t pte_flags(pte_t pte)
467467
return native_pte_val(pte) & PTE_FLAGS_MASK;
468468
}
469469

470-
extern uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM];
471-
472470
#define __pte2cm_idx(cb) \
473471
((((cb) >> (_PAGE_BIT_PAT - 2)) & 4) | \
474472
(((cb) >> (_PAGE_BIT_PCD - 1)) & 2) | \
@@ -478,16 +476,8 @@ extern uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM];
478476
(((i) & 2) << (_PAGE_BIT_PCD - 1)) | \
479477
(((i) & 1) << _PAGE_BIT_PWT))
480478

481-
static inline unsigned long cachemode2protval(enum page_cache_mode pcm)
482-
{
483-
if (likely(pcm == 0))
484-
return 0;
485-
return __cachemode2pte_tbl[pcm];
486-
}
487-
static inline pgprot_t cachemode2pgprot(enum page_cache_mode pcm)
488-
{
489-
return __pgprot(cachemode2protval(pcm));
490-
}
479+
unsigned long cachemode2protval(enum page_cache_mode pcm);
480+
491481
static inline unsigned long protval_4k_2_large(unsigned long val)
492482
{
493483
return (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |

arch/x86/mm/init.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,22 @@
4949
* Index into __pte2cachemode_tbl[] are the caching attribute bits of the pte
5050
* (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
5151
*/
52-
uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
52+
static uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
5353
[_PAGE_CACHE_MODE_WB ] = 0 | 0 ,
5454
[_PAGE_CACHE_MODE_WC ] = 0 | _PAGE_PCD,
5555
[_PAGE_CACHE_MODE_UC_MINUS] = 0 | _PAGE_PCD,
5656
[_PAGE_CACHE_MODE_UC ] = _PAGE_PWT | _PAGE_PCD,
5757
[_PAGE_CACHE_MODE_WT ] = 0 | _PAGE_PCD,
5858
[_PAGE_CACHE_MODE_WP ] = 0 | _PAGE_PCD,
5959
};
60-
EXPORT_SYMBOL(__cachemode2pte_tbl);
60+
61+
unsigned long cachemode2protval(enum page_cache_mode pcm)
62+
{
63+
if (likely(pcm == 0))
64+
return 0;
65+
return __cachemode2pte_tbl[pcm];
66+
}
67+
EXPORT_SYMBOL(cachemode2protval);
6168

6269
static uint8_t __pte2cachemode_tbl[8] = {
6370
[__pte2cm_idx( 0 | 0 | 0 )] = _PAGE_CACHE_MODE_WB,

arch/x86/mm/pat/set_memory.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ static DEFINE_SPINLOCK(cpa_lock);
6868
#define CPA_PAGES_ARRAY 4
6969
#define CPA_NO_CHECK_ALIAS 8 /* Do not search for aliases */
7070

71+
static inline pgprot_t cachemode2pgprot(enum page_cache_mode pcm)
72+
{
73+
return __pgprot(cachemode2protval(pcm));
74+
}
75+
7176
#ifdef CONFIG_PROC_FS
7277
static unsigned long direct_pages_count[PG_LEVEL_NUM];
7378

0 commit comments

Comments
 (0)