Skip to content

Commit e942d75

Browse files
committed
Merge tag 'powerpc-5.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - fix miscompilation with GCC 4.9 by using asm_goto_volatile for put_user() - fix for an RCU splat at boot caused by a recent lockdep change - fix for a possible deadlock in our EEH debugfs code - several fixes for handling of _PAGE_ACCESSED on 32-bit platforms - build fix when CONFIG_NUMA=n Thanks to Andreas Schwab, Christophe Leroy, Oliver O'Halloran, Qian Cai, and Scott Cheloha. * tag 'powerpc-5.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/numa: Fix build when CONFIG_NUMA=n powerpc/8xx: Manage _PAGE_ACCESSED through APG bits in L1 entry powerpc/8xx: Always fault when _PAGE_ACCESSED is not set powerpc/40x: Always fault when _PAGE_ACCESSED is not set powerpc/603: Always fault when _PAGE_ACCESSED is not set powerpc: Use asm_goto_volatile for put_user() powerpc/smp: Call rcu_cpu_starting() earlier powerpc/eeh_cache: Fix a possible debugfs deadlock
2 parents 4429f14 + 3fb4a8f commit e942d75

10 files changed

Lines changed: 44 additions & 104 deletions

File tree

arch/powerpc/include/asm/nohash/32/kup-8xx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static inline void restore_user_access(unsigned long flags)
6363
static inline bool
6464
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
6565
{
66-
return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xf0000000),
66+
return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xff000000),
6767
"Bug: fault blocked by AP register !");
6868
}
6969

arch/powerpc/include/asm/nohash/32/mmu-8xx.h

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@
3333
* respectively NA for All or X for Supervisor and no access for User.
3434
* Then we use the APG to say whether accesses are according to Page rules or
3535
* "all Supervisor" rules (Access to all)
36-
* Therefore, we define 2 APG groups. lsb is _PMD_USER
37-
* 0 => Kernel => 01 (all accesses performed according to page definition)
38-
* 1 => User => 00 (all accesses performed as supervisor iaw page definition)
39-
* 2-15 => Not Used
40-
*/
41-
#define MI_APG_INIT 0x40000000
42-
43-
/*
44-
* 0 => Kernel => 01 (all accesses performed according to page definition)
45-
* 1 => User => 10 (all accesses performed according to swaped page definition)
46-
* 2-15 => Not Used
47-
*/
48-
#define MI_APG_KUEP 0x60000000
36+
* _PAGE_ACCESSED is also managed via APG. When _PAGE_ACCESSED is not set, say
37+
* "all User" rules, that will lead to NA for all.
38+
* Therefore, we define 4 APG groups. lsb is _PAGE_ACCESSED
39+
* 0 => Kernel => 11 (all accesses performed according as user iaw page definition)
40+
* 1 => Kernel+Accessed => 01 (all accesses performed according to page definition)
41+
* 2 => User => 11 (all accesses performed according as user iaw page definition)
42+
* 3 => User+Accessed => 00 (all accesses performed as supervisor iaw page definition) for INIT
43+
* => 10 (all accesses performed according to swaped page definition) for KUEP
44+
* 4-15 => Not Used
45+
*/
46+
#define MI_APG_INIT 0xdc000000
47+
#define MI_APG_KUEP 0xde000000
4948

5049
/* The effective page number register. When read, contains the information
5150
* about the last instruction TLB miss. When MI_RPN is written, bits in
@@ -106,25 +105,9 @@
106105
#define MD_Ks 0x80000000 /* Should not be set */
107106
#define MD_Kp 0x40000000 /* Should always be set */
108107

109-
/*
110-
* All pages' PP data bits are set to either 000 or 011 or 001, which means
111-
* respectively RW for Supervisor and no access for User, or RO for
112-
* Supervisor and no access for user and NA for ALL.
113-
* Then we use the APG to say whether accesses are according to Page rules or
114-
* "all Supervisor" rules (Access to all)
115-
* Therefore, we define 2 APG groups. lsb is _PMD_USER
116-
* 0 => Kernel => 01 (all accesses performed according to page definition)
117-
* 1 => User => 00 (all accesses performed as supervisor iaw page definition)
118-
* 2-15 => Not Used
119-
*/
120-
#define MD_APG_INIT 0x40000000
121-
122-
/*
123-
* 0 => No user => 01 (all accesses performed according to page definition)
124-
* 1 => User => 10 (all accesses performed according to swaped page definition)
125-
* 2-15 => Not Used
126-
*/
127-
#define MD_APG_KUAP 0x60000000
108+
/* See explanation above at the definition of MI_APG_INIT */
109+
#define MD_APG_INIT 0xdc000000
110+
#define MD_APG_KUAP 0xde000000
128111

