Skip to content

Commit 8100775

Browse files
committed
Merge tag 'powerpc-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - A fix for a CMA change that broke booting guests with > 2G RAM on Power8 hosts. - Fix the RTAS call filter to allow a special case that applications rely on. - A change to our execve path, to make the execve syscall exit tracepoint work. - Three fixes to wire up our various RNGs earlier in boot so they're available for use in the initial seeding in random_init(). - A build fix for when KASAN is enabled along with STRUCTLEAK_BYREF_ALL. Thanks to Andrew Donnellan, Aneesh Kumar K.V, Christophe Leroy, Jason Donenfeld, Nathan Lynch, Naveen N. Rao, Sathvika Vasireddy, Sumit Dubey2, Tyrel Datwyler, and Zi Yan. * tag 'powerpc-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/powernv: wire up rng during setup_arch powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN powerpc/rtas: Allow ibm,platform-dump RTAS call with null buffer address powerpc: Enable execve syscall exit tracepoint powerpc/pseries: wire up rng during setup_arch() powerpc/microwatt: wire up rng during setup_arch() powerpc/mm: Move CMA reservations after initmem_init()
2 parents 393ed5d + f3eac42 commit 8100775

File tree

13 files changed

+83
-40
lines changed

13 files changed

+83
-40
lines changed

arch/powerpc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
18551855
tm_reclaim_current(0);
18561856
#endif
18571857

1858-
memset(regs->gpr, 0, sizeof(regs->gpr));
1858+
memset(&regs->gpr[1], 0, sizeof(regs->gpr) - sizeof(regs->gpr[0]));
18591859
regs->ctr = 0;
18601860
regs->link = 0;
18611861
regs->xer = 0;

arch/powerpc/kernel/prom_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2302,7 +2302,7 @@ static void __init prom_init_stdout(void)
23022302

23032303
static int __init prom_find_machine_type(void)
23042304
{
2305-
char compat[256];
2305+
static char compat[256] __prombss;
23062306
int len, i = 0;
23072307
#ifdef CONFIG_PPC64
23082308
phandle rtas;

arch/powerpc/kernel/rtas.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ static struct rtas_filter rtas_filters[] __ro_after_init = {
10711071
{ "get-time-of-day", -1, -1, -1, -1, -1 },
10721072
{ "ibm,get-vpd", -1, 0, -1, 1, 2 },
10731073
{ "ibm,lpar-perftools", -1, 2, 3, -1, -1 },
1074-
{ "ibm,platform-dump", -1, 4, 5, -1, -1 },
1074+
{ "ibm,platform-dump", -1, 4, 5, -1, -1 }, /* Special cased */
10751075
{ "ibm,read-slot-reset-state", -1, -1, -1, -1, -1 },
10761076
{ "ibm,scan-log-dump", -1, 0, 1, -1, -1 },
10771077
{ "ibm,set-dynamic-indicator", -1, 2, -1, -1, -1 },
@@ -1120,6 +1120,15 @@ static bool block_rtas_call(int token, int nargs,
11201120
size = 1;
11211121

11221122
end = base + size - 1;
1123+
1124+
/*
1125+
* Special case for ibm,platform-dump - NULL buffer
1126+
* address is used to indicate end of dump processing
1127+
*/
1128+
if (!strcmp(f->name, "ibm,platform-dump") &&
1129+
base == 0)
1130+
return false;
1131+
11231132
if (!in_rmo_buf(base, end))
11241133
goto err;
11251134
}

arch/powerpc/kernel/setup-common.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,6 @@ void __init setup_arch(char **cmdline_p)
935935
/* Print various info about the machine that has been gathered so far. */
936936
print_system_info();
937937

938-
/* Reserve large chunks of memory for use by CMA for KVM. */
939-
kvm_cma_reserve();
940-
941-
/* Reserve large chunks of memory for us by CMA for hugetlb */
942-
gigantic_hugetlb_cma_reserve();
943-
944938
klp_init_thread_info(&init_task);
945939

946940
setup_initial_init_mm(_stext, _etext, _edata, _end);
@@ -955,6 +949,13 @@ void __init setup_arch(char **cmdline_p)
955949

956950
initmem_init();
957951

952+
/*
953+
* Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must
954+
* be called after initmem_init(), so that pageblock_order is initialised.
955+
*/
956+
kvm_cma_reserve();
957+
gigantic_hugetlb_cma_reserve();
958+
958959
early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
959960

960961
if (ppc_md.setup_arch)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _MICROWATT_H
3+
#define _MICROWATT_H
4+
5+
void microwatt_rng_init(void);
6+
7+
#endif /* _MICROWATT_H */

arch/powerpc/platforms/microwatt/rng.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/archrandom.h>
1212
#include <asm/cputable.h>
1313
#include <asm/machdep.h>
14+
#include "microwatt.h"
1415

1516
#define DARN_ERR 0xFFFFFFFFFFFFFFFFul
1617

@@ -29,20 +30,15 @@ static int microwatt_get_random_darn(unsigned long *v)
2930
return 1;
3031
}
3132

32-
static __init int rng_init(void)
33+
void __init microwatt_rng_init(void)
3334
{
3435
unsigned long val;
3536
int i;
3637

3738
for (i = 0; i < 10; i++) {
3839
if (microwatt_get_random_darn(&val)) {
3940
ppc_md.get_random_seed = microwatt_get_random_darn;
40-
return 0;
41+
return;
4142
}
4243
}
43-
44-
pr_warn("Unable to use DARN for get_random_seed()\n");
45-
46-
return -EIO;
4744
}
48-
machine_subsys_initcall(, rng_init);

arch/powerpc/platforms/microwatt/setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <asm/xics.h>
1717
#include <asm/udbg.h>
1818

19+
#include "microwatt.h"
20+
1921
static void __init microwatt_init_IRQ(void)
2022
{
2123
xics_init();
@@ -32,10 +34,16 @@ static int __init microwatt_populate(void)
3234
}
3335
machine_arch_initcall(microwatt, microwatt_populate);
3436

37+
static void __init microwatt_setup_arch(void)
38+
{
39+
microwatt_rng_init();
40+
}
41+
3542
define_machine(microwatt) {
3643
.name = "microwatt",
3744
.probe = microwatt_probe,
3845
.init_IRQ = microwatt_init_IRQ,
46+
.setup_arch = microwatt_setup_arch,
3947
.progress = udbg_progress,
4048
.calibrate_decr = generic_calibrate_decr,
4149
};

arch/powerpc/platforms/powernv/powernv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ ssize_t memcons_copy(struct memcons *mc, char *to, loff_t pos, size_t count);
4242
u32 __init memcons_get_size(struct memcons *mc);
4343
struct memcons *__init memcons_init(struct device_node *node, const char *mc_prop_name);
4444

45+
void pnv_rng_init(void);
46+
4547
#endif /* _POWERNV_H */

arch/powerpc/platforms/powernv/rng.c

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <asm/prom.h>
1818
#include <asm/machdep.h>
1919
#include <asm/smp.h>
20+
#include "powernv.h"
2021

2122
#define DARN_ERR 0xFFFFFFFFFFFFFFFFul
2223

@@ -28,7 +29,6 @@ struct powernv_rng {
2829

2930
static DEFINE_PER_CPU(struct powernv_rng *, powernv_rng);
3031

31-
3232
int powernv_hwrng_present(void)
3333
{
3434
struct powernv_rng *rng;
@@ -98,9 +98,6 @@ static int __init initialise_darn(void)
9898
return 0;
9999
}
100100
}
101-
102-
pr_warn("Unable to use DARN for get_random_seed()\n");
103-
104101
return -EIO;
105102
}
106103

