powerpc/pseries/papr-sysparm: Expose character device to user space
authorNathan Lynch <nathanl@linux.ibm.com>
Tue, 12 Dec 2023 17:01:58 +0000 (11:01 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 13 Dec 2023 10:38:21 +0000 (21:38 +1100)
commit905b9e48786ec55b2c469db77fb46e20bf3e4901
tree41dc3e20c6cc7c56df709052fa6da0be7c87d759
parent35aae182bd7b422be3cefc08c12207bf2b973364
powerpc/pseries/papr-sysparm: Expose character device to user space

Until now the papr_sysparm APIs have been kernel-internal. But user
space needs access to PAPR system parameters too. The only method
available to user space today to get or set system parameters is using
sys_rtas() and /dev/mem to pass RTAS-addressable buffers between user
space and firmware. This is incompatible with lockdown and should be
deprecated.

So provide an alternative ABI to user space in the form of a
/dev/papr-sysparm character device with just two ioctl commands (get
and set). The data payloads involved are small enough to fit in the
ioctl argument buffer, making the code relatively simple.

Exposing the system parameters through sysfs has been considered but
it would be too awkward:

* The kernel currently does not have to contain an exhaustive list of
  defined system parameters. This is a convenient property to maintain
  because we don't have to update the kernel whenever a new parameter
  is added to PAPR. Exporting a named attribute in sysfs for each
  parameter would negate this.

* Some system parameters are text-based and some are not.

* Retrieval of at least one system parameter requires input data,
  which a simple read-oriented interface can't support.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-11-e9eafd0c8c6c@linux.ibm.com
Documentation/userspace-api/ioctl/ioctl-number.rst
arch/powerpc/include/asm/papr-sysparm.h
arch/powerpc/include/uapi/asm/papr-sysparm.h [new file with mode: 0644]
arch/powerpc/platforms/pseries/papr-sysparm.c