Skip to content

Commit

Permalink
Merge tag 'powerpc-5.19-3' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/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()
  • Loading branch information
torvalds committed Jun 26, 2022
2 parents 393ed5d + f3eac42 commit 8100775
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 40 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,7 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
tm_reclaim_current(0);
#endif

memset(regs->gpr, 0, sizeof(regs->gpr));
memset(&regs->gpr[1], 0, sizeof(regs->gpr) - sizeof(regs->gpr[0]));
regs->ctr = 0;
regs->link = 0;
regs->xer = 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/prom_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,7 @@ static void __init prom_init_stdout(void)

static int __init prom_find_machine_type(void)
{
char compat[256];
static char compat[256] __prombss;
int len, i = 0;
#ifdef CONFIG_PPC64
phandle rtas;
Expand Down
11 changes: 10 additions & 1 deletion arch/powerpc/kernel/rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ static struct rtas_filter rtas_filters[] __ro_after_init = {
{ "get-time-of-day", -1, -1, -1, -1, -1 },
{ "ibm,get-vpd", -1, 0, -1, 1, 2 },
{ "ibm,lpar-perftools", -1, 2, 3, -1, -1 },
{ "ibm,platform-dump", -1, 4, 5, -1, -1 },
{ "ibm,platform-dump", -1, 4, 5, -1, -1 }, /* Special cased */
{ "ibm,read-slot-reset-state", -1, -1, -1, -1, -1 },
{ "ibm,scan-log-dump", -1, 0, 1, -1, -1 },
{ "ibm,set-dynamic-indicator", -1, 2, -1, -1, -1 },
Expand Down Expand Up @@ -1120,6 +1120,15 @@ static bool block_rtas_call(int token, int nargs,
size = 1;

end = base + size - 1;

/*
* Special case for ibm,platform-dump - NULL buffer
* address is used to indicate end of dump processing
*/
if (!strcmp(f->name, "ibm,platform-dump") &&
base == 0)
return false;

if (!in_rmo_buf(base, end))
goto err;
}
Expand Down
13 changes: 7 additions & 6 deletions arch/powerpc/kernel/setup-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,12 +935,6 @@ void __init setup_arch(char **cmdline_p)
/* Print various info about the machine that has been gathered so far. */
print_system_info();

/* Reserve large chunks of memory for use by CMA for KVM. */
kvm_cma_reserve();

/* Reserve large chunks of memory for us by CMA for hugetlb */
gigantic_hugetlb_cma_reserve();

klp_init_thread_info(&init_task);

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

initmem_init();

/*
* Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must
* be called after initmem_init(), so that pageblock_order is initialised.
*/
kvm_cma_reserve();
gigantic_hugetlb_cma_reserve();

early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);

if (ppc_md.setup_arch)
Expand Down
7 changes: 7 additions & 0 deletions arch/powerpc/platforms/microwatt/microwatt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _MICROWATT_H
#define _MICROWATT_H

void microwatt_rng_init(void);

#endif /* _MICROWATT_H */
10 changes: 3 additions & 7 deletions arch/powerpc/platforms/microwatt/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <asm/archrandom.h>
#include <asm/cputable.h>
#include <asm/machdep.h>
#include "microwatt.h"

#define DARN_ERR 0xFFFFFFFFFFFFFFFFul

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

static __init int rng_init(void)
void __init microwatt_rng_init(void)
{
unsigned long val;
int i;

for (i = 0; i < 10; i++) {
if (microwatt_get_random_darn(&val)) {
ppc_md.get_random_seed = microwatt_get_random_darn;
return 0;
return;
}
}

pr_warn("Unable to use DARN for get_random_seed()\n");

return -EIO;
}
machine_subsys_initcall(, rng_init);
8 changes: 8 additions & 0 deletions arch/powerpc/platforms/microwatt/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <asm/xics.h>
#include <asm/udbg.h>

#include "microwatt.h"

static void __init microwatt_init_IRQ(void)
{
xics_init();
Expand All @@ -32,10 +34,16 @@ static int __init microwatt_populate(void)
}
machine_arch_initcall(microwatt, microwatt_populate);

static void __init microwatt_setup_arch(void)
{
microwatt_rng_init();
}

define_machine(microwatt) {
.name = "microwatt",
.probe = microwatt_probe,
.init_IRQ = microwatt_init_IRQ,
.setup_arch = microwatt_setup_arch,
.progress = udbg_progress,
.calibrate_decr = generic_calibrate_decr,
};
2 changes: 2 additions & 0 deletions arch/powerpc/platforms/powernv/powernv.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ ssize_t memcons_copy(struct memcons *mc, char *to, loff_t pos, size_t count);
u32 __init memcons_get_size(struct memcons *mc);
struct memcons *__init memcons_init(struct device_node *node, const char *mc_prop_name);

void pnv_rng_init(void);

#endif /* _POWERNV_H */
52 changes: 36 additions & 16 deletions arch/powerpc/platforms/powernv/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/smp.h>
#include "powernv.h"

#define DARN_ERR 0xFFFFFFFFFFFFFFFFul

Expand All @@ -28,7 +29,6 @@ struct powernv_rng {

static DEFINE_PER_CPU(struct powernv_rng *, powernv_rng);


int powernv_hwrng_present(void)
{
struct powernv_rng *rng;
Expand Down Expand Up @@ -98,9 +98,6 @@ static int __init initialise_darn(void)
return 0;
}
}

pr_warn("Unable to use DARN for get_random_seed()\n");

return -EIO;
}

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

rng_init_per_cpu(rng, dn);

pr_info_once("Registering arch random hook.\n");

ppc_md.get_random_seed = powernv_get_random_long;

return 0;
}

static __init int rng_init(void)
static int __init pnv_get_random_long_early(unsigned long *v)
{
struct device_node *dn;
int rc;

if (!slab_is_available())
return 0;

if (cmpxchg(&ppc_md.get_random_seed, pnv_get_random_long_early,
NULL) != pnv_get_random_long_early)
return 0;

for_each_compatible_node(dn, NULL, "ibm,power-rng") {
rc = rng_create(dn);
if (rc) {
pr_err("Failed creating rng for %pOF (%d).\n",
dn, rc);
if (rng_create(dn))
continue;
}

/* Create devices for hwrng driver */
of_platform_device_create(dn, NULL, NULL);
}

initialise_darn();
if (!ppc_md.get_random_seed)
return 0;
return ppc_md.get_random_seed(v);
}

void __init pnv_rng_init(void)
{
struct device_node *dn;

/* Prefer darn over the rest. */
if (!initialise_darn())
return;

dn = of_find_compatible_node(NULL, NULL, "ibm,power-rng");
if (dn)
ppc_md.get_random_seed = pnv_get_random_long_early;

of_node_put(dn);
}

static int __init pnv_rng_late_init(void)
{
unsigned long v;
/* In case it wasn't called during init for some other reason. */
if (ppc_md.get_random_seed == pnv_get_random_long_early)
pnv_get_random_long_early(&v);
return 0;
}
machine_subsys_initcall(powernv, rng_init);
machine_subsys_initcall(powernv, pnv_rng_late_init);
2 changes: 2 additions & 0 deletions arch/powerpc/platforms/powernv/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ static void __init pnv_setup_arch(void)
pnv_check_guarded_cores();

/* XXX PMCS */

pnv_rng_init();
}

static void __init pnv_init(void)
Expand Down
2 changes: 2 additions & 0 deletions arch/powerpc/platforms/pseries/pseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@ void pseries_lpar_read_hblkrm_characteristics(void);
static inline void pseries_lpar_read_hblkrm_characteristics(void) { }
#endif

void pseries_rng_init(void);

#endif /* _PSERIES_PSERIES_H */
11 changes: 3 additions & 8 deletions arch/powerpc/platforms/pseries/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <asm/archrandom.h>
#include <asm/machdep.h>
#include <asm/plpar_wrappers.h>
#include "pseries.h"


static int pseries_get_random_long(unsigned long *v)
Expand All @@ -24,19 +25,13 @@ static int pseries_get_random_long(unsigned long *v)
return 0;
}

static __init int rng_init(void)
void __init pseries_rng_init(void)
{
struct device_node *dn;

dn = of_find_compatible_node(NULL, NULL, "ibm,random");
if (!dn)
return -ENODEV;

pr_info("Registering arch random hook.\n");

return;
ppc_md.get_random_seed = pseries_get_random_long;

of_node_put(dn);
return 0;
}
machine_subsys_initcall(pseries, rng_init);
1 change: 1 addition & 0 deletions arch/powerpc/platforms/pseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ static void __init pSeries_setup_arch(void)
}

ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
pseries_rng_init();
}

static void pseries_panic(char *str)
Expand Down

0 comments on commit 8100775

Please sign in to comment.