@@ -163,32 +160,55 @@ static __init int rng_create(struct device_node *dn)
163160

164161
rng_init_per_cpu(rng, dn);
165162

166-
pr_info_once("Registering arch random hook.\n");
167-
168163
ppc_md.get_random_seed = powernv_get_random_long;
169164

170165
return 0;
171166
}
172167

173-
static __init int rng_init(void)
168+
static int __init pnv_get_random_long_early(unsigned long *v)
174169
{
175170
struct device_node *dn;
176-
int rc;
171+
172+
if (!slab_is_available())
173+
return 0;
174+
175+
if (cmpxchg(&ppc_md.get_random_seed, pnv_get_random_long_early,
176+
NULL) != pnv_get_random_long_early)
177+
return 0;
177178

178179
for_each_compatible_node(dn, NULL, "ibm,power-rng") {
179-
rc = rng_create(dn);
180-
if (rc) {
181-
pr_err("Failed creating rng for %pOF (%d).\n",
182-
dn, rc);
180+
if (rng_create(dn))
183181
continue;
184-
}
185-
186182
/* Create devices for hwrng driver */
187183
of_platform_device_create(dn, NULL, NULL);
188184
}
189185

190-
initialise_darn();
186+
if (!ppc_md.get_random_seed)
187+
return 0;
188+
return ppc_md.get_random_seed(v);
189+
}
190+
191+
void __init pnv_rng_init(void)
192+
{
193+
struct device_node *dn;
191194

195+
/* Prefer darn over the rest. */
196+
if (!initialise_darn())
197+
return;
198+
199+
dn = of_find_compatible_node(NULL, NULL, "ibm,power-rng");
200+
if (dn)
201+
ppc_md.get_random_seed = pnv_get_random_long_early;
202+
203+
of_node_put(dn);
204+
}
205+
206+
static int __init pnv_rng_late_init(void)
207+
{
208+
unsigned long v;
209+
/* In case it wasn't called during init for some other reason. */
210+
if (ppc_md.get_random_seed == pnv_get_random_long_early)
211+
pnv_get_random_long_early(&v);
192212
return 0;
193213
}
194-
machine_subsys_initcall(powernv, rng_init);
214+
machine_subsys_initcall(powernv, pnv_rng_late_init);

arch/powerpc/platforms/powernv/setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ static void __init pnv_setup_arch(void)
203203
pnv_check_guarded_cores();
204204

205205
/* XXX PMCS */
206+
207+
pnv_rng_init();
206208
}
207209

208210
static void __init pnv_init(void)

0 commit comments

Comments
 (0)