* [PATCH v3 10/17] openrisc: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/openrisc/Kconfig | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 591acc5990dc..ca1d0f18fe16 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,6 +25,7 @@ config OPENRISC
select HAVE_UID16
select GENERIC_ATOMIC64
select GENERIC_CLOCKEVENTS_BROADCAST
+ select GENERIC_CMDLINE
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
select GENERIC_SMP_IDLE_THREAD
@@ -162,15 +163,6 @@ config OPENRISC_HAVE_SHADOW_GPRS
On SMP systems, this feature is mandatory.
On a unicore system it's safe to say N here if you are unsure.
-config CMDLINE
- string "Default kernel command string"
- default ""
- help
- On some architectures there is currently no way for the boot loader
- to pass arguments to the kernel. For these architectures, you should
- supply some command-line options at build time by entering them
- here.
-
menu "Debugging options"
config JUMP_UPON_UNHANDLED_EXCEPTION
--
2.25.0
^ permalink raw reply related
* [PATCH v3 09/17] nios2: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/nios2/Kconfig | 24 +-----------------------
arch/nios2/kernel/setup.c | 13 ++++---------
2 files changed, 5 insertions(+), 32 deletions(-)
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..f66c97b15813 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -90,31 +90,9 @@ config NIOS2_ALIGNMENT_TRAP
comment "Boot options"
-config CMDLINE_BOOL
- bool "Default bootloader kernel arguments"
- default y
-
-config CMDLINE
- string "Default kernel command string"
- default ""
- depends on CMDLINE_BOOL
- help
- On some platforms, there is currently no way for the boot loader to
- pass arguments to the kernel. For these platforms, you can supply
- some command-line options at build time by entering them here. In
- other cases you can specify kernel args so that you don't have
- to set them up in board prom initialization routines.
-
-config CMDLINE_FORCE
- bool "Force default kernel command string"
- depends on CMDLINE_BOOL
- help
- Set this to have arguments from the default kernel command string
- override those passed by the boot loader.
-
config NIOS2_CMDLINE_IGNORE_DTB
bool "Ignore kernel command string from DTB"
- depends on CMDLINE_BOOL
+ depends on CMDLINE != ""
depends on !CMDLINE_FORCE
default y
help
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
index d2f21957e99c..42464f457a6d 100644
--- a/arch/nios2/kernel/setup.c
+++ b/arch/nios2/kernel/setup.c
@@ -20,6 +20,7 @@
#include <linux/initrd.h>
#include <linux/of_fdt.h>
#include <linux/screen_info.h>
+#include <linux/cmdline.h>
#include <asm/mmu_context.h>
#include <asm/sections.h>
@@ -108,7 +109,7 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
unsigned r7)
{
unsigned dtb_passed = 0;
- char cmdline_passed[COMMAND_LINE_SIZE] __maybe_unused = { 0, };
+ char cmdline_passed[COMMAND_LINE_SIZE] = { 0, };
#if defined(CONFIG_NIOS2_PASS_CMDLINE)
if (r4 == 0x534f494e) { /* r4 is magic NIOS */
@@ -127,14 +128,8 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
early_init_devtree((void *)dtb_passed);
-#ifndef CONFIG_CMDLINE_FORCE
- if (cmdline_passed[0])
- strlcpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
-#ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
- else
- strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif
+ if (cmdline_passed[0] || IS_ENABLED(CONFIG_NIOS2_CMDLINE_IGNORE_DTB))
+ cmdline_build(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
parse_early_param();
}
--
2.25.0
^ permalink raw reply related
* [PATCH v3 08/17] microblaze: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/microblaze/Kconfig | 24 +-----------------------
arch/microblaze/configs/mmu_defconfig | 2 +-
arch/microblaze/kernel/head.S | 4 ++--
3 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 0660f47012bc..1242f34bc2a2 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -15,6 +15,7 @@ config MICROBLAZE
select COMMON_CLK
select DMA_DIRECT_REMAP
select GENERIC_ATOMIC64
+ select GENERIC_CMDLINE
select GENERIC_CPU_DEVICES
select GENERIC_IDLE_POLL_SETUP
select GENERIC_IRQ_PROBE
@@ -93,29 +94,6 @@ source "kernel/Kconfig.hz"
config MMU
def_bool y
-comment "Boot options"
-
-config CMDLINE_BOOL
- bool "Default bootloader kernel arguments"
-
-config CMDLINE
- string "Default kernel command string"
- depends on CMDLINE_BOOL
- default "console=ttyUL0,115200"
- help
- On some architectures there is currently no way for the boot loader
- to pass arguments to the kernel. For these architectures, you should
- supply some command-line options at build time by entering them
- here.
-
-config CMDLINE_FORCE
- bool "Force default kernel command string"
- depends on CMDLINE_BOOL
- default n
- help
- Set this to have arguments from the default kernel command string
- override those passed by the boot loader.
-
endmenu
menu "Kernel features"
diff --git a/arch/microblaze/configs/mmu_defconfig b/arch/microblaze/configs/mmu_defconfig
index 51337fffb947..b4d2219d0a8f 100644
--- a/arch/microblaze/configs/mmu_defconfig
+++ b/arch/microblaze/configs/mmu_defconfig
@@ -16,7 +16,7 @@ CONFIG_XILINX_MICROBLAZE0_USE_DIV=1
CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=2
CONFIG_XILINX_MICROBLAZE0_USE_FPU=2
CONFIG_HZ_100=y
-CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttyUL0,115200"
CONFIG_CMDLINE_FORCE=y
CONFIG_HIGHMEM=y
CONFIG_PCI_XILINX=y
diff --git a/arch/microblaze/kernel/head.S b/arch/microblaze/kernel/head.S
index ec2fcb545e64..605b18c86ac8 100644
--- a/arch/microblaze/kernel/head.S
+++ b/arch/microblaze/kernel/head.S
@@ -105,7 +105,7 @@ _copy_fdt:
addik r3, r3, -4 /* descrement loop */
no_fdt_arg:
-#ifndef CONFIG_CMDLINE_BOOL
+#if CONFIG_CMDLINE == ""
/*
* handling command line
* copy command line directly to cmd_line placed in data section.
@@ -126,7 +126,7 @@ _copy_command_line:
addik r5, r4, 0 /* add new space for command line */
tovirt(r5,r5)
skip:
-#endif /* CONFIG_CMDLINE_BOOL */
+#endif /* CONFIG_CMDLINE */
#ifdef NOT_COMPILE
/* save bram context */
--
2.25.0
^ permalink raw reply related
* [PATCH v3 07/17] hexagon: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/hexagon/Kconfig | 11 +----------
arch/hexagon/kernel/setup.c | 10 ++--------
2 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 44a409967af1..1e69c99bae6b 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -18,6 +18,7 @@ config HEXAGON
select HAVE_PERF_EVENTS
# GENERIC_ALLOCATOR is used by dma_alloc_coherent()
select GENERIC_ALLOCATOR
+ select GENERIC_CMDLINE
select GENERIC_IRQ_SHOW
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
@@ -91,16 +92,6 @@ config HEXAGON_ARCH_VERSION
int "Architecture version"
default 2
-config CMDLINE
- string "Default kernel command string"
- default ""
- help
- On some platforms, there is currently no way for the boot loader
- to pass arguments to the kernel. For these, you should supply some
- command-line options at build time by entering them here. At a
- minimum, you should specify the memory size and the root device
- (e.g., mem=64M root=/dev/nfs).
-
config SMP
bool "Multi-Processing support"
help
diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c
index 1880d9beaf2b..be586cea4076 100644
--- a/arch/hexagon/kernel/setup.c
+++ b/arch/hexagon/kernel/setup.c
@@ -13,6 +13,7 @@
#include <linux/seq_file.h>
#include <linux/console.h>
#include <linux/of_fdt.h>
+#include <linux/cmdline.h>
#include <asm/io.h>
#include <asm/sections.h>
#include <asm/setup.h>
@@ -22,7 +23,6 @@
#include <asm/time.h>
char cmd_line[COMMAND_LINE_SIZE];
-static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
int on_simulator;
@@ -38,8 +38,6 @@ void calibrate_delay(void)
void __init setup_arch(char **cmdline_p)
{
- char *p = &external_cmdline_buffer;
-
/*
* These will eventually be pulled in via either some hypervisor
* or devicetree description. Hardwiring for now.
@@ -65,11 +63,7 @@ void __init setup_arch(char **cmdline_p)
else
on_simulator = 0;
- if (p[0] != '\0')
- strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
- else
- strlcpy(boot_command_line, default_command_line,
- COMMAND_LINE_SIZE);
+ cmdline_build(boot_command_line, external_cmdline_buffer, COMMAND_LINE_SIZE);
/*
* boot_command_line and the value set up by setup_arch
--
2.25.0
^ permalink raw reply related
* [PATCH v3 06/17] arm64: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/arm64/Kconfig | 33 +-----------------------------
arch/arm64/kernel/idreg-override.c | 9 ++++----
2 files changed, 5 insertions(+), 37 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 5656e7aacd69..eeff7730ccf0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -105,6 +105,7 @@ config ARM64
select GENERIC_ALLOCATOR
select GENERIC_ARCH_TOPOLOGY
select GENERIC_CLOCKEVENTS_BROADCAST
+ select GENERIC_CMDLINE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
@@ -1831,38 +1832,6 @@ config ARM64_ACPI_PARKING_PROTOCOL
protocol even if the corresponding data is present in the ACPI
MADT table.
-config CMDLINE
- string "Default kernel command string"
- default ""
- help
- Provide a set of default command-line options at build time by
- entering them here. As a minimum, you should specify the the
- root device (e.g. root=/dev/nfs).
-
-choice
- prompt "Kernel command line type" if CMDLINE != ""
- default CMDLINE_FROM_BOOTLOADER
- help
- Choose how the kernel will handle the provided default kernel
- command line string.
-
-config CMDLINE_FROM_BOOTLOADER
- bool "Use bootloader kernel arguments if available"
- help
- Uses the command-line options passed by the boot loader. If
- the boot loader doesn't provide any, the default kernel command
- string provided in CMDLINE will be used.
-
-config CMDLINE_FORCE
- bool "Always use the default kernel command string"
- help
- Always use the default kernel command string, even if the boot
- loader passes other arguments to the kernel.
- This is useful if you cannot or don't want to change the
- command-line options your boot loader passes to the kernel.
-
-endchoice
-
config EFI_STUB
bool
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
index 83f1c4b92095..8bc955cdcf82 100644
--- a/arch/arm64/kernel/idreg-override.c
+++ b/arch/arm64/kernel/idreg-override.c
@@ -9,6 +9,7 @@
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/libfdt.h>
+#include <linux/cmdline.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
@@ -187,12 +188,10 @@ static __init const u8 *get_bootargs_cmdline(void)
static __init void parse_cmdline(void)
{
const u8 *prop = get_bootargs_cmdline();
+ static char __initdata cmdline[COMMAND_LINE_SIZE];
- if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
- __parse_cmdline(CONFIG_CMDLINE, true);
-
- if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && prop)
- __parse_cmdline(prop, true);
+ cmdline_build(cmdline, prop, COMMAND_LINE_SIZE);
+ __parse_cmdline(cmdline, true);
}
/* Keep checkers quiet */
--
2.25.0
^ permalink raw reply related
* [PATCH v3 05/17] arm: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This converts the architecture to GENERIC_CMDLINE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/arm/Kconfig | 38 +----------------------------------
arch/arm/kernel/atags_parse.c | 15 +++++---------
2 files changed, 6 insertions(+), 47 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5da96f5df48f..67bc75f2da81 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -50,6 +50,7 @@ config ARM
select GENERIC_ARCH_TOPOLOGY if ARM_CPU_TOPOLOGY
select GENERIC_ATOMIC64 if CPU_V7M || CPU_V6 || !CPU_32v6K || !AEABI
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+ select GENERIC_CMDLINE if ATAGS
select GENERIC_IRQ_IPI if SMP
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
@@ -1740,43 +1741,6 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
endchoice
-config CMDLINE
- string "Default kernel command string"
- default ""
- help
- On some architectures (e.g. CATS), there is currently no way
- for the boot loader to pass arguments to the kernel. For these
- architectures, you should supply some command-line options at build
- time by entering them here. As a minimum, you should specify the
- memory size and the root device (e.g., mem=64M root=/dev/nfs).
-
-choice
- prompt "Kernel command line type" if CMDLINE != ""
- default CMDLINE_FROM_BOOTLOADER
- depends on ATAGS
-
-config CMDLINE_FROM_BOOTLOADER
- bool "Use bootloader kernel arguments if available"
- help
- Uses the command-line options passed by the boot loader. If
- the boot loader doesn't provide any, the default kernel command
- string provided in CMDLINE will be used.
-
-config CMDLINE_EXTEND
- bool "Extend bootloader kernel arguments"
- help
- The command-line arguments provided by the boot loader will be
- appended to the default kernel command string.
-
-config CMDLINE_FORCE
- bool "Always use the default kernel command string"
- help
- Always use the default kernel command string, even if the boot
- loader passes other arguments to the kernel.
- This is useful if you cannot or don't want to change the
- command-line options your boot loader passes to the kernel.
-endchoice
-
config XIP_KERNEL
bool "Kernel Execute-In-Place from ROM"
depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c
index 373b61f9a4f0..3d5bd52ee458 100644
--- a/arch/arm/kernel/atags_parse.c
+++ b/arch/arm/kernel/atags_parse.c
@@ -14,6 +14,7 @@
* is not parsed in any way).
*/
+#include <linux/cmdline.h>
#include <linux/init.h>
#include <linux/initrd.h>
#include <linux/kernel.h>
@@ -120,16 +121,10 @@ __tagtable(ATAG_REVISION, parse_tag_revision);
static int __init parse_tag_cmdline(const struct tag *tag)
{
-#if defined(CONFIG_CMDLINE_EXTEND)
- strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
- strlcat(default_command_line, tag->u.cmdline.cmdline,
- COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
- pr_warn("Ignoring tag cmdline (using the default kernel command line)\n");
-#else
- strlcpy(default_command_line, tag->u.cmdline.cmdline,
- COMMAND_LINE_SIZE);
-#endif
+ cmdline_build(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
+
+ if IS_ENABLED(CONFIG_CMDLINE_FORCE)
+ pr_warn("Ignoring tag cmdline (using the default kernel command line)\n");
return 0;
}
--
2.25.0
^ permalink raw reply related
* [PATCH v3 04/17] powerpc: Convert to GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This updates the powerpc code to use the new cmdline building function.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/Kconfig | 37 +--------------------------------
arch/powerpc/kernel/prom_init.c | 17 +++++++--------
2 files changed, 8 insertions(+), 46 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 386ae12d8523..5181efd7757e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -167,6 +167,7 @@ config PPC
select EDAC_SUPPORT
select GENERIC_ATOMIC64 if PPC32
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+ select GENERIC_CMDLINE
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC
@@ -886,42 +887,6 @@ config PPC_DENORMALISATION
Add support for handling denormalisation of single precision
values. Useful for bare metal only. If unsure say Y here.
-config CMDLINE
- string "Initial kernel command string"
- default ""
- help
- On some platforms, there is currently no way for the boot loader to
- pass arguments to the kernel. For these platforms, you can supply
- some command-line options at build time by entering them here. In
- most cases you will need to specify the root device here.
-
-choice
- prompt "Kernel command line type" if CMDLINE != ""
- default CMDLINE_FROM_BOOTLOADER
-
-config CMDLINE_FROM_BOOTLOADER
- bool "Use bootloader kernel arguments if available"
- help
- Uses the command-line options passed by the boot loader. If
- the boot loader doesn't provide any, the default kernel command
- string provided in CMDLINE will be used.
-
-config CMDLINE_EXTEND
- bool "Extend bootloader kernel arguments"
- help
- The command-line arguments provided by the boot loader will be
- appended to the default kernel command string.
-
-config CMDLINE_FORCE
- bool "Always use the default kernel command string"
- help
- Always use the default kernel command string, even if the boot
- loader passes other arguments to the kernel.
- This is useful if you cannot or don't want to change the
- command-line options your boot loader passes to the kernel.
-
-endchoice
-
config EXTRA_TARGETS
string "Additional default image types"
help
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index ccf77b985c8f..157d508e9fe9 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -152,7 +152,7 @@ static struct prom_t __prombss prom;
static unsigned long __prombss prom_entry;
static char __prombss of_stdout_device[256];
-static char __prombss prom_scratch[256];
+static char __prombss prom_scratch[COMMAND_LINE_SIZE];
static unsigned long __prombss dt_header_start;
static unsigned long __prombss dt_struct_start, dt_struct_end;
@@ -765,22 +765,19 @@ static unsigned long prom_memparse(const char *ptr, const char **retptr)
* Early parsing of the command line passed to the kernel, used for
* "mem=x" and the options that affect the iommu
*/
+#define cmdline_strlcat prom_strlcat
+#include <linux/cmdline.h>
+
static void __init early_cmdline_parse(void)
{
const char *opt;
-
- char *p;
int l = 0;
- prom_cmd_line[0] = 0;
- p = prom_cmd_line;
-
if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && (long)prom.chosen > 0)
- l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
+ l = prom_getprop(prom.chosen, "bootargs", prom_scratch,
+ COMMAND_LINE_SIZE - 1);
- if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || l <= 0 || p[0] == '\0')
- prom_strlcat(prom_cmd_line, " " CONFIG_CMDLINE,
- sizeof(prom_cmd_line));
+ __cmdline_build(prom_cmd_line, l > 0 ? prom_scratch : NULL, sizeof(prom_scratch));
prom_printf("command line: %s\n", prom_cmd_line);
--
2.25.0
^ permalink raw reply related
* [PATCH v3 01/17] cmdline: Add generic function to build command line.
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This code provides architectures with a way to build command line
based on what is built in the kernel and what is handed over by the
bootloader, based on selected compile-time options.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v3:
- Addressed comments from Will
- Added capability to have src == dst
---
include/linux/cmdline.h | 57 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 include/linux/cmdline.h
diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
new file mode 100644
index 000000000000..dea87edd41be
--- /dev/null
+++ b/include/linux/cmdline.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CMDLINE_H
+#define _LINUX_CMDLINE_H
+
+#include <linux/string.h>
+
+/* Allow architectures to override strlcat, powerpc can't use strings so early */
+#ifndef cmdline_strlcat
+#define cmdline_strlcat strlcat
+#endif
+
+/*
+ * This function will append or prepend a builtin command line to the command
+ * line provided by the bootloader. Kconfig options can be used to alter
+ * the behavior of this builtin command line.
+ * @dst: The destination of the final appended/prepended string.
+ * @src: The starting string or NULL if there isn't one.
+ * @len: the length of dest buffer.
+ */
+static __always_inline void __cmdline_build(char *dst, const char *src, size_t len)
+{
+ if (!len || src == dst)
+ return;
+
+ if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !src) {
+ dst[0] = 0;
+ cmdline_strlcat(dst, CONFIG_CMDLINE, len);
+ return;
+ }
+
+ if (dst != src)
+ dst[0] = 0;
+
+ if (IS_ENABLED(CONFIG_CMDLINE_PREPEND))
+ cmdline_strlcat(dst, CONFIG_CMDLINE " ", len);
+
+ cmdline_strlcat(dst, src, len);
+
+ if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+ cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
+}
+
+#define cmdline_build(dst, src, len) do { \
+ char *__c_dst = (dst); \
+ const char *__c_src = (src); \
+ \
+ if (__c_src == __c_dst) { \
+ static char __c_tmp[COMMAND_LINE_SIZE] __initdata = ""; \
+ \
+ cmdline_strlcat(__c_tmp, __c_src, COMMAND_LINE_SIZE); \
+ __cmdline_build(__c_dst, __c_tmp, (len)); \
+ } else { \
+ __cmdline_build(__c_dst, __c_src, (len)); \
+ } \
+} while (0)
+
+#endif /* _LINUX_CMDLINE_H */
--
2.25.0
^ permalink raw reply related
* [PATCH v3 00/17] Implement GENERIC_CMDLINE
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
The purpose of this series is to improve and enhance the
handling of kernel boot arguments.
It is first focussed on powerpc but also extends the capability
for other arches.
This is based on suggestion from Daniel Walker <danielwa@cisco.com>
Main changes in V3:
- Also accept destination equal to source in cmdline_build() by setting a tmp buffer in __initdata. Powerpc provides different source and destination and call __cmdline_build() directly.
- Taken comments received from Will and Rob
- Converted all architectures (Only tested on powerpc)
Christophe Leroy (17):
cmdline: Add generic function to build command line.
drivers: of: use cmdline building function
cmdline: Gives architectures opportunity to use generically defined
boot cmdline manipulation
powerpc: Convert to GENERIC_CMDLINE
arm: Convert to GENERIC_CMDLINE
arm64: Convert to GENERIC_CMDLINE
hexagon: Convert to GENERIC_CMDLINE
microblaze: Convert to GENERIC_CMDLINE
nios2: Convert to GENERIC_CMDLINE
openrisc: Convert to GENERIC_CMDLINE
riscv: Convert to GENERIC_CMDLINE
sh: Convert to GENERIC_CMDLINE
sparc: Convert to GENERIC_CMDLINE
xtensa: Convert to GENERIC_CMDLINE
x86: Convert to GENERIC_CMDLINE
mips: Convert to GENERIC_CMDLINE
cmdline: Remove CONFIG_CMDLINE_EXTEND
arch/arm/Kconfig | 38 +-------------
arch/arm/kernel/atags_parse.c | 15 ++----
arch/arm64/Kconfig | 33 +-----------
arch/arm64/kernel/idreg-override.c | 9 ++--
arch/hexagon/Kconfig | 11 +---
arch/hexagon/kernel/setup.c | 10 +---
arch/microblaze/Kconfig | 24 +--------
arch/microblaze/configs/mmu_defconfig | 2 +-
arch/microblaze/kernel/head.S | 4 +-
arch/mips/Kconfig | 1 +
arch/mips/Kconfig.debug | 44 ----------------
arch/mips/configs/ar7_defconfig | 1 -
arch/mips/configs/bcm47xx_defconfig | 1 -
arch/mips/configs/bcm63xx_defconfig | 1 -
arch/mips/configs/bmips_be_defconfig | 1 -
arch/mips/configs/bmips_stb_defconfig | 1 -
arch/mips/configs/capcella_defconfig | 1 -
arch/mips/configs/ci20_defconfig | 1 -
arch/mips/configs/cu1000-neo_defconfig | 1 -
arch/mips/configs/cu1830-neo_defconfig | 1 -
arch/mips/configs/e55_defconfig | 1 -
arch/mips/configs/generic_defconfig | 1 -
arch/mips/configs/gpr_defconfig | 1 -
arch/mips/configs/loongson3_defconfig | 1 -
arch/mips/configs/mpc30x_defconfig | 1 -
arch/mips/configs/rt305x_defconfig | 1 -
arch/mips/configs/tb0219_defconfig | 1 -
arch/mips/configs/tb0226_defconfig | 1 -
arch/mips/configs/tb0287_defconfig | 1 -
arch/mips/configs/workpad_defconfig | 1 -
arch/mips/configs/xway_defconfig | 1 -
arch/mips/kernel/relocate.c | 4 +-
arch/mips/kernel/setup.c | 40 +--------------
arch/mips/pic32/pic32mzda/early_console.c | 2 +-
arch/mips/pic32/pic32mzda/init.c | 2 -
arch/nios2/Kconfig | 24 +--------
arch/nios2/kernel/setup.c | 13 ++---
arch/openrisc/Kconfig | 10 +---
arch/powerpc/Kconfig | 37 +------------
arch/powerpc/kernel/prom_init.c | 17 +++---
arch/riscv/Kconfig | 44 +---------------
arch/riscv/kernel/setup.c | 5 +-
arch/sh/Kconfig | 30 +----------
arch/sh/configs/ap325rxa_defconfig | 2 +-
arch/sh/configs/dreamcast_defconfig | 2 +-
arch/sh/configs/ecovec24-romimage_defconfig | 2 +-
arch/sh/configs/ecovec24_defconfig | 2 +-
arch/sh/configs/edosk7760_defconfig | 2 +-
arch/sh/configs/espt_defconfig | 2 +-
arch/sh/configs/j2_defconfig | 2 +-
arch/sh/configs/kfr2r09-romimage_defconfig | 2 +-
arch/sh/configs/kfr2r09_defconfig | 2 +-
arch/sh/configs/lboxre2_defconfig | 2 +-
arch/sh/configs/microdev_defconfig | 2 +-
arch/sh/configs/migor_defconfig | 2 +-
arch/sh/configs/polaris_defconfig | 2 +-
arch/sh/configs/r7780mp_defconfig | 2 +-
arch/sh/configs/r7785rp_defconfig | 2 +-
arch/sh/configs/rsk7201_defconfig | 2 +-
arch/sh/configs/rsk7203_defconfig | 2 +-
arch/sh/configs/rts7751r2d1_defconfig | 2 +-
arch/sh/configs/rts7751r2dplus_defconfig | 2 +-
arch/sh/configs/sdk7780_defconfig | 2 +-
arch/sh/configs/sdk7786_defconfig | 2 +-
arch/sh/configs/se7206_defconfig | 2 +-
arch/sh/configs/se7343_defconfig | 2 +-
arch/sh/configs/se7712_defconfig | 2 +-
arch/sh/configs/se7721_defconfig | 2 +-
arch/sh/configs/se7724_defconfig | 2 +-
arch/sh/configs/se7751_defconfig | 2 +-
arch/sh/configs/se7780_defconfig | 2 +-
arch/sh/configs/sh03_defconfig | 2 +-
arch/sh/configs/sh2007_defconfig | 2 +-
arch/sh/configs/sh7757lcr_defconfig | 2 +-
arch/sh/configs/sh7763rdp_defconfig | 2 +-
arch/sh/configs/shmin_defconfig | 2 +-
arch/sh/configs/shx3_defconfig | 2 +-
arch/sh/configs/titan_defconfig | 2 +-
arch/sh/configs/ul2_defconfig | 2 +-
arch/sh/kernel/setup.c | 11 +---
arch/sparc/Kconfig | 18 +------
arch/sparc/prom/bootstr_64.c | 2 +-
arch/x86/Kconfig | 45 +---------------
arch/x86/kernel/setup.c | 17 +-----
arch/xtensa/Kconfig | 15 +-----
arch/xtensa/configs/audio_kc705_defconfig | 1 -
arch/xtensa/configs/common_defconfig | 1 -
arch/xtensa/configs/generic_kc705_defconfig | 1 -
arch/xtensa/configs/iss_defconfig | 1 -
arch/xtensa/configs/nommu_kc705_defconfig | 1 -
arch/xtensa/configs/smp_lx200_defconfig | 1 -
arch/xtensa/configs/virt_defconfig | 1 -
arch/xtensa/configs/xip_kc705_defconfig | 1 -
arch/xtensa/kernel/setup.c | 10 +---
drivers/firmware/efi/libstub/x86-stub.c | 26 +++++-----
drivers/of/fdt.c | 23 ++-------
include/linux/cmdline.h | 57 +++++++++++++++++++++
init/Kconfig | 46 +++++++++++++++++
98 files changed, 209 insertions(+), 580 deletions(-)
create mode 100644 include/linux/cmdline.h
--
2.25.0
^ permalink raw reply
* [PATCH v3 03/17] cmdline: Gives architectures opportunity to use generically defined boot cmdline manipulation
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
Most architectures have similar boot command line manipulation
options. This patchs adds the definition in init/Kconfig, gated by
CONFIG_HAVE_CMDLINE that the architectures can select to use them.
CONFIG_CMDLINE_EXTEND is understood differently by architectures.
For some of them it appends built-in CMDLINE to bootloader provided
line. For others it appends the bootloader provided CMDLINE to the
built-in one.
To avoid confusion, this commit brings to different options:
- CONFIG_CMDLINE_APPEND to append the built-in CMDLINE to the
bootloader line.
- CONFIG_CMDLINE_PREPEND to prepend the built-in CMDLINE in front of
the bootloader line.
For compatibility with existing architecture which uses CONFIG_OF, as
OF has already been converted to generic cmdline, we keep
CONFIG_CMDLINE_EXTEND as a synonym to CONFIG_CMDLINE_APPEND until
arm, powerpc, riscv and sh architectures have been converted.
A few differences are identified and will have to be taken
into account when converting the architecture to generic cmdline:
- riscv has CMDLINE_FALLBACK instead of CMDLINE_FROM_BOOTLOADER
- Some architectures are using CONFIG_CMDLINE_OVERRIDE or
CONFIG_CMDLINE_OVERWRITE instead of CONFIG_CMDLINE_FORCE.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v3:
- Comments from Will.
- Remove CONFIG_CMDLINE_BOOL. Using CONFIG_CMDLINE != "" instead, like arm and powerpc.
- Changed EXTEND to APPEND. Keep EXTEND for backward compatibility.
---
include/linux/cmdline.h | 2 +-
init/Kconfig | 52 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
index dea87edd41be..38306c109041 100644
--- a/include/linux/cmdline.h
+++ b/include/linux/cmdline.h
@@ -36,7 +36,7 @@ static __always_inline void __cmdline_build(char *dst, const char *src, size_t l
cmdline_strlcat(dst, src, len);
- if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+ if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || IS_ENABLED(CONFIG_CMDLINE_APPEND))
cmdline_strlcat(dst, " " CONFIG_CMDLINE, len);
}
diff --git a/init/Kconfig b/init/Kconfig
index 5f5c776ef192..af0d84662cc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -117,6 +117,58 @@ config INIT_ENV_ARG_LIMIT
Maximum of each of the number of arguments and environment
variables passed to init from the kernel command line.
+config GENERIC_CMDLINE
+ bool
+
+config CMDLINE
+ string "Default kernel command string" if GENERIC_CMDLINE
+ default ""
+ help
+ Defines a default kernel command string.
+ If this string is not empty, additional choices are proposed
+ below to determine how it will be used by the kernel.
+
+choice
+ prompt "Kernel command line type" if CMDLINE != ""
+ default CMDLINE_PREPEND if ARCH_WANT_CMDLINE_PREPEND_BY_DEFAULT
+ default CMDLINE_FROM_BOOTLOADER
+ depends on GENERIC_CMDLINE
+ help
+ Determine how the default kernel arguments are combined with any
+ arguments passed by the bootloader if any.
+
+config CMDLINE_FROM_BOOTLOADER
+ bool "Use bootloader kernel arguments if available"
+ help
+ Uses the command-line options passed by the boot loader. If
+ the boot loader doesn't provide any, the default kernel command
+ string provided in CMDLINE will be used.
+
+config CMDLINE_APPEND
+ bool "Append to the bootloader kernel arguments"
+ help
+ The default kernel command string will be appended to the
+ command-line arguments provided by the bootloader.
+
+config CMDLINE_PREPEND
+ bool "Prepend to the bootloader kernel arguments"
+ help
+ The default kernel command string will be prepended to the
+ command-line arguments provided by the bootloader.
+
+config CMDLINE_FORCE
+ bool "Always use the default kernel command string"
+ help
+ Always use the default kernel command string, ignoring any
+ arguments provided by the bootloader.
+endchoice
+
+config CMDLINE_EXTEND
+ bool
+ default CMDLINE_APPEND
+ help
+ To be removed once all architectures are converted to generic CMDLINE
+
config COMPILE_TEST
bool "Compile also drivers which will not load"
depends on HAS_IOMEM
--
2.25.0
^ permalink raw reply related
* [PATCH v3 02/17] drivers: of: use cmdline building function
From: Christophe Leroy @ 2021-03-26 13:44 UTC (permalink / raw)
To: will, danielwa, robh, daniel
Cc: linux-arch, devicetree, microblaze, linux-xtensa, linux-sh,
linux-hexagon, x86, linux-kernel, nios2, linux-mips, openrisc,
sparclinux, linux-riscv, linuxppc-dev, linux-arm-kernel
In-Reply-To: <cover.1616765869.git.christophe.leroy@csgroup.eu>
This patch uses the new cmdline building function to
concatenate the of provided cmdline with built-in parts
based on compile-time options.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/of/fdt.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index dcc1dd96911a..cf2b95b8f298 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -25,6 +25,7 @@
#include <linux/serial_core.h>
#include <linux/sysfs.h>
#include <linux/random.h>
+#include <linux/cmdline.h>
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
#include <asm/page.h>
@@ -1050,26 +1051,10 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
/* Retrieve command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
- if (p != NULL && l > 0)
- strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
+ if (l <= 0)
+ p = NULL;
- /*
- * CONFIG_CMDLINE is meant to be a default in case nothing else
- * managed to set the command line, unless CONFIG_CMDLINE_FORCE
- * is set in which case we override whatever was found earlier.
- */
-#ifdef CONFIG_CMDLINE
-#if defined(CONFIG_CMDLINE_EXTEND)
- strlcat(data, " ", COMMAND_LINE_SIZE);
- strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#elif defined(CONFIG_CMDLINE_FORCE)
- strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#else
- /* No arguments from boot loader, use kernel's cmdl*/
- if (!((char *)data)[0])
- strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif /* CONFIG_CMDLINE */
+ cmdline_build(data, p, COMMAND_LINE_SIZE);
pr_debug("Command line is: %s\n", (char *)data);
--
2.25.0
^ permalink raw reply related
* [PATCH] powerpc: powernv: Remove unneeded variable: "rc"
From: dingsenjie @ 2021-03-26 11:53 UTC (permalink / raw)
To: mpe, benh, paulus; +Cc: dingsenjie, linuxppc-dev, linux-kernel
From: dingsenjie <dingsenjie@yulong.com>
Remove unneeded variable: "rc".
Signed-off-by: dingsenjie <dingsenjie@yulong.com>
---
arch/powerpc/platforms/powernv/opal-prd.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-prd.c b/arch/powerpc/platforms/powernv/opal-prd.c
index deddaeb..a191f4c 100644
--- a/arch/powerpc/platforms/powernv/opal-prd.c
+++ b/arch/powerpc/platforms/powernv/opal-prd.c
@@ -105,7 +105,6 @@ static int opal_prd_mmap(struct file *file, struct vm_area_struct *vma)
{
size_t addr, size;
pgprot_t page_prot;
- int rc;
pr_devel("opal_prd_mmap(0x%016lx, 0x%016lx, 0x%lx, 0x%lx)\n",
vma->vm_start, vma->vm_end, vma->vm_pgoff,
@@ -121,10 +120,8 @@ static int opal_prd_mmap(struct file *file, struct vm_area_struct *vma)
page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
size, vma->vm_page_prot);
- rc = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size,
+ return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size,
page_prot);
-
- return rc;
}
static bool opal_msg_queue_empty(void)
--
1.9.1
^ permalink raw reply related
* Re: [PATCH] docs: powerpc: Fix misspellings and grammar errors
From: Michael Ellerman @ 2021-03-26 11:15 UTC (permalink / raw)
To: He Ying, benh, paulus, corbet, ruscur, oohall, heying24
Cc: linuxppc-dev, linux-kernel, linux-doc
In-Reply-To: <20210326100853.173586-1-heying24@huawei.com>
He Ying <heying24@huawei.com> writes:
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: He Ying <heying24@huawei.com>
> ---
> Documentation/powerpc/booting.rst | 2 +-
> Documentation/powerpc/dawr-power9.rst | 2 +-
> Documentation/powerpc/eeh-pci-error-recovery.rst | 2 +-
> Documentation/powerpc/elfnote.rst | 2 +-
> Documentation/powerpc/firmware-assisted-dump.rst | 2 +-
> Documentation/powerpc/kaslr-booke32.rst | 2 +-
> Documentation/powerpc/mpc52xx.rst | 2 +-
> Documentation/powerpc/papr_hcalls.rst | 4 ++--
> Documentation/powerpc/transactional_memory.rst | 4 ++--
> 9 files changed, 11 insertions(+), 11 deletions(-)
LGTM.
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
cheers
^ permalink raw reply
* Re: [PATCH next v1 2/3] printk: remove safe buffers
From: John Ogness @ 2021-03-26 11:12 UTC (permalink / raw)
To: Petr Mladek
Cc: Sergey Senozhatsky, Peter Zijlstra, Paul Mackerras, Tiezhu Yang,
Rafael Aquini, Alexey Kardashevskiy, Yue Hu, Jordan Niethe,
Kees Cook, Paul E. McKenney, Alistair Popple,
Guilherme G. Piccoli, Nicholas Piggin, Steven Rostedt,
Thomas Gleixner, kexec, linux-kernel, Sergey Senozhatsky,
Eric Biederman, Andrew Morton, linuxppc-dev,
Cédric Le Goater
In-Reply-To: <YFnHKlCvIA2nI41c@alley>
On 2021-03-23, Petr Mladek <pmladek@suse.com> wrote:
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -1142,8 +1126,6 @@ void __init setup_log_buf(int early)
>> new_descs, ilog2(new_descs_count),
>> new_infos);
>>
>> - printk_safe_enter_irqsave(flags);
>> -
>> log_buf_len = new_log_buf_len;
>> log_buf = new_log_buf;
>> new_log_buf_len = 0;
>> @@ -1159,8 +1141,6 @@ void __init setup_log_buf(int early)
>> */
>> prb = &printk_rb_dynamic;
>>
>> - printk_safe_exit_irqrestore(flags);
>
> This will allow to add new messages from the IRQ context when we
> are copying them to the new buffer. They might get lost in
> the small race window.
>
> Also the messages from NMI might get lost because they are not
> longer stored in the per-CPU buffer.
>
> A possible solution might be to do something like this:
>
> prb_for_each_record(0, &printk_rb_static, seq, &r)
> free -= add_to_rb(&printk_rb_dynamic, &r);
>
> prb = &printk_rb_dynamic;
>
> /*
> * Copy the remaining messages that might have appeared
> * from IRQ or NMI context after we ended copying and
> * before we switched the buffers. They must be finalized
> * because only one CPU is up at this stage.
> */
> prb_for_each_record(seq, &printk_rb_static, seq, &r)
> free -= add_to_rb(&printk_rb_dynamic, &r);
OK. I'll probably rework it some and combine it with the "dropped" test
so that we can identify if messages were dropped during the transition
(because of static ringbuffer overrun).
>> -
>> if (seq != prb_next_seq(&printk_rb_static)) {
>> pr_err("dropped %llu messages\n",
>> prb_next_seq(&printk_rb_static) - seq);
>> @@ -2666,7 +2631,6 @@ void console_unlock(void)
>> size_t ext_len = 0;
>> size_t len;
>>
>> - printk_safe_enter_irqsave(flags);
>> skip:
>> if (!prb_read_valid(prb, console_seq, &r))
>> break;
>> @@ -2711,6 +2675,8 @@ void console_unlock(void)
>> printk_time);
>> console_seq++;
>>
>> + printk_safe_enter_irqsave(flags);
>
> What is the purpose of the printk_safe context here, please?
console_lock_spinning_enable() needs to be called with interrupts
disabled. I should have just used local_irq_save().
I could add local_irq_save() to console_lock_spinning_enable() and
restore them at the end of console_lock_spinning_disable_and_check(),
but then I would need to add a @flags argument to both functions. I
think it is simpler to just do the disable/enable from the caller,
console_unlock().
BTW, I could not find any sane way of disabling interrupts via a
raw_spin_lock_irqsave() of @console_owner_lock because of the how it is
used with lockdep. In particular for
console_lock_spinning_disable_and_check().
John Ogness
^ permalink raw reply
* Re: VDSO ELF header
From: Christophe Leroy @ 2021-03-26 10:50 UTC (permalink / raw)
To: Michael Ellerman, Laurent Dufour, Dmitry Safonov; +Cc: linuxppc-dev
In-Reply-To: <87blb6gpkj.fsf@mpe.ellerman.id.au>
Le 26/03/2021 à 11:46, Michael Ellerman a écrit :
> Laurent Dufour <ldufour@linux.ibm.com> writes:
>> Le 25/03/2021 à 17:56, Laurent Dufour a écrit :
>>> Le 25/03/2021 à 17:46, Christophe Leroy a écrit :
>>>> Le 25/03/2021 à 17:11, Laurent Dufour a écrit :
>>>>> Since v5.11 and the changes you made to the VDSO code, it no more exposing
>>>>> the ELF header at the beginning of the VDSO mapping in user space.
>>>>>
>>>>> This is confusing CRIU which is checking for this ELF header cookie
>>>>> (https://github.com/checkpoint-restore/criu/issues/1417).
>>>>
>>>> How does it do on other architectures ?
>>>
>>> Good question, I'll double check the CRIU code.
>>
>> On x86, there are 2 VDSO entries:
>> 7ffff7fcb000-7ffff7fce000 r--p 00000000 00:00 0 [vvar]
>> 7ffff7fce000-7ffff7fcf000 r-xp 00000000 00:00 0 [vdso]
>>
>> And the VDSO is starting with the ELF header.
>>
>>>>> I'm not an expert in loading and ELF part and reading the change you made, I
>>>>> can't identify how this could work now as I'm expecting the loader to need
>>>>> that ELF header to do the relocation.
>>>>
>>>> I think the loader is able to find it at the expected place.
>>>
>>> Actually, it seems the loader relies on the AUX vector AT_SYSINFO_EHDR. I guess
>>> CRIU should do the same.
>>>
>>>>>
>>>>> From my investigation it seems that the first bytes of the VDSO area are now
>>>>> the vdso_arch_data.
>>>>>
>>>>> Is the ELF header put somewhere else?
>>>>> How could the loader process the VDSO without that ELF header?
>>>>>
>>>>
>>>> Like most other architectures, we now have the data section as first page and
>>>> the text section follows. So you will likely find the elf header on the second
>>>> page.
>>
>> I'm wondering if the data section you're refering to is the vvar section I can
>> see on x86.
>
> Many of the other architectures have separate vm_special_mapping's for
> the data page and the vdso binary, where the former is called "vvar".
>
> eg, s390:
>
> static struct vm_special_mapping vvar_mapping = {
> .name = "[vvar]",
> .fault = vvar_fault,
> };
>
> static struct vm_special_mapping vdso_mapping = {
> .name = "[vdso]",
> .mremap = vdso_mremap,
> };
>
>
> I guess we probably should be doing that too.
>
Dmitry proposed the same, see
https://github.com/0x7f454c46/linux/commit/783c7a2532d2219edbcf555cc540eab05f698d2a
Discussion at https://github.com/checkpoint-restore/criu/issues/1417
Christophe
^ permalink raw reply
* Re: VDSO ELF header
From: Michael Ellerman @ 2021-03-26 10:46 UTC (permalink / raw)
To: Laurent Dufour, Christophe Leroy; +Cc: linuxppc-dev
In-Reply-To: <30c51951-332b-7aa8-13ba-44a0b6ae3498@linux.ibm.com>
Laurent Dufour <ldufour@linux.ibm.com> writes:
> Le 25/03/2021 à 17:56, Laurent Dufour a écrit :
>> Le 25/03/2021 à 17:46, Christophe Leroy a écrit :
>>> Le 25/03/2021 à 17:11, Laurent Dufour a écrit :
>>>> Since v5.11 and the changes you made to the VDSO code, it no more exposing
>>>> the ELF header at the beginning of the VDSO mapping in user space.
>>>>
>>>> This is confusing CRIU which is checking for this ELF header cookie
>>>> (https://github.com/checkpoint-restore/criu/issues/1417).
>>>
>>> How does it do on other architectures ?
>>
>> Good question, I'll double check the CRIU code.
>
> On x86, there are 2 VDSO entries:
> 7ffff7fcb000-7ffff7fce000 r--p 00000000 00:00 0 [vvar]
> 7ffff7fce000-7ffff7fcf000 r-xp 00000000 00:00 0 [vdso]
>
> And the VDSO is starting with the ELF header.
>
>>>> I'm not an expert in loading and ELF part and reading the change you made, I
>>>> can't identify how this could work now as I'm expecting the loader to need
>>>> that ELF header to do the relocation.
>>>
>>> I think the loader is able to find it at the expected place.
>>
>> Actually, it seems the loader relies on the AUX vector AT_SYSINFO_EHDR. I guess
>> CRIU should do the same.
>>
>>>>
>>>> From my investigation it seems that the first bytes of the VDSO area are now
>>>> the vdso_arch_data.
>>>>
>>>> Is the ELF header put somewhere else?
>>>> How could the loader process the VDSO without that ELF header?
>>>>
>>>
>>> Like most other architectures, we now have the data section as first page and
>>> the text section follows. So you will likely find the elf header on the second
>>> page.
>
> I'm wondering if the data section you're refering to is the vvar section I can
> see on x86.
Many of the other architectures have separate vm_special_mapping's for
the data page and the vdso binary, where the former is called "vvar".
eg, s390:
static struct vm_special_mapping vvar_mapping = {
.name = "[vvar]",
.fault = vvar_fault,
};
static struct vm_special_mapping vdso_mapping = {
.name = "[vdso]",
.mremap = vdso_mremap,
};
I guess we probably should be doing that too.
cheers
^ permalink raw reply
* [PATCH] powerpc/64: Move security code into security.c
From: Michael Ellerman @ 2021-03-26 10:12 UTC (permalink / raw)
To: linuxppc-dev
When the original spectre/meltdown mitigations were merged we put them
in setup_64.c for lack of a better place.
Since then we created security.c for some of the other mitigation
related code. But it should all be in there.
This sort of code movement can cause trouble for backports, but
hopefully this code is relatively stable these days (famous last words).
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/security.c | 261 ++++++++++++++++++++++++++++++++
arch/powerpc/kernel/setup_64.c | 264 ---------------------------------
2 files changed, 261 insertions(+), 264 deletions(-)
diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index e4e1a94ccf6a..287286ddf7dc 100644
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -7,6 +7,7 @@
#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/device.h>
+#include <linux/memblock.h>
#include <linux/nospec.h>
#include <linux/prctl.h>
#include <linux/seq_buf.h>
@@ -18,6 +19,7 @@
#include <asm/setup.h>
#include <asm/inst.h>
+#include "setup.h"
u64 powerpc_security_features __read_mostly = SEC_FTR_DEFAULT;
@@ -541,6 +543,178 @@ void setup_count_cache_flush(void)
toggle_branch_cache_flush(enable);
}
+static enum l1d_flush_type enabled_flush_types;
+static void *l1d_flush_fallback_area;
+static bool no_rfi_flush;
+static bool no_entry_flush;
+static bool no_uaccess_flush;
+bool rfi_flush;
+static bool entry_flush;
+static bool uaccess_flush;
+DEFINE_STATIC_KEY_FALSE(uaccess_flush_key);
+EXPORT_SYMBOL(uaccess_flush_key);
+
+static int __init handle_no_rfi_flush(char *p)
+{
+ pr_info("rfi-flush: disabled on command line.");
+ no_rfi_flush = true;
+ return 0;
+}
+early_param("no_rfi_flush", handle_no_rfi_flush);
+
+static int __init handle_no_entry_flush(char *p)
+{
+ pr_info("entry-flush: disabled on command line.");
+ no_entry_flush = true;
+ return 0;
+}
+early_param("no_entry_flush", handle_no_entry_flush);
+
+static int __init handle_no_uaccess_flush(char *p)
+{
+ pr_info("uaccess-flush: disabled on command line.");
+ no_uaccess_flush = true;
+ return 0;
+}
+early_param("no_uaccess_flush", handle_no_uaccess_flush);
+
+/*
+ * The RFI flush is not KPTI, but because users will see doco that says to use
+ * nopti we hijack that option here to also disable the RFI flush.
+ */
+static int __init handle_no_pti(char *p)
+{
+ pr_info("rfi-flush: disabling due to 'nopti' on command line.\n");
+ handle_no_rfi_flush(NULL);
+ return 0;
+}
+early_param("nopti", handle_no_pti);
+
+static void do_nothing(void *unused)
+{
+ /*
+ * We don't need to do the flush explicitly, just enter+exit kernel is
+ * sufficient, the RFI exit handlers will do the right thing.
+ */
+}
+
+void rfi_flush_enable(bool enable)
+{
+ if (enable) {
+ do_rfi_flush_fixups(enabled_flush_types);
+ on_each_cpu(do_nothing, NULL, 1);
+ } else
+ do_rfi_flush_fixups(L1D_FLUSH_NONE);
+
+ rfi_flush = enable;
+}
+
+static void entry_flush_enable(bool enable)
+{
+ if (enable) {
+ do_entry_flush_fixups(enabled_flush_types);
+ on_each_cpu(do_nothing, NULL, 1);
+ } else {
+ do_entry_flush_fixups(L1D_FLUSH_NONE);
+ }
+
+ entry_flush = enable;
+}
+
+static void uaccess_flush_enable(bool enable)
+{
+ if (enable) {
+ do_uaccess_flush_fixups(enabled_flush_types);
+ static_branch_enable(&uaccess_flush_key);
+ on_each_cpu(do_nothing, NULL, 1);
+ } else {
+ static_branch_disable(&uaccess_flush_key);
+ do_uaccess_flush_fixups(L1D_FLUSH_NONE);
+ }
+
+ uaccess_flush = enable;
+}
+
+static void __ref init_fallback_flush(void)
+{
+ u64 l1d_size, limit;
+ int cpu;
+
+ /* Only allocate the fallback flush area once (at boot time). */
+ if (l1d_flush_fallback_area)
+ return;
+
+ l1d_size = ppc64_caches.l1d.size;
+
+ /*
+ * If there is no d-cache-size property in the device tree, l1d_size
+ * could be zero. That leads to the loop in the asm wrapping around to
+ * 2^64-1, and then walking off the end of the fallback area and
+ * eventually causing a page fault which is fatal. Just default to
+ * something vaguely sane.
+ */
+ if (!l1d_size)
+ l1d_size = (64 * 1024);
+
+ limit = min(ppc64_bolted_size(), ppc64_rma_size);
+
+ /*
+ * Align to L1d size, and size it at 2x L1d size, to catch possible
+ * hardware prefetch runoff. We don't have a recipe for load patterns to
+ * reliably avoid the prefetcher.
+ */
+ l1d_flush_fallback_area = memblock_alloc_try_nid(l1d_size * 2,
+ l1d_size, MEMBLOCK_LOW_LIMIT,
+ limit, NUMA_NO_NODE);
+ if (!l1d_flush_fallback_area)
+ panic("%s: Failed to allocate %llu bytes align=0x%llx max_addr=%pa\n",
+ __func__, l1d_size * 2, l1d_size, &limit);
+
+
+ for_each_possible_cpu(cpu) {
+ struct paca_struct *paca = paca_ptrs[cpu];
+ paca->rfi_flush_fallback_area = l1d_flush_fallback_area;
+ paca->l1d_flush_size = l1d_size;
+ }
+}
+
+void setup_rfi_flush(enum l1d_flush_type types, bool enable)
+{
+ if (types & L1D_FLUSH_FALLBACK) {
+ pr_info("rfi-flush: fallback displacement flush available\n");
+ init_fallback_flush();
+ }
+
+ if (types & L1D_FLUSH_ORI)
+ pr_info("rfi-flush: ori type flush available\n");
+
+ if (types & L1D_FLUSH_MTTRIG)
+ pr_info("rfi-flush: mttrig type flush available\n");
+
+ enabled_flush_types = types;
+
+ if (!cpu_mitigations_off() && !no_rfi_flush)
+ rfi_flush_enable(enable);
+}
+
+void setup_entry_flush(bool enable)
+{
+ if (cpu_mitigations_off())
+ return;
+
+ if (!no_entry_flush)
+ entry_flush_enable(enable);
+}
+
+void setup_uaccess_flush(bool enable)
+{
+ if (cpu_mitigations_off())
+ return;
+
+ if (!no_uaccess_flush)
+ uaccess_flush_enable(enable);
+}
+
#ifdef CONFIG_DEBUG_FS
static int count_cache_flush_set(void *data, u64 val)
{
@@ -579,5 +753,92 @@ static __init int count_cache_flush_debugfs_init(void)
return 0;
}
device_initcall(count_cache_flush_debugfs_init);
+
+static int rfi_flush_set(void *data, u64 val)
+{
+ bool enable;
+
+ if (val == 1)
+ enable = true;
+ else if (val == 0)
+ enable = false;
+ else
+ return -EINVAL;
+
+ /* Only do anything if we're changing state */
+ if (enable != rfi_flush)
+ rfi_flush_enable(enable);
+
+ return 0;
+}
+
+static int rfi_flush_get(void *data, u64 *val)
+{
+ *val = rfi_flush ? 1 : 0;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_rfi_flush, rfi_flush_get, rfi_flush_set, "%llu\n");
+
+static int entry_flush_set(void *data, u64 val)
+{
+ bool enable;
+
+ if (val == 1)
+ enable = true;
+ else if (val == 0)
+ enable = false;
+ else
+ return -EINVAL;
+
+ /* Only do anything if we're changing state */
+ if (enable != entry_flush)
+ entry_flush_enable(enable);
+
+ return 0;
+}
+
+static int entry_flush_get(void *data, u64 *val)
+{
+ *val = entry_flush ? 1 : 0;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_entry_flush, entry_flush_get, entry_flush_set, "%llu\n");
+
+static int uaccess_flush_set(void *data, u64 val)
+{
+ bool enable;
+
+ if (val == 1)
+ enable = true;
+ else if (val == 0)
+ enable = false;
+ else
+ return -EINVAL;
+
+ /* Only do anything if we're changing state */
+ if (enable != uaccess_flush)
+ uaccess_flush_enable(enable);
+
+ return 0;
+}
+
+static int uaccess_flush_get(void *data, u64 *val)
+{
+ *val = uaccess_flush ? 1 : 0;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_uaccess_flush, uaccess_flush_get, uaccess_flush_set, "%llu\n");
+
+static __init int rfi_flush_debugfs_init(void)
+{
+ debugfs_create_file("rfi_flush", 0600, powerpc_debugfs_root, NULL, &fops_rfi_flush);
+ debugfs_create_file("entry_flush", 0600, powerpc_debugfs_root, NULL, &fops_entry_flush);
+ debugfs_create_file("uaccess_flush", 0600, powerpc_debugfs_root, NULL, &fops_uaccess_flush);
+ return 0;
+}
+device_initcall(rfi_flush_debugfs_init);
#endif /* CONFIG_DEBUG_FS */
#endif /* CONFIG_PPC_BOOK3S_64 */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 04a31586f760..ccbfcc88758c 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -50,7 +50,6 @@
#include <asm/setup.h>
#include <asm/rtas.h>
#include <asm/iommu.h>
-#include <asm/security_features.h>
#include <asm/serial.h>
#include <asm/cache.h>
#include <asm/page.h>
@@ -942,266 +941,3 @@ static int __init disable_hardlockup_detector(void)
return 0;
}
early_initcall(disable_hardlockup_detector);
-
-#ifdef CONFIG_PPC_BOOK3S_64
-static enum l1d_flush_type enabled_flush_types;
-static void *l1d_flush_fallback_area;
-static bool no_rfi_flush;
-static bool no_entry_flush;
-static bool no_uaccess_flush;
-bool rfi_flush;
-static bool entry_flush;
-static bool uaccess_flush;
-DEFINE_STATIC_KEY_FALSE(uaccess_flush_key);
-EXPORT_SYMBOL(uaccess_flush_key);
-
-static int __init handle_no_rfi_flush(char *p)
-{
- pr_info("rfi-flush: disabled on command line.");
- no_rfi_flush = true;
- return 0;
-}
-early_param("no_rfi_flush", handle_no_rfi_flush);
-
-static int __init handle_no_entry_flush(char *p)
-{
- pr_info("entry-flush: disabled on command line.");
- no_entry_flush = true;
- return 0;
-}
-early_param("no_entry_flush", handle_no_entry_flush);
-
-static int __init handle_no_uaccess_flush(char *p)
-{
- pr_info("uaccess-flush: disabled on command line.");
- no_uaccess_flush = true;
- return 0;
-}
-early_param("no_uaccess_flush", handle_no_uaccess_flush);
-
-/*
- * The RFI flush is not KPTI, but because users will see doco that says to use
- * nopti we hijack that option here to also disable the RFI flush.
- */
-static int __init handle_no_pti(char *p)
-{
- pr_info("rfi-flush: disabling due to 'nopti' on command line.\n");
- handle_no_rfi_flush(NULL);
- return 0;
-}
-early_param("nopti", handle_no_pti);
-
-static void do_nothing(void *unused)
-{
- /*
- * We don't need to do the flush explicitly, just enter+exit kernel is
- * sufficient, the RFI exit handlers will do the right thing.
- */
-}
-
-void rfi_flush_enable(bool enable)
-{
- if (enable) {
- do_rfi_flush_fixups(enabled_flush_types);
- on_each_cpu(do_nothing, NULL, 1);
- } else
- do_rfi_flush_fixups(L1D_FLUSH_NONE);
-
- rfi_flush = enable;
-}
-
-static void entry_flush_enable(bool enable)
-{
- if (enable) {
- do_entry_flush_fixups(enabled_flush_types);
- on_each_cpu(do_nothing, NULL, 1);
- } else {
- do_entry_flush_fixups(L1D_FLUSH_NONE);
- }
-
- entry_flush = enable;
-}
-
-static void uaccess_flush_enable(bool enable)
-{
- if (enable) {
- do_uaccess_flush_fixups(enabled_flush_types);
- static_branch_enable(&uaccess_flush_key);
- on_each_cpu(do_nothing, NULL, 1);
- } else {
- static_branch_disable(&uaccess_flush_key);
- do_uaccess_flush_fixups(L1D_FLUSH_NONE);
- }
-
- uaccess_flush = enable;
-}
-
-static void __ref init_fallback_flush(void)
-{
- u64 l1d_size, limit;
- int cpu;
-
- /* Only allocate the fallback flush area once (at boot time). */
- if (l1d_flush_fallback_area)
- return;
-
- l1d_size = ppc64_caches.l1d.size;
-
- /*
- * If there is no d-cache-size property in the device tree, l1d_size
- * could be zero. That leads to the loop in the asm wrapping around to
- * 2^64-1, and then walking off the end of the fallback area and
- * eventually causing a page fault which is fatal. Just default to
- * something vaguely sane.
- */
- if (!l1d_size)
- l1d_size = (64 * 1024);
-
- limit = min(ppc64_bolted_size(), ppc64_rma_size);
-
- /*
- * Align to L1d size, and size it at 2x L1d size, to catch possible
- * hardware prefetch runoff. We don't have a recipe for load patterns to
- * reliably avoid the prefetcher.
- */
- l1d_flush_fallback_area = memblock_alloc_try_nid(l1d_size * 2,
- l1d_size, MEMBLOCK_LOW_LIMIT,
- limit, NUMA_NO_NODE);
- if (!l1d_flush_fallback_area)
- panic("%s: Failed to allocate %llu bytes align=0x%llx max_addr=%pa\n",
- __func__, l1d_size * 2, l1d_size, &limit);
-
-
- for_each_possible_cpu(cpu) {
- struct paca_struct *paca = paca_ptrs[cpu];
- paca->rfi_flush_fallback_area = l1d_flush_fallback_area;
- paca->l1d_flush_size = l1d_size;
- }
-}
-
-void setup_rfi_flush(enum l1d_flush_type types, bool enable)
-{
- if (types & L1D_FLUSH_FALLBACK) {
- pr_info("rfi-flush: fallback displacement flush available\n");
- init_fallback_flush();
- }
-
- if (types & L1D_FLUSH_ORI)
- pr_info("rfi-flush: ori type flush available\n");
-
- if (types & L1D_FLUSH_MTTRIG)
- pr_info("rfi-flush: mttrig type flush available\n");
-
- enabled_flush_types = types;
-
- if (!cpu_mitigations_off() && !no_rfi_flush)
- rfi_flush_enable(enable);
-}
-
-void setup_entry_flush(bool enable)
-{
- if (cpu_mitigations_off())
- return;
-
- if (!no_entry_flush)
- entry_flush_enable(enable);
-}
-
-void setup_uaccess_flush(bool enable)
-{
- if (cpu_mitigations_off())
- return;
-
- if (!no_uaccess_flush)
- uaccess_flush_enable(enable);
-}
-
-#ifdef CONFIG_DEBUG_FS
-static int rfi_flush_set(void *data, u64 val)
-{
- bool enable;
-
- if (val == 1)
- enable = true;
- else if (val == 0)
- enable = false;
- else
- return -EINVAL;
-
- /* Only do anything if we're changing state */
- if (enable != rfi_flush)
- rfi_flush_enable(enable);
-
- return 0;
-}
-
-static int rfi_flush_get(void *data, u64 *val)
-{
- *val = rfi_flush ? 1 : 0;
- return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(fops_rfi_flush, rfi_flush_get, rfi_flush_set, "%llu\n");
-
-static int entry_flush_set(void *data, u64 val)
-{
- bool enable;
-
- if (val == 1)
- enable = true;
- else if (val == 0)
- enable = false;
- else
- return -EINVAL;
-
- /* Only do anything if we're changing state */
- if (enable != entry_flush)
- entry_flush_enable(enable);
-
- return 0;
-}
-
-static int entry_flush_get(void *data, u64 *val)
-{
- *val = entry_flush ? 1 : 0;
- return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(fops_entry_flush, entry_flush_get, entry_flush_set, "%llu\n");
-
-static int uaccess_flush_set(void *data, u64 val)
-{
- bool enable;
-
- if (val == 1)
- enable = true;
- else if (val == 0)
- enable = false;
- else
- return -EINVAL;
-
- /* Only do anything if we're changing state */
- if (enable != uaccess_flush)
- uaccess_flush_enable(enable);
-
- return 0;
-}
-
-static int uaccess_flush_get(void *data, u64 *val)
-{
- *val = uaccess_flush ? 1 : 0;
- return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(fops_uaccess_flush, uaccess_flush_get, uaccess_flush_set, "%llu\n");
-
-static __init int rfi_flush_debugfs_init(void)
-{
- debugfs_create_file("rfi_flush", 0600, powerpc_debugfs_root, NULL, &fops_rfi_flush);
- debugfs_create_file("entry_flush", 0600, powerpc_debugfs_root, NULL, &fops_entry_flush);
- debugfs_create_file("uaccess_flush", 0600, powerpc_debugfs_root, NULL, &fops_uaccess_flush);
- return 0;
-}
-device_initcall(rfi_flush_debugfs_init);
-#endif
-#endif /* CONFIG_PPC_BOOK3S_64 */
--
2.25.1
^ permalink raw reply related
* [PATCH] docs: powerpc: Fix misspellings and grammar errors
From: He Ying @ 2021-03-26 10:08 UTC (permalink / raw)
To: mpe, benh, paulus, corbet, ruscur, oohall, heying24
Cc: linuxppc-dev, linux-kernel, linux-doc
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: He Ying <heying24@huawei.com>
---
Documentation/powerpc/booting.rst | 2 +-
Documentation/powerpc/dawr-power9.rst | 2 +-
Documentation/powerpc/eeh-pci-error-recovery.rst | 2 +-
Documentation/powerpc/elfnote.rst | 2 +-
Documentation/powerpc/firmware-assisted-dump.rst | 2 +-
Documentation/powerpc/kaslr-booke32.rst | 2 +-
Documentation/powerpc/mpc52xx.rst | 2 +-
Documentation/powerpc/papr_hcalls.rst | 4 ++--
Documentation/powerpc/transactional_memory.rst | 4 ++--
9 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Documentation/powerpc/booting.rst b/Documentation/powerpc/booting.rst
index 2d0ec2ff2b57..11aa440f98cc 100644
--- a/Documentation/powerpc/booting.rst
+++ b/Documentation/powerpc/booting.rst
@@ -94,7 +94,7 @@ should:
a) add your platform support as a _boolean_ option in
arch/powerpc/Kconfig, following the example of PPC_PSERIES,
- PPC_PMAC and PPC_MAPLE. The later is probably a good
+ PPC_PMAC and PPC_MAPLE. The latter is probably a good
example of a board support to start from.
b) create your main platform file as
diff --git a/Documentation/powerpc/dawr-power9.rst b/Documentation/powerpc/dawr-power9.rst
index c96ab6befd9c..e55ac6a24b97 100644
--- a/Documentation/powerpc/dawr-power9.rst
+++ b/Documentation/powerpc/dawr-power9.rst
@@ -4,7 +4,7 @@ DAWR issues on POWER9
On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop
if it points to cache inhibited (CI) memory. Currently Linux has no way to
-disinguish CI memory when configuring the DAWR, so (for now) the DAWR is
+distinguish CI memory when configuring the DAWR, so (for now) the DAWR is
disabled by this commit::
commit 9654153158d3e0684a1bdb76dbababdb7111d5a0
diff --git a/Documentation/powerpc/eeh-pci-error-recovery.rst b/Documentation/powerpc/eeh-pci-error-recovery.rst
index 438a87ebc095..d6643a91bdf8 100644
--- a/Documentation/powerpc/eeh-pci-error-recovery.rst
+++ b/Documentation/powerpc/eeh-pci-error-recovery.rst
@@ -73,7 +73,7 @@ return all-ff's (0xff, 0xffff, 0xffffffff for 8/16/32-bit reads).
This value was chosen because it is the same value you would
get if the device was physically unplugged from the slot.
This includes access to PCI memory, I/O space, and PCI config
-space. Interrupts; however, will continued to be delivered.
+space. Interrupts; however, will continue to be delivered.
Detection and recovery are performed with the aid of ppc64
firmware. The programming interfaces in the Linux kernel
diff --git a/Documentation/powerpc/elfnote.rst b/Documentation/powerpc/elfnote.rst
index 06602248621c..3ec8d61e9a33 100644
--- a/Documentation/powerpc/elfnote.rst
+++ b/Documentation/powerpc/elfnote.rst
@@ -8,7 +8,7 @@ capabilities and information which can be used by a bootloader or userland.
Types and Descriptors
---------------------
-The types to be used with the "PowerPC" namesapce are defined in [#f1]_.
+The types to be used with the "PowerPC" namespace are defined in [#f1]_.
1) PPC_ELFNOTE_CAPABILITIES
diff --git a/Documentation/powerpc/firmware-assisted-dump.rst b/Documentation/powerpc/firmware-assisted-dump.rst
index 6c0ae070ba67..e363fc48529a 100644
--- a/Documentation/powerpc/firmware-assisted-dump.rst
+++ b/Documentation/powerpc/firmware-assisted-dump.rst
@@ -207,7 +207,7 @@ Currently the dump will be copied from /proc/vmcore to a new file upon
user intervention. The dump data available through /proc/vmcore will be
in ELF format. Hence the existing kdump infrastructure (kdump scripts)
to save the dump works fine with minor modifications. KDump scripts on
-major Distro releases have already been modified to work seemlessly (no
+major Distro releases have already been modified to work seamlessly (no
user intervention in saving the dump) when FADump is used, instead of
KDump, as dump mechanism.
diff --git a/Documentation/powerpc/kaslr-booke32.rst b/Documentation/powerpc/kaslr-booke32.rst
index 8b259fdfdf03..5681c1d1b65b 100644
--- a/Documentation/powerpc/kaslr-booke32.rst
+++ b/Documentation/powerpc/kaslr-booke32.rst
@@ -38,5 +38,5 @@ bit of the entropy to decide the index of the 64M zone. Then we chose a
kernstart_virt_addr
-To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enable and you
+To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you
want to disable it at runtime, add "nokaslr" to the kernel cmdline.
diff --git a/Documentation/powerpc/mpc52xx.rst b/Documentation/powerpc/mpc52xx.rst
index 30260707c3fe..5243b1763fad 100644
--- a/Documentation/powerpc/mpc52xx.rst
+++ b/Documentation/powerpc/mpc52xx.rst
@@ -34,7 +34,7 @@ To compile/use :
Some remarks:
- The port is named mpc52xxx, and config options are PPC_MPC52xx. The MGT5100
- is not supported, and I'm not sure anyone is interesting in working on it
+ is not supported, and I'm not sure anyone is interested in working on it
so. I didn't took 5xxx because there's apparently a lot of 5xxx that have
nothing to do with the MPC5200. I also included the 'MPC' for the same
reason.
diff --git a/Documentation/powerpc/papr_hcalls.rst b/Documentation/powerpc/papr_hcalls.rst
index 48fcf1255a33..3d553e8a2937 100644
--- a/Documentation/powerpc/papr_hcalls.rst
+++ b/Documentation/powerpc/papr_hcalls.rst
@@ -40,7 +40,7 @@ and any in-arguments for the hcall are provided in registers *r4-r12*. If values
have to be passed through a memory buffer, the data stored in that buffer should be
in Big-endian byte order.
-Once control is returns back to the guest after hypervisor has serviced the
+Once control returns back to the guest after hypervisor has serviced the
'HVCS' instruction the return value of the hcall is available in *r3* and any
out values are returned in registers *r4-r12*. Again like in case of in-arguments,
any out values stored in a memory buffer will be in Big-endian byte order.
@@ -147,7 +147,7 @@ corresponding opcode values please look into the arch specific header [4]_:
| Out: *numBytesRead*
| Return Value: *H_Success, H_Parameter, H_P2, H_P3, H_Hardware*
-Given a DRC Index of an NVDIMM, read N-bytes from the the metadata area
+Given a DRC Index of an NVDIMM, read N-bytes from the metadata area
associated with it, at a specified offset and copy it to provided buffer.
The metadata area stores configuration information such as label information,
bad-blocks etc. The metadata area is located out-of-band of NVDIMM storage
diff --git a/Documentation/powerpc/transactional_memory.rst b/Documentation/powerpc/transactional_memory.rst
index b5b09bf00966..040a20675fd1 100644
--- a/Documentation/powerpc/transactional_memory.rst
+++ b/Documentation/powerpc/transactional_memory.rst
@@ -189,7 +189,7 @@ kernel aborted a transaction:
====================== ================================
These can be checked by the user program's abort handler as TEXASR[0:7]. If
-bit 7 is set, it indicates that the error is consider persistent. For example
+bit 7 is set, it indicates that the error is considered persistent. For example
a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.
GDB
@@ -271,4 +271,4 @@ with these lines:
hrfid and mtmsrd have the same quirk.
-The Linux kernel uses this quirk in it's early exception handling.
+The Linux kernel uses this quirk in its early exception handling.
--
2.17.1
^ permalink raw reply related
* [PATCH] arch/powerpc: Remove unneeded variable: "ret"
From: zuoqilin1 @ 2021-03-26 7:56 UTC (permalink / raw)
To: mpe, benh, paulus; +Cc: zuoqilin, linuxppc-dev, linux-kernel
From: zuoqilin <zuoqilin@yulong.com>
Remove unneeded variable: "ret".
Signed-off-by: zuoqilin <zuoqilin@yulong.com>
---
arch/powerpc/platforms/pseries/cmm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index 45a3a30..95ebb0c 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -475,8 +475,6 @@ static int cmm_reboot_notifier(struct notifier_block *nb,
static int cmm_memory_cb(struct notifier_block *self,
unsigned long action, void *arg)
{
- int ret = 0;
-
switch (action) {
case MEM_GOING_OFFLINE:
mutex_lock(&hotplug_mutex);
@@ -493,7 +491,7 @@ static int cmm_memory_cb(struct notifier_block *self,
break;
}
- return notifier_from_errno(ret);
+ return notifier_from_errno(0);
}
static struct notifier_block cmm_mem_nb = {
--
1.9.1
^ permalink raw reply related
* Re: [PATCH] crypto: nx: fix incorrect kernel-doc comment syntax in files
From: Herbert Xu @ 2021-03-26 9:34 UTC (permalink / raw)
To: Aditya Srivastava
Cc: nayna, corbet, rdunlap, linux-kernel, linuxppc-dev, pfsmorigo,
linux-crypto, leitao, lukas.bulwahn, linux-kernel-mentees, davem,
paulus
In-Reply-To: <20210321123007.15505-1-yashsri421@gmail.com>
On Sun, Mar 21, 2021 at 06:00:07PM +0530, Aditya Srivastava wrote:
> The opening comment mark '/**' is used for highlighting the beginning of
> kernel-doc comments.
> There are certain files in drivers/crypto/nx, which follow this syntax,
> but the content inside does not comply with kernel-doc.
> Such lines were probably not meant for kernel-doc parsing, but are parsed
> due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
> causes unexpected warnings from kernel-doc.
>
> E.g., presence of kernel-doc like comment in the header lines for
> drivers/crypto/nx/nx-sha256.c at header causes these warnings:
> "warning: Function parameter or member 'tfm' not described in 'nx_crypto_ctx_sha256_init'"
> "warning: expecting prototype for SHA(). Prototype was for nx_crypto_ctx_sha256_init() instead"
>
> Similarly for other files too.
>
> Provide a simple fix by replacing such occurrences with general comment
> format, i.e. '/*', to prevent kernel-doc from parsing it.
>
> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
> ---
> * Applies perfectly on next-20210319
>
> drivers/crypto/nx/nx-aes-cbc.c | 2 +-
> drivers/crypto/nx/nx-aes-ccm.c | 2 +-
> drivers/crypto/nx/nx-aes-ctr.c | 2 +-
> drivers/crypto/nx/nx-aes-ecb.c | 2 +-
> drivers/crypto/nx/nx-aes-gcm.c | 2 +-
> drivers/crypto/nx/nx-aes-xcbc.c | 2 +-
> drivers/crypto/nx/nx-sha256.c | 2 +-
> drivers/crypto/nx/nx-sha512.c | 2 +-
> drivers/crypto/nx/nx.c | 2 +-
> drivers/crypto/nx/nx_debugfs.c | 2 +-
> 10 files changed, 10 insertions(+), 10 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH] crypto: vmx: fix incorrect kernel-doc comment syntax in files
From: Herbert Xu @ 2021-03-26 9:34 UTC (permalink / raw)
To: Aditya Srivastava
Cc: nayna, corbet, rdunlap, linuxppc-dev, linux-kernel, pfsmorigo,
linux-crypto, leitao, lukas.bulwahn, linux-kernel-mentees, davem,
paulus
In-Reply-To: <20210320202525.12562-1-yashsri421@gmail.com>
On Sun, Mar 21, 2021 at 01:55:25AM +0530, Aditya Srivastava wrote:
> The opening comment mark '/**' is used for highlighting the beginning of
> kernel-doc comments.
> There are certain files in drivers/crypto/vmx, which follow this syntax,
> but the content inside does not comply with kernel-doc.
> Such lines were probably not meant for kernel-doc parsing, but are parsed
> due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
> causes unexpected warnings from kernel-doc.
>
> E.g., presence of kernel-doc like comment in the header line for
> drivers/crypto/vmx/vmx.c causes this warning by kernel-doc:
>
> "warning: expecting prototype for Routines supporting VMX instructions on the Power 8(). Prototype was for p8_init() instead"
>
> Similarly for other files too.
>
> Provide a simple fix by replacing such occurrences with general comment
> format, i.e. '/*', to prevent kernel-doc from parsing it.
>
> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
> ---
> * Applies perfectly on next-20210319
>
> drivers/crypto/vmx/aes.c | 2 +-
> drivers/crypto/vmx/aes_cbc.c | 2 +-
> drivers/crypto/vmx/aes_ctr.c | 2 +-
> drivers/crypto/vmx/aes_xts.c | 2 +-
> drivers/crypto/vmx/ghash.c | 2 +-
> drivers/crypto/vmx/vmx.c | 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH v3 00/10] Rid W=1 warnings in Crypto
From: Herbert Xu @ 2021-03-26 9:31 UTC (permalink / raw)
To: Lee Jones
Cc: Alexandre Belloni, Aymen Sghaier, Kent Yoder, Ayush Sawal,
Joakim Bech, Nicolas Ferre, Paul Mackerras, Andreas Westin,
Breno Leitão, Atul Gupta, Niklas Hernaeus, M R Gowda,
Horia Geantă, Rohit Maheshwari, Nayna Jain, Manoj Malviya,
Ludovic Desroches, Jonas Linde, Rob Rice, Zaibo Xu, Harsh Jain,
Declan Murphy, Tudor Ambarus, Vinay Kumar Yadav, Shujuan Chen,
Henrique Cerri, Daniele Alessandrelli, linux-arm-kernel,
Jonathan Cameron, linux-kernel, Berne Hebark, linux-crypto,
Jitendra Lulla, Paulo Flabiano Smorigo, linuxppc-dev,
David S. Miller
In-Reply-To: <20210318124422.3200180-1-lee.jones@linaro.org>
On Thu, Mar 18, 2021 at 12:44:12PM +0000, Lee Jones wrote:
> This is set 1 of 2 sets required to fully clean Crypto.
>
> v2: No functional changes since v1.
> v3: Description change and additional struct header fix
>
> Lee Jones (10):
> crypto: hisilicon: sec_drv: Supply missing description for
> 'sec_queue_empty()'s 'queue' param
> crypto: bcm: Fix a whole host of kernel-doc misdemeanours
> crypto: chelsio: chcr_core: Fix some kernel-doc issues
> crypto: ux500: hash: hash_core: Fix worthy kernel-doc headers and
> remove others
> crypto: keembay: ocs-hcu: Fix incorrectly named functions/structs
> crypto: atmel-ecc: Struct headers need to start with keyword 'struct'
> crypto: caam: caampkc: Provide the name of the function and provide
> missing descriptions
> crypto: vmx: Source headers are not good kernel-doc candidates
> crypto: nx: nx-aes-cbc: Repair some kernel-doc problems
> crypto: cavium: nitrox_isr: Demote non-compliant kernel-doc headers
>
> drivers/crypto/atmel-ecc.c | 2 +-
> drivers/crypto/bcm/cipher.c | 7 ++--
> drivers/crypto/bcm/spu.c | 16 ++++-----
> drivers/crypto/bcm/spu2.c | 43 +++++++++++++----------
> drivers/crypto/bcm/util.c | 4 +--
> drivers/crypto/caam/caamalg_qi2.c | 3 ++
> drivers/crypto/caam/caampkc.c | 3 +-
> drivers/crypto/cavium/nitrox/nitrox_isr.c | 4 +--
> drivers/crypto/chelsio/chcr_algo.c | 8 ++---
> drivers/crypto/chelsio/chcr_core.c | 2 +-
> drivers/crypto/hisilicon/sec/sec_drv.c | 1 +
> drivers/crypto/keembay/ocs-hcu.c | 8 ++---
> drivers/crypto/nx/nx-aes-cbc.c | 2 +-
> drivers/crypto/nx/nx.c | 5 +--
> drivers/crypto/nx/nx_debugfs.c | 2 +-
> drivers/crypto/ux500/cryp/cryp.c | 5 +--
> drivers/crypto/ux500/cryp/cryp_core.c | 5 +--
> drivers/crypto/ux500/cryp/cryp_irq.c | 2 +-
> drivers/crypto/ux500/hash/hash_core.c | 15 +++-----
> drivers/crypto/vmx/vmx.c | 2 +-
> 20 files changed, 73 insertions(+), 66 deletions(-)
>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Andreas Westin <andreas.westin@stericsson.com>
> Cc: Atul Gupta <atul.gupta@chelsio.com>
> Cc: Aymen Sghaier <aymen.sghaier@nxp.com>
> Cc: Ayush Sawal <ayush.sawal@chelsio.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Berne Hebark <berne.herbark@stericsson.com>
> Cc: "Breno Leitão" <leitao@debian.org>
> Cc: Daniele Alessandrelli <daniele.alessandrelli@intel.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Declan Murphy <declan.murphy@intel.com>
> Cc: Harsh Jain <harsh@chelsio.com>
> Cc: Henrique Cerri <mhcerri@br.ibm.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: "Horia Geantă" <horia.geanta@nxp.com>
> Cc: Jitendra Lulla <jlulla@chelsio.com>
> Cc: Joakim Bech <joakim.xx.bech@stericsson.com>
> Cc: Jonas Linde <jonas.linde@stericsson.com>
> Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
> Cc: Kent Yoder <yoder1@us.ibm.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-crypto@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> Cc: Manoj Malviya <manojmalviya@chelsio.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: M R Gowda <yeshaswi@chelsio.com>
> Cc: Nayna Jain <nayna@linux.ibm.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Niklas Hernaeus <niklas.hernaeus@stericsson.com>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Paulo Flabiano Smorigo <pfsmorigo@gmail.com>
> Cc: Rob Rice <rob.rice@broadcom.com>
> Cc: Rohit Maheshwari <rohitm@chelsio.com>
> Cc: Shujuan Chen <shujuan.chen@stericsson.com>
> Cc: Tudor Ambarus <tudor.ambarus@microchip.com>
> Cc: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
> Cc: Zaibo Xu <xuzaibo@huawei.com>
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH] soc/fsl: qbman: fix conflicting alignment attributes
From: Arnd Bergmann @ 2021-03-26 8:51 UTC (permalink / raw)
To: Li Yang
Cc: Madalin-cristian Bucur, SoC Team, Lee Jones, Roy Pledge,
YueHaibing, lkml, Scott Wood, Claudiu Manoil, Jakub Kicinski,
linuxppc-dev, Sebastian Andrzej Siewior,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
In-Reply-To: <CADRPPNQJfJ=KmRGkX5Uo6VfWDsihrMUKV7OkQ7jtb3+Byb0RLQ@mail.gmail.com>
On Fri, Mar 26, 2021 at 3:17 AM Li Yang <leoyang.li@nxp.com> wrote:
> On Tue, Mar 23, 2021 at 8:17 AM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > When building with W=1, gcc points out that the __packed attribute
> > on struct qm_eqcr_entry conflicts with the 8-byte alignment
> > attribute on struct qm_fd inside it:
> >
> > drivers/soc/fsl/qbman/qman.c:189:1: error: alignment 1 of 'struct qm_eqcr_entry' is less than 8 [-Werror=packed-not-aligned]
> >
> > I assume that the alignment attribute is the correct one, and
> > that qm_eqcr_entry cannot actually be unaligned in memory,
> > so add the same alignment on the outer struct.
> >
> > Fixes: c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> > drivers/soc/fsl/qbman/qman.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
> > index a1b9be1d105a..fde4edd83c14 100644
> > --- a/drivers/soc/fsl/qbman/qman.c
> > +++ b/drivers/soc/fsl/qbman/qman.c
> > @@ -186,7 +186,7 @@ struct qm_eqcr_entry {
> > __be32 tag;
> > struct qm_fd fd;
> > u8 __reserved3[32];
> > -} __packed;
> > +} __packed __aligned(8);
>
> The EQCR structure is actually aligned on 64-byte from the manual.
> But probably 8 is enough to let the compiler not complain.
The important bit is that all members inside are at most 8-byte long
and naturally aligned, so the compiler can now optimize the accesses
because it can assume that each member can be updated atomically.
Marking a structure as unaligned with the __packed attribute can lead
to rather unoptimized code, which is particularly important when the
structure is mapped as uncached -- accessing it one byte at a time
means you have eight times the latency for a simple read. I think on
arm64, the compiler doesn't actually have to do that, but at least if you
run a 32-bit kernel, the packing would prevent the use of ldrd or ldm
instructions that need an aligned word.
Arnd
^ permalink raw reply
* Re: [PATCH V2 1/5] powerpc/perf: Expose processor pipeline stage cycles using PERF_SAMPLE_WEIGHT_STRUCT
From: Madhavan Srinivasan @ 2021-03-26 8:32 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: ravi.bangoria, Athira Rajeev, peterz, linux-kernel,
linux-perf-users, jolsa, kjain, linuxppc-dev, kan.liang
In-Reply-To: <YFyKw1ezDio0z9yM@kernel.org>
On 3/25/21 6:36 PM, Arnaldo Carvalho de Melo wrote:
> Em Wed, Mar 24, 2021 at 10:05:23AM +0530, Madhavan Srinivasan escreveu:
>> On 3/22/21 8:27 PM, Athira Rajeev wrote:
>>> Performance Monitoring Unit (PMU) registers in powerpc provides
>>> information on cycles elapsed between different stages in the
>>> pipeline. This can be used for application tuning. On ISA v3.1
>>> platform, this information is exposed by sampling registers.
>>> Patch adds kernel support to capture two of the cycle counters
>>> as part of perf sample using the sample type:
>>> PERF_SAMPLE_WEIGHT_STRUCT.
>>>
>>> The power PMU function 'get_mem_weight' currently uses 64 bit weight
>>> field of perf_sample_data to capture memory latency. But following the
>>> introduction of PERF_SAMPLE_WEIGHT_TYPE, weight field could contain
>>> 64-bit or 32-bit value depending on the architexture support for
>>> PERF_SAMPLE_WEIGHT_STRUCT. Patches uses WEIGHT_STRUCT to expose the
>>> pipeline stage cycles info. Hence update the ppmu functions to work for
>>> 64-bit and 32-bit weight values.
>>>
>>> If the sample type is PERF_SAMPLE_WEIGHT, use the 64-bit weight field.
>>> if the sample type is PERF_SAMPLE_WEIGHT_STRUCT, memory subsystem
>>> latency is stored in the low 32bits of perf_sample_weight structure.
>>> Also for CPU_FTR_ARCH_31, capture the two cycle counter information in
>>> two 16 bit fields of perf_sample_weight structure.
>> Changes looks fine to me.
> You mean just the kernel part or can I add your Reviewed-by to all the
> patchset?
Yes, kindly add it, I did review the patchset. My bad, i should have
mentioned it here
or should have replied to the cover letter.
Maddy
>
>> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
>>
>>
>>> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
>>> ---
>>> arch/powerpc/include/asm/perf_event_server.h | 2 +-
>>> arch/powerpc/perf/core-book3s.c | 4 ++--
>>> arch/powerpc/perf/isa207-common.c | 29 +++++++++++++++++++++++++---
>>> arch/powerpc/perf/isa207-common.h | 6 +++++-
>>> 4 files changed, 34 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
>>> index 00e7e671bb4b..112cf092d7b3 100644
>>> --- a/arch/powerpc/include/asm/perf_event_server.h
>>> +++ b/arch/powerpc/include/asm/perf_event_server.h
>>> @@ -43,7 +43,7 @@ struct power_pmu {
>>> u64 alt[]);
>>> void (*get_mem_data_src)(union perf_mem_data_src *dsrc,
>>> u32 flags, struct pt_regs *regs);
>>> - void (*get_mem_weight)(u64 *weight);
>>> + void (*get_mem_weight)(u64 *weight, u64 type);
>>> unsigned long group_constraint_mask;
>>> unsigned long group_constraint_val;
>>> u64 (*bhrb_filter_map)(u64 branch_sample_type);
>>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>>> index 766f064f00fb..6936763246bd 100644
>>> --- a/arch/powerpc/perf/core-book3s.c
>>> +++ b/arch/powerpc/perf/core-book3s.c
>>> @@ -2206,9 +2206,9 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
>>> ppmu->get_mem_data_src)
>>> ppmu->get_mem_data_src(&data.data_src, ppmu->flags, regs);
>>> - if (event->attr.sample_type & PERF_SAMPLE_WEIGHT &&
>>> + if (event->attr.sample_type & PERF_SAMPLE_WEIGHT_TYPE &&
>>> ppmu->get_mem_weight)
>>> - ppmu->get_mem_weight(&data.weight.full);
>>> + ppmu->get_mem_weight(&data.weight.full, event->attr.sample_type);
>>> if (perf_event_overflow(event, &data, regs))
>>> power_pmu_stop(event, 0);
>>> diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
>>> index e4f577da33d8..5dcbdbd54598 100644
>>> --- a/arch/powerpc/perf/isa207-common.c
>>> +++ b/arch/powerpc/perf/isa207-common.c
>>> @@ -284,8 +284,10 @@ void isa207_get_mem_data_src(union perf_mem_data_src *dsrc, u32 flags,
>>> }
>>> }
>>> -void isa207_get_mem_weight(u64 *weight)
>>> +void isa207_get_mem_weight(u64 *weight, u64 type)
>>> {
>>> + union perf_sample_weight *weight_fields;
>>> + u64 weight_lat;
>>> u64 mmcra = mfspr(SPRN_MMCRA);
>>> u64 exp = MMCRA_THR_CTR_EXP(mmcra);
>>> u64 mantissa = MMCRA_THR_CTR_MANT(mmcra);
>>> @@ -296,9 +298,30 @@ void isa207_get_mem_weight(u64 *weight)
>>> mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
>>> if (val == 0 || val == 7)
>>> - *weight = 0;
>>> + weight_lat = 0;
>>> else
>>> - *weight = mantissa << (2 * exp);
>>> + weight_lat = mantissa << (2 * exp);
>>> +
>>> + /*
>>> + * Use 64 bit weight field (full) if sample type is
>>> + * WEIGHT.
>>> + *
>>> + * if sample type is WEIGHT_STRUCT:
>>> + * - store memory latency in the lower 32 bits.
>>> + * - For ISA v3.1, use remaining two 16 bit fields of
>>> + * perf_sample_weight to store cycle counter values
>>> + * from sier2.
>>> + */
>>> + weight_fields = (union perf_sample_weight *)weight;
>>> + if (type & PERF_SAMPLE_WEIGHT)
>>> + weight_fields->full = weight_lat;
>>> + else {
>>> + weight_fields->var1_dw = (u32)weight_lat;
>>> + if (cpu_has_feature(CPU_FTR_ARCH_31)) {
>>> + weight_fields->var2_w = P10_SIER2_FINISH_CYC(mfspr(SPRN_SIER2));
>>> + weight_fields->var3_w = P10_SIER2_DISPATCH_CYC(mfspr(SPRN_SIER2));
>>> + }
>>> + }
>>> }
>>> int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp, u64 event_config1)
>>> diff --git a/arch/powerpc/perf/isa207-common.h b/arch/powerpc/perf/isa207-common.h
>>> index 1af0e8c97ac7..fc30d43c4d0c 100644
>>> --- a/arch/powerpc/perf/isa207-common.h
>>> +++ b/arch/powerpc/perf/isa207-common.h
>>> @@ -265,6 +265,10 @@
>>> #define ISA207_SIER_DATA_SRC_SHIFT 53
>>> #define ISA207_SIER_DATA_SRC_MASK (0x7ull << ISA207_SIER_DATA_SRC_SHIFT)
>>> +/* Bits in SIER2/SIER3 for Power10 */
>>> +#define P10_SIER2_FINISH_CYC(sier2) (((sier2) >> (63 - 37)) & 0x7fful)
>>> +#define P10_SIER2_DISPATCH_CYC(sier2) (((sier2) >> (63 - 13)) & 0x7fful)
>>> +
>>> #define P(a, b) PERF_MEM_S(a, b)
>>> #define PH(a, b) (P(LVL, HIT) | P(a, b))
>>> #define PM(a, b) (P(LVL, MISS) | P(a, b))
>>> @@ -278,6 +282,6 @@ int isa207_get_alternatives(u64 event, u64 alt[], int size, unsigned int flags,
>>> const unsigned int ev_alt[][MAX_ALT]);
>>> void isa207_get_mem_data_src(union perf_mem_data_src *dsrc, u32 flags,
>>> struct pt_regs *regs);
>>> -void isa207_get_mem_weight(u64 *weight);
>>> +void isa207_get_mem_weight(u64 *weight, u64 type);
>>> #endif
^ permalink raw reply
* [PATCH] powerpc/mm/book3s64: Use the correct storage key value when calling H_PROTECT
From: Aneesh Kumar K.V @ 2021-03-26 7:07 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, Murilo Opsfelder Araujo
H_PROTECT expect the flag value to include
flags: AVPN, pp0, pp1, pp2, key0-key4, Noexec, CMO Option flags
This patch updates hpte_updatepp() to fetch the storage key value from the linux page
table and use the same in H_PROTECT hcall.
native_hpte_updatepp() is not updated because the kernel doesn't clear the existing
storage key value there. The kernel also doesn't use hpte_updatepp() callback for
updating storage keys.
This fixes the below kernel crash observed with KUAP enabled.
BUG: Unable to handle kernel data access on write at 0xc009fffffc440000
Faulting instruction address: 0xc0000000000b7030
Key fault AMR: 0xfcffffffffffffff IAMR: 0xc0000077bc498100
Found HPTE: v = 0x40070adbb6fffc05 r = 0x1ffffffffff1194
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
.........
CFAR: c000000000010100 DAR: c009fffffc440000 DSISR: 02200000 IRQMASK: 0
..........
NIP [c0000000000b7030] memset+0x68/0x104
LR [c0000000003ef00c] pcpu_alloc+0x54c/0xb50
Call Trace:
[c00000001c7534f0] [c0000000003ef01c] pcpu_alloc+0x55c/0xb50 (unreliable)
[c00000001c753600] [c0000000008bb214] blk_stat_alloc_callback+0x94/0x150
[c00000001c753650] [c0000000008b7a04] blk_mq_init_allocated_queue+0x64/0x560
[c00000001c7536b0] [c0000000008b8024] blk_mq_init_queue+0x54/0xb0
[c00000001c7536e0] [c000000000b87650] scsi_mq_alloc_queue+0x30/0xa0
[c00000001c753710] [c000000000b88b2c] scsi_alloc_sdev+0x1cc/0x300
[c00000001c7537b0] [c000000000b897b0] scsi_probe_and_add_lun+0xb50/0x1020
[c00000001c753950] [c000000000b8a35c] __scsi_scan_target+0x17c/0x790
[c00000001c753a80] [c000000000b8ab90] scsi_scan_channel+0x90/0xe0
[c00000001c753ad0] [c000000000b8ae48] scsi_scan_host_selected+0x148/0x1f0
[c00000001c753b60] [c000000000b8b31c] do_scan_async+0x2c/0x2a0
[c00000001c753be0] [c000000000187a18] async_run_entry_fn+0x78/0x220
[c00000001c753c70] [c000000000176a74] process_one_work+0x264/0x540
[c00000001c753d10] [c000000000177338] worker_thread+0xa8/0x600
[c00000001c753da0] [c0000000001807b0] kthread+0x190/0x1a0
[c00000001c753e10] [c00000000000d8f0] ret_from_kernel_thread+0x5c/0x6c
With KUAP enabled the kernel uses storage key 3 for all its translations. But as
shown by the debug print, in this specific case we have the hash page table
entry created with key value 0.
[ 2.249497] Found HPTE: v = 0x40070adbb6fffc05 r = 0x1ffffffffff1194
and DSISR indicates a key fault.
This can happen due to parallel fault on the same EA by different CPUs
CPU 0 CPU 1
fault on X
H_PAGE_BUSY set
fault on X
finish fault handling and
clear H_PAGE_BUSY
check for H_PAGE_BUSY
continue with fault handling.
This implies CPU1 will end up calling hpte_updatepp for address X
and the kernel updated the hash pte entry with key 0
Fixes: d94b827e89dc ("powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation")
Debugged-by: Michael Ellerman <mpe@ellerman.id.au>
Reported-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
Similar change for bolted hash pte entries was done by
https://lore.kernel.org/linuxppc-dev/20210211135130.3474832-2-mpe@ellerman.id.au/
arch/powerpc/platforms/pseries/lpar.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 764170fdb0f7..3805519a6469 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -887,7 +887,8 @@ static long pSeries_lpar_hpte_updatepp(unsigned long slot,
want_v = hpte_encode_avpn(vpn, psize, ssize);
- flags = (newpp & 7) | H_AVPN;
+ flags = (newpp & (HPTE_R_PP | HPTE_R_N | HPTE_R_KEY_LO)) | H_AVPN;
+ flags |= (newpp & HPTE_R_KEY_HI) >> 48;
if (mmu_has_feature(MMU_FTR_KERNEL_RO))
/* Move pp0 into bit 8 (IBM 55) */
flags |= (newpp & HPTE_R_PP0) >> 55;
--
2.30.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox