Skip to content

Commit 7fa3e10

Browse files
Christoph Hellwigsuryasaimadhu
authored andcommitted
x86/mm: Move pgprot2cachemode out of line
This helper is only used by x86 low-level MM code. Also remove the entirely pointless __pte2cachemode_tbl export as that symbol can be marked static now. 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 1f6f655 commit 7fa3e10

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

arch/x86/include/asm/memtype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ extern void memtype_free_io(resource_size_t start, resource_size_t end);
2525
extern bool pat_pfn_immune_to_uc_mtrr(unsigned long pfn);
2626

2727
bool x86_has_pat_wp(void);
28+
enum page_cache_mode pgprot2cachemode(pgprot_t pgprot);
2829

2930
#endif /* _ASM_X86_MEMTYPE_H */

arch/x86/include/asm/pgtable_types.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ static inline pteval_t pte_flags(pte_t pte)
468468
}
469469

470470
extern uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM];
471-
extern uint8_t __pte2cachemode_tbl[8];
472471

473472
#define __pte2cm_idx(cb) \
474473
((((cb) >> (_PAGE_BIT_PAT - 2)) & 4) | \
@@ -489,15 +488,6 @@ static inline pgprot_t cachemode2pgprot(enum page_cache_mode pcm)
489488
{
490489
return __pgprot(cachemode2protval(pcm));
491490
}
492-
static inline enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
493-
{
494-
unsigned long masked;
495-
496-
masked = pgprot_val(pgprot) & _PAGE_CACHE_MASK;
497-
if (likely(masked == 0))
498-
return 0;
499-
return __pte2cachemode_tbl[__pte2cm_idx(masked)];
500-
}
501491
static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
502492
{
503493
pgprotval_t val = pgprot_val(pgprot);

arch/x86/mm/init.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
5959
};
6060
EXPORT_SYMBOL(__cachemode2pte_tbl);
6161

62-
uint8_t __pte2cachemode_tbl[8] = {
62+
static uint8_t __pte2cachemode_tbl[8] = {
6363
[__pte2cm_idx( 0 | 0 | 0 )] = _PAGE_CACHE_MODE_WB,
6464
[__pte2cm_idx(_PAGE_PWT | 0 | 0 )] = _PAGE_CACHE_MODE_UC_MINUS,
6565
[__pte2cm_idx( 0 | _PAGE_PCD | 0 )] = _PAGE_CACHE_MODE_UC_MINUS,
@@ -69,14 +69,23 @@ uint8_t __pte2cachemode_tbl[8] = {
6969
[__pte2cm_idx(0 | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
7070
[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
7171
};
72-
EXPORT_SYMBOL(__pte2cachemode_tbl);
7372

7473
/* Check that the write-protect PAT entry is set for write-protect */
7574
bool x86_has_pat_wp(void)
7675
{
7776
return __pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] == _PAGE_CACHE_MODE_WP;
7877
}
7978

79+
enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
80+
{
81+
unsigned long masked;
82+
83+
masked = pgprot_val(pgprot) & _PAGE_CACHE_MASK;
84+
if (likely(masked == 0))
85+
return 0;
86+
return __pte2cachemode_tbl[__pte2cm_idx(masked)];
87+
}
88+
8089
static unsigned long __initdata pgt_buf_start;
8190
static unsigned long __initdata pgt_buf_end;
8291
static unsigned long __initdata pgt_buf_top;

0 commit comments

Comments
 (0)