Skip to content

Commit 08179b4

Browse files
committed
Merge branch 'parisc-5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull parisc updates from Helge Deller: - Optimize parisc page table locks by using the existing page_table_lock - Export argv0-preserve flag in binfmt_misc for usage in qemu-user - Fix interrupt table (IVT) checksum so firmware will call crash handler (HPMC) - Increase IRQ stack to 64kb on 64-bit kernel - Switch to common devmem_is_allowed() implementation - Minor fix to get_whan() * 'parisc-5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: binfmt_misc: pass binfmt_misc flags to the interpreter parisc: Optimize per-pagetable spinlocks parisc: Replace test_ti_thread_flag() with test_tsk_thread_flag() parisc: Bump 64-bit IRQ stack size to 64 KB parisc: Fix IVT checksum calculation wrt HPMC parisc: Use the generic devmem_is_allowed() parisc: Drop out of get_whan() if task is running again
2 parents 2671fe5 + 2347961 commit 08179b4

20 files changed

Lines changed: 141 additions & 235 deletions

File tree

‎arch/parisc/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config PARISC
3434
select GENERIC_SMP_IDLE_THREAD
3535
select GENERIC_CPU_DEVICES
3636
select GENERIC_STRNCPY_FROM_USER
37+
select GENERIC_LIB_DEVMEM_IS_ALLOWED
3738
select SYSCTL_ARCH_UNALIGN_ALLOW
3839
select SYSCTL_EXCEPTION_TRACE
3940
select HAVE_MOD_ARCH_SPECIFIC
@@ -310,6 +311,16 @@ config IRQSTACKS
310311
for handling hard and soft interrupts. This can help avoid
311312
overflowing the process kernel stacks.
312313

314+
config TLB_PTLOCK
315+
bool "Use page table locks in TLB fault handler"
316+
depends on SMP
317+
default n
318+
help
319+
Select this option to enable page table locking in the TLB
320+
fault handler. This ensures that page table entries are
321+
updated consistently on SMP machines at the expense of some
322+
loss in performance.
323+
313324
config HOTPLUG_CPU
314325
bool
315326
default y if SMP

‎arch/parisc/include/asm/compat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static __inline__ void __user *arch_compat_alloc_user_space(long len)
179179

180180
static inline int __is_compat_task(struct task_struct *t)
181181
{
182-
return test_ti_thread_flag(task_thread_info(t), TIF_32BIT);
182+
return test_tsk_thread_flag(t, TIF_32BIT);
183183
}
184184

185185
static inline int is_compat_task(void)

‎arch/parisc/include/asm/io.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,6 @@ extern void iowrite64be(u64 val, void __iomem *addr);
321321
*/
322322
#define xlate_dev_kmem_ptr(p) p
323323

324+
extern int devmem_is_allowed(unsigned long pfn);
325+
324326
#endif

‎arch/parisc/include/asm/mmu_context.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/mm.h>
66
#include <linux/sched.h>
77
#include <linux/atomic.h>
8+
#include <linux/spinlock.h>
89
#include <asm-generic/mm_hooks.h>
910

1011
/* on PA-RISC, we actually have enough contexts to justify an allocator
@@ -50,6 +51,12 @@ static inline void switch_mm_irqs_off(struct mm_struct *prev,
5051
struct mm_struct *next, struct task_struct *tsk)
5152
{
5253
if (prev != next) {
54+
#ifdef CONFIG_TLB_PTLOCK
55+
/* put physical address of page_table_lock in cr28 (tr4)
56+
for TLB faults */
57+
spinlock_t *pgd_lock = &next->page_table_lock;
58+
mtctl(__pa(__ldcw_align(&pgd_lock->rlock.raw_lock)), 28);
59+
#endif
5360
mtctl(__pa(next->pgd), 25);
5461
load_context(next->context);
5562
}

‎arch/parisc/include/asm/page.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extern int npmem_ranges;
112112
#else
113113
#define BITS_PER_PTE_ENTRY 2
114114
#define BITS_PER_PMD_ENTRY 2
115-
#define BITS_PER_PGD_ENTRY BITS_PER_PMD_ENTRY
115+
#define BITS_PER_PGD_ENTRY 2
116116
#endif
117117
#define PGD_ENTRY_SIZE (1UL << BITS_PER_PGD_ENTRY)
118118
#define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY)

‎arch/parisc/include/asm/pgalloc.h‎

Lines changed: 18 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,23 @@
1515
#define __HAVE_ARCH_PGD_FREE
1616
#include <asm-generic/pgalloc.h>
1717

