Skip to content

Commit cb95712

Browse files
committed
Merge tag 'powerpc-5.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Add perf support for emitting extended registers for power10. - A fix for CPU hotplug on pseries, where on large/loaded systems we may not wait long enough for the CPU to be offlined, leading to crashes. - Addition of a raw cputable entry for Power10, which is not required to boot, but is required to make our PMU setup work correctly in guests. - Three fixes for the recent changes on 32-bit Book3S to move modules into their own segment for strict RWX. - A fix for a recent change in our powernv PCI code that could lead to crashes. - A change to our perf interrupt accounting to avoid soft lockups when using some events, found by syzkaller. - A change in the way we handle power loss events from the hypervisor on pseries. We no longer immediately shut down if we're told we're running on a UPS. - A few other minor fixes. Thanks to Alexey Kardashevskiy, Andreas Schwab, Aneesh Kumar K.V, Anju T Sudhakar, Athira Rajeev, Christophe Leroy, Frederic Barrat, Greg Kurz, Kajol Jain, Madhavan Srinivasan, Michael Neuling, Michael Roth, Nageswara R Sastry, Oliver O'Halloran, Thiago Jung Bauermann, Vaidyanathan Srinivasan, Vasant Hegde. * tag 'powerpc-5.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/perf/hv-24x7: Move cpumask file to top folder of hv-24x7 driver powerpc/32s: Fix module loading failure when VMALLOC_END is over 0xf0000000 powerpc/pseries: Do not initiate shutdown when system is running on UPS powerpc/perf: Fix soft lockups due to missed interrupt accounting powerpc/powernv/pci: Fix possible crash when releasing DMA resources powerpc/pseries/hotplug-cpu: wait indefinitely for vCPU death powerpc/32s: Fix is_module_segment() when MODULES_VADDR is defined powerpc/kasan: Fix KASAN_SHADOW_START on BOOK3S_32 powerpc/fixmap: Fix the size of the early debug area powerpc/pkeys: Fix build error with PPC_MEM_KEYS disabled powerpc/kernel: Cleanup machine check function declarations powerpc: Add POWER10 raw mode cputable entry powerpc/perf: Add extended regs support for power10 platform powerpc/perf: Add support for outputting extended regs in perf intr_regs powerpc: Fix P10 PVR revision in /proc/cpuinfo for SMT4 cores
2 parents 550c212 + 64ef8f2 commit cb95712

21 files changed

+161
-25
lines changed

Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Description: read only
4343
This sysfs interface exposes the number of cores per chip
4444
present in the system.
4545

46-
What: /sys/devices/hv_24x7/interface/cpumask
46+
What: /sys/devices/hv_24x7/cpumask
4747
Date: July 2020
4848
Contact: Linux on PowerPC Developer List <[email protected]>
4949
Description: read only

arch/powerpc/include/asm/cputable.h

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#ifndef __ASSEMBLY__
1111

12+
/*
13+
* Added to include __machine_check_early_realmode_* functions
14+
*/
15+
#include <asm/mce.h>
16+
1217
/* This structure can grow, it's real size is used by head.S code
1318
* via the mkdefs mechanism.
1419
*/

arch/powerpc/include/asm/fixmap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum fixed_addresses {
5252
FIX_HOLE,
5353
/* reserve the top 128K for early debugging purposes */
5454
FIX_EARLY_DEBUG_TOP = FIX_HOLE,
55-
FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128, PAGE_SIZE)/PAGE_SIZE)-1,
55+
FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, PAGE_SIZE)/PAGE_SIZE)-1,
5656
#ifdef CONFIG_HIGHMEM
5757
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
5858
FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,

arch/powerpc/include/asm/kasan.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@
1515
#ifndef __ASSEMBLY__
1616

1717
#include <asm/page.h>
18+
#include <linux/sizes.h>
1819

1920
#define KASAN_SHADOW_SCALE_SHIFT 3
2021

22+
#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_MODULES) && defined(CONFIG_STRICT_KERNEL_RWX)
23+
#define KASAN_KERN_START ALIGN_DOWN(PAGE_OFFSET - SZ_256M, SZ_256M)
24+
#else
25+
#define KASAN_KERN_START PAGE_OFFSET
26+
#endif
27+
2128
#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET + \
22-
(PAGE_OFFSET >> KASAN_SHADOW_SCALE_SHIFT))
29+
(KASAN_KERN_START >> KASAN_SHADOW_SCALE_SHIFT))
2330

2431
#define KASAN_SHADOW_OFFSET ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET)
2532

arch/powerpc/include/asm/mce.h

+7
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ struct mce_error_info {
210210
#define MCE_EVENT_RELEASE true
211211
#define MCE_EVENT_DONTRELEASE false
212212

213+
struct pt_regs;
214+
struct notifier_block;
215+
213216
extern void save_mce_event(struct pt_regs *regs, long handled,
214217
struct mce_error_info *mce_err, uint64_t nip,
215218
uint64_t addr, uint64_t phys_addr);
@@ -225,5 +228,9 @@ int mce_register_notifier(struct notifier_block *nb);
225228
int mce_unregister_notifier(struct notifier_block *nb);
226229
#ifdef CONFIG_PPC_BOOK3S_64
227230
void flush_and_reload_slb(void);
231+
long __machine_check_early_realmode_p7(struct pt_regs *regs);
232+
long __machine_check_early_realmode_p8(struct pt_regs *regs);
233+
long __machine_check_early_realmode_p9(struct pt_regs *regs);
234+
long __machine_check_early_realmode_p10(struct pt_regs *regs);
228235
#endif /* CONFIG_PPC_BOOK3S_64 */
229236
#endif /* __ASM_PPC64_MCE_H__ */

arch/powerpc/include/asm/perf_event.h

+3
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ static inline bool is_sier_available(void) { return false; }
4040

4141
/* To support perf_regs sier update */
4242
extern bool is_sier_available(void);
43+
/* To define perf extended regs mask value */
44+
extern u64 PERF_REG_EXTENDED_MASK;
45+
#define PERF_REG_EXTENDED_MASK PERF_REG_EXTENDED_MASK
4346
#endif

arch/powerpc/include/asm/perf_event_server.h

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ struct power_pmu {
6262
int *blacklist_ev;
6363
/* BHRB entries in the PMU */
6464
int bhrb_nr;
65+
/*
66+
* set this flag with `PERF_PMU_CAP_EXTENDED_REGS` if
67+
* the pmu supports extended perf regs capability
68+
*/
69+
int capabilities;
6570
};
6671

6772
/*

arch/powerpc/include/uapi/asm/perf_regs.h

+19-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ enum perf_event_powerpc_regs {
4848
PERF_REG_POWERPC_DSISR,
4949
PERF_REG_POWERPC_SIER,
5050
PERF_REG_POWERPC_MMCRA,
51-
PERF_REG_POWERPC_MAX,
51+
/* Extended registers */
52+
PERF_REG_POWERPC_MMCR0,
53+
PERF_REG_POWERPC_MMCR1,
54+
PERF_REG_POWERPC_MMCR2,
55+
PERF_REG_POWERPC_MMCR3,
56+
PERF_REG_POWERPC_SIER2,
57+
PERF_REG_POWERPC_SIER3,
58+
/* Max regs without the extended regs */
59+
PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1,
5260
};
61+
62+
#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1)
63+
64+
/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 */
65+
#define PERF_REG_PMU_MASK_300 (((1ULL << (PERF_REG_POWERPC_MMCR2 + 1)) - 1) - PERF_REG_PMU_MASK)
66+
/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 */
67+
#define PERF_REG_PMU_MASK_31 (((1ULL << (PERF_REG_POWERPC_SIER3 + 1)) - 1) - PERF_REG_PMU_MASK)
68+
69+
#define PERF_REG_MAX_ISA_300 (PERF_REG_POWERPC_MMCR2 + 1)
70+
#define PERF_REG_MAX_ISA_31 (PERF_REG_POWERPC_SIER3 + 1)
5371
#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */

