Skip to content

Commit 81ad4bb

Browse files
committed
Merge branch 'for-next/mm' into for-next/core
Lots of cleanup to our various page-table definitions, but also some non-critical fixes and removal of some unnecessary memory types. The most interesting change here is the reduction of ARCH_DMA_MINALIGN back to 64 bytes, since we're not aware of any machines that need a higher value with the way the code is structured (only needed for non-coherent DMA). * for-next/mm: arm64: tlb: fix the TTL value of tlb_get_level arm64/mm: Rename ARM64_SWAPPER_USES_SECTION_MAPS arm64: head: fix code comments in set_cpu_boot_mode_flag arm64: mm: drop unused __pa(__idmap_text_start) arm64: mm: fix the count comments in compute_indices arm64/mm: Fix ttbr0 values stored in struct thread_info for software-pan arm64: mm: Pass original fault address to handle_mm_fault() arm64/mm: Drop SECTION_[SHIFT|SIZE|MASK] arm64/mm: Use CONT_PMD_SHIFT for ARM64_MEMSTART_SHIFT arm64/mm: Drop SWAPPER_INIT_MAP_SIZE arm64: mm: decode xFSC in mem_abort_decode() arm64: mm: Add is_el1_data_abort() helper arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES) arm64: mm: Remove unused support for Normal-WT memory type arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC arm64: mm: Remove unused support for Device-GRE memory type arm64: mm: Use better bitmap_zalloc() arm64/mm: Make vmemmap_free() available only with CONFIG_MEMORY_HOTPLUG arm64/mm: Remove [PUD|PMD]_TABLE_BIT from [pud|pmd]_bad() arm64/mm: Validate CONFIG_PGTABLE_LEVELS
2 parents 078834c + 52218fc commit 81ad4bb

18 files changed

Lines changed: 66 additions & 62 deletions

File tree

arch/arm64/include/asm/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* cache before the transfer is done, causing old data to be seen by
4848
* the CPU.
4949
*/
50-
#define ARCH_DMA_MINALIGN (128)
50+
#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5151

5252
#ifdef CONFIG_KASAN_SW_TAGS
5353
#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)

arch/arm64/include/asm/kernel-pgtable.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
* 64K (section size = 512M).
1919
*/
2020
#ifdef CONFIG_ARM64_4K_PAGES
21-
#define ARM64_SWAPPER_USES_SECTION_MAPS 1
21+
#define ARM64_KERNEL_USES_PMD_MAPS 1
2222
#else
23-
#define ARM64_SWAPPER_USES_SECTION_MAPS 0
23+
#define ARM64_KERNEL_USES_PMD_MAPS 0
2424
#endif
2525

2626
/*
@@ -33,7 +33,7 @@
3333
* VA range, so pages required to map highest possible PA are reserved in all
3434
* cases.
3535
*/
36-
#if ARM64_SWAPPER_USES_SECTION_MAPS
36+
#if ARM64_KERNEL_USES_PMD_MAPS
3737
#define SWAPPER_PGTABLE_LEVELS (CONFIG_PGTABLE_LEVELS - 1)
3838
#define IDMAP_PGTABLE_LEVELS (ARM64_HW_PGTABLE_LEVELS(PHYS_MASK_SHIFT) - 1)
3939
#else
@@ -90,26 +90,23 @@
9090
#define IDMAP_DIR_SIZE (IDMAP_PGTABLE_LEVELS * PAGE_SIZE)
9191

9292
/* Initial memory map size */
93-
#if ARM64_SWAPPER_USES_SECTION_MAPS
94-
#define SWAPPER_BLOCK_SHIFT SECTION_SHIFT
95-
#define SWAPPER_BLOCK_SIZE SECTION_SIZE
93+
#if ARM64_KERNEL_USES_PMD_MAPS
94+
#define SWAPPER_BLOCK_SHIFT PMD_SHIFT
95+
#define SWAPPER_BLOCK_SIZE PMD_SIZE
9696
#define SWAPPER_TABLE_SHIFT PUD_SHIFT
9797
#else
9898
#define SWAPPER_BLOCK_SHIFT PAGE_SHIFT
9999
#define SWAPPER_BLOCK_SIZE PAGE_SIZE
100100
#define SWAPPER_TABLE_SHIFT PMD_SHIFT
101101
#endif
102102