18-
/* Allocate the top level pgd (page directory)
19-
*
20-
* Here (for 64 bit kernels) we implement a Hybrid L2/L3 scheme: we
21-
* allocate the first pmd adjacent to the pgd. This means that we can
22-
* subtract a constant offset to get to it. The pmd and pgd sizes are
23-
* arranged so that a single pmd covers 4GB (giving a full 64-bit
24-
* process access to 8TB) so our lookups are effectively L2 for the
25-
* first 4GB of the kernel (i.e. for all ILP32 processes and all the
26-
* kernel for machines with under 4GB of memory) */
18+
/* Allocate the top level pgd (page directory) */
2719
static inline pgd_t *pgd_alloc(struct mm_struct *mm)
2820
{
29-
pgd_t *pgd = (pgd_t *)__get_free_pages(GFP_KERNEL,
30-
PGD_ALLOC_ORDER);
31-
pgd_t *actual_pgd = pgd;
21+
pgd_t *pgd;
3222

33-
if (likely(pgd != NULL)) {
34-
memset(pgd, 0, PAGE_SIZE<<PGD_ALLOC_ORDER);
35-
#if CONFIG_PGTABLE_LEVELS == 3
36-
actual_pgd += PTRS_PER_PGD;
37-
/* Populate first pmd with allocated memory. We mark it
38-
* with PxD_FLAG_ATTACHED as a signal to the system that this
39-
* pmd entry may not be cleared. */
40-
set_pgd(actual_pgd, __pgd((PxD_FLAG_PRESENT |
41-
PxD_FLAG_VALID |
42-
PxD_FLAG_ATTACHED)
43-
+ (__u32)(__pa((unsigned long)pgd) >> PxD_VALUE_SHIFT)));
44-
/* The first pmd entry also is marked with PxD_FLAG_ATTACHED as
45-
* a signal that this pmd may not be freed */
46-
set_pgd(pgd, __pgd(PxD_FLAG_ATTACHED));
47-
#endif
48-
}
49-
spin_lock_init(pgd_spinlock(actual_pgd));
50-
return actual_pgd;
23+
pgd = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
24+
if (unlikely(pgd == NULL))
25+
return NULL;
26+
27+
memset(pgd, 0, PAGE_SIZE << PGD_ORDER);
28+
29+
return pgd;
5130
}
5231

5332
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
5433
{
55-
#if CONFIG_PGTABLE_LEVELS == 3
56-
pgd -= PTRS_PER_PGD;
57-
#endif
58-
free_pages((unsigned long)pgd, PGD_ALLOC_ORDER);
34+
free_pages((unsigned long)pgd, PGD_ORDER);
5935
}
6036

6137
#if CONFIG_PGTABLE_LEVELS == 3
@@ -70,41 +46,25 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7046

7147
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7248
{
73-
return (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_ORDER);
49+
pmd_t *pmd;
50+
51+
pmd = (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_ORDER);
52+
if (likely(pmd))
53+
memset ((void *)pmd, 0, PAGE_SIZE << PMD_ORDER);
54+
return pmd;
7455
}
7556

7657
static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7758
{
78-
if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED) {
79-
/*
80-
* This is the permanent pmd attached to the pgd;
81-
* cannot free it.
82-
* Increment the counter to compensate for the decrement
83-
* done by generic mm code.
84-
*/
85-
mm_inc_nr_pmds(mm);
86-
return;
87-
}
8859
free_pages((unsigned long)pmd, PMD_ORDER);
8960
}
90-
9161
#endif
9262

9363
static inline void
9464
pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
9565
{
96-
#if CONFIG_PGTABLE_LEVELS == 3
97-
/* preserve the gateway marker if this is the beginning of
98-
* the permanent pmd */
99-
if(pmd_flag(*pmd) & PxD_FLAG_ATTACHED)
100-
set_pmd(pmd, __pmd((PxD_FLAG_PRESENT |
101-
PxD_FLAG_VALID |
102-
PxD_FLAG_ATTACHED)
103-
+ (__u32)(__pa((unsigned long)pte) >> PxD_VALUE_SHIFT)));
104-
else
105-
#endif
106-
set_pmd(pmd, __pmd((PxD_FLAG_PRESENT | PxD_FLAG_VALID)
107-
+ (__u32)(__pa((unsigned long)pte) >> PxD_VALUE_SHIFT)));
66+
set_pmd(pmd, __pmd((PxD_FLAG_PRESENT | PxD_FLAG_VALID)
67+
+ (__u32)(__pa((unsigned long)pte) >> PxD_VALUE_SHIFT)));
10868
}
10969