arch/powerpc/kernel/cputable.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ extern void __setup_cpu_power9(unsigned long offset, struct cpu_spec* spec);
7272
extern void __restore_cpu_power9(void);
7373
extern void __setup_cpu_power10(unsigned long offset, struct cpu_spec* spec);
7474
extern void __restore_cpu_power10(void);
75-
extern long __machine_check_early_realmode_p7(struct pt_regs *regs);
76-
extern long __machine_check_early_realmode_p8(struct pt_regs *regs);
77-
extern long __machine_check_early_realmode_p9(struct pt_regs *regs);
7875
#endif /* CONFIG_PPC64 */
7976
#if defined(CONFIG_E500)
8077
extern void __setup_cpu_e5500(unsigned long offset, struct cpu_spec* spec);
@@ -542,6 +539,25 @@ static struct cpu_spec __initdata cpu_specs[] = {
542539
.machine_check_early = __machine_check_early_realmode_p9,
543540
.platform = "power9",
544541
},
542+
{ /* Power10 */
543+
.pvr_mask = 0xffff0000,
544+
.pvr_value = 0x00800000,
545+
.cpu_name = "POWER10 (raw)",
546+
.cpu_features = CPU_FTRS_POWER10,
547+
.cpu_user_features = COMMON_USER_POWER10,
548+
.cpu_user_features2 = COMMON_USER2_POWER10,
549+
.mmu_features = MMU_FTRS_POWER10,
550+
.icache_bsize = 128,
551+
.dcache_bsize = 128,
552+
.num_pmcs = 6,
553+
.pmc_type = PPC_PMC_IBM,
554+
.oprofile_cpu_type = "ppc64/power10",
555+
.oprofile_type = PPC_OPROFILE_INVALID,
556+
.cpu_setup = __setup_cpu_power10,
557+
.cpu_restore = __restore_cpu_power10,
558+
.machine_check_early = __machine_check_early_realmode_p10,
559+
.platform = "power10",
560+
},
545561
{ /* Cell Broadband Engine */
546562
.pvr_mask = 0xffff0000,
547563
.pvr_value = 0x00700000,

arch/powerpc/kernel/dt_cpu_ftrs.c

-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ struct dt_cpu_feature {
6464
* Set up the base CPU
6565
*/
6666

67-
extern long __machine_check_early_realmode_p8(struct pt_regs *regs);
68-
extern long __machine_check_early_realmode_p9(struct pt_regs *regs);
69-
extern long __machine_check_early_realmode_p10(struct pt_regs *regs);
70-
7167
static int hv_mode;
7268

7369
static struct {

arch/powerpc/kernel/setup-common.c

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
311311
min = pvr & 0xFF;
312312
break;
313313
case 0x004e: /* POWER9 bits 12-15 give chip type */
314+
case 0x0080: /* POWER10 bit 12 gives SMT8/4 */
314315
maj = (pvr >> 8) & 0x0F;
315316
min = pvr & 0xFF;
316317
break;

arch/powerpc/mm/book3s32/mmu.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,17 @@ static bool is_module_segment(unsigned long addr)
191191
{
192192
if (!IS_ENABLED(CONFIG_MODULES))
193193
return false;
194+
#ifdef MODULES_VADDR
195+
if (addr < ALIGN_DOWN(MODULES_VADDR, SZ_256M))
196+
return false;
197+
if (addr > ALIGN(MODULES_END, SZ_256M) - 1)
198+
return false;
199+
#else
194200
if (addr < ALIGN_DOWN(VMALLOC_START, SZ_256M))
195201
return false;
196-
if (addr >= ALIGN(VMALLOC_END, SZ_256M))
202+
if (addr > ALIGN(VMALLOC_END, SZ_256M) - 1)
197203
return false;
204+
#endif
198205
return true;
199206
}
200207

arch/powerpc/mm/book3s64/hash_utils.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,10 @@ void hash__early_init_mmu_secondary(void)
11151115
&& cpu_has_feature(CPU_FTR_HVMODE))
11161116
tlbiel_all();
11171117

1118-
if (IS_ENABLED(CONFIG_PPC_MEM_KEYS) && mmu_has_feature(MMU_FTR_PKEY))
1118+
#ifdef CONFIG_PPC_MEM_KEYS
1119+
if (mmu_has_feature(MMU_FTR_PKEY))
11191120
mtspr(SPRN_UAMOR, default_uamor);
1121+
#endif
11201122
}
11211123
#endif /* CONFIG_SMP */
11221124

arch/powerpc/perf/core-book3s.c

+5
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
21412141

21422142
if (perf_event_overflow(event, &data, regs))
21432143
power_pmu_stop(event, 0);
2144+
} else if (period) {
2145+
/* Account for interrupt in case of invalid SIAR */
2146+
if (perf_event_account_interrupt(event))
2147+
power_pmu_stop(event, 0);
21442148
}
21452149
}
21462150