129112
/* The effective page number register. When read, contains the information
130113
* about the last instruction TLB miss. When MD_RPN is written, bits in

arch/powerpc/include/asm/nohash/32/pte-8xx.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
* into the TLB.
4040
*/
4141
#define _PAGE_GUARDED 0x0010 /* Copied to L1 G entry in DTLB */
42-
#define _PAGE_SPECIAL 0x0020 /* SW entry */
42+
#define _PAGE_ACCESSED 0x0020 /* Copied to L1 APG 1 entry in I/DTLB */
4343
#define _PAGE_EXEC 0x0040 /* Copied to PP (bit 21) in ITLB */
44-
#define _PAGE_ACCESSED 0x0080 /* software: page referenced */
44+
#define _PAGE_SPECIAL 0x0080 /* SW entry */
4545

4646
#define _PAGE_NA 0x0200 /* Supervisor NA, User no access */
4747
#define _PAGE_RO 0x0600 /* Supervisor RO, User no access */
@@ -59,11 +59,12 @@
5959

6060
#define _PMD_PRESENT 0x0001
6161
#define _PMD_PRESENT_MASK _PMD_PRESENT
62-
#define _PMD_BAD 0x0fd0
62+
#define _PMD_BAD 0x0f90
6363
#define _PMD_PAGE_MASK 0x000c
6464
#define _PMD_PAGE_8M 0x000c
6565
#define _PMD_PAGE_512K 0x0004
66-
#define _PMD_USER 0x0020 /* APG 1 */
66+
#define _PMD_ACCESSED 0x0020 /* APG 1 */
67+
#define _PMD_USER 0x0040 /* APG 2 */
6768

6869
#define _PTE_NONE_MASK 0
6970

arch/powerpc/include/asm/topology.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
struct device;
88
struct device_node;
9+
struct drmem_lmb;
910

1011
#ifdef CONFIG_NUMA
1112

@@ -61,6 +62,9 @@ static inline int early_cpu_to_node(int cpu)
6162
*/
6263
return (nid < 0) ? 0 : nid;
6364
}
65+
66+
int of_drconf_to_nid_single(struct drmem_lmb *lmb);
67+
6468
#else
6569

6670
static inline int early_cpu_to_node(int cpu) { return 0; }
@@ -84,10 +88,12 @@ static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
8488
return 0;
8589
}
8690

87-
#endif /* CONFIG_NUMA */
91+
static inline int of_drconf_to_nid_single(struct drmem_lmb *lmb)
92+
{
93+
return first_online_node;
94+
}
8895

89-
struct drmem_lmb;
90-
int of_drconf_to_nid_single(struct drmem_lmb *lmb);
96+
#endif /* CONFIG_NUMA */
9197

9298
#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
9399
extern int find_and_online_cpu_nid(int cpu);