11070
#define pmd_populate(mm, pmd, pte_page) \

‎arch/parisc/include/asm/pgtable.h‎

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include <asm/processor.h>
2424
#include <asm/cache.h>
2525

26-
static inline spinlock_t *pgd_spinlock(pgd_t *);
27-
2826
/*
2927
* kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
3028
* memory. For the return value to be meaningful, ADDR must be >=
@@ -42,12 +40,8 @@ static inline spinlock_t *pgd_spinlock(pgd_t *);
4240

4341
/* This is for the serialization of PxTLB broadcasts. At least on the N class
4442
* systems, only one PxTLB inter processor broadcast can be active at any one
45-
* time on the Merced bus.
46-
47-
* PTE updates are protected by locks in the PMD.
48-
*/
43+
* time on the Merced bus. */
4944
extern spinlock_t pa_tlb_flush_lock;
50-
extern spinlock_t pa_swapper_pg_lock;
5145
#if defined(CONFIG_64BIT) && defined(CONFIG_SMP)
5246
extern int pa_serialize_tlb_flushes;
5347
#else
@@ -86,18 +80,16 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
8680
* within a page table are directly modified. Thus, the following
8781
* hook is made available.
8882
*/
89-
#define set_pte(pteptr, pteval) \
90-
do{ \
91-
*(pteptr) = (pteval); \
92-
} while(0)
93-
94-
#define set_pte_at(mm, addr, ptep, pteval) \
95-
do { \
96-
unsigned long flags; \
97-
spin_lock_irqsave(pgd_spinlock((mm)->pgd), flags);\
98-
set_pte(ptep, pteval); \
99-
purge_tlb_entries(mm, addr); \
100-
spin_unlock_irqrestore(pgd_spinlock((mm)->pgd), flags);\
83+
#define set_pte(pteptr, pteval) \
84+
do { \
85+
*(pteptr) = (pteval); \
86+
barrier(); \
87+
} while(0)
88+
89+
#define set_pte_at(mm, addr, pteptr, pteval) \
90+
do { \
91+
*(pteptr) = (pteval); \
92+
purge_tlb_entries(mm, addr); \
10193
} while (0)
10294

10395
#endif /* !__ASSEMBLY__ */
@@ -120,12 +112,10 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
120112
#define KERNEL_INITIAL_SIZE (1 << KERNEL_INITIAL_ORDER)
121113

122114
#if CONFIG_PGTABLE_LEVELS == 3
123-
#define PGD_ORDER 1 /* Number of pages per pgd */
124-
#define PMD_ORDER 1 /* Number of pages per pmd */
125-
#define PGD_ALLOC_ORDER (2 + 1) /* first pgd contains pmd */
115+
#define PMD_ORDER 1
116+
#define PGD_ORDER 0
126117
#else
127-
#define PGD_ORDER 1 /* Number of pages per pgd */
128-
#define PGD_ALLOC_ORDER (PGD_ORDER + 1)
118+
#define PGD_ORDER 1
129119
#endif
130120

131121
/* Definitions for 3rd level (we use PLD here for Page Lower directory
@@ -240,11 +230,9 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
240230
* able to effectively address 40/42/44-bits of physical address space
241231
* depending on 4k/16k/64k PAGE_SIZE */
242232
#define _PxD_PRESENT_BIT 31
243-
#define _PxD_ATTACHED_BIT 30
244-
#define _PxD_VALID_BIT 29
233+
#define _PxD_VALID_BIT 30
245234

246235
#define PxD_FLAG_PRESENT (1 << xlate_pabit(_PxD_PRESENT_BIT))
247-
#define PxD_FLAG_ATTACHED (1 << xlate_pabit(_PxD_ATTACHED_BIT))
248236
#define PxD_FLAG_VALID (1 << xlate_pabit(_PxD_VALID_BIT))
249237
#define PxD_FLAG_MASK (0xf)
250238
#define PxD_FLAG_SHIFT (4)
@@ -326,23 +314,10 @@ extern unsigned long *empty_zero_page;
326314
#define pgd_flag(x) (pgd_val(x) & PxD_FLAG_MASK)
327315
#define pgd_address(x) ((unsigned long)(pgd_val(x) &~ PxD_FLAG_MASK) << PxD_VALUE_SHIFT)
328316

329-
#if CONFIG_PGTABLE_LEVELS == 3
330-
/* The first entry of the permanent pmd is not there if it contains
331-
* the gateway marker */
332-
#define pmd_none(x) (!pmd_val(x) || pmd_flag(x) == PxD_FLAG_ATTACHED)
333-
#else
334317
#define pmd_none(x) (!pmd_val(x))
335-
#endif
336318
#define pmd_bad(x) (!(pmd_flag(x) & PxD_FLAG_VALID))
337319
#define pmd_present(x) (pmd_flag(x) & PxD_FLAG_PRESENT)
338320
static inline void pmd_clear(pmd_t *pmd) {
339-
#if CONFIG_PGTABLE_LEVELS == 3
340-
if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED)
341-
/* This is the entry pointing to the permanent pmd
342-
* attached to the pgd; cannot clear it */
343-
set_pmd(pmd, __pmd(PxD_FLAG_ATTACHED));
344-
else
345-
#endif
346321
set_pmd(pmd, __pmd(0));
347322
}
348323

@@ -358,12 +333,6 @@ static inline void pmd_clear(pmd_t *pmd) {
358333
#define pud_bad(x) (!(pud_flag(x) & PxD_FLAG_VALID))
359334
#define pud_present(x) (pud_flag(x) & PxD_FLAG_PRESENT)
360335
static inline void pud_clear(pud_t *pud) {
361-
#if CONFIG_PGTABLE_LEVELS == 3
362-
if(pud_flag(*pud) & PxD_FLAG_ATTACHED)
363-
/* This is the permanent pmd attached to the pud; cannot
364-
* free it */
365-
return;
366-
#endif
367336
set_pud(pud, __pud(0));
368337
}
369338
#endif
@@ -456,57 +425,35 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
456425
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
457426
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
458427

459-
460-
static inline spinlock_t *pgd_spinlock(pgd_t *pgd)
461-
{
462-
if (unlikely(pgd == swapper_pg_dir))
463-
return &pa_swapper_pg_lock;
464-
return (spinlock_t *)((char *)pgd + (PAGE_SIZE << (PGD_ALLOC_ORDER - 1)));
465-
}
466-
467-
468428
static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
469429
{
470430
pte_t pte;
471-
unsigned long flags;
472431

473432
if (!pte_young(*ptep))
474433
return 0;
475434

476-
spin_lock_irqsave(pgd_spinlock(vma->vm_mm->pgd), flags);
477435
pte = *ptep;
478436
if (!pte_young(pte)) {
479-
spin_unlock_irqrestore(pgd_spinlock(vma->vm_mm->pgd), flags);
480437
return 0;
481438
}
482-
set_pte(ptep, pte_mkold(pte));
483-
purge_tlb_entries(vma->vm_mm, addr);
484-
spin_unlock_irqrestore(pgd_spinlock(vma->vm_mm->pgd), flags);
439+
set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
485440
return 1;
486441
}
487442

488443
struct mm_struct;
489444
static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
490445
{
491446
pte_t old_pte;
492-
unsigned long flags;
493447

494-
spin_lock_irqsave(pgd_spinlock(mm->pgd), flags);
495448
old_pte = *ptep;
496-
set_pte(ptep, __pte(0));
497-
purge_tlb_entries(mm, addr);
498-
spin_unlock_irqrestore(pgd_spinlock(mm->pgd), flags);
449+
set_pte_at(mm, addr, ptep, __pte(0));
499450

500451
return old_pte;
501452
}
502453

503454
static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
504455
{
505-
unsigned long flags;
506-
spin_lock_irqsave(pgd_spinlock(mm->pgd), flags);
507-
set_pte(ptep, pte_wrprotect(*ptep));
508-
purge_tlb_entries(mm, addr);
509-
spin_unlock_irqrestore(pgd_spinlock(mm->pgd), flags);
456+
set_pte_at(mm, addr, ptep, pte_wrprotect(*ptep));
510457
}
511458

512459
#define pte_same(A,B) (pte_val(A) == pte_val(B))

‎arch/parisc/kernel/asm-offsets.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ int main(void)
268268
DEFINE(ASM_BITS_PER_PGD, BITS_PER_PGD);
269269
DEFINE(ASM_BITS_PER_PMD, BITS_PER_PMD);
270270
DEFINE(ASM_BITS_PER_PTE, BITS_PER_PTE);
271-
DEFINE(ASM_PGD_PMD_OFFSET, -(PAGE_SIZE << PGD_ORDER));
272271
DEFINE(ASM_PMD_ENTRY, ((PAGE_OFFSET & PMD_MASK) >> PMD_SHIFT));
273272
DEFINE(ASM_PGD_ENTRY, PAGE_OFFSET >> PGDIR_SHIFT);
274273
DEFINE(ASM_PGD_ENTRY_SIZE, PGD_ENTRY_SIZE);

0 commit comments

Comments
 (0)