@@ -2323,6 +2327,7 @@ int register_power_pmu(struct power_pmu *pmu)
23232327
pmu->name);
23242328

23252329
power_pmu.attr_groups = ppmu->attr_groups;
2330+
power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
23262331

23272332
#ifdef MSR_HV
23282333
/*

arch/powerpc/perf/hv-24x7.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -1128,14 +1128,22 @@ static struct bin_attribute *if_bin_attrs[] = {
11281128
NULL,
11291129
};
11301130

1131+
static struct attribute *cpumask_attrs[] = {
1132+
&dev_attr_cpumask.attr,
1133+
NULL,
1134+
};
1135+
1136+
static struct attribute_group cpumask_attr_group = {
1137+
.attrs = cpumask_attrs,
1138+
};
1139+
11311140
static struct attribute *if_attrs[] = {
11321141
&dev_attr_catalog_len.attr,
11331142
&dev_attr_catalog_version.attr,
11341143
&dev_attr_domains.attr,
11351144
&dev_attr_sockets.attr,
11361145
&dev_attr_chipspersocket.attr,
11371146
&dev_attr_coresperchip.attr,
1138-
&dev_attr_cpumask.attr,
11391147
NULL,
11401148
};
11411149

@@ -1151,6 +1159,7 @@ static const struct attribute_group *attr_groups[] = {
11511159
&event_desc_group,
11521160
&event_long_desc_group,
11531161
&if_group,
1162+
&cpumask_attr_group,
11541163
NULL,
11551164
};
11561165

arch/powerpc/perf/perf_regs.c

+41-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#include <asm/ptrace.h>
1414
#include <asm/perf_regs.h>
1515

16+
u64 PERF_REG_EXTENDED_MASK;
17+
1618
#define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)
1719

18-
#define REG_RESERVED (~((1ULL << PERF_REG_POWERPC_MAX) - 1))
20+
#define REG_RESERVED (~(PERF_REG_EXTENDED_MASK | PERF_REG_PMU_MASK))
1921

2022
static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
2123
PT_REGS_OFFSET(PERF_REG_POWERPC_R0, gpr[0]),
@@ -69,10 +71,36 @@ static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
6971
PT_REGS_OFFSET(PERF_REG_POWERPC_MMCRA, dsisr),
7072
};
7173

74+
/* Function to return the extended register values */
75+
static u64 get_ext_regs_value(int idx)
76+
{
77+
switch (idx) {
78+
case PERF_REG_POWERPC_MMCR0:
79+
return mfspr(SPRN_MMCR0);
80+
case PERF_REG_POWERPC_MMCR1:
81+
return mfspr(SPRN_MMCR1);
82+
case PERF_REG_POWERPC_MMCR2:
83+
return mfspr(SPRN_MMCR2);
84+
#ifdef CONFIG_PPC64
85+
case PERF_REG_POWERPC_MMCR3:
86+
return mfspr(SPRN_MMCR3);
87+
case PERF_REG_POWERPC_SIER2:
88+
return mfspr(SPRN_SIER2);
89+
case PERF_REG_POWERPC_SIER3:
90+
return mfspr(SPRN_SIER3);
91+
#endif
92+
default: return 0;
93+
}
94+
}
95+
7296
u64 perf_reg_value(struct pt_regs *regs, int idx)
7397
{
74-
if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
75-
return 0;
98+
u64 perf_reg_extended_max = PERF_REG_POWERPC_MAX;
99+
100+
if (cpu_has_feature(CPU_FTR_ARCH_31))
101+
perf_reg_extended_max = PERF_REG_MAX_ISA_31;
102+
else if (cpu_has_feature(CPU_FTR_ARCH_300))
103+
perf_reg_extended_max = PERF_REG_MAX_ISA_300;
76104

77105
if (idx == PERF_REG_POWERPC_SIER &&
78106
(IS_ENABLED(CONFIG_FSL_EMB_PERF_EVENT) ||
@@ -85,6 +113,16 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
85113
IS_ENABLED(CONFIG_PPC32)))
86114
return 0;
87115

116+
if (idx >= PERF_REG_POWERPC_MAX && idx < perf_reg_extended_max)
117+
return get_ext_regs_value(idx);
118+
119+
/*
120+
* If the idx is referring to value beyond the
121+
* supported registers, return 0 with a warning
122+
*/
123+
if (WARN_ON_ONCE(idx >= perf_reg_extended_max))
124+
return 0;
125+
88126
return regs_get_register(regs, pt_regs_offset[idx]);
89127
}
90128

arch/powerpc/perf/power10-pmu.c

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
#define POWER10_MMCRA_IFM3 0x00000000C0000000UL
8888
#define POWER10_MMCRA_BHRB_MASK 0x00000000C0000000UL
8989

90+
extern u64 PERF_REG_EXTENDED_MASK;
91+
9092
/* Table of alternatives, sorted by column 0 */
9193
static const unsigned int power10_event_alternatives[][MAX_ALT] = {
9294
{ PM_RUN_CYC_ALT, PM_RUN_CYC },
@@ -397,6 +399,7 @@ static struct power_pmu power10_pmu = {
397399
.cache_events = &power10_cache_events,
398400
.attr_groups = power10_pmu_attr_groups,
399401
.bhrb_nr = 32,
402+
.capabilities = PERF_PMU_CAP_EXTENDED_REGS,
400403
};
401404

402405
int init_power10_pmu(void)
@@ -408,6 +411,9 @@ int init_power10_pmu(void)
408411
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10"))
409412
return -ENODEV;
410413

414+
/* Set the PERF_REG_EXTENDED_MASK here */
415+
PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_31;
416+
411417
rc = register_power_pmu(&power10_pmu);
412418
if (rc)
413419
return rc;

arch/powerpc/perf/power9-pmu.c

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ enum {
9090
#define POWER9_MMCRA_IFM3 0x00000000C0000000UL
9191
#define POWER9_MMCRA_BHRB_MASK 0x00000000C0000000UL
9292

93+
extern u64 PERF_REG_EXTENDED_MASK;
94+
9395
/* Nasty Power9 specific hack */
9496
#define PVR_POWER9_CUMULUS 0x00002000
9597

@@ -434,6 +436,7 @@ static struct power_pmu power9_pmu = {
434436
.cache_events = &power9_cache_events,
435437
.attr_groups = power9_pmu_attr_groups,
436438
.bhrb_nr = 32,
439+
.capabilities = PERF_PMU_CAP_EXTENDED_REGS,
437440
};
438441

439442
int init_power9_pmu(void)
@@ -457,6 +460,9 @@ int init_power9_pmu(void)
457460
}
458461
}
459462

463+
/* Set the PERF_REG_EXTENDED_MASK here */
464+
PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_300;
465+
460466
rc = register_power_pmu(&power9_pmu);
461467
if (rc)
462468
return rc;

arch/powerpc/platforms/powernv/pci-ioda.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ void pnv_pci_ioda2_release_pe_dma(struct pnv_ioda_pe *pe)
27052705
struct iommu_table *tbl = pe->table_group.tables[0];
27062706
int64_t rc;
27072707

2708-
if (pe->dma_setup_done)
2708+
if (!pe->dma_setup_done)
27092709
return;
27102710

27112711
rc = pnv_pci_ioda2_unset_window(&pe->table_group, 0);

0 commit comments

Comments
 (0)