[PATCH v9 1/7] powerpc/pseries: Define common functions for RTAS sequence calls

2025-03-15 Thread Haren Myneni
The RTAS call can be normal where retrieves the data form the
hypervisor once or sequence based RTAS call which has to
issue multiple times until the complete data is obtained. For
some of these sequence RTAS calls, the OS should not interleave
calls with different input until the sequence is completed.
The data is collected for each call and copy to the buffer
for the entire sequence during ioctl() handle and then expose
this buffer to the user space with read() handle.

One such sequence RTAS call is ibm,get-vpd and its support is
already included in the current code. To add the similar support
for other sequence based calls, move the common functions in to
separate file and update papr_rtas_sequence struct with the
following callbacks so that RTAS call specific code will be
defined and executed to complete the sequence.

struct papr_rtas_sequence {
int error;
void params;
void (*begin) (struct papr_rtas_sequence *);
void (*end) (struct papr_rtas_sequence *);
const char * (*work) (struct papr_rtas_sequence *, size_t *);
};

params: Input parameters used to pass for RTAS call.
Begin:  RTAS call specific function to initialize data
including work area allocation.
End:RTAS call specific function to free up resources
(free work area) after the sequence is completed.
Work:   The actual RTAS call specific function which collects
the data from the hypervisor.

Signed-off-by: Haren Myneni 
---
 arch/powerpc/platforms/pseries/Makefile   |   2 +-
 .../platforms/pseries/papr-rtas-common.c  | 311 
 .../platforms/pseries/papr-rtas-common.h  |  61 +++
 arch/powerpc/platforms/pseries/papr-vpd.c | 351 +++---
 4 files changed, 417 insertions(+), 308 deletions(-)
 create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.c
 create mode 100644 arch/powerpc/platforms/pseries/papr-rtas-common.h

diff --git a/arch/powerpc/platforms/pseries/Makefile 
b/arch/powerpc/platforms/pseries/Makefile
index 7bf506f6b8c8..697c216b70dc 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
 
 obj-y  := lpar.o hvCall.o nvram.o reconfig.o \
   of_helpers.o rtas-work-area.o papr-sysparm.o \
-  papr-vpd.o \
+  papr-rtas-common.o papr-vpd.o \
   setup.o iommu.o event_sources.o ras.o \
   firmware.o power.o dlpar.o mobility.o rng.o \
   pci.o pci_dlpar.o eeh_pseries.o msi.o \
diff --git a/arch/powerpc/platforms/pseries/papr-rtas-common.c 
b/arch/powerpc/platforms/pseries/papr-rtas-common.c
new file mode 100644
index ..4b9c0bbd4fb8
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/papr-rtas-common.c
@@ -0,0 +1,311 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) "papr-common: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "papr-rtas-common.h"
+
+/*
+ * Sequence based RTAS HCALL has to issue multiple times to retrieve
+ * complete data from the hypervisor. For some of these RTAS calls,
+ * the OS should not interleave calls with different input until the
+ * sequence is completed. So data is collected for these calls during
+ * ioctl handle and export to user space with read() handle.
+ * This file provides common functions needed for such sequence based
+ * RTAS calls Ex: ibm,get-vpd and ibm,get-indices.
+ */
+
+bool papr_rtas_blob_has_data(const struct papr_rtas_blob *blob)
+{
+   return blob->data && blob->len;
+}
+
+void papr_rtas_blob_free(const struct papr_rtas_blob *blob)
+{
+   if (blob) {
+   kvfree(blob->data);
+   kfree(blob);
+   }
+}
+
+/**
+ * papr_rtas_blob_extend() - Append data to a &struct papr_rtas_blob.
+ * @blob: The blob to extend.
+ * @data: The new data to append to @blob.
+ * @len:  The length of @data.
+ *
+ * Context: May sleep.
+ * Return: -ENOMEM on allocation failure, 0 otherwise.
+ */
+static int papr_rtas_blob_extend(struct papr_rtas_blob *blob,
+   const char *data, size_t len)
+{
+   const size_t new_len = blob->len + len;
+   const size_t old_len = blob->len;
+   const char *old_ptr = blob->data;
+   char *new_ptr;
+
+   new_ptr = kvrealloc(old_ptr, new_len, GFP_KERNEL_ACCOUNT);
+   if (!new_ptr)
+   return -ENOMEM;
+
+   memcpy(&new_ptr[old_len], data, len);
+   blob->data = new_ptr;
+   blob->len = new_len;
+   return 0;
+}
+
+/**
+ * papr_rtas_blob_generate() - Construct a new &struct papr_rtas_blob.
+ * @seq: work function of the caller that is called to obtain
+ *   data with the caller RTAS call.
+ *
+ * The @work callback is invoked until it returns NULL. @seq is
+ * passed to @work in its first argument on each c

[PATCH v9 6/7] powerpc/pseries: Add papr-platform-dump character driver for dump retrieval

2025-03-15 Thread Haren Myneni
ibm,platform-dump RTAS call in combination with writable mapping
/dev/mem is issued to collect platform dump from the hypervisor
and may need multiple calls to get the complete dump. The current
implementation uses rtas_platform_dump() API provided by librtas
library to issue these RTAS calls. But /dev/mem access by the
user space is prohibited under system lockdown.

The solution should be to restrict access to RTAS function in user
space and provide kernel interfaces to collect dump. This patch
adds papr-platform-dump character driver and expose standard
interfaces such as open / ioctl/ read to user space in ways that
are compatible with lockdown.

PAPR (7.3.3.4.1 ibm,platform-dump) provides a method to obtain
the complete dump:
- Each dump will be identified by ID called dump tag.
- A sequence of RTAS calls have to be issued until retrieve the
  complete dump. The hypervisor expects the first RTAS call with
  the sequence 0 and the subsequent calls with the sequence
  number returned from the previous calls.
- The hypervisor returns "dump complete" status once the complete
  dump is retrieved. But expects one more RTAS call from the
  partition with the NULL buffer to invalidate dump which means
  the dump will be removed in the hypervisor.
- Sequence of calls are allowed with different dump IDs at the
  same time but not with the same dump ID.

Expose these interfaces to user space with a /dev/papr-platform-dump
character device using the following programming model:

   int devfd = open("/dev/papr-platform-dump", O_RDONLY);
   int fd = ioctl(devfd,PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE, &dump_id)
- Restrict user space to access with the same dump ID.
  Typically we do not expect user space requests the dump
  again for the same dump ID.
   char *buf = malloc(size);
   length = read(fd, buf, size);
- size should be minimum 1K based on PAPR and  <= 4K based
  on RTAS work area size. It will be restrict to RTAS work
  area size. Using 4K work area based on the current
  implementation in librtas library
- Each read call issue RTAS call to get the data based on
  the size requirement and returns bytes returned from the
  hypervisor
- If the previous call returns dump complete status, the
  next read returns 0 like EOF.
   ret = ioctl(PAPR_PLATFORM_DUMP_IOC_INVALIDATE, &dump_id)
- RTAS call with NULL buffer to invalidates the dump.

The read API should use the file descriptor obtained from ioctl
based on dump ID so that gets dump contents for the corresponding
dump ID. Implemented support in librtas (rtas_platform_dump()) for
this new ABI to support system lockdown.

Signed-off-by: Haren Myneni 
---
 .../userspace-api/ioctl/ioctl-number.rst  |   2 +
 .../include/uapi/asm/papr-platform-dump.h |  15 +
 arch/powerpc/platforms/pseries/Makefile   |   1 +
 .../platforms/pseries/papr-platform-dump.c| 411 ++
 4 files changed, 429 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/papr-platform-dump.h
 create mode 100644 arch/powerpc/platforms/pseries/papr-platform-dump.c

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
b/Documentation/userspace-api/ioctl/ioctl-number.rst
index f9332b634116..1b661436aa7c 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -365,6 +365,8 @@ Code  Seq#Include File  
 Comments
  

 0xB2  03-05 arch/powerpc/include/uapi/asm/papr-indices.h 
powerpc/pseries indices API
  

+0xB2  06-07 arch/powerpc/include/uapi/asm/papr-platform-dump.h   
powerpc/pseries Platform Dump API
+ 

 0xB3  00 linux/mmc/ioctl.h
 0xB4  00-0F  linux/gpio.h

 0xB5  00-0F  uapi/linux/rpmsg.h  

diff --git a/arch/powerpc/include/uapi/asm/papr-platform-dump.h 
b/arch/powerpc/include/uapi/asm/papr-platform-dump.h
new file mode 100644
index ..a1d89c290dab
--- /dev/null
+++ b/arch/powerpc/include/uapi/asm/papr-platform-dump.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_PAPR_PLATFORM_DUMP_H_
+#define _UAPI_PAPR_PLATFORM_DUMP_H_
+
+#include 
+#include 
+
+/*
+ * ioctl for /dev/papr-platform-dump. Returns a platform-dump handle fd
+ * corresponding to dump tag.
+ */
+#define PAPR_PLATFORM_DUMP_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 6, 
__u64)
+#define PAPR_PLATFORM_DUMP_IOC_INVALIDATE_IOW(PAPR_MISCDEV_IOC_ID, 7, 
__u64)
+
+#endif /* _UAPI_PAPR_

[PATCH v9 7/7] powerpc/pseries: Add a char driver for physical-attestation RTAS

2025-03-15 Thread Haren Myneni
The RTAS call ibm,physical-attestation is used to retrieve
information about the trusted boot state of the firmware and
hypervisor on the system, and also Trusted Platform Modules (TPM)
data if the system is TCG 2.0 compliant.

This RTAS interface expects the caller to define different command
structs such as RetrieveTPMLog, RetrievePlatformCertificat and etc,
in a work area with a maximum size of 4K bytes and the response
buffer will be returned in the same work area.

The current implementation of this RTAS function is in the user
space but allocation of the work area is restricted with the system
lockdown. So this patch implements this RTAS function in the kernel
and expose to the user space with open/ioctl/read interfaces.

PAPR (2.13+ 21.3 ibm,physical-attestation) defines RTAS function:
- Pass the command struct to obtain the response buffer for the
  specific command.
- This RTAS function is sequence RTAS call and has to issue RTAS
  call multiple times to get the complete response buffer (max 64K).
  The hypervisor expects the first RTAS call with the sequence 1 and
  the subsequent calls with the sequence number returned from the
  previous calls.

Expose these interfaces to user space with a
/dev/papr-physical-attestation character device using the following
programming model:

 int devfd = open("/dev/papr-physical-attestation");
 int fd = ioctl(devfd, PAPR_PHY_ATTEST_IOC_HANDLE,
  struct papr_phy_attest_io_block);
 - The user space defines the command struct and requests the
   response for any command.
 - Obtain the complete response buffer and returned the buffer as
   blob to the command specific FD.
 size = read(fd, buf, len);
 - Can retrieve the response buffer once or multiple times until the
   end of BLOB buffer.

Implemented this new kernel ABI support in librtas library for
system lockdown

Signed-off-by: Haren Myneni 
---
 .../userspace-api/ioctl/ioctl-number.rst  |   2 +
 arch/powerpc/include/asm/rtas.h   |   1 +
 .../uapi/asm/papr-physical-attestation.h  |  31 ++
 arch/powerpc/kernel/rtas.c|   2 +-
 arch/powerpc/platforms/pseries/Makefile   |   2 +-
 .../platforms/pseries/papr-phy-attest.c   | 288 ++
 6 files changed, 324 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/include/uapi/asm/papr-physical-attestation.h
 create mode 100644 arch/powerpc/platforms/pseries/papr-phy-attest.c

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 1b661436aa7c..504d059970d4 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -367,6 +367,8 @@ Code  Seq#Include File  
 Comments
  

 0xB2  06-07 arch/powerpc/include/uapi/asm/papr-platform-dump.h   
powerpc/pseries Platform Dump API
  

+0xB2  08  arch/powerpc/include/uapi/asm/papr-physical-attestation.h  
powerpc/pseries Physical Attestation API
+ 

 0xB3  00 linux/mmc/ioctl.h
 0xB4  00-0F  linux/gpio.h

 0xB5  00-0F  uapi/linux/rpmsg.h  

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index fcd822f0e1d7..75fa0293c508 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -518,6 +518,7 @@ extern struct mutex rtas_ibm_get_vpd_lock;
 extern struct mutex rtas_ibm_get_indices_lock;
 extern struct mutex rtas_ibm_set_dynamic_indicator_lock;
 extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock;
+extern struct mutex rtas_ibm_physical_attestation_lock;
 
 #define GLOBAL_INTERRUPT_QUEUE 9005
 
diff --git a/arch/powerpc/include/uapi/asm/papr-physical-attestation.h 
b/arch/powerpc/include/uapi/asm/papr-physical-attestation.h
new file mode 100644
index ..ea746837bb9a
--- /dev/null
+++ b/arch/powerpc/include/uapi/asm/papr-physical-attestation.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_PAPR_PHYSICAL_ATTESTATION_H_
+#define _UAPI_PAPR_PHYSICAL_ATTESTATION_H_
+
+#include 
+#include 
+#include 
+
+#define PAPR_PHYATTEST_MAX_INPUT 4084 /* Max 4K buffer: 4K-12 */
+
+/*
+ * Defined in PAPR 2.13+ 21.6 Attestation Command Structures.
+ * User space pass this struct and the max size should be 4K.
+ */
+struct papr_phy_attest_io_block {
+   __u8 version;
+   __u8 command;
+   __u8 TCG_major_ver;
+   __u8 TCG_minor_ver;
+   __be32 length;
+   __be32 correlator;
+   __u8 payload[PAPR_PHYATTEST_MAX_INPUT];
+};
+

[PATCH v9 5/7] powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support

2025-03-15 Thread Haren Myneni
The RTAS call ibm,get-dynamic-sensor-state is used to get the
sensor state identified by the location code and the sensor
token. The librtas library provides an API
rtas_get_dynamic_sensor() which uses /dev/mem access for work
area allocation but is restricted under system lockdown.

This patch provides an interface with new ioctl
 PAPR_DYNAMIC_SENSOR_IOC_GET to the papr-indices character
driver which executes this HCALL and copies the sensor state
in the user specified ioctl buffer.

Refer PAPR 7.3.19 ibm,get-dynamic-sensor-state for more
information on this RTAS call.
- User input parameters to the RTAS call: location code string
  and the sensor token

Expose these interfaces to user space with a /dev/papr-indices
character device using the following programming model:
 int fd = open("/dev/papr-indices", O_RDWR);
 int ret = ioctl(fd, PAPR_DYNAMIC_SENSOR_IOC_GET,
struct papr_indices_io_block)
  - The user space specifies input parameters in
papr_indices_io_block struct
  - Returned state for the specified sensor is copied to
papr_indices_io_block.dynamic_param.state

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/rtas.h   |  1 +
 arch/powerpc/kernel/rtas.c|  2 +-
 arch/powerpc/platforms/pseries/papr-indices.c | 67 +++
 3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 2da52f59e4c6..fcd822f0e1d7 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -517,6 +517,7 @@ extern unsigned long rtas_rmo_buf;
 extern struct mutex rtas_ibm_get_vpd_lock;
 extern struct mutex rtas_ibm_get_indices_lock;
 extern struct mutex rtas_ibm_set_dynamic_indicator_lock;
+extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock;
 
 #define GLOBAL_INTERRUPT_QUEUE 9005
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 88fa416730af..a4848e7f248e 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -92,12 +92,12 @@ struct rtas_function {
  * Per-function locks for sequence-based RTAS functions.
  */
 static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock);
-static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock);
 static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock);
 static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock);
 DEFINE_MUTEX(rtas_ibm_get_vpd_lock);
 DEFINE_MUTEX(rtas_ibm_get_indices_lock);
 DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock);
+DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock);
 
 static struct rtas_function rtas_function_table[] __ro_after_init = {
[RTAS_FNIDX__CHECK_EXCEPTION] = {
diff --git a/arch/powerpc/platforms/pseries/papr-indices.c 
b/arch/powerpc/platforms/pseries/papr-indices.c
index c46b728d5f47..3c7545591c45 100644
--- a/arch/powerpc/platforms/pseries/papr-indices.c
+++ b/arch/powerpc/platforms/pseries/papr-indices.c
@@ -371,6 +371,67 @@ static long papr_dynamic_indicator_ioc_set(struct 
papr_indices_io_block __user *
return ret;
 }
 
+/**
+ * papr_dynamic_sensor_ioc_get - ibm,get-dynamic-sensor-state RTAS Call
+ * PAPR 2.13 7.3.19
+ *
+ * @ubuf: Input parameters to RTAS call such as sensor token
+ *Copies the state in user space buffer.
+ *
+ *
+ * Returns success or -errno.
+ */
+
+static long papr_dynamic_sensor_ioc_get(struct papr_indices_io_block __user 
*ubuf)
+{
+   struct papr_indices_io_block kbuf;
+   struct rtas_work_area *work_area;
+   s32 fwrc, token, ret;
+   u32 rets;
+
+   token = rtas_function_token(RTAS_FN_IBM_GET_DYNAMIC_SENSOR_STATE);
+   if (token == RTAS_UNKNOWN_SERVICE)
+   return -ENOENT;
+
+   mutex_lock(&rtas_ibm_get_dynamic_sensor_state_lock);
+   work_area = papr_dynamic_indice_buf_from_user(ubuf, &kbuf);
+   if (IS_ERR(work_area)) {
+   ret = PTR_ERR(work_area);
+   goto out;
+   }
+
+   do {
+   fwrc = rtas_call(token, 2, 2, &rets,
+   kbuf.dynamic_param.token,
+   rtas_work_area_phys(work_area));
+   } while (rtas_busy_delay(fwrc));
+
+   rtas_work_area_free(work_area);
+
+   switch (fwrc) {
+   case RTAS_SUCCESS:
+   if (put_user(rets, &ubuf->dynamic_param.state))
+   ret = -EFAULT;
+   else
+   ret = 0;
+   break;
+   case RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR:  /* No such indicator */
+   ret = -EOPNOTSUPP;
+   break;
+   default:
+   pr_err("unexpected ibm,get-dynamic-sensor result %d\n",
+   fwrc);
+   fallthrough;
+   case RTAS_HARDWARE_ERROR:   /* Hardware/platform error */
+   ret = -EIO;
+   break;
+   }
+
+out:
+   mutex_unlock(&rtas_ibm_get_dynamic_sensor_state_lock);
+   return ret;
+}
+
 /*
  * Top-level ioctl han

[PATCH v2 06/13] nios2: move pr_debug() about memory start and end to setup_arch()

2025-03-15 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" 

This will help with pulling out memblock_free_all() to the generic
code and reducing code duplication in arch::mem_init().

Signed-off-by: Mike Rapoport (Microsoft) 
---
 arch/nios2/kernel/setup.c | 2 ++
 arch/nios2/mm/init.c  | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
index da122a5fa43b..a4cffbfc1399 100644
--- a/arch/nios2/kernel/setup.c
+++ b/arch/nios2/kernel/setup.c
@@ -149,6 +149,8 @@ void __init setup_arch(char **cmdline_p)
memory_start = memblock_start_of_DRAM();
memory_end = memblock_end_of_DRAM();
 
+   pr_debug("%s: start=%lx, end=%lx\n", __func__, memory_start, 
memory_end);
+
setup_initial_init_mm(_stext, _etext, _edata, _end);
init_task.thread.kregs = &fake_regs;
 
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c
index a2278485de19..aa692ad30044 100644
--- a/arch/nios2/mm/init.c
+++ b/arch/nios2/mm/init.c
@@ -65,8 +65,6 @@ void __init mem_init(void)
unsigned long end_mem   = memory_end; /* this must not include
kernel stack at top */
 
-   pr_debug("mem_init: start=%lx, end=%lx\n", memory_start, memory_end);
-
end_mem &= PAGE_MASK;
high_memory = __va(end_mem);
 
-- 
2.47.2




[PATCH 10/13] arch, mm: set high_memory in free_area_init()

2025-03-15 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" 

high_memory defines upper bound on the directly mapped memory.
This bound is defined by the beginning of ZONE_HIGHMEM when a system has
high memory and by the end of memory otherwise.

All this is known to generic memory management initialization code that
can set high_memory while initializing core mm structures.

Remove per-architecture calculation of high_memory and add a generic
version to free_area_init().

Signed-off-by: Mike Rapoport (Microsoft) 
---
 arch/alpha/mm/init.c   |  1 -
 arch/arc/mm/init.c |  2 --
 arch/arm/mm/mmu.c  |  2 --
 arch/arm/mm/nommu.c|  1 -
 arch/arm64/mm/init.c   |  2 --
 arch/csky/mm/init.c|  1 -
 arch/hexagon/mm/init.c |  6 --
 arch/loongarch/kernel/numa.c   |  1 -
 arch/loongarch/mm/init.c   |  2 --
 arch/m68k/mm/init.c|  2 --
 arch/m68k/mm/mcfmmu.c  |  1 -
 arch/m68k/mm/motorola.c|  2 --
 arch/m68k/sun3/config.c|  1 -
 arch/microblaze/mm/init.c  |  2 --
 arch/mips/mm/init.c|  2 --
 arch/nios2/mm/init.c   |  6 --
 arch/openrisc/mm/init.c|  2 --
 arch/parisc/mm/init.c  |  1 -
 arch/powerpc/kernel/setup-common.c |  1 -
 arch/riscv/mm/init.c   |  1 -
 arch/s390/mm/init.c|  2 --
 arch/sh/mm/init.c  |  7 ---
 arch/sparc/mm/init_32.c|  1 -
 arch/sparc/mm/init_64.c|  2 --
 arch/um/kernel/um_arch.c   |  1 -
 arch/x86/kernel/setup.c|  2 --
 arch/x86/mm/init_32.c  |  3 ---
 arch/x86/mm/numa_32.c  |  3 ---
 arch/xtensa/mm/init.c  |  2 --
 mm/memory.c|  8 
 mm/mm_init.c   | 23 +++
 mm/nommu.c |  2 --
 32 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index ec0eeae9c653..3ab2d2f3c917 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -276,7 +276,6 @@ srm_paging_stop (void)
 void __init
 mem_init(void)
 {
-   high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
 }
 
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 7ef883d58dc1..05025122e965 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -150,8 +150,6 @@ void __init setup_arch_memory(void)
 */
max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
 
-   high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
-
arch_pfn_offset = min(min_low_pfn, min_high_pfn);
kmap_init();
 #endif /* CONFIG_HIGHMEM */
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index f02f872ea8a9..e492d58a0386 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1250,8 +1250,6 @@ void __init adjust_lowmem_bounds(void)
 
arm_lowmem_limit = lowmem_limit;
 
-   high_memory = __va(arm_lowmem_limit - 1) + 1;
-
if (!memblock_limit)
memblock_limit = arm_lowmem_limit;
 
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 1a8f6914ee59..65903ed5e80d 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -146,7 +146,6 @@ void __init adjust_lowmem_bounds(void)
phys_addr_t end;
adjust_lowmem_bounds_mpu();
end = memblock_end_of_DRAM();
-   high_memory = __va(end - 1) + 1;
memblock_set_current_limit(end);
 }
 
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 9c0b8d9558fc..a48fcccd67fa 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -314,8 +314,6 @@ void __init arm64_memblock_init(void)
}
 
early_init_fdt_scan_reserved_mem();
-
-   high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
 }
 
 void __init bootmem_init(void)
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index ba6694d6170a..a22801aa503a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -47,7 +47,6 @@ void __init mem_init(void)
 #ifdef CONFIG_HIGHMEM
unsigned long tmp;
 #endif
-   high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
memblock_free_all();
 
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index 508bb6a8dcc9..d412c2314509 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -100,12 +100,6 @@ static void __init paging_init(void)
 * initial kernel segment table's physical address.
 */
init_mm.context.ptbase = __pa(init_mm.pgd);
-
-   /*
-* Start of high memory area.  Will probably need something more
-* fancy if we...  get more fancy.
-*/
-   high_memory = (void *)((bootmem_lastpg + 1) << PAGE_SHIFT);
 }
 
 #ifndef DMA_RESERVE
diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c
index 84fe7f854820..8eb489725b1a 100644
--- a/arch/loongarch/kernel/numa.c
+++ b/arch/loongarch/kernel/numa.c
@@ -389

Re: [Kernel 6.12.17] [PowerPC e5500] KVM HV compilation error