103-
/* The size of the initial kernel direct mapping */
104-
#define SWAPPER_INIT_MAP_SIZE (_AC(1, UL) << SWAPPER_TABLE_SHIFT)
105-
106103
/*
107104
* Initial memory map attributes.
108105
*/
109106
#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED)
110107
#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S)
111108

112-
#if ARM64_SWAPPER_USES_SECTION_MAPS
109+
#if ARM64_KERNEL_USES_PMD_MAPS
113110
#define SWAPPER_MM_MMUFLAGS (PMD_ATTRINDX(MT_NORMAL) | SWAPPER_PMD_FLAGS)
114111
#else
115112
#define SWAPPER_MM_MMUFLAGS (PTE_ATTRINDX(MT_NORMAL) | SWAPPER_PTE_FLAGS)
@@ -125,7 +122,7 @@
125122
#if defined(CONFIG_ARM64_4K_PAGES)
126123
#define ARM64_MEMSTART_SHIFT PUD_SHIFT
127124
#elif defined(CONFIG_ARM64_16K_PAGES)
128-
#define ARM64_MEMSTART_SHIFT (PMD_SHIFT + 5)
125+
#define ARM64_MEMSTART_SHIFT CONT_PMD_SHIFT
129126
#else
130127
#define ARM64_MEMSTART_SHIFT PMD_SHIFT
131128
#endif

arch/arm64/include/asm/memory.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@
135135
#define MT_NORMAL 0
136136
#define MT_NORMAL_TAGGED 1
137137
#define MT_NORMAL_NC 2
138-
#define MT_NORMAL_WT 3
139-
#define MT_DEVICE_nGnRnE 4
140-
#define MT_DEVICE_nGnRE 5
141-
#define MT_DEVICE_GRE 6
138+
#define MT_DEVICE_nGnRnE 3
139+
#define MT_DEVICE_nGnRE 4
142140

143141
/*
144142
* Memory types for Stage-2 translation

arch/arm64/include/asm/mmu_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
177177
return;
178178

179179
if (mm == &init_mm)
180-
ttbr = __pa_symbol(reserved_pg_dir);
180+
ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
181181
else
182-
ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
182+
ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) | ASID(mm) << 48;
183183

184184
WRITE_ONCE(task_thread_info(tsk)->ttbr0, ttbr);
185185
}

arch/arm64/include/asm/pgtable-hwdef.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
#define PGDIR_MASK (~(PGDIR_SIZE-1))
7272
#define PTRS_PER_PGD (1 << (VA_BITS - PGDIR_SHIFT))
7373

74-
/*
75-
* Section address mask and size definitions.
76-
*/
77-
#define SECTION_SHIFT PMD_SHIFT
78-
#define SECTION_SIZE (_AC(1, UL) << SECTION_SHIFT)
79-
#define SECTION_MASK (~(SECTION_SIZE-1))
80-
8174
/*
8275
* Contiguous page definitions.
8376
*/

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ extern bool arm64_use_ng_mappings;
5555
#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE))
5656
#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE))
5757
#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC))
58-
#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT))
5958
#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL))
6059
#define PROT_NORMAL_TAGGED (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_TAGGED))
6160

arch/arm64/include/asm/pgtable.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,12 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
511511

512512
#define pmd_none(pmd) (!pmd_val(pmd))
513513

514-
#define pmd_bad(pmd) (!(pmd_val(pmd) & PMD_TABLE_BIT))
515-
516514
#define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \
517515
PMD_TYPE_TABLE)
518516
#define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \
519517
PMD_TYPE_SECT)
520518
#define pmd_leaf(pmd) pmd_sect(pmd)
519+
#define pmd_bad(pmd) (!pmd_table(pmd))
521520

522521
#define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE)
523522
#define pte_leaf_size(pte) (pte_cont(pte) ? CONT_PTE_SIZE : PAGE_SIZE)
@@ -604,7 +603,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
604603
pr_err("%s:%d: bad pmd %016llx.\n", __FILE__, __LINE__, pmd_val(e))
605604

606605
#define pud_none(pud) (!pud_val(pud))
607-
#define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT))
606+
#define pud_bad(pud) (!pud_table(pud))
608607
#define pud_present(pud) pte_present(pud_pte(pud))
609608
#define pud_leaf(pud) pud_sect(pud)
610609
#define pud_valid(pud) pte_valid(pud_pte(pud))

arch/arm64/include/asm/sysreg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,7 @@
703703
/* MAIR_ELx memory attributes (used by Linux) */
704704
#define MAIR_ATTR_DEVICE_nGnRnE UL(0x00)
705705
#define MAIR_ATTR_DEVICE_nGnRE UL(0x04)
706-
#define MAIR_ATTR_DEVICE_GRE UL(0x0c)
707706
#define MAIR_ATTR_NORMAL_NC UL(0x44)
708-
#define MAIR_ATTR_NORMAL_WT UL(0xbb)
709707
#define MAIR_ATTR_NORMAL_TAGGED UL(0xf0)
710708
#define MAIR_ATTR_NORMAL UL(0xff)
711709
#define MAIR_ATTR_MASK UL(0xff)

arch/arm64/include/asm/tlb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather *tlb);
2828
*/
2929
static inline int tlb_get_level(struct mmu_gather *tlb)
3030
{
31+
/* The TTL field is only valid for the leaf entry. */
32+
if (tlb->freed_tables)
33+
return 0;
34+
3135
if (tlb->cleared_ptes && !(tlb->cleared_pmds ||
3236
tlb->cleared_puds ||
3337
tlb->cleared_p4ds))

arch/arm64/kernel/acpi.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,37 @@ void __init acpi_boot_table_init(void)
239239
}
240240
}
241241

242+
static pgprot_t __acpi_get_writethrough_mem_attribute(void)
243+
{
244+
/*
245+
* Although UEFI specifies the use of Normal Write-through for
246+
* EFI_MEMORY_WT, it is seldom used in practice and not implemented
247+
* by most (all?) CPUs. Rather than allocate a MAIR just for this
248+
* purpose, emit a warning and use Normal Non-cacheable instead.
249+
*/
250+
pr_warn_once("No MAIR allocation for EFI_MEMORY_WT; treating as Normal Non-cacheable\n");
251+
return __pgprot(PROT_NORMAL_NC);
252+
}
253+
242254
pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
243255
{
244256
/*
245257
* According to "Table 8 Map: EFI memory types to AArch64 memory
246258
* types" of UEFI 2.5 section 2.3.6.1, each EFI memory type is
247259
* mapped to a corresponding MAIR attribute encoding.
248260
* The EFI memory attribute advises all possible capabilities
249-
* of a memory region. We use the most efficient capability.
261+
* of a memory region.
250262
*/
251263

252264
u64 attr;
253265

254266
attr = efi_mem_attributes(addr);
255267
if (attr & EFI_MEMORY_WB)
256268
return PAGE_KERNEL;
257-
if (attr & EFI_MEMORY_WT)
258-
return __pgprot(PROT_NORMAL_WT);
259269
if (attr & EFI_MEMORY_WC)
260270
return __pgprot(PROT_NORMAL_NC);
271+
if (attr & EFI_MEMORY_WT)
272+
return __acpi_get_writethrough_mem_attribute();
261273
return __pgprot(PROT_DEVICE_nGnRnE);
262274
}
263275

@@ -340,10 +352,10 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
340352
default:
341353
if (region->attribute & EFI_MEMORY_WB)
342354
prot = PAGE_KERNEL;
343-
else if (region->attribute & EFI_MEMORY_WT)
344-
prot = __pgprot(PROT_NORMAL_WT);
345355
else if (region->attribute & EFI_MEMORY_WC)
346356
prot = __pgprot(PROT_NORMAL_NC);
357+
else if (region->attribute & EFI_MEMORY_WT)
358+
prot = __acpi_get_writethrough_mem_attribute();
347359
}
348360
}
349361
return __ioremap(phys, size, prot);

0 commit comments

Comments
 (0)