Skip to content

Commit 460b48a

Browse files
committed
Merge tag 'powerpc-5.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "A minor fix to our IMC PMU code to print a less confusing error message when the driver can't initialise properly. A fix for a bug where a user requesting an unsupported branch sampling filter can corrupt PMU state, preventing the PMU from counting properly. And finally a fix for a bug in our support for kexec_file_load(), which prevented loading a kernel and initramfs. Most versions of kexec don't yet use kexec_file_load(). Thanks to: Anju T Sudhakar, Dave Young, Madhavan Srinivasan, Ravi Bangoria, Thiago Jung Bauermann" * tag 'powerpc-5.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/kexec: Fix loading of kernel + initramfs with kexec_file_load() powerpc/perf: Fix MMCRA corruption by bhrb_filter powerpc/powernv: Return for invalid IMC domain
2 parents b44a1dd + 8b909e3 commit 460b48a

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

arch/powerpc/kernel/kexec_elf_64.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ static int elf_exec_load(struct kimage *image, struct elfhdr *ehdr,
547547
kbuf.memsz = phdr->p_memsz;
548548
kbuf.buf_align = phdr->p_align;
549549
kbuf.buf_min = phdr->p_paddr + base;
550+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
550551
ret = kexec_add_buffer(&kbuf);
551552
if (ret)
552553
goto out;
@@ -581,7 +582,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
581582
struct kexec_buf kbuf = { .image = image, .buf_min = 0,
582583
.buf_max = ppc64_rma_size };
583584
struct kexec_buf pbuf = { .image = image, .buf_min = 0,
584-
.buf_max = ppc64_rma_size, .top_down = true };
585+
.buf_max = ppc64_rma_size, .top_down = true,
586+
.mem = KEXEC_BUF_MEM_UNKNOWN };
585587

586588
ret = build_elf_exec_info(kernel_buf, kernel_len, &ehdr, &elf_info);
587589
if (ret)
@@ -606,6 +608,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
606608
kbuf.bufsz = kbuf.memsz = initrd_len;
607609
kbuf.buf_align = PAGE_SIZE;
608610
kbuf.top_down = false;
611+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
609612
ret = kexec_add_buffer(&kbuf);
610613
if (ret)
611614
goto out;
@@ -638,6 +641,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
638641
kbuf.bufsz = kbuf.memsz = fdt_size;
639642
kbuf.buf_align = PAGE_SIZE;
640643
kbuf.top_down = true;
644+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
641645
ret = kexec_add_buffer(&kbuf);
642646
if (ret)
643647
goto out;

arch/powerpc/perf/core-book3s.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,7 @@ static int power_pmu_event_init(struct perf_event *event)
18461846
int n;
18471847
int err;
18481848
struct cpu_hw_events *cpuhw;
1849+
u64 bhrb_filter;
18491850

18501851
if (!ppmu)
18511852
return -ENOENT;
@@ -1951,13 +1952,14 @@ static int power_pmu_event_init(struct perf_event *event)
19511952
err = power_check_constraints(cpuhw, events, cflags, n + 1);
19521953

19531954
if (has_branch_stack(event)) {
1954-
cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
1955+
bhrb_filter = ppmu->bhrb_filter_map(
19551956
event->attr.branch_sample_type);
19561957

1957-
if (cpuhw->bhrb_filter == -1) {
1958+
if (bhrb_filter == -1) {
19581959
put_cpu_var(cpu_hw_events);
19591960
return -EOPNOTSUPP;
19601961
}
1962+
cpuhw->bhrb_filter = bhrb_filter;
19611963
}
19621964

19631965
put_cpu_var(cpu_hw_events);

arch/powerpc/perf/power8-pmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enum {
2525
#define POWER8_MMCRA_IFM1 0x0000000040000000UL
2626
#define POWER8_MMCRA_IFM2 0x0000000080000000UL
2727
#define POWER8_MMCRA_IFM3 0x00000000C0000000UL
28+
#define POWER8_MMCRA_BHRB_MASK 0x00000000C0000000UL
2829

2930
/*
3031
* Raw event encoding for PowerISA v2.07 (Power8):
@@ -239,6 +240,8 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type)
239240

240241
static void power8_config_bhrb(u64 pmu_bhrb_filter)
241242
{
243+
pmu_bhrb_filter &= POWER8_MMCRA_BHRB_MASK;
244+
242245
/* Enable BHRB filter in PMU */
243246
mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter));
244247
}

arch/powerpc/perf/power9-pmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum {
8888
#define POWER9_MMCRA_IFM1 0x0000000040000000UL
8989
#define POWER9_MMCRA_IFM2 0x0000000080000000UL
9090
#define POWER9_MMCRA_IFM3 0x00000000C0000000UL
91+
#define POWER9_MMCRA_BHRB_MASK 0x00000000C0000000UL
9192

9293
/* Nasty Power9 specific hack */
9394
#define PVR_POWER9_CUMULUS 0x00002000
@@ -296,6 +297,8 @@ static u64 power9_bhrb_filter_map(u64 branch_sample_type)
296297

297298
static void power9_config_bhrb(u64 pmu_bhrb_filter)
298299
{
300+
pmu_bhrb_filter &= POWER9_MMCRA_BHRB_MASK;
301+
299302
/* Enable BHRB filter in PMU */
300303
mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter));
301304
}

arch/powerpc/platforms/powernv/opal-imc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index, int domain)
157157
struct imc_pmu *pmu_ptr;
158158
u32 offset;
159159

160+
/* Return for unknown domain */
161+
if (domain < 0)
162+
return -EINVAL;
163+
160164
/* memory for pmu */
161165
pmu_ptr = kzalloc(sizeof(*pmu_ptr), GFP_KERNEL);
162166
if (!pmu_ptr)

0 commit comments

Comments
 (0)