2025-03-15 Thread Greg KH
On Wed, Mar 05, 2025 at 03:54:06PM +0100, Paolo Bonzini wrote:
> On Wed, Mar 5, 2025 at 3:19 PM Greg KH  wrote:
> > On Wed, Mar 05, 2025 at 03:14:13PM +0100, Christian Zigotzky wrote:
> > > Hi All,
> > >
> > > The stable long-term kernel 6.12.17 cannot compile with KVM HV support 
> > > for e5500 PowerPC machines anymore.
> > >
> > > Bug report: https://github.com/chzigotzky/kernels/issues/6
> > >
> > > Kernel config: 
> > > https://github.com/chzigotzky/kernels/blob/6_12/configs/x5000_defconfig
> > >
> > > Error messages:
> > >
> > > arch/powerpc/kvm/e500_mmu_host.c: In function 'kvmppc_e500_shadow_map':
> > > arch/powerpc/kvm/e500_mmu_host.c:447:9: error: implicit declaration of 
> > > function '__kvm_faultin_pfn' [-Werror=implicit-function-declaration]
> > >pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page);
> > >  ^
> > >   CC  kernel/notifier.o
> > > arch/powerpc/kvm/e500_mmu_host.c:500:2: error: implicit declaration of 
> > > function 'kvm_release_faultin_page'; did you mean 'kvm_read_guest_page'? 
> > > [-Werror=implicit-function-declaration]
> > >   kvm_release_faultin_page(kvm, page, !!ret, writable);
> > >
> > > After that, I compiled it without KVM HV support.
> > >
> > > Kernel config: 
> > > https://github.com/chzigotzky/kernels/blob/6_12/configs/e5500_defconfig
> > >
> > > Please check the error messages.
> >
> > Odd, what commit caused this problem?
> 
> 48fe216d7db6b651972c1c1d8e3180cd699971b0
> 
> > Any hint as to what commit is missing to fix it?
> 
> A big-ass 90 patch series. __kvm_faultin_pfn and
> kvm_release_faultin_page were introduced in 6.13, as part of a big
> revamp of how KVM does page faults on all architectures.
> 
> Just revert all this crap and apply the version that I've just sent
> (https://lore.kernel.org/stable/20250305144938.212918-1-pbonz...@redhat.com/):
> 
> commit 48fe216d7db6b651972c1c1d8e3180cd699971b0
> KVM: e500: always restore irqs
> 
> commit 833f69be62ac366b5c23b4a6434389e470dd5c7f
> KVM: PPC: e500: Use __kvm_faultin_pfn() to handle page faults
> Message-ID: <20241010182427.1434605-55-sea...@google.com>
> Stable-dep-of: 87ecfdbc699c ("KVM: e500: always restore irqs")
> 
> commit f2623aec7fdc2675667042c85f87502c9139c098
> KVM: PPC: e500: Mark "struct page" pfn accessed before dropping mmu_lock
> Message-ID: <20241010182427.1434605-54-sea...@google.com>
> Stable-dep-of: 87ecfdbc699c ("KVM: e500: always restore irqs")
> 
> commit dec857329fb9a66a5bce4f9db14c97ef64725a32
> KVM: PPC: e500: Mark "struct page" dirty in kvmppc_e500_shadow_map()
> Message-ID: <20241010182427.1434605-53-sea...@google.com>
> Stable-dep-of: 87ecfdbc699c ("KVM: e500: always restore irqs")
> 
> And this, ladies and gentlemen, is why I always include the apparently
> silly Message-ID trailer. Don't you just love how someone, whether
> script or human, cherry picked patches 53-55 without even wondering
> what was in the 52 before. I'm not sure if it'd be worse for it to be
> a human or a script... because if it's a script, surely the same level
> of sophistication could have been put into figuring out whether the
> thing even COMPILES.
> 
> Sasha, this wins the prize for most ridiculous automatic backport
> ever. Please stop playing maintainer if you can't be bothered to read
> the commit messages for random stuff that you apply.

Sasha, I thought we weren't taking any kvm patches that were not
explicitly tagged for stable?  The filter list says that...

Anyway, let me go revert these, thanks for the report.

thanks,

greg k-h



[PATCH] dt-bindings: powerpc: Convert fsl/pmc.txt to YAML

2025-03-15 Thread J . Neuschäfer via B4 Relay
From: "J. Neuschäfer" 

This patch rewrites pmc.txt into YAML format. Descriptive texts are
expanded or shortened in a few places to better fit today's conventions.

The list of compatible strings (and combinations of them) is based on
existing device trees in arch/powerpc as well as compatible strings
already mentioned in the plain-text version of the binding.

One thing I didn't handle are soc-clk@... nodes as seen in
Documentation/devicetree/bindings/powerpc/fsl/pmc.yaml.

Signed-off-by: J. Neuschäfer 
---
 .../devicetree/bindings/powerpc/fsl/pmc.txt|  63 
 .../devicetree/bindings/powerpc/fsl/pmc.yaml   | 159 +
 2 files changed, 159 insertions(+), 63 deletions(-)

diff --git a/Documentation/devicetree/bindings/powerpc/fsl/pmc.txt 
b/Documentation/devicetree/bindings/powerpc/fsl/pmc.txt
deleted file mode 100644
index 
07256b7ffcaab2ba57b33cf279df45d830ce33b3..
--- a/Documentation/devicetree/bindings/powerpc/fsl/pmc.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-* Power Management Controller
-
-Properties:
-- compatible: "fsl,-pmc".
-
-  "fsl,mpc8349-pmc" should be listed for any chip whose PMC is
-  compatible.  "fsl,mpc8313-pmc" should also be listed for any chip
-  whose PMC is compatible, and implies deep-sleep capability.
-
-  "fsl,mpc8548-pmc" should be listed for any chip whose PMC is
-  compatible.  "fsl,mpc8536-pmc" should also be listed for any chip
-  whose PMC is compatible, and implies deep-sleep capability.
-
-  "fsl,mpc8641d-pmc" should be listed for any chip whose PMC is
-  compatible; all statements below that apply to "fsl,mpc8548-pmc" also
-  apply to "fsl,mpc8641d-pmc".
-
-  Compatibility does not include bit assignments in SCCR/PMCDR/DEVDISR; these
-  bit assignments are indicated via the sleep specifier in each device's
-  sleep property.
-
-- reg: For devices compatible with "fsl,mpc8349-pmc", the first resource
-  is the PMC block, and the second resource is the Clock Configuration
-  block.
-
-  For devices compatible with "fsl,mpc8548-pmc", the first resource
-  is a 32-byte block beginning with DEVDISR.
-
-- interrupts: For "fsl,mpc8349-pmc"-compatible devices, the first
-  resource is the PMC block interrupt.
-
-- fsl,mpc8313-wakeup-timer: For "fsl,mpc8313-pmc"-compatible devices,
-  this is a phandle to an "fsl,gtm" node on which timer 4 can be used as
-  a wakeup source from deep sleep.
-
-Sleep specifiers:
-
-  fsl,mpc8349-pmc: Sleep specifiers consist of one cell.  For each bit
-  that is set in the cell, the corresponding bit in SCCR will be saved
-  and cleared on suspend, and restored on resume.  This sleep controller
-  supports disabling and resuming devices at any time.
-
-  fsl,mpc8536-pmc: Sleep specifiers consist of three cells, the third of
-  which will be ORed into PMCDR upon suspend, and cleared from PMCDR
-  upon resume.  The first two cells are as described for fsl,mpc8578-pmc.
-  This sleep controller only supports disabling devices during system
-  sleep, or permanently.
-
-  fsl,mpc8548-pmc: Sleep specifiers consist of one or two cells, the
-  first of which will be ORed into DEVDISR (and the second into
-  DEVDISR2, if present -- this cell should be zero or absent if the
-  hardware does not have DEVDISR2) upon a request for permanent device
-  disabling.  This sleep controller does not support configuring devices
-  to disable during system sleep (unless supported by another compatible
-  match), or dynamically.
-
-Example:
-
-   power@b00 {
-   compatible = "fsl,mpc8313-pmc", "fsl,mpc8349-pmc";
-   reg = <0xb00 0x100 0xa00 0x100>;
-   interrupts = <80 8>;
-   };
diff --git a/Documentation/devicetree/bindings/powerpc/fsl/pmc.yaml 
b/Documentation/devicetree/bindings/powerpc/fsl/pmc.yaml
new file mode 100644
index 
..bb2db8adb74c54fec5d07393573f156c63a9e886
--- /dev/null
+++ b/Documentation/devicetree/bindings/powerpc/fsl/pmc.yaml
@@ -0,0 +1,159 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/fsl/pmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Power Management Controller
+
+maintainers:
+  - J. Neuschäfer 
+
+description: |
+  The Power Management Controller in several MPC8xxx SoCs helps save power by
+  controlling chip-wide low-power states as well as peripheral clock gating.
+
+  Sleep of peripheral devices is configured by the `sleep` property, for
+  example `sleep = <&pmc 0x0030>`. Any cells after the &pmc phandle are
+  called a sleep specifier.
+
+  For "fsl,mpc8349-pmc", sleep specifiers consist of one cell.  For each bit 
that
+  is set in the cell, the corresponding bit in SCCR will be saved and cleared
+  on suspend, and restored on resume.  This sleep controller supports disabling
+  and resuming devices at any time.
+
+  For "fsl,mpc8536-pmc", sleep specifiers consist of three cells, the

Re: [PATCH] dt-bindings: powerpc: Convert fsl/pmc.txt to YAML

2025-03-15 Thread Rob Herring (Arm)


On Sat, 15 Mar 2025 18:27:05 +0100, J. Neuschäfer wrote:
> This patch rewrites pmc.txt into YAML format. Descriptive texts are
> expanded or shortened in a few places to better fit today's conventions.
> 
> The list of compatible strings (and combinations of them) is based on
> existing device trees in arch/powerpc as well as compatible strings
> already mentioned in the plain-text version of the binding.
> 
> One thing I didn't handle are soc-clk@... nodes as seen in
> Documentation/devicetree/bindings/powerpc/fsl/pmc.yaml.
> 
> Signed-off-by: J. Neuschäfer 
> ---
>  .../devicetree/bindings/powerpc/fsl/pmc.txt|  63 
>  .../devicetree/bindings/powerpc/fsl/pmc.yaml   | 159 
> +
>  2 files changed, 159 insertions(+), 63 deletions(-)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/powerpc/fsl/pmc.example.dtb: 
/example-0/sata@19000: failed to match any schema with compatible: 
['fsl,mpc8377-sata', 'fsl,pq-sata']
Documentation/devicetree/bindings/powerpc/fsl/pmc.example.dtb: 
/example-0/sata@19000: failed to match any schema with compatible: 
['fsl,mpc8377-sata', 'fsl,pq-sata']

doc reference errors (make refcheckdocs):

See 
https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250315-fslpmc-yaml-v1-1-10ba354a8...@posteo.net

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.




[PATCH 12/13] arch, mm: introduce arch_mm_preinit

2025-03-15 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" 

Currently, implementation of mem_init() in every architecture consists of
one or more of the following:

* initializations that must run before page allocator is active, for
  instance swiotlb_init()
* a call to memblock_free_all() to release all the memory to the buddy
  allocator
* initializations that must run after page allocator is ready and there is
  no arch-specific hook other than mem_init() for that, like for example
  register_page_bootmem_info() in x86 and sparc64 or simple setting of
  mem_init_done = 1 in several architectures
* a bunch of semi-related stuff that apparently had no better place to
  live, for example a ton of BUILD_BUG_ON()s in parisc.

Introduce arch_mm_preinit() that will be the first thing called from
mm_core_init(). On architectures that have initializations that must happen
before the page allocator is ready, move those into arch_mm_preinit() along
with the code that does not depend on ordering with page allocator setup.

On several architectures this results in reduction of mem_init() to a
single call to memblock_free_all() that allows its consolidation next.

Signed-off-by: Mike Rapoport (Microsoft) 
---
 arch/arc/mm/init.c  | 13 ++---
 arch/arm/mm/init.c  | 21 -
 arch/arm64/mm/init.c| 21 -
 arch/mips/mm/init.c | 11 +++
 arch/powerpc/mm/mem.c   |  9 ++---
 arch/riscv/mm/init.c|  8 ++--
 arch/s390/mm/init.c |  5 -
 arch/sparc/mm/init_32.c |  5 -
 arch/um/kernel/mem.c|  7 +--
 arch/x86/mm/init_32.c   |  6 +-
 arch/x86/mm/init_64.c   |  5 -
 include/linux/mm.h  |  1 +
 mm/mm_init.c|  5 +
 13 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 11ce638731c9..90715b4a0bfa 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -157,11 +157,16 @@ void __init setup_arch_memory(void)
free_area_init(max_zone_pfn);
 }
 
-static void __init highmem_init(void)
+void __init arch_mm_preinit(void)
 {
 #ifdef CONFIG_HIGHMEM
memblock_phys_free(high_mem_start, high_mem_sz);
 #endif
+
+   BUILD_BUG_ON((PTRS_PER_PGD * sizeof(pgd_t)) > PAGE_SIZE);
+   BUILD_BUG_ON((PTRS_PER_PUD * sizeof(pud_t)) > PAGE_SIZE);
+   BUILD_BUG_ON((PTRS_PER_PMD * sizeof(pmd_t)) > PAGE_SIZE);
+   BUILD_BUG_ON((PTRS_PER_PTE * sizeof(pte_t)) > PAGE_SIZE);
 }
 
 /*
@@ -172,13 +177,7 @@ static void __init highmem_init(void)
  */
 void __init mem_init(void)
 {
-   highmem_init();
memblock_free_all();
-
-   BUILD_BUG_ON((PTRS_PER_PGD * sizeof(pgd_t)) > PAGE_SIZE);
-   BUILD_BUG_ON((PTRS_PER_PUD * sizeof(pud_t)) > PAGE_SIZE);
-   BUILD_BUG_ON((PTRS_PER_PMD * sizeof(pmd_t)) > PAGE_SIZE);
-   BUILD_BUG_ON((PTRS_PER_PTE * sizeof(pte_t)) > PAGE_SIZE);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 7bb5ce02b9b5..7222100b0631 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -237,12 +237,7 @@ static inline void poison_init_mem(void *s, size_t count)
*p++ = 0xe7fddef0;
 }
 