arch/powerpc/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ do { \
178178
* are no aliasing issues.
179179
*/
180180
#define __put_user_asm_goto(x, addr, label, op) \
181-
asm volatile goto( \
181+
asm_volatile_goto( \
182182
"1: " op "%U1%X1 %0,%1 # put_user\n" \
183183
EX_TABLE(1b, %l2) \
184184
: \
@@ -191,7 +191,7 @@ do { \
191191
__put_user_asm_goto(x, ptr, label, "std")
192192
#else /* __powerpc64__ */
193193
#define __put_user_asm2_goto(x, addr, label) \
194-
asm volatile goto( \
194+
asm_volatile_goto( \
195195
"1: stw%X1 %0, %1\n" \
196196
"2: stw%X1 %L0, %L1\n" \
197197
EX_TABLE(1b, %l2) \

arch/powerpc/kernel/eeh_cache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,17 @@ static int eeh_addr_cache_show(struct seq_file *s, void *v)
264264
{
265265
struct pci_io_addr_range *piar;
266266
struct rb_node *n;
267+
unsigned long flags;
267268

268-
spin_lock(&pci_io_addr_cache_root.piar_lock);
269+
spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
269270
for (n = rb_first(&pci_io_addr_cache_root.rb_root); n; n = rb_next(n)) {
270271
piar = rb_entry(n, struct pci_io_addr_range, rb_node);
271272

272273
seq_printf(s, "%s addr range [%pap-%pap]: %s\n",
273274
(piar->flags & IORESOURCE_IO) ? "i/o" : "mem",
274275
&piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
275276
}
276-
spin_unlock(&pci_io_addr_cache_root.piar_lock);
277+
spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
277278

278279
return 0;
279280
}

arch/powerpc/kernel/head_40x.S

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,7 @@ _ENTRY(saved_ksp_limit)
284284

285285
rlwimi r11, r10, 22, 20, 29 /* Compute PTE address */
286286
lwz r11, 0(r11) /* Get Linux PTE */
287-
#ifdef CONFIG_SWAP
288287
li r9, _PAGE_PRESENT | _PAGE_ACCESSED
289-
#else
290-
li r9, _PAGE_PRESENT
291-
#endif
292288
andc. r9, r9, r11 /* Check permission */
293289
bne 5f
294290

@@ -369,11 +365,7 @@ _ENTRY(saved_ksp_limit)
369365

370366
rlwimi r11, r10, 22, 20, 29 /* Compute PTE address */
371367
lwz r11, 0(r11) /* Get Linux PTE */
372-
#ifdef CONFIG_SWAP
373368
li r9, _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
374-
#else
375-
li r9, _PAGE_PRESENT | _PAGE_EXEC
376-
#endif
377369
andc. r9, r9, r11 /* Check permission */
378370
bne 5f
379371

arch/powerpc/kernel/head_8xx.S

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ SystemCall:
202202

203203
InstructionTLBMiss:
204204
mtspr SPRN_SPRG_SCRATCH0, r10
205-
#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)
206205
mtspr SPRN_SPRG_SCRATCH1, r11
207-
#endif
208206

209207
/* If we are faulting a kernel address, we have to use the
210208
* kernel page tables.
@@ -224,25 +222,13 @@ InstructionTLBMiss:
224222
3:
225223
mtcr r11
226224
#endif
227-
#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)
228225
lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */
229226
mtspr SPRN_MD_TWC, r11
230-
#else
231-
lwz r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */
232-
mtspr SPRN_MI_TWC, r10 /* Set segment attributes */
233-
mtspr SPRN_MD_TWC, r10
234-
#endif
235227
mfspr r10, SPRN_MD_TWC
236228
lwz r10, 0(r10) /* Get the pte */
237-
#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)
229+
rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
238230
rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K
239231
mtspr SPRN_MI_TWC, r11
240-
#endif
241-
#ifdef CONFIG_SWAP
242-
rlwinm r11, r10, 32-5, _PAGE_PRESENT
243-
and r11, r11, r10
244-
rlwimi r10, r11, 0, _PAGE_PRESENT
245-
#endif
246232
/* The Linux PTE won't go exactly into the MMU TLB.
247233
* Software indicator bits 20 and 23 must be clear.
248234
* Software indicator bits 22, 24, 25, 26, and 27 must be
@@ -256,9 +242,7 @@ InstructionTLBMiss:
256242

257243
/* Restore registers */
258244
0: mfspr r10, SPRN_SPRG_SCRATCH0
259-
#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)
260245
mfspr r11, SPRN_SPRG_SCRATCH1
261-
#endif
262246
rfi
263247
patch_site 0b, patch__itlbmiss_exit_1
264248

@@ -268,9 +252,7 @@ InstructionTLBMiss:
268252
addi r10, r10, 1
269253
stw r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
270254
mfspr r10, SPRN_SPRG_SCRATCH0
271-
#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)
272255
mfspr r11, SPRN_SPRG_SCRATCH1
273-
#endif
274256
rfi
275257
#endif
276258

@@ -297,30 +279,16 @@ DataStoreTLBMiss:
297279
mfspr r10, SPRN_MD_TWC
298280
lwz r10, 0(r10) /* Get the pte */
299281

300-
/* Insert the Guarded flag into the TWC from the Linux PTE.
282+
/* Insert Guarded and Accessed flags into the TWC from the Linux PTE.
301283
* It is bit 27 of both the Linux PTE and the TWC (at least
302284
* I got that right :-). It will be better when we can put
303285
* this into the Linux pgd/pmd and load it in the operation
304286
* above.
305287
*/
306-
rlwimi r11, r10, 0, _PAGE_GUARDED
288+
rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
307289
rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K
308290
mtspr SPRN_MD_TWC, r11
309291

310-
/* Both _PAGE_ACCESSED and _PAGE_PRESENT has to be set.
311-
* We also need to know if the insn is a load/store, so:
312-
* Clear _PAGE_PRESENT and load that which will
313-
* trap into DTLB Error with store bit set accordinly.
314-
*/
315-
/* PRESENT=0x1, ACCESSED=0x20
316-
* r11 = ((r10 & PRESENT) & ((r10 & ACCESSED) >> 5));
317-
* r10 = (r10 & ~PRESENT) | r11;
318-
*/
319-
#ifdef CONFIG_SWAP
320-
rlwinm r11, r10, 32-5, _PAGE_PRESENT
321-
and r11, r11, r10
322-
rlwimi r10, r11, 0, _PAGE_PRESENT
323-
#endif
324292
/* The Linux PTE won't go exactly into the MMU TLB.
325293
* Software indicator bits 24, 25, 26, and 27 must be
326294
* set. All other Linux PTE bits control the behavior
@@ -711,7 +679,7 @@ initial_mmu:
711679
li r9, 4 /* up to 4 pages of 8M */
712680
mtctr r9
713681
lis r9, KERNELBASE@h /* Create vaddr for TLB */
714-
li r10, MI_PS8MEG | MI_SVALID /* Set 8M byte page */
682+
li r10, MI_PS8MEG | _PMD_ACCESSED | MI_SVALID
715683
li r11, MI_BOOTINIT /* Create RPN for address 0 */
716684
1:
717685
mtspr SPRN_MI_CTR, r8 /* Set instruction MMU control */
@@ -775,7 +743,7 @@ _GLOBAL(mmu_pin_tlb)
775743
#ifdef CONFIG_PIN_TLB_TEXT
776744
LOAD_REG_IMMEDIATE(r5, 28 << 8)
777745
LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
778-
LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)
746+
LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
779747
LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_RO | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT)
780748
LOAD_REG_ADDR(r9, _sinittext)
781749
li r0, 4
@@ -797,7 +765,7 @@ _GLOBAL(mmu_pin_tlb)
797765
LOAD_REG_IMMEDIATE(r5, 28 << 8 | MD_TWAM)
798766
#ifdef CONFIG_PIN_TLB_DATA
799767
LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
800-
LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)
768+
LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
801769
#ifdef CONFIG_PIN_TLB_IMMR
802770
li r0, 3
803771
#else
@@ -834,7 +802,7 @@ _GLOBAL(mmu_pin_tlb)
834802
#endif
835803
#ifdef CONFIG_PIN_TLB_IMMR
836804
LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID)
837-
LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED)
805+
LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED | _PMD_ACCESSED)
838806
mfspr r8, SPRN_IMMR
839807
rlwinm r8, r8, 0, 0xfff80000
840808
ori r8, r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \

arch/powerpc/kernel/head_book3s_32.S

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,7 @@ InstructionTLBMiss:
457457
cmplw 0,r1,r3
458458
#endif
459459
mfspr r2, SPRN_SPRG_PGDIR
460-
#ifdef CONFIG_SWAP
461460
li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
462-
#else
463-
li r1,_PAGE_PRESENT | _PAGE_EXEC
464-
#endif
465461
#if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC)
466462
bgt- 112f
467463
lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */
@@ -523,11 +519,7 @@ DataLoadTLBMiss:
523519
lis r1, TASK_SIZE@h /* check if kernel address */
524520
cmplw 0,r1,r3
525521
mfspr r2, SPRN_SPRG_PGDIR
526-
#ifdef CONFIG_SWAP
527522
li r1, _PAGE_PRESENT | _PAGE_ACCESSED
528-
#else
529-
li r1, _PAGE_PRESENT
530-
#endif
531523
bgt- 112f
532524
lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */
533525
addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */
@@ -603,11 +595,7 @@ DataStoreTLBMiss:
603595
lis r1, TASK_SIZE@h /* check if kernel address */
604596
cmplw 0,r1,r3
605597
mfspr r2, SPRN_SPRG_PGDIR
606-
#ifdef CONFIG_SWAP
607598
li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED
608-
#else
609-
li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT
610-
#endif
611599
bgt- 112f
612600
lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */
613601
addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */

arch/powerpc/kernel/smp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,13 +1393,14 @@ static void add_cpu_to_masks(int cpu)
13931393
/* Activate a secondary processor. */
13941394
void start_secondary(void *unused)
13951395
{
1396-
unsigned int cpu = smp_processor_id();
1396+
unsigned int cpu = raw_smp_processor_id();
13971397

13981398
mmgrab(&init_mm);
13991399
current->active_mm = &init_mm;
14001400

14011401
smp_store_cpu_info(cpu);
14021402
set_dec(tb_ticks_per_jiffy);
1403+
rcu_cpu_starting(cpu);
14031404
preempt_disable();
14041405
cpu_callin_map[cpu] = 1;
14051406

0 commit comments

Comments
 (0)