-/*
- * mem_init() marks the free areas in the mem_map and tells us how much
- * memory is free.  This is done after various parts of the system have
- * claimed their memory after the kernel image.
- */
-void __init mem_init(void)
+void __init arch_mm_preinit(void)
 {
 #ifdef CONFIG_ARM_LPAE
swiotlb_init(max_pfn > arm_dma_pfn_limit, SWIOTLB_VERBOSE);
@@ -253,9 +248,6 @@ void __init mem_init(void)
memblock_phys_free(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
 #endif
 
-   /* this will put all unused low memory onto the freelists */
-   memblock_free_all();
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
@@ -271,6 +263,17 @@ void __init mem_init(void)
 #endif
 }
 
+/*
+ * mem_init() marks the free areas in the mem_map and tells us how much
+ * memory is free.  This is done after various parts of the system have
+ * claimed their memory after the kernel image.
+ */
+void __init mem_init(void)
+{
+   /* this will put all unused low memory onto the freelists */
+   memblock_free_all();
+}
+
 #ifdef CONFIG_STRICT_KERNEL_RWX
 struct section_perm {
const char *name;
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index a48fcccd67fa..8eff6a6eb11e 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -362,12 +362,7 @@ void __init bootmem_init(void)
memblock_dump_all();
 }
 
-/*
- * mem_init() marks the free areas in the mem_map and tells us how much memory
- * is free.  This is done after various parts of the system have claimed their
- * memory after the kernel image.
- */
-void __init mem_init(void)
+void __init arch_mm_preinit(void)
 {
unsigned int flags = SWIOTLB_VERBOSE;
bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit);
@@ -391,9 +386,6 @

RE: [PATCH v3 net-next 04/13] net: enetc: add MAC filter for i.MX95 ENETC PF

2025-03-15 Thread Wei Fang
> On 3/4/25 8:21 AM, Wei Fang wrote:
> > +static void enetc_mac_list_del_matched_entries(struct enetc_pf *pf, u16
> si_bit,
> > +  struct enetc_mac_addr *mac,
> > +  int mac_cnt)
> > +{
> > +   struct enetc_mac_list_entry *entry;
> > +   int i;
> > +
> > +   for (i = 0; i < mac_cnt; i++) {
> > +   entry = enetc_mac_list_lookup_entry(pf, mac[i].addr);
> > +   if (entry) {
> > +   entry->si_bitmap &= ~si_bit;
> > +   if (!entry->si_bitmap) {
> 
> 
> Minor nit: here and elsewhere you could reduce the level of indentation
> restructoring the code as:

Okay, I will improve it, thanks.
> 
>   if (!entry)
>   continue;
> 
>   entry->si_bitmap &= ~si_bit;
>   if (entry->si_bitmap)
>   continue;
> /P



[PATCH 5/6] mips: drop GENERIC_IOMAP wrapper

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

All PIO on MIPS platforms is memory mapped, so there is no benefit in
the lib/iomap.c wrappers that switch between inb/outb and readb/writeb
style accessses.

In fact, the '#define PIO_RESERVED 0' setting completely disables
the GENERIC_IOMAP functionality, and the '#define PIO_OFFSET
mips_io_port_base' setting is based on a misunderstanding of what the
offset is meant to do.

MIPS started using GENERIC_IOMAP in 2018 with commit b962aeb02205 ("MIPS:
Use GENERIC_IOMAP") replacing a simple custom implementation of the same
interfaces, but at the time the asm-generic/io.h version was not usable
yet. Since the header is now always included, it's now possible to go
back to the even simpler version.

Use the normal GENERIC_PCI_IOMAP functionality for all mips platforms
without the hacky GENERIC_IOMAP, and provide a custom pci_iounmap()
for the CONFIG_PCI_DRIVERS_LEGACY case to ensure the I/O port base never
gets unmapped.

The readsl() prototype needs an extra 'const' keyword to make it
compatible with the generic ioread32_rep() alias.

Signed-off-by: Arnd Bergmann 
---
 arch/mips/Kconfig  |  2 +-
 arch/mips/include/asm/io.h | 21 -
 arch/mips/lib/iomap-pci.c  |  9 +
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1924f2d83932..2a2120a6d852 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -38,7 +38,6 @@ config MIPS
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_GETTIMEOFDAY
-   select GENERIC_IOMAP
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
select GENERIC_ISA_DMA if EISA
@@ -47,6 +46,7 @@ config MIPS
select GENERIC_LIB_CMPDI2
select GENERIC_LIB_LSHRDI3
select GENERIC_LIB_UCMPDI2
+   select GENERIC_PCI_IOMAP
select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC
select GENERIC_SMP_IDLE_THREAD
select GENERIC_IDLE_POLL_SETUP
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 0bddb568af7c..1fe56d1870a6 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -66,17 +66,6 @@ static inline void set_io_port_base(unsigned long base)
mips_io_port_base = base;
 }
 
-/*
- * Provide the necessary definitions for generic iomap. We make use of
- * mips_io_port_base for iomap(), but we don't reserve any low addresses for
- * use with I/O ports.
- */
-
-#define HAVE_ARCH_PIO_SIZE
-#define PIO_OFFSET mips_io_port_base
-#define PIO_MASK   IO_SPACE_LIMIT
-#define PIO_RESERVED   0x0UL
-
 /*
  * Enforce in-order execution of data I/O.  In the MIPS architecture
  * these are equivalent to corresponding platform-specific memory
@@ -397,8 +386,8 @@ static inline void writes##bwlq(volatile void __iomem *mem, 
\
}   \
 }  \
\
-static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
-  unsigned int count)  \
+static inline void reads##bwlq(const volatile void __iomem *mem,   \
+  void *addr, unsigned int count)  \
 {  \
volatile type *__addr = addr;   \
\
@@ -555,6 +544,12 @@ extern void (*_dma_cache_inv)(unsigned long start, 
unsigned long size);
 
 void __ioread64_copy(void *to, const void __iomem *from, size_t count);
 
+#ifdef CONFIG_PCI_DRIVERS_LEGACY
+struct pci_dev;
+void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
+#define pci_iounmap pci_iounmap
+#endif
+
 #include 
 
 static inline void *isa_bus_to_virt(unsigned long address)
diff --git a/arch/mips/lib/iomap-pci.c b/arch/mips/lib/iomap-pci.c
index a9cb28813f0b..2f82c776c6d0 100644
--- a/arch/mips/lib/iomap-pci.c
+++ b/arch/mips/lib/iomap-pci.c
@@ -43,4 +43,13 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
return (void __iomem *) (ctrl->io_map_base + port);
 }
 
+void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
+{
+   struct pci_controller *ctrl = dev->bus->sysdata;
+   void __iomem *base = (void __iomem *)ctrl->io_map_base;
+
+   if (addr < base || addr > (base + resource_size(ctrl->io_resource)))
+   iounmap(addr);
+}
+
 #endif /* CONFIG_PCI_DRIVERS_LEGACY */
-- 
2.39.5




[PATCH 4/6] powerpc: asm/io.h: remove split ioread64/iowrite64 helpers

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

In previous kernels, there were conflicting definitions for what
ioread64_lo_hi() and similar functions were supposed to do on
architectures with native 64-bit MMIO. Based on the actual usage in
drivers, they are in fact expected to be a pair of 32-bit accesses on
all architectures, which makes the powerpc64 definition wrong.

Remove it and use the generic implementation instead.

Drivers that want to have split lo/hi or hi/lo accesses on 32-bit
architectures but can use 64-bit accesses where supported should instead
use ioread64()/iowrite64() after including the corresponding header file.

Signed-off-by: Arnd Bergmann 
---
 arch/powerpc/include/asm/io.h | 48 ---
 1 file changed, 48 deletions(-)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index fd92ac450169..d36c4ccaca08 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -738,35 +738,11 @@ static inline unsigned int ioread32be(const void __iomem 
*addr)
 #define ioread32be ioread32be
 
 #ifdef __powerpc64__
-static inline u64 ioread64_lo_hi(const void __iomem *addr)
-{
-   return readq(addr);
-}
-#define ioread64_lo_hi ioread64_lo_hi
-
-static inline u64 ioread64_hi_lo(const void __iomem *addr)
-{
-   return readq(addr);
-}
-#define ioread64_hi_lo ioread64_hi_lo
-
 static inline u64 ioread64be(const void __iomem *addr)
 {
return readq_be(addr);
 }
 #define ioread64be ioread64be
-
-static inline u64 ioread64be_lo_hi(const void __iomem *addr)
-{
-   return readq_be(addr);
-}
-#define ioread64be_lo_hi ioread64be_lo_hi
-
-static inline u64 ioread64be_hi_lo(const void __iomem *addr)
-{
-   return readq_be(addr);
-}
-#define ioread64be_hi_lo ioread64be_hi_lo
 #endif /* __powerpc64__ */
 
 static inline void iowrite16be(u16 val, void __iomem *addr)
@@ -782,35 +758,11 @@ static inline void iowrite32be(u32 val, void __iomem 
*addr)
 #define iowrite32be iowrite32be
 
 #ifdef __powerpc64__
-static inline void iowrite64_lo_hi(u64 val, void __iomem *addr)
-{
-   writeq(val, addr);
-}
-#define iowrite64_lo_hi iowrite64_lo_hi
-
-static inline void iowrite64_hi_lo(u64 val, void __iomem *addr)
-{
-   writeq(val, addr);
-}
-#define iowrite64_hi_lo iowrite64_hi_lo
-
 static inline void iowrite64be(u64 val, void __iomem *addr)
 {
writeq_be(val, addr);
 }
 #define iowrite64be iowrite64be
-
-static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr)
-{
-   writeq_be(val, addr);
-}
-#define iowrite64be_lo_hi iowrite64be_lo_hi
-
-static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr)
-{
-   writeq_be(val, addr);
-}
-#define iowrite64be_hi_lo iowrite64be_hi_lo
 #endif /* __powerpc64__ */
 
 struct pci_dev;
-- 
2.39.5




[PATCH v9 2/7] powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls

2025-03-15 Thread Haren Myneni
To issue ibm,get-indices, ibm,set-dynamic-indicator and
ibm,get-dynamic-sensor-state in the user space, the RMO buffer is
allocated for the work area which is restricted under system
lockdown. So instead of user space execution, the kernel will
provide /dev/papr-indices interface to execute these RTAS calls.

The user space assigns data in papr_indices_io_block struct
depends on the specific HCALL and passes to the following ioctls:

PAPR_INDICES_IOC_GET:   Use for ibm,get-indices. Returns a
get-indices handle fd to read data.
PAPR_DYNAMIC_SENSOR_IOC_GET:Use for  ibm,get-dynamic-sensor-state.
Updates the sensor state in
papr_indices_io_block.dynamic_param.state

PAPR_DYNAMIC_INDICATOR_IOC_SET: Use for ibm,set-dynamic-indicator.
Sets the new state for the input
indicator.

Signed-off-by: Haren Myneni 
---
 .../userspace-api/ioctl/ioctl-number.rst  |  2 +
 arch/powerpc/include/uapi/asm/papr-indices.h  | 41 +++
 2 files changed, 43 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 6d1465315df3..f9332b634116 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -363,6 +363,8 @@ Code  Seq#Include File  
 Comments
  

 0xB2  01-02  arch/powerpc/include/uapi/asm/papr-sysparm.h
powerpc/pseries system parameter API
  

+0xB2  03-05 arch/powerpc/include/uapi/asm/papr-indices.h 
powerpc/pseries indices API
+ 

 0xB3  00 linux/mmc/ioctl.h
 0xB4  00-0F  linux/gpio.h

 0xB5  00-0F  uapi/linux/rpmsg.h  

diff --git a/arch/powerpc/include/uapi/asm/papr-indices.h 
b/arch/powerpc/include/uapi/asm/papr-indices.h
new file mode 100644
index ..c2999d89d52a
--- /dev/null
+++ b/arch/powerpc/include/uapi/asm/papr-indices.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_PAPR_INDICES_H_
+#define _UAPI_PAPR_INDICES_H_
+
+#include 
+#include 
+#include 
+
+#define LOC_CODE_SIZE  80
+#define RTAS_GET_INDICES_BUF_SIZE  SZ_4K
+
+struct papr_indices_io_block {
+   union {
+   struct {
+   __u8 is_sensor; /* 0 for indicator and 1 for sensor */
+   __u32 indice_type;
+   } indices;
+   struct {
+   __u32 token; /* Sensor or indicator token */
+   __u32 state; /* get / set state */
+   /*
+* PAPR+ 12.3.2.4 Converged Location Code Rules - Length
+* Restrictions. 79 characters plus null.
+*/
+   char location_code_str[LOC_CODE_SIZE]; /* location code 
*/
+   } dynamic_param;
+   };
+};
+
+/*
+ * ioctls for /dev/papr-indices.
+ * PAPR_INDICES_IOC_GET: Returns a get-indices handle fd to read data
+ * PAPR_DYNAMIC_SENSOR_IOC_GET: Gets the state of the input sensor
+ * PAPR_DYNAMIC_INDICATOR_IOC_SET: Sets the new state for the input indicator
+ */
+#define PAPR_INDICES_IOC_GET   _IOW(PAPR_MISCDEV_IOC_ID, 3, struct 
papr_indices_io_block)
+#define PAPR_DYNAMIC_SENSOR_IOC_GET_IOWR(PAPR_MISCDEV_IOC_ID, 4, struct 
papr_indices_io_block)
+#define PAPR_DYNAMIC_INDICATOR_IOC_SET _IOW(PAPR_MISCDEV_IOC_ID, 5, struct 
papr_indices_io_block)
+
+
+#endif /* _UAPI_PAPR_INDICES_H_ */
-- 
2.43.5




Re: [PATCH bpf-next 01/11] bpf: Move insn if/else into do_check_insn()

2025-03-15 Thread Luis Gerhorst
Eduard Zingerman  writes:
> On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote:
>> +err = do_check_insn(env, insn, pop_log, &do_print_state, regs, 
>> state,
>> +&prev_insn_idx);
>
> - `regs` remains declared in do_check(), while nothing prevents
>   pushing its declaration to do_check_insn().
> - `state` is `env->cur_state`, so I'd avoid passing it as a parameter
>   (just to reduce count);
> - `prev_insn_idx` is unused by `do_check_insn`;
> - `pop_log` is not used by `do_check_insn`;

Changed for v2, thank you very much.

> - given that `insn` is presumed to correspond to `env->insn_idx` in
>   many places down the stack not sure about this parameter.

I don't have a strong opinion on this either. Unless someone objects I
will keep it as it matches the other check_*() functions like this.

>> +if (err < 0) {
>> +return err;
>> +} else if (err == INSN_IDX_MODIFIED) {
>
> Also, I'd get rid of `INSN_IDX_MODIFIED` and move `env->insn_idx++`
> into `do_check_insn()`. This would save a few mental cycles when
> looking at the code with full patch-set applied:
>
>   } else if (err == INSN_IDX_MODIFIED) {
>   continue;
>   } else if (err == PROCESS_BPF_EXIT) {
>   goto process_bpf_exit;
>   }
>   WARN_ON_ONCE(err);
>
>   if (state->speculative && cur_aux(env)->nospec_result) {
>   ... bunch of actions ...
>   }
>
>   env->insn_idx++;
>
> One needs to stop for a moment and think why "bunch of actions" is
> performed for regular index increment, but not for INSN_IDX_MODIFIED.

That certainly makes it more readable. I changed it for v2.

If we have an instruction that does not simply do `insn_idx++` but
jumps, the `nospec_result` check should never trigger. Otherwise, the
patched nospec might be skipped. Currently, this is satisfied because
`nospec_result` is only used for store-instructions. I will add a
comment and WARN_ON_ONCE to document that for v2.



Re: [PATCH] powerpc/powermac: replace KERN_INFO calls with pr_info

2025-03-15 Thread Denis Kirjanov
On Sun, Feb 2, 2025 at 3:28 PM Denis Kirjanov  wrote:
>
> pr_info makes code cleaner and simplifies syntax
>
> Signed-off-by: Denis Kirjanov 
> ---
Hello, ping?

>  arch/powerpc/platforms/powermac/feature.c |  8 
>  arch/powerpc/platforms/powermac/low_i2c.c | 12 ++--
>  arch/powerpc/platforms/powermac/pci.c | 12 ++--
>  arch/powerpc/platforms/powermac/pic.c |  6 +++---
>  arch/powerpc/platforms/powermac/setup.c   |  2 +-
>  arch/powerpc/platforms/powermac/smp.c | 12 ++--
>  6 files changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powermac/feature.c 
> b/arch/powerpc/platforms/powermac/feature.c
> index 6365cea27abc..d3bcfe590384 100644
> --- a/arch/powerpc/platforms/powermac/feature.c
> +++ b/arch/powerpc/platforms/powermac/feature.c
> @@ -2527,7 +2527,7 @@ static int __init probe_motherboard(void)
> pmac_mb.board_flags |= PMAC_MB_MOBILE;
>
>
> -   printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
> +   pr_info("PowerMac motherboard: %s\n", pmac_mb.model_name);
>  done:
> of_node_put(dt);
> return ret;
> @@ -2574,11 +2574,11 @@ static void __init probe_uninorth(void)
> }
> }
>
> -   printk(KERN_INFO "Found %s memory controller & host bridge"
> +   pr_info("Found %s memory controller & host bridge"
>" @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" :
>uninorth_maj == 4 ? "U4" : "UniNorth",
>(unsigned int)res.start, uninorth_rev);
> -   printk(KERN_INFO "Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
> +   pr_info("Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
>
> /* Set the arbitrer QAck delay according to what Apple does
>  */
> @@ -2664,7 +2664,7 @@ static void __init probe_one_macio(const char *name, 
> const char *compat, int typ
> revp = of_get_property(node, "revision-id", NULL);
> if (revp)
> macio_chips[i].rev = *revp;
> -   printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 
> 0x%p\n",
> +   pr_info("Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
> macio_names[type], macio_chips[i].rev, macio_chips[i].base);
>
> return;
> diff --git a/arch/powerpc/platforms/powermac/low_i2c.c 
> b/arch/powerpc/platforms/powermac/low_i2c.c
> index c097d591670e..fe38e6e0f8db 100644
> --- a/arch/powerpc/platforms/powermac/low_i2c.c
> +++ b/arch/powerpc/platforms/powermac/low_i2c.c
> @@ -554,7 +554,7 @@ static struct pmac_i2c_host_kw *__init 
> kw_i2c_host_init(struct device_node *np)
> "keywest i2c", host))
> host->irq = 0;
>
> -   printk(KERN_INFO "KeyWest i2c @0x%08x irq %d %pOF\n",
> +   pr_info("KeyWest i2c @0x%08x irq %d %pOF\n",
>*addrp, host->irq, np);
>
> return host;
> @@ -588,7 +588,7 @@ static void __init kw_i2c_add(struct pmac_i2c_host_kw 
> *host,
> bus->flags = pmac_i2c_multibus;
> list_add(&bus->link, &pmac_i2c_busses);
>
> -   printk(KERN_INFO " channel %d bus %s\n", channel,
> +   pr_info(" channel %d bus %s\n", channel,
>(controller == busnode) ? "" : busnode->full_name);
>  }
>
> @@ -793,7 +793,7 @@ static void __init pmu_i2c_probe(void)
> if (busnode == NULL)
> return;
>
> -   printk(KERN_INFO "PMU i2c %pOF\n", busnode);
> +   pr_info("PMU i2c %pOF\n", busnode);
>
> /*
>  * We add bus 1 and 2 only for now, bus 0 is "special"
> @@ -817,7 +817,7 @@ static void __init pmu_i2c_probe(void)
> bus->flags = pmac_i2c_multibus;
> list_add(&bus->link, &pmac_i2c_busses);
>
> -   printk(KERN_INFO " channel %d bus \n", channel);
> +   pr_info(" channel %d bus \n", channel);
> }
>  }
>
> @@ -909,7 +909,7 @@ static void __init smu_i2c_probe(void)
> if (controller == NULL)
> return;
>
> -   printk(KERN_INFO "SMU i2c %pOF\n", controller);
> +   pr_info("SMU i2c %pOF\n", controller);
>
> /* Look for childs, note that they might not be of the right
>  * type as older device trees mix i2c busses and other things
> @@ -943,7 +943,7 @@ static void __init smu_i2c_probe(void)
> bus->flags = 0;
> list_add(&bus->link, &pmac_i2c_busses);
>
> -   printk(KERN_INFO " channel %x bus %pOF\n",
> +   pr_info(" channel %x bus %pOF\n",
>bus->channel, busnode);
> }
>  }
> diff --git a/arch/powerpc/platforms/powermac/pci.c 
> b/arch/powerpc/platforms/powermac/pci.c
> index d71359b5331c..5404189866af 100644
> --- a/arch/powerpc/platforms/powermac/pci.c
> +++ b/arch/powerpc/platforms/powermac/pci.c
> @@ -482,7 +482,7 @@ static void __init init_bandit(struct pci_controller *bp)
> magic |= BANDIT_COHERENT;
> udelay(2);

[PATCH 1/6] alpha: stop using asm-generic/iomap.h

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

Alpha has custom definitions for ioread64()/iowrite64(), which now
don't exist in the lib/iomap.c variant. This is an endless source
of build failures, since alpha tries to share a couple of function
declarations.

Change alpha to have its own prototypes that match the definitions
in arch/alpha/kerne/io.c instead.

Signed-off-by: Arnd Bergmann 
---
 arch/alpha/include/asm/io.h | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 65fe1e54c6da..fa3e4c246cda 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -10,10 +10,6 @@
 #include 
 #include 
 
-/* The generic header contains only prototypes.  Including it ensures that
-   the implementation we have here matches that interface.  */
-#include 
-
 /*
  * Virtual -> physical identity mapping starts at this offset
  */
@@ -276,13 +272,24 @@ extern void   __raw_writeq(u64 b, volatile 
void __iomem *addr);
 #define __raw_writel __raw_writel
 #define __raw_writeq __raw_writeq
 
-/*
- * Mapping from port numbers to __iomem space is pretty easy.
- */
+extern unsigned int ioread8(const void __iomem *);
+extern unsigned int ioread16(const void __iomem *);
+extern unsigned int ioread32(const void __iomem *);
+extern u64 ioread64(const void __iomem *);
+
+extern void iowrite8(u8, void __iomem *);
+extern void iowrite16(u16, void __iomem *);
+extern void iowrite32(u32, void __iomem *);
+extern void iowrite64(u64, void __iomem *);
+
+extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long 
count);
+extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long 
count);
+extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long 
count);
+
+extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long 
count);
+extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long 
count);
+extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long 
count);
 
-/* These two have to be extern inline because of the extern prototype from
-   .  It is not legal to mix "extern" and "static" for
-   the same declaration.  */
 extern inline void __iomem *ioport_map(unsigned long port, unsigned int size)
 {
return IO_CONCAT(__IO_PREFIX,ioportmap) (port);
@@ -629,10 +636,6 @@ extern void outsl (unsigned long port, const void *src, 
unsigned long count);
 #define RTC_PORT(x)(0x70 + (x))
 #define RTC_ALWAYS_BCD 0
 
-/*
- * These get provided from  since alpha does not
- * select GENERIC_IOMAP.
- */
 #define ioread64 ioread64
 #define iowrite64 iowrite64
 #define ioread8_rep ioread8_rep
-- 
2.39.5




[PATCH v7 2/7] powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls

2025-03-15 Thread Haren Myneni
To issue ibm,get-indices, ibm,set-dynamic-indicator and
ibm,get-dynamic-sensor-state in the user space, the RMO buffer is
allocated for the work area which is restricted under system
lockdown. So instead of user space execution, the kernel will
provide /dev/papr-indices interface to execute these RTAS calls.

The user space assigns data in papr_indices_io_block struct
depends on the specific HCALL and passes to the following ioctls:

PAPR_INDICES_IOC_GET:   Use for ibm,get-indices. Returns a
get-indices handle fd to read data.
PAPR_DYNAMIC_SENSOR_IOC_GET:Use for  ibm,get-dynamic-sensor-state.
Updates the sensor state in
papr_indices_io_block.dynamic_param.state

PAPR_DYNAMIC_INDICATOR_IOC_SET: Use for ibm,set-dynamic-indicator.
Sets the new state for the input
indicator.

Signed-off-by: Haren Myneni 
---
 .../userspace-api/ioctl/ioctl-number.rst  |  2 +
 arch/powerpc/include/uapi/asm/papr-indices.h  | 41 +++
 2 files changed, 43 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/papr-indices.h

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 6d1465315df3..f9332b634116 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -363,6 +363,8 @@ Code  Seq#Include File  
 Comments
  

 0xB2  01-02  arch/powerpc/include/uapi/asm/papr-sysparm.h
powerpc/pseries system parameter API
  

+0xB2  03-05 arch/powerpc/include/uapi/asm/papr-indices.h 
powerpc/pseries indices API
+ 

 0xB3  00 linux/mmc/ioctl.h
 0xB4  00-0F  linux/gpio.h

 0xB5  00-0F  uapi/linux/rpmsg.h  

diff --git a/arch/powerpc/include/uapi/asm/papr-indices.h 
b/arch/powerpc/include/uapi/asm/papr-indices.h
new file mode 100644
index ..c2999d89d52a
--- /dev/null
+++ b/arch/powerpc/include/uapi/asm/papr-indices.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_PAPR_INDICES_H_
+#define _UAPI_PAPR_INDICES_H_
+
+#include 
+#include 
+#include 
+
+#define LOC_CODE_SIZE  80
+#define RTAS_GET_INDICES_BUF_SIZE  SZ_4K
+
+struct papr_indices_io_block {
+   union {
+   struct {
+   __u8 is_sensor; /* 0 for indicator and 1 for sensor */
+   __u32 indice_type;
+   } indices;
+   struct {
+   __u32 token; /* Sensor or indicator token */
+   __u32 state; /* get / set state */
+   /*
+* PAPR+ 12.3.2.4 Converged Location Code Rules - Length
+* Restrictions. 79 characters plus null.
+*/
+   char location_code_str[LOC_CODE_SIZE]; /* location code 
*/
+   } dynamic_param;
+   };
+};
+
+/*
+ * ioctls for /dev/papr-indices.
+ * PAPR_INDICES_IOC_GET: Returns a get-indices handle fd to read data
+ * PAPR_DYNAMIC_SENSOR_IOC_GET: Gets the state of the input sensor
+ * PAPR_DYNAMIC_INDICATOR_IOC_SET: Sets the new state for the input indicator
+ */
+#define PAPR_INDICES_IOC_GET   _IOW(PAPR_MISCDEV_IOC_ID, 3, struct 
papr_indices_io_block)
+#define PAPR_DYNAMIC_SENSOR_IOC_GET_IOWR(PAPR_MISCDEV_IOC_ID, 4, struct 
papr_indices_io_block)
+#define PAPR_DYNAMIC_INDICATOR_IOC_SET _IOW(PAPR_MISCDEV_IOC_ID, 5, struct 
papr_indices_io_block)
+
+
+#endif /* _UAPI_PAPR_INDICES_H_ */
-- 
2.43.5




Re: [PATCH 00/13] arch, mm: reduce code duplication in mem_init()

2025-03-15 Thread Dave Hansen
On 3/6/25 10:51, Mike Rapoport wrote:
>  53 files changed, 151 insertions(+), 618 deletions(-)
>  delete mode 100644 arch/x86/include/asm/numa_32.h
>  delete mode 100644 arch/x86/mm/highmem_32.c

Holy cow, nice work. For the x86 bits:

Acked-by: Dave Hansen 




[PATCH 5/9] powerpc/pseries/htmdump: Add htm info support to htmdump module

2025-03-15 Thread Athira Rajeev
Support dumping system processor configuration from Hardware
Trace Macro (HTM) function via debugfs interface. Under
debugfs folder "/sys/kernel/debug/powerpc/htmdump", add
file "htminfo”.

The interface allows only read of this file which will present the
content of HTM buffer from the hcall. The 16th offset of HTM
buffer has value for the number of entries for array of processors.
Use this information to copy data to the debugfs file

Signed-off-by: Athira Rajeev 
---
 arch/powerpc/platforms/pseries/htmdump.c | 49 
 1 file changed, 49 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/htmdump.c 
b/arch/powerpc/platforms/pseries/htmdump.c
index 703ad2f8b5f0..8c75248f2682 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -13,6 +13,7 @@
 
 static void *htm_buf;
 static void *htm_status_buf;
+static void *htm_info_buf;
 static u32 nodeindex;
 static u32 nodalchipindex;
 static u32 coreindexonchip;
@@ -243,6 +244,46 @@ static const struct file_operations htmstatus_fops = {
.open   = simple_open,
 };
 
+static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
+size_t count, loff_t *ppos)
+{
+   void *htm_info_buf = filp->private_data;
+   long rc, ret;
+   u64 *num_entries;
+   u64 to_copy;
+
+   /*
+* Invoke H_HTM call with:
+* - operation as htm status (H_HTM_OP_STATUS)
+* - last three values as addr, size and offset
+*/
+   rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+  htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, 
virt_to_phys(htm_info_buf),
+  PAGE_SIZE, 0);
+
+   ret = htm_return_check(rc);
+   if (ret <= 0)
+   return ret;
+
+   /*
+* HTM status buffer, start of buffer + 0x10 gives the
+* number of HTM entries in the buffer. Each entry of processor
+* is 16 bytes.
+*
+* So total count to copy is:
+* 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
+*/
+   num_entries = htm_info_buf + 0x10;
+   to_copy = 32 + (be64_to_cpu(*num_entries) * 16);
+   return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, 
to_copy);
+}
+
+static const struct file_operations htminfo_fops = {
+   .llseek = NULL,
+   .read   = htminfo_read,
+   .open   = simple_open,
+};
+
 DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, 
"%llu\n");
 DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
 
@@ -280,7 +321,15 @@ static int htmdump_init_debugfs(void)
return -ENOMEM;
}
 
+   /* Debugfs interface file to present System Processor Configuration */
+   htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+   if (!htm_info_buf) {
+   pr_err("Failed to allocate htm info buf\n");
+   return -ENOMEM;
+   }
+
debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, 
htm_status_buf, &htmstatus_fops);
+   debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, 
&htminfo_fops);
 
return 0;
 }
-- 
2.43.5




[PATCH v2 4/6] powerpc: book3s: vas: use lock guard for mutex

2025-03-15 Thread Shrikanth Hegde
use lock guards for scope based resource management of mutex.
This would make the code simpler and easier to maintain.

More details on lock guards can be found at
https://lore.kernel.org/all/20230612093537.614161...@infradead.org/T/#u

This shows the use of both guard and scoped_guard

Signed-off-by: Shrikanth Hegde 
---
 arch/powerpc/platforms/book3s/vas-api.c | 32 ++---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/platforms/book3s/vas-api.c 
b/arch/powerpc/platforms/book3s/vas-api.c
index 0b6365d85d11..d7462c16d828 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -425,23 +425,22 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
return VM_FAULT_SIGBUS;
}
 
-   mutex_lock(&txwin->task_ref.mmap_mutex);
/*
 * The window may be inactive due to lost credit (Ex: core
 * removal with DLPAR). If the window is active again when
 * the credit is available, map the new paste address at the
 * window virtual address.
 */
-   if (txwin->status == VAS_WIN_ACTIVE) {
-   paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
-   if (paste_addr) {
-   fault = vmf_insert_pfn(vma, vma->vm_start,
-   (paste_addr >> PAGE_SHIFT));
-   mutex_unlock(&txwin->task_ref.mmap_mutex);
-   return fault;
+   scoped_guard(mutex, &txwin->task_ref.mmap_mutex) {
+   if (txwin->status == VAS_WIN_ACTIVE) {
+   paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
+   if (paste_addr) {
+   fault = vmf_insert_pfn(vma, vma->vm_start,
+   (paste_addr >> PAGE_SHIFT));
+   return fault;
+   }
}
}
-   mutex_unlock(&txwin->task_ref.mmap_mutex);
 
/*
 * Received this fault due to closing the actual window.
@@ -494,9 +493,8 @@ static void vas_mmap_close(struct vm_area_struct *vma)
return;
}
 
-   mutex_lock(&txwin->task_ref.mmap_mutex);
-   txwin->task_ref.vma = NULL;
-   mutex_unlock(&txwin->task_ref.mmap_mutex);
+   scoped_guard(mutex, &txwin->task_ref.mmap_mutex)
+   txwin->task_ref.vma = NULL;
 }
 
 static const struct vm_operations_struct vas_vm_ops = {
@@ -543,18 +541,16 @@ static int coproc_mmap(struct file *fp, struct 
vm_area_struct *vma)
 * close/open event and allows mmap() only when the window is
 * active.
 */
-   mutex_lock(&txwin->task_ref.mmap_mutex);
+   guard(mutex)(&txwin->task_ref.mmap_mutex);
if (txwin->status != VAS_WIN_ACTIVE) {
pr_err("Window is not active\n");
-   rc = -EACCES;
-   goto out;
+   return -EACCES;
}
 
paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
if (!paste_addr) {
pr_err("Window paste address failed\n");
-   rc = -EINVAL;
-   goto out;
+   return -EINVAL;
}
 
pfn = paste_addr >> PAGE_SHIFT;
@@ -574,8 +570,6 @@ static int coproc_mmap(struct file *fp, struct 
vm_area_struct *vma)
txwin->task_ref.vma = vma;
vma->vm_ops = &vas_vm_ops;
 
-out:
-   mutex_unlock(&txwin->task_ref.mmap_mutex);
return rc;
 }
 
-- 
2.39.3




Re: [PATCH bpf-next 01/11] bpf: Move insn if/else into do_check_insn()

2025-03-15 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote:
> This is required to catch the errors later and fall back to a nospec if
> on a speculative path.
> 
> Move code into do_check_insn(), replace
> * "continue" with "return INSN_IDX_MODIFIED"
> * "goto process_bpf_exit" with "return PROCESS_BPF_EXIT"
> * "do_print_state = " with "*do_print_state = "
> 
> Signed-off-by: Luis Gerhorst 
> Acked-by: Henriette Herzog 
> Cc: Maximilian Ott 
> Cc: Milan Stephan 
> ---

This refactoring is a long overdue, thank you!
A few nits below.

[...]

> + err = do_check_insn(env, insn, pop_log, &do_print_state, regs, 
> state,
> + &prev_insn_idx);

- `regs` remains declared in do_check(), while nothing prevents
  pushing its declaration to do_check_insn().
- `state` is `env->cur_state`, so I'd avoid passing it as a parameter
  (just to reduce count);
- `prev_insn_idx` is unused by `do_check_insn`;
- `pop_log` is not used by `do_check_insn`;
- given that `insn` is presumed to correspond to `env->insn_idx` in
  many places down the stack not sure about this parameter.

> + if (err < 0) {
> + return err;
> + } else if (err == INSN_IDX_MODIFIED) {

Also, I'd get rid of `INSN_IDX_MODIFIED` and move `env->insn_idx++`
into `do_check_insn()`. This would save a few mental cycles when
looking at the code with full patch-set applied:

} else if (err == INSN_IDX_MODIFIED) {
continue;
} else if (err == PROCESS_BPF_EXIT) {
goto process_bpf_exit;
}
WARN_ON_ONCE(err);

if (state->speculative && cur_aux(env)->nospec_result) {
... bunch of actions ...
}

env->insn_idx++;

One needs to stop for a moment and think why "bunch of actions" is
performed for regular index increment, but not for INSN_IDX_MODIFIED.

> + continue;
> + } else if (err == PROCESS_BPF_EXIT) {

[...]




Re: [PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states

2025-03-15 Thread Vaibhav Jain
Gautam Menghani  writes:

> When a system is being suspended to RAM, the PCI devices are also
> suspended and the PPC code ends up calling pseries_msi_compose_msg() and
> this triggers the BUG_ON() in __pci_read_msi_msg() because the device at
> this point is in reduced power state. In reduced power state, the memory
> mapped registers of the PCI device are not accessible.
>
> To replicate the bug:
> 1. Make sure deep sleep is selected
>   # cat /sys/power/mem_sleep
>   s2idle [deep]
>
> 2. Make sure console is not suspended (so that dmesg logs are visible)
>   echo N > /sys/module/printk/parameters/console_suspend
>
> 3. Suspend the system
>   echo mem > /sys/power/state
>
> To fix this behaviour, read the cached msi message of the device when the
> device is not in PCI_D0 power state instead of touching the hardware.
>
> Fixes: a5f3d2c17b07 ("powerpc/pseries/pci: Add MSI domains")
> Cc: sta...@vger.kernel.org # v5.15+
> Signed-off-by: Gautam Menghani 
LGTM. Hence
Reviewed-by: Vaibhav Jain 

-- 
Cheers
~ Vaibhav



Re: [PATCH v4 net-next 02/14] net: enetc: add command BD ring support for i.MX95 ENETC

2025-03-15 Thread Vladimir Oltean
On Fri, Mar 14, 2025 at 06:51:06AM +0200, Wei Fang wrote:
> > I don't understand the need for si->ops->setup_cbdr() and
> > si->ops->teardown_cbdr()?
> > Doesn't every call site know which kind of SI it is dealing with, and thus 
> > it can
> > appropriately call the direct symbol?
> > - the v1 PSI and the VSI call enetc_setup_cbdr() and enetc_teardown_cbdr()
> > - the v4 PSI calls enetc4_setup_cbdr() and enetc4_teardown_cbdr()
> 
> Yes, for PSI we can use directly call these functions because they are 
> different
> drivers, but for VSI, v1 and v4 will use the same driver. I just want the PSI 
> and
> VSI to be consistent. If you don't like this, I can remove these interfaces 
> from
> the patch set, and add vf_setup_cbdr and vf_teardown_cbdr in the future when
> I add the VF support for ENETC v4.

It's not that I don't like them, the point is rather simple: as far as
this patch set is concerned, converting direct function calls to
indirect ones is an unfinished idea. It needs to be evaluated in full
context, which is not present here - as you say, v4 VSIs need to be
further modified to call a different set of operations - but right now,
they call a single set of CBDR functions. Changes which require
subsequent patch sets in order to make any sense at all are discouraged.

Given the fact that the PSI code paths still don't benefit from an
indirect function call in any way, I would in principle recommend to
keep calling their CBDR methods directly. For VSIs I don't know which is
preferable (if-else vs function pointer), I need to see that code first.



Re: [PATCH bpf-next 00/11] bpf: Mitigate Spectre v1 using barriers

2025-03-15 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote:
> This improves the expressiveness of unprivileged BPF by inserting
> speculation barriers instead of rejecting the programs.
> 
> The approach was previously presented at LPC'24 [1] and RAID'24 [2].
> 
> To mitigate the Spectre v1 (PHT) vulnerability, the kernel rejects
> potentially-dangerous unprivileged BPF programs as of
> commit 9183671af6db ("bpf: Fix leakage under speculation on mispredicted
> branches"). In [2], we have analyzed 364 object files from open source
> projects (Linux Samples and Selftests, BCC, Loxilb, Cilium, libbpf
> Examples, Parca, and Prevail) and found that this affects 31% to 54% of
> programs.
> 
> To resolve this in the majority of cases this patchset adds a fall-back
> for mitigating Spectre v1 using speculation barriers. The kernel still
> optimistically attempts to verify all speculative paths but uses
> speculation barriers against v1 when unsafe behavior is detected. This
> allows for more programs to be accepted without disabling the BPF
> Spectre mitigations (e.g., by setting cpu_mitigations_off()).
> 
> In [1] we have measured the overhead of this approach relative to having
> mitigations off and including the upstream Spectre v4 mitigations. For
> event tracing and stack-sampling profilers, we found that mitigations
> increase BPF program execution time by 0% to 62%. For the Loxilb network
> load balancer, we have measured a 14% slowdown in SCTP performance but
> no significant slowdown for TCP. This overhead only applies to programs
> that were previously rejected.
> 
> I reran the expressiveness-evaluation with v6.14 and made sure the main
> results still match those from [1] and [2] (which used v6.5).
> 
> Main design decisions are:
> 
> * Do not use separate bytecode insns for v1 and v4 barriers. This
>   simplifies the verifier significantly and has the only downside that
>   performance on PowerPC is not as high as it could be.
> 
> * Allow archs to still disable v1/v4 mitigations separately by setting
>   bpf_jit_bypass_spec_v1/v4(). This has the benefit that archs can
>   benefit from improved BPF expressiveness / performance if they are not
>   vulnerable (e.g., ARM64 for v4 in the kernel).
> 
> * Do not remove the empty BPF_NOSPEC implementation for backends for
>   which it is unknown whether they are vulnerable to Spectre v1.

[...]

I think it would be good to have some tests checking that nospec
instructions are inserted in expected locations.
Could you please take look at use of __xlated tag in e.g.
tools/testing/selftests/bpf/progs/verifier_sdiv.c ?

[...]




Re: [PATCH v4 1/2] watchdog: Add a new flag WDIOF_STOP_MAYSLEEP

2025-03-15 Thread George Cherian
Hi Julius,
>>  static const struct watchdog_ops adv_ec_wdt_ops = {
>> diff --git a/drivers/watchdog/arm_smc_wdt.c b/drivers/watchdog/arm_smc_wdt.c
>> index 8f3d0c3a005f..794cf0086912 100644
>> --- a/drivers/watchdog/arm_smc_wdt.c
>> +++ b/drivers/watchdog/arm_smc_wdt.c
>> @@ -90,7 +90,8 @@ static const struct watchdog_info smcwd_info = {
>> .identity   = DRV_NAME,
>> .options= WDIOF_SETTIMEOUT |
>>   WDIOF_KEEPALIVEPING |
>> - WDIOF_MAGICCLOSE,
>> + WDIOF_MAGICCLOSE |
>> + WDIOF_STOP_MAYSLEEP,
>>  };
>
>I don't think this driver can sleep, unless I'm missing something?

The only reason I added to avoid any inadvertent hang in TF-A.
Anyways the approach is going to change so this patch is not 
needed anymore.
>`arm_smccc_smc()` does a synchronous call into firmware that always
>returns back to the caller.

Thanks for the insight.
-George


Re: [PATCH v8 0/7] Add character devices for indices, platform-dump and physical-attestation RTAS

2025-03-15 Thread Sathvika Vasireddy



On 3/12/25 4:20 AM, Haren Myneni wrote:

Several APIs such as rtas_get_indices(), rtas_get_dynamic_sensor(),
rtas_set_dynamic_indicator(), rtas_platform_dump() and
rtas_physical_attestation()  provided by librtas library are
implemented in user space using rtas syscall in combination with
writable mappings of /dev/mem. But this implementation is not
compatible with system lockdown which prohibits /dev/mem access.
The current kernel already provides char based driver interfaces
for several RTAS calls such as VPD and system parameters to
support lockdown feature.

This patch series adds new char based drivers, /dev/papr-indices
for ibm,get-indices, ibm,get-dynamic-sensor-state and
ibm,set-dynamic-indicator RTAS Calls. /dev/papr-platform-dump
for ibm,platform-dump and /dev/papr-physical-attestation
fir ibm,physical-attestation. Providing the similar
open/ioctl/read interfaces to the user space as in the case of
VPD and system parameters.

I have made changes to librtas library to use the new kernel
interfaces if the corresponding device entry is available.

This patch series has the following patches:
powerpc/pseries: Define common functions for RTAS sequence calls
- For some of sequence based RTAS calls, the OS should not start
   another sequence with different input until the previous sequence
   is completed. So the sequence should be completed during ioctl()
   and expose the entire buffer during read(). ibm,get-indices is
   sequence based RTAS function similar to ibm,get-vpd and we already
   have the corresponding implementation for VPD driver. So update
   papr_rtas_sequence struct for RTAS call specific functions and move
   the top level sequence functions in to a separate file.

powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
- /dev/papr-indices driver supports ibm,get-indices,
   ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls.
   papr-indices.h introduces 3 different ioctls for these RTAS calls and
   the corresponding ioctl input buffer.

powerpc/pseries: Add papr-indices char driver for ibm,get-indices
- Introduce /dev/papr-indices char based driver and add support for
   get-indices RTAS function

powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
- Update /dev/papr-indices for set-dynamic-indicator RTAS function

powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
-  Update /dev/papr-indices for  get-dynamic-sensor-state RTAS function

powerpc/pseries: Add papr-platform-dump character driver for dump
retrieval
- Introduce /dev/papr-platform-dump char driver and adds support for
   ibm,platform-dump. Received suggestions from the previous post as a
   separate patch - Updated the patch with invalidating the dump using
   a separate ioctl.

powerpc/pseries: Add a char driver for papr-physical-attestation RTAS
- Introduce /dev/papr-physical-attestation char driver to provide
   kernel interface for ibm,physical-attestation RTAS function.

Changelog:
v8:
- Fixed build warnings for the proper function parameter descriptions
   (vpd_sequence_begin(), few papr_rtas_*() functions, and etc) as
   reported by kernel test robot 

v7:
- Pass the proper next value to the subsequent RTAS calls for the
   get-indices sequence RTAS.
   (Vasireddy Sathvika found this bug).

v6:
- Define the proper command ID for PAPR_PHY_ATTEST_IOC_HANDLE ioctl
- Update ioctls description in ioctl-number.rst.

v5:
- Return with -EINPROGRESS in papr_platform_dump_invalidate_ioctl()
   if the complete dump is not read (Suggested by Michal Suchánek).

v4:
- Include patch "Add char driver for papr-physical-attestation RTAS"
   in this series. ibm,physical-attestation is sequence based RTAS
   call and the implementation is also similar to ibm,get-vpd and
   ibm,get-indices.

v3:
- put_unused_fd() only after get_unused_fd() successful for the failure
   case later ("Add papr-platform-dump character driver for dump
   retrieval" patch).

v2:
- Added unlock rtas_ibm_set_dynamic_indicator_lock and
   rtas_ibm_get_dynamic_sensor_state_lock mutex for failure cases
   as reported by Dan Carpenter
- Fixed build warnings for the proper function parameter descriptions
   as reported by kernel test robot 

Haren Myneni (7):
   powerpc/pseries: Define common functions for RTAS sequence calls
   powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
   powerpc/pseries: Add papr-indices char driver for ibm,get-indices
   powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
   powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
   powerpc/pseries: Add papr-platform-dump character driver for dump
 retrieval
   powerpc/pseries: Add a char driver for physical-attestation RTAS

  .../userspace-api/ioctl/ioctl-number.rst  |   6 +
  arch/powerpc/include/asm/rtas.h   |   4 +
  arch/powerpc/include/uapi/asm/papr-indices.h  |  41 ++
  .../uapi/asm/papr-physical-attestation.h  |  31 ++
  .../include/uapi/asm

[PATCH 6/6] m68k/nommu: stop using GENERIC_IOMAP

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

There is no need to go through the GENERIC_IOMAP wrapper for PIO on
nommu platforms, since these always come from PCI I/O space that is
itself memory mapped.

Instead, the generic ioport_map() can just return the MMIO location
of the ports directly by applying the PCI_IO_PA offset, while
ioread32/iowrite32 trivially turn into readl/writel as they do
on most other architectures.

Signed-off-by: Arnd Bergmann 
---
 arch/m68k/Kconfig | 2 +-
 arch/m68k/include/asm/io_no.h | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index b2ed0308c0ea..b50c275fa94d 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -18,7 +18,7 @@ config M68K
select DMA_DIRECT_REMAP if M68K_NONCOHERENT_DMA && !COLDFIRE
select GENERIC_ATOMIC64
select GENERIC_CPU_DEVICES
-   select GENERIC_IOMAP if HAS_IOPORT
+   select GENERIC_IOMAP if HAS_IOPORT && MMU
select GENERIC_IRQ_SHOW
select GENERIC_LIB_ASHLDI3
select GENERIC_LIB_ASHRDI3
diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 2c96e8480173..516371d5587a 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -123,10 +123,6 @@ static inline void writel(u32 value, volatile void __iomem 
*addr)
 #define PCI_IO_SIZE0x0001  /* 64k */
 #define PCI_IO_MASK(PCI_IO_SIZE - 1)
 
-#define HAVE_ARCH_PIO_SIZE
-#define PIO_OFFSET 0
-#define PIO_MASK   0x
-#define PIO_RESERVED   0x1
 #define PCI_IOBASE ((void __iomem *) PCI_IO_PA)
 #define PCI_SPACE_LIMITPCI_IO_MASK
 #endif /* CONFIG_PCI */
-- 
2.39.5




Re: [Kernel 6.12.17] [PowerPC e5500] KVM HV compilation error

2025-03-15 Thread Greg KH
On Wed, Mar 05, 2025 at 06:53:19AM -0800, Sean Christopherson wrote:
> On Wed, Mar 05, 2025, Greg KH wrote:
> > On Wed, Mar 05, 2025 at 03:14:13PM +0100, Christian Zigotzky wrote:
> > > Hi All,
> > > 
> > > The stable long-term kernel 6.12.17 cannot compile with KVM HV support 
> > > for e5500 PowerPC machines anymore.
> > > 
> > > Bug report: https://github.com/chzigotzky/kernels/issues/6
> > > 
> > > Kernel config: 
> > > https://github.com/chzigotzky/kernels/blob/6_12/configs/x5000_defconfig
> > > 
> > > Error messages:
> > > 
> > > arch/powerpc/kvm/e500_mmu_host.c: In function 'kvmppc_e500_shadow_map':
> > > arch/powerpc/kvm/e500_mmu_host.c:447:9: error: implicit declaration of 
> > > function '__kvm_faultin_pfn' [-Werror=implicit-function-declaration]
> > >pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page);
> > >  ^
> > >   CC  kernel/notifier.o
> > > arch/powerpc/kvm/e500_mmu_host.c:500:2: error: implicit declaration of 
> > > function 'kvm_release_faultin_page'; did you mean 'kvm_read_guest_page'? 
> > > [-Werror=implicit-function-declaration]
> > >   kvm_release_faultin_page(kvm, page, !!ret, writable);
> > > 
> > > After that, I compiled it without KVM HV support.
> > > 
> > > Kernel config: 
> > > https://github.com/chzigotzky/kernels/blob/6_12/configs/e5500_defconfig
> > > 
> > > Please check the error messages.
> > 
> > Odd, what commit caused this problem?  Any hint as to what commit is
> > missing to fix it?
> 
> 833f69be62ac.  It most definitely should be reverted.  The "dependency" for 
> commit
> 87ecfdbc699c ("KVM: e500: always restore irqs") is a superficial code 
> conflict.
> 
> Oof.  The same buggy patch was queue/proposed for all stable trees from 5.4 
> onward,
> but it look like it only landed in 6.1, 6.6, and 6.12.  I'll send reverts.
> 
> commit 833f69be62ac366b5c23b4a6434389e470dd5c7f
> Author: Sean Christopherson 
> AuthorDate: Thu Oct 10 11:23:56 2024 -0700
> Commit: Greg Kroah-Hartman 
> CommitDate: Mon Feb 17 10:04:56 2025 +0100
> 
> KVM: PPC: e500: Use __kvm_faultin_pfn() to handle page faults
> 
> [ Upstream commit 419cfb983ca93e75e905794521afefcfa07988bb ]
> 
> Convert PPC e500 to use __kvm_faultin_pfn()+kvm_release_faultin_page(),
> and continue the inexorable march towards the demise of
> kvm_pfn_to_refcounted_page().
> 
> Signed-off-by: Sean Christopherson 
> Tested-by: Dmitry Osipenko 
> Signed-off-by: Paolo Bonzini 
> Message-ID: <20241010182427.1434605-55-sea...@google.com>
> Stable-dep-of: 87ecfdbc699c ("KVM: e500: always restore irqs")
> Signed-off-by: Sasha Levin 

All now reverted, sorry about that.

greg k-h



Re: [PATCH bpf-next 02/11] bpf: Return -EFAULT on misconfigurations

2025-03-15 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote:
> Mark these cases as non-recoverable to later prevent them from being
> cought when they occur during speculative path verification.
> 
> Signed-off-by: Luis Gerhorst 
> Acked-by: Henriette Herzog 
> Cc: Maximilian Ott 
> Cc: Milan Stephan 
> ---

The only pace I'm aware of that might act upon specific error code
from verifier syscall is libbpf. Looking through libbpf code, it seems
that this change does not interfere with libbpf.

Reviewed-by: Eduard Zingerman 

[...]




Re: [PATCH bpf-next 03/11] bpf: Return -EFAULT on internal errors

2025-03-15 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:29 +0100, Luis Gerhorst wrote:
> This prevents us from trying to recover from these on speculative paths
> in the future.
> 
> Signed-off-by: Luis Gerhorst 
> Acked-by: Henriette Herzog 
> Cc: Maximilian Ott 
> Cc: Milan Stephan 
> ---

Same as for previous patch.

Reviewed-by: Eduard Zingerman 

[...]




[PATCH v9 0/7] Add character devices for indices, platform-dump

2025-03-15 Thread Haren Myneni
Several APIs such as rtas_get_indices(), rtas_get_dynamic_sensor(),
rtas_set_dynamic_indicator(), rtas_platform_dump() and
rtas_physical_attestation()  provided by librtas library are
implemented in user space using rtas syscall in combination with
writable mappings of /dev/mem. But this implementation is not
compatible with system lockdown which prohibits /dev/mem access.
The current kernel already provides char based driver interfaces
for several RTAS calls such as VPD and system parameters to
support lockdown feature.

This patch series adds new char based drivers, /dev/papr-indices
for ibm,get-indices, ibm,get-dynamic-sensor-state and
ibm,set-dynamic-indicator RTAS Calls. /dev/papr-platform-dump
for ibm,platform-dump and /dev/papr-physical-attestation
fir ibm,physical-attestation. Providing the similar
open/ioctl/read interfaces to the user space as in the case of
VPD and system parameters.

I have made changes to librtas library to use the new kernel
interfaces if the corresponding device entry is available.

This patch series has the following patches:
powerpc/pseries: Define common functions for RTAS sequence calls
- For some of sequence based RTAS calls, the OS should not start
  another sequence with different input until the previous sequence
  is completed. So the sequence should be completed during ioctl()
  and expose the entire buffer during read(). ibm,get-indices is
  sequence based RTAS function similar to ibm,get-vpd and we already
  have the corresponding implementation for VPD driver. So update
  papr_rtas_sequence struct for RTAS call specific functions and move
  the top level sequence functions in to a separate file.

powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
- /dev/papr-indices driver supports ibm,get-indices,
  ibm,get-dynamic-sensor-state and ibm,set-dynamic-indicator RTAS Calls.
  papr-indices.h introduces 3 different ioctls for these RTAS calls and
  the corresponding ioctl input buffer.

powerpc/pseries: Add papr-indices char driver for ibm,get-indices
- Introduce /dev/papr-indices char based driver and add support for
  get-indices RTAS function

powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
- Update /dev/papr-indices for set-dynamic-indicator RTAS function

powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
-  Update /dev/papr-indices for  get-dynamic-sensor-state RTAS function

powerpc/pseries: Add papr-platform-dump character driver for dump
   retrieval
- Introduce /dev/papr-platform-dump char driver and adds support for
  ibm,platform-dump. Received suggestions from the previous post as a
  separate patch - Updated the patch with invalidating the dump using
  a separate ioctl.

powerpc/pseries: Add a char driver for papr-physical-attestation RTAS
- Introduce /dev/papr-physical-attestation char driver to provide
  kernel interface for ibm,physical-attestation RTAS function.

Thanks to Sathvika Vasireddy for testing these kernel APIs with various
tools.
 
Changelog:
v9:
- Fixed syntax issue in papr-rtas-common.c as reported by
  Mukesh Kumar Chaurasiya

v8:
- Fixed build warnings for the proper function parameter descriptions
  (vpd_sequence_begin(), few papr_rtas_*() functions, and etc) as
  reported by kernel test robot 

v7:
- Pass the proper next value to the subsequent RTAS calls for the
  get-indices sequence RTAS.
  (Vasireddy Sathvika found this bug).

v6:
- Define the proper command ID for PAPR_PHY_ATTEST_IOC_HANDLE ioctl
- Update ioctls description in ioctl-number.rst.

v5:
- Return with -EINPROGRESS in papr_platform_dump_invalidate_ioctl()
  if the complete dump is not read (Suggested by Michal Suchánek).

v4:
- Include patch "Add char driver for papr-physical-attestation RTAS"
  in this series. ibm,physical-attestation is sequence based RTAS
  call and the implementation is also similar to ibm,get-vpd and
  ibm,get-indices.

v3:
- put_unused_fd() only after get_unused_fd() successful for the failure
  case later ("Add papr-platform-dump character driver for dump
  retrieval" patch).

v2:
- Added unlock rtas_ibm_set_dynamic_indicator_lock and
  rtas_ibm_get_dynamic_sensor_state_lock mutex for failure cases
  as reported by Dan Carpenter
- Fixed build warnings for the proper function parameter descriptions
  as reported by kernel test robot 

Haren Myneni (7):
  powerpc/pseries: Define common functions for RTAS sequence calls
  powerpc/pseries: Define papr_indices_io_block for papr-indices ioctls
  powerpc/pseries: Add papr-indices char driver for ibm,get-indices
  powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support
  powerpc/pseries: Add ibm,get-dynamic-sensor-state RTAS call support
  powerpc/pseries: Add papr-platform-dump character driver for dump
retrieval
  powerpc/pseries: Add a char driver for physical-attestation RTAS

 .../userspace-api/ioctl/ioctl-number.rst  |   6 +
 arch/powerpc/include/asm/rtas.h   |   4 +
 arch/powerpc/include/uapi/asm/papr-indices.h  | 

[PATCH v9 4/7] powerpc/pseries: Add ibm,set-dynamic-indicator RTAS call support

2025-03-15 Thread Haren Myneni
The RTAS call ibm,set-dynamic-indicator is used to set the new
indicator state identified by a location code. The current
implementation uses rtas_set_dynamic_indicator() API provided by
librtas library which allocates RMO buffer and issue this RTAS
call in the user space. But /dev/mem access by the user space
is prohibited under system lockdown.

This patch provides an interface with new ioctl
PAPR_DYNAMIC_INDICATOR_IOC_SET to the papr-indices character
driver and expose this interface to the user space that is
compatible with lockdown.

Refer PAPR 7.3.18 ibm,set-dynamic-indicator for more
information on this RTAS call.
-  User input parameters to the RTAS call: location code
   string, indicator token and new state

Expose these interfaces to user space with a /dev/papr-indices
character device using the following programming model:
 int fd = open("/dev/papr-indices", O_RDWR);
 int ret = ioctl(fd, PAPR_DYNAMIC_INDICATOR_IOC_SET,
struct papr_indices_io_block)
  - The user space passes input parameters in papr_indices_io_block
struct

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/rtas.h   |   1 +
 arch/powerpc/kernel/rtas.c|   2 +-
 arch/powerpc/platforms/pseries/papr-indices.c | 120 ++
 3 files changed, 122 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 7dc527a5aaac..2da52f59e4c6 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -516,6 +516,7 @@ extern unsigned long rtas_rmo_buf;
 
 extern struct mutex rtas_ibm_get_vpd_lock;
 extern struct mutex rtas_ibm_get_indices_lock;
+extern struct mutex rtas_ibm_set_dynamic_indicator_lock;
 
 #define GLOBAL_INTERRUPT_QUEUE 9005
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 76c634b92cb2..88fa416730af 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -95,9 +95,9 @@ static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock);
 static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock);
 static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock);
 static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock);
-static DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock);
 DEFINE_MUTEX(rtas_ibm_get_vpd_lock);
 DEFINE_MUTEX(rtas_ibm_get_indices_lock);
+DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock);
 
 static struct rtas_function rtas_function_table[] __ro_after_init = {
[RTAS_FNIDX__CHECK_EXCEPTION] = {
diff --git a/arch/powerpc/platforms/pseries/papr-indices.c 
b/arch/powerpc/platforms/pseries/papr-indices.c
index a0b3c9a61c5c..c46b728d5f47 100644
--- a/arch/powerpc/platforms/pseries/papr-indices.c
+++ b/arch/powerpc/platforms/pseries/papr-indices.c
@@ -20,6 +20,13 @@
 #include 
 #include "papr-rtas-common.h"
 
+/*
+ * Function-specific return values for ibm,set-dynamic-indicator and
+ * ibm,get-dynamic-sensor-state RTAS calls.
+ * PAPR+ v2.13 7.3.18 and 7.3.19.
+ */
+#define RTAS_IBM_DYNAMIC_INDICE_NO_INDICATOR   -3
+
 /**
  * struct rtas_get_indices_params - Parameters (in and out) for
  *  ibm,get-indices.
@@ -260,6 +267,110 @@ static long papr_indices_create_handle(struct 
papr_indices_io_block __user *ubuf
return fd;
 }
 
+/*
+ * Create work area with the input parameters. This function is used
+ * for both ibm,set-dynamic-indicator and ibm,get-dynamic-sensor-state
+ * RTAS Calls.
+ */
+static struct rtas_work_area *
+papr_dynamic_indice_buf_from_user(struct papr_indices_io_block __user *ubuf,
+   struct papr_indices_io_block *kbuf)
+{
+   struct rtas_work_area *work_area;
+   u32 length;
+   __be32 len_be;
+
+   if (copy_from_user(kbuf, ubuf, sizeof(*kbuf)))
+   return ERR_PTR(-EFAULT);
+
+
+   if (!string_is_terminated(kbuf->dynamic_param.location_code_str,
+   ARRAY_SIZE(kbuf->dynamic_param.location_code_str)))
+   return ERR_PTR(-EINVAL);
+
+   /*
+* The input data in the work area should be as follows:
+* - 32-bit integer length of the location code string,
+*   including NULL.
+* - Location code string, NULL terminated, identifying the
+*   token (sensor or indicator).
+* PAPR 2.13 - R1–7.3.18–5 ibm,set-dynamic-indicator
+*   - R1–7.3.19–5 ibm,get-dynamic-sensor-state
+*/
+   /*
+* Length that user space passed should also include NULL
+* terminator.
+*/
+   length = strlen(kbuf->dynamic_param.location_code_str) + 1;
+   if (length > LOC_CODE_SIZE)
+   return ERR_PTR(-EINVAL);
+
+   len_be = cpu_to_be32(length);
+
+   work_area = rtas_work_area_alloc(LOC_CODE_SIZE + sizeof(u32));
+   memcpy(rtas_work_area_raw_buf(work_area), &len_be, sizeof(u32));
+   memcpy((rtas_work_area_raw_buf(work_area) + sizeof(u32)),
+   &kbuf->dynamic_param.location_cod

[PATCH 2/6] sh: remove duplicate ioread/iowrite helpers

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

The ioread/iowrite functions on sh only do memory mapped I/O like the
generic verion, and never map onto non-MMIO inb/outb variants, so they
just add complexity. In particular, the use of asm-generic/iomap.h
ties the declaration to the x86 implementation.

Remove the custom versions and use the architecture-independent fallback
code instead. Some of the calling conventions on sh are different here,
so fix that by adding 'volatile' keywords where required by the generic
implementation and change the cpg clock driver to no longer depend on
the interesting choice of return types for ioread8/ioread16/ioread32.

Signed-off-by: Arnd Bergmann 
---
 arch/sh/include/asm/io.h |  30 ++--
 arch/sh/kernel/Makefile  |   3 -
 arch/sh/kernel/iomap.c   | 162 ---
 arch/sh/kernel/ioport.c  |   5 --
 arch/sh/lib/io.c |   4 +-
 drivers/sh/clk/cpg.c |  25 +++---
 6 files changed, 21 insertions(+), 208 deletions(-)
 delete mode 100644 arch/sh/kernel/iomap.c

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index cf5eab840d57..0f663ebec700 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define __IO_PREFIX generic
 #include 
@@ -100,7 +99,7 @@ pfx##writes##bwlq(volatile void __iomem *mem, const void 
*addr,  \
}   \
 }  \
\
-static inline void pfx##reads##bwlq(volatile void __iomem *mem,
\
+static inline void pfx##reads##bwlq(const volatile void __iomem *mem,  \
void *addr, unsigned int count) \
 {  \
volatile type *__addr = addr;   \
@@ -114,37 +113,18 @@ static inline void pfx##reads##bwlq(volatile void __iomem 
*mem,   \
 __BUILD_MEMORY_STRING(__raw_, b, u8)
 __BUILD_MEMORY_STRING(__raw_, w, u16)
 
-void __raw_writesl(void __iomem *addr, const void *data, int longlen);
-void __raw_readsl(const void __iomem *addr, void *data, int longlen);
+void __raw_writesl(void volatile __iomem *addr, const void *data, int longlen);
+void __raw_readsl(const volatile void __iomem *addr, void *data, int longlen);
 
 __BUILD_MEMORY_STRING(__raw_, q, u64)
 
 #define ioport_map ioport_map
-#define ioport_unmap ioport_unmap
 #define pci_iounmap pci_iounmap
 
-#define ioread8 ioread8
-#define ioread16 ioread16
-#define ioread16be ioread16be
-#define ioread32 ioread32
-#define ioread32be ioread32be
-
-#define iowrite8 iowrite8
-#define iowrite16 iowrite16
-#define iowrite16be iowrite16be
-#define iowrite32 iowrite32
-#define iowrite32be iowrite32be
-
-#define ioread8_rep ioread8_rep
-#define ioread16_rep ioread16_rep
-#define ioread32_rep ioread32_rep
-
-#define iowrite8_rep iowrite8_rep
-#define iowrite16_rep iowrite16_rep
-#define iowrite32_rep iowrite32_rep
-
 #ifdef CONFIG_HAS_IOPORT_MAP
 
+extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
+
 /*
  * Slowdown I/O port space accesses for antique hardware.
  */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index ba917008d63e..7b453592adaf 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -21,10 +21,7 @@ obj-y:= head_32.o debugtraps.o dumpstack.o   
\
   syscalls_32.o time.o topology.o traps.o  \
   traps_32.o unwinder.o
 
-ifndef CONFIG_GENERIC_IOMAP
-obj-y  += iomap.o
 obj-$(CONFIG_HAS_IOPORT_MAP)   += ioport.o
-endif
 
 obj-y  += sys_sh32.o
 obj-y  += cpu/
diff --git a/arch/sh/kernel/iomap.c b/arch/sh/kernel/iomap.c
deleted file mode 100644
index 0a0dff4e66de..
--- a/arch/sh/kernel/iomap.c
+++ /dev/null
@@ -1,162 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * arch/sh/kernel/iomap.c
- *
- * Copyright (C) 2000  Niibe Yutaka
- * Copyright (C) 2005 - 2007 Paul Mundt
- */
-#include 
-#include 
-
-unsigned int ioread8(const void __iomem *addr)
-{
-   return readb(addr);
-}
-EXPORT_SYMBOL(ioread8);
-
-unsigned int ioread16(const void __iomem *addr)
-{
-   return readw(addr);
-}
-EXPORT_SYMBOL(ioread16);
-
-unsigned int ioread16be(const void __iomem *addr)
-{
-   return be16_to_cpu(__raw_readw(addr));
-}
-EXPORT_SYMBOL(ioread16be);
-
-unsigned int ioread32(const void __iomem *addr)
-{
-   return readl(addr);
-}
-EXPORT_SYMBOL(ioread32);
-
-unsigned int ioread32be(const void __iomem *addr)
-{
-   return be32_to_cpu(__raw_readl(addr));
-}
-EXPORT_SYMBOL(ioread32be);
-
-void iowrite8(u8 val, void __iomem *addr)
-{
-   writeb(val, addr);
-}
-EXPORT_SYMBOL(iowrite8);
-
-void iowrite16(u16 val, void __iomem *addr)

[PATCH 0/6] asm-generic: io.h cleanups

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

After the previous round of cleanups for asm-generic/io,h on the
ioread64 helpers, I had another look at the architecture specific
versions, especially those that caused build failures in the past.

These are some simplifications that I would like to merge at the same
time, please have a look. Hopefully these are all uncontroversial.

I have a few more patches for m68k that need a more thorough
review and testing, will post them after the merge window.

Arnd Bergmann (6):
  alpha: stop using asm-generic/iomap.h
  sh: remove duplicate ioread/iowrite helpers
  parisc: stop using asm-generic/iomap.h
  powerpc: asm/io.h: remove split ioread64/iowrite64 helpers
  mips: drop GENERIC_IOMAP wrapper
  m68k/nommu: stop using GENERIC_IOMAP

 arch/alpha/include/asm/io.h   |  31 ---
 arch/m68k/Kconfig |   2 +-
 arch/m68k/include/asm/io_no.h |   4 -
 arch/mips/Kconfig |   2 +-
 arch/mips/include/asm/io.h|  21 ++---
 arch/mips/lib/iomap-pci.c |   9 ++
 arch/parisc/include/asm/io.h  |  36 ++--
 arch/powerpc/include/asm/io.h |  48 --
 arch/sh/include/asm/io.h  |  30 ++-
 arch/sh/kernel/Makefile   |   3 -
 arch/sh/kernel/iomap.c| 162 --
 arch/sh/kernel/ioport.c   |   5 --
 arch/sh/lib/io.c  |   4 +-
 drivers/sh/clk/cpg.c  |  25 +++---
 14 files changed, 84 insertions(+), 298 deletions(-)
 delete mode 100644 arch/sh/kernel/iomap.c

-- 
2.39.5

Cc: Richard Henderson 
Cc: Matt Turner 
Cc: Geert Uytterhoeven 
Cc: Greg Ungerer 
Cc: Thomas Bogendoerfer 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Madhavan Srinivasan 
Cc: Michael Ellerman 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Cc: Naveen N Rao 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: John Paul Adrian Glaubitz 
Cc: Arnd Bergmann 
Cc: Julian Vetter 
Cc: Bjorn Helgaas 
Cc: linux-al...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-m...@vger.kernel.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux...@vger.kernel.org



[PATCH 3/6] parisc: stop using asm-generic/iomap.h

2025-03-15 Thread Arnd Bergmann
From: Arnd Bergmann 

parisc uses custom iomap helpers to map bus specific function calls into
a linear __iomem token, but it tries to use the declarations from the x86
"generic iomap" code.

Untangle the two by duplicating the required declations and dropping
the #include that pulls in more stuff that is not needed here, to
allow simplify the generic version later.

Signed-off-by: Arnd Bergmann 
---
 arch/parisc/include/asm/io.h | 36 +++-
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h
index 3143cf29ce27..59d85d2386bb 100644
--- a/arch/parisc/include/asm/io.h
+++ b/arch/parisc/include/asm/io.h
@@ -227,36 +227,54 @@ extern void outsl (unsigned long port, const void *src, 
unsigned long count);
 #define F_EXTEND(x) ((unsigned long)((x) | (0xULL)))
 
 #ifdef CONFIG_64BIT
-#define ioread64 ioread64
-#define ioread64be ioread64be
-#define iowrite64 iowrite64
-#define iowrite64be iowrite64be
 extern u64 ioread64(const void __iomem *addr);
 extern u64 ioread64be(const void __iomem *addr);
+#define ioread64 ioread64
+#define ioread64be ioread64be
+
 extern void iowrite64(u64 val, void __iomem *addr);
 extern void iowrite64be(u64 val, void __iomem *addr);
+#define iowrite64 iowrite64
+#define iowrite64be iowrite64be
 #endif
 
-#include 
-/*
- * These get provided from  since parisc does not
- * select GENERIC_IOMAP.
- */
+extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
+extern void ioport_unmap(void __iomem *);
 #define ioport_map ioport_map
 #define ioport_unmap ioport_unmap
+
+extern unsigned int ioread8(const void __iomem *);
+extern unsigned int ioread16(const void __iomem *);
+extern unsigned int ioread16be(const void __iomem *);
+extern unsigned int ioread32(const void __iomem *);
+extern unsigned int ioread32be(const void __iomem *);
 #define ioread8 ioread8
 #define ioread16 ioread16
 #define ioread32 ioread32
 #define ioread16be ioread16be
 #define ioread32be ioread32be
+
+extern void iowrite8(u8, void __iomem *);
+extern void iowrite16(u16, void __iomem *);
+extern void iowrite16be(u16, void __iomem *);
+extern void iowrite32(u32, void __iomem *);
+extern void iowrite32be(u32, void __iomem *);
 #define iowrite8 iowrite8
 #define iowrite16 iowrite16
 #define iowrite32 iowrite32
 #define iowrite16be iowrite16be
 #define iowrite32be iowrite32be
+
+extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long 
count);
+extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long 
count);
+extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long 
count);
 #define ioread8_rep ioread8_rep
 #define ioread16_rep ioread16_rep
 #define ioread32_rep ioread32_rep
+
+extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long 
count);
+extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long 
count);
+extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long 
count);
 #define iowrite8_rep iowrite8_rep
 #define iowrite16_rep iowrite16_rep
 #define iowrite32_rep iowrite32_rep
-- 
2.39.5




[PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().

2025-03-15 Thread xie.ludan
From: XieLudan 

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: XieLudan 
---
 sound/soc/fsl/imx-audmux.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index cc2918ee2cf5..6062503d3543 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -77,45 +77,41 @@ static ssize_t audmux_read_file(struct file *file, char 
__user *user_buf,
ret = sysfs_emit(buf, "PDCR: %08x\nPTCR: %08x\n", pdcr, ptcr);
 
if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR)
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"TxFS output from %s, ",
audmux_port_string((ptcr >> 27) & 0x7));
else
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"TxFS input, ");
 
if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR)
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"TxClk output from %s",
audmux_port_string((ptcr >> 22) & 0x7));
else
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-   "TxClk input");
+   ret += sysfs_emit(buf + ret, "TxClk input");
 
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
+   ret += sysfs_emit(buf + ret, "\n");
 
if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) {
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-   "Port is symmetric");
+   ret += sysfs_emit(buf + ret, "Port is symmetric");
} else {
if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR)
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"RxFS output from %s, ",
audmux_port_string((ptcr >> 17) & 0x7));
else
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-   "RxFS input, ");
+   ret += sysfs_emit(buf + ret, "RxFS input, ");
 
if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR)
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"RxClk output from %s",
audmux_port_string((ptcr >> 12) & 0x7));
else
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-   "RxClk input");
+   ret += sysfs_emit(buf + ret, "RxClk input");
}
 
-   ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+   ret += sysfs_emit(buf + ret,
"\nData received from %s\n",
audmux_port_string((pdcr >> 13) & 0x7));
 
-- 
2.25.1

[PATCH v9 3/7] powerpc/pseries: Add papr-indices char driver for ibm,get-indices

2025-03-15 Thread Haren Myneni
The RTAS call ibm,get-indices is used to obtain indices and
location codes for a specified indicator or sensor token. The
current implementation uses rtas_get_indices() API provided by
librtas library which allocates RMO buffer and issue this RTAS
call in the user space. But writable mapping /dev/mem access by
the user space is prohibited under system lockdown.

To overcome the restricted access in the user space, the kernel
provide interfaces to collect indices data from the hypervisor.
This patch adds papr-indices character driver and expose standard
interfaces such as open / ioctl/ read to user space in ways that
are compatible with lockdown.

PAPR (2.13 7.3.17 ibm,get-indices RTAS Call) describes the
following steps to retrieve all indices data:
- User input parameters to the RTAS call: sensor or indicator,
  and indice type
- ibm,get-indices is sequence RTAS call which means has to issue
  multiple times to get the entire list of indicators or sensors
  of a particular type. The hypervisor expects the first RTAS call
  with the sequence 1 and the subsequent calls with the sequence
  number returned from the previous calls.
- The OS may not interleave calls to ibm,get-indices for different
  indicator or sensor types. Means other RTAS calls with different
  type should not be issued while the previous type sequence is in
  progress. So collect the entire list of indices and copied to
  buffer BLOB during ioctl() and expose this buffer to the user
  space with the file descriptor.
- The hypervisor fills the work area with a specific format but
  does not return the number of bytes written to the buffer.
  Instead of parsing the data for each call to determine the data
  length, copy the work area size (RTAS_GET_INDICES_BUF_SIZE) to
  the buffer. Return work-area size of data to the user space for
  each read() call.

Expose these interfaces to user space with a /dev/papr-indices
character device using the following programming model:

 int devfd = open("/dev/papr-indices", O_RDONLY);
 int fd = ioctl(devfd, PAPR_INDICES_IOC_GET,
struct papr_indices_io_block)
  - Collect all indices data for the specified token to the buffer
 char *buf = malloc(RTAS_GET_INDICES_BUF_SIZE);
 length = read(fd, buf,  RTAS_GET_INDICES_BUF_SIZE)
  - RTAS_GET_INDICES_BUF_SIZE of data is returned to the user
space.
  - The user space retrieves the indices and their location codes
from the buffer
  - Should issue multiple read() calls until reaches the end of
BLOB buffer.

The read() should use the file descriptor obtained from ioctl to
get the data that is exposed to file descriptor. Implemented
support in librtas (rtas_get_indices()) for this new ABI for
system lockdown.

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/rtas.h   |   1 +
 arch/powerpc/kernel/rtas.c|   2 +-
 arch/powerpc/platforms/pseries/Makefile   |   2 +-
 arch/powerpc/platforms/pseries/papr-indices.c | 301 ++
 4 files changed, 304 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/platforms/pseries/papr-indices.c

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 04406162fc5a..7dc527a5aaac 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -515,6 +515,7 @@ extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
 extern unsigned long rtas_rmo_buf;
 
 extern struct mutex rtas_ibm_get_vpd_lock;
+extern struct mutex rtas_ibm_get_indices_lock;
 
 #define GLOBAL_INTERRUPT_QUEUE 9005
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index d31c9799cab2..76c634b92cb2 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -93,11 +93,11 @@ struct rtas_function {
  */
 static DEFINE_MUTEX(rtas_ibm_activate_firmware_lock);
 static DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock);
-static DEFINE_MUTEX(rtas_ibm_get_indices_lock);
 static DEFINE_MUTEX(rtas_ibm_lpar_perftools_lock);
 static DEFINE_MUTEX(rtas_ibm_physical_attestation_lock);
 static DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock);
 DEFINE_MUTEX(rtas_ibm_get_vpd_lock);
+DEFINE_MUTEX(rtas_ibm_get_indices_lock);
 
 static struct rtas_function rtas_function_table[] __ro_after_init = {
[RTAS_FNIDX__CHECK_EXCEPTION] = {
diff --git a/arch/powerpc/platforms/pseries/Makefile 
b/arch/powerpc/platforms/pseries/Makefile
index 697c216b70dc..e1db61877bb9 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
 
 obj-y  := lpar.o hvCall.o nvram.o reconfig.o \
   of_helpers.o rtas-work-area.o papr-sysparm.o \
-  papr-rtas-common.o papr-vpd.o \
+  papr-rtas-common.o papr-vpd.o papr-indices.o \
   setup.o iommu.o event_sources.o ras.o \
   firmware.o power.o dlpar.o mobilit

Re: [PATCH bpf-next 00/11] bpf: Mitigate Spectre v1 using barriers

2025-03-15 Thread Luis Gerhorst
Eduard Zingerman  writes:
> I think it would be good to have some tests checking that nospec
> instructions are inserted in expected locations.
> Could you please take look at use of __xlated tag in e.g.
> tools/testing/selftests/bpf/progs/verifier_sdiv.c ?

That looks very promising, I will look into it for v2. Thanks for the
pointer.

I guess it might be worth it to add __xlated to at least on test per
nospec-related code path. If there are other rewrites at play that will
make it harder to adapt the tests when the other rewrite is ever
changed, but it might also help in catching interactions between the
other rewrites and the nospec.

Also, thanks for the review of patches 2 and 3.



Soekris crypto 1411, where to find ?

2025-03-15 Thread DiTBho Down in The Bunny hole
hi
this is probably not the right place to ask, but I've been searching
eBay and similar places for 2 years and haven't found one yet.
I support older MIPS hardware and need to find a Soekris crypto 1411
miniPCI module or two, to add VPN acceleration.

Anyone have an idea where to buy it?

Soekris company went out of business years ago.

Let me know.
D.