From: Nathan Lynch via B4 Relay <devnull+nathanl.linux.ibm.com@kernel.org>
To: Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>
Cc: "Nathan Lynch" <nathanl@linux.ibm.com>,
tyreld@linux.ibm.com, "Michal Suchánek" <msuchanek@suse.de>,
linuxppc-dev@lists.ozlabs.org, gcwilson@linux.ibm.com
Subject: [PATCH v3 00/10] powerpc/pseries: New character devices for system parameters and VPD
Date: Wed, 25 Oct 2023 22:24:14 -0500 [thread overview]
Message-ID: <20231025-papr-sys_rtas-vs-lockdown-v3-0-5eb04559e7d8@linux.ibm.com> (raw)
Add character devices that expose PAPR-specific system parameters and
VPD to user space.
The problem: important platform features are enabled on Linux VMs
through the powerpc-specific rtas() syscall in combination with
writeable mappings of /dev/mem. In typical usage, this is encapsulated
behind APIs provided by the librtas library. This paradigm is
incompatible with lockdown, which prohibits /dev/mem access. It also
is too low-level in many cases: a single logical operation may require
multiple sys_rtas() calls in succession to complete. This carries the
risk that a process may exit while leaving an operation unfinished. It
also means that callers must coordinate their use of the syscall for
functions that cannot tolerate multiple concurrent clients, such as
ibm,get-vpd.
The solution presented here is to add a pair of small pseries-specific
"drivers," one for VPD and one for system parameters. The new drivers
expose these facilities to user space in ways that are compatible with
lockdown and require no coordination between their clients.
Since the ibm,get-vpd call sequence performed by the papr-vpd driver
must be serialized against all other uses of the function, the series
begins by adding some new APIs to the core RTAS support code for this
purpose.
Both drivers could potentially support poll() methods to notify
clients of changes to parameters or VPD that happen due to partition
migration and other events. But that should be safe to leave for
later, assuming there's any interest.
I have made changes to librtas to prefer the new interfaces and
verified that existing clients work correctly with the new code. A
draft PR for that work is here:
https://github.com/ibm-power-utilities/librtas/pull/36
The user-space ABI has not changed since v1 of this series.
I expect to propose at least one more small driver in this style for
platform dump retrieval in a separate submission in the future.
---
Changes in v3:
- Add new rtas_function_lock()/unlock() APIs and convert existing code
to use them.
- Convert papr-vpd to use rtas_function_lock()/unlock() instead of
having sys_rtas() obtain a driver-private mutex.
- Rebase on current powerpc/next.
- Link to v2: https://lore.kernel.org/r/20231013-papr-sys_rtas-vs-lockdown-v2-0-ead01ce01722@linux.ibm.com
Changes in v2:
- Fix unused-but-set variable warning in papr-sysparm code.
- Rebase on powerpc/next branch.
- Link to v1: https://lore.kernel.org/r/20231006-papr-sys_rtas-vs-lockdown-v1-0-3a36bfb66e2e@linux.ibm.com
Changes in v1 vs initial RFC:
- Add papr-sysparm driver and tests.
- Add a papr-miscdev.h uapi header.
- Prevent sys_rtas() from interfering with papr-vpd call sequences.
- Handle -4 ("VPD changed") status in papr-vpd.
- Include string_helpers.h in papr-vpd.c, per Michal Suchánek
- Link to RFC: https://lore.kernel.org/r/20230822-papr-sys_rtas-vs-lockdown-v1-0-932623cf3c7b@linux.ibm.com
---
Nathan Lynch (10):
powerpc/rtas: Factor out function descriptor lookup
powerpc/rtas: Facilitate high-level call sequences
powerpc/rtas: Serialize firmware activation sequences
powerpc/rtas: Warn if per-function lock isn't held
powerpc/uapi: Export papr-miscdev.h header
powerpc/pseries: Add papr-vpd character driver for VPD retrieval
powerpc/pseries/papr-sysparm: Validate buffer object lengths
powerpc/pseries/papr-sysparm: Expose character device to user space
powerpc/selftests: Add test for papr-vpd
powerpc/selftests: Add test for papr-sysparm
Documentation/userspace-api/ioctl/ioctl-number.rst | 4 +
arch/powerpc/include/asm/papr-sysparm.h | 17 +-
arch/powerpc/include/asm/rtas.h | 2 +
arch/powerpc/include/uapi/asm/papr-miscdev.h | 9 +
arch/powerpc/include/uapi/asm/papr-sysparm.h | 58 +++
arch/powerpc/include/uapi/asm/papr-vpd.h | 22 +
arch/powerpc/kernel/rtas.c | 157 ++++++-
arch/powerpc/platforms/pseries/Makefile | 1 +
arch/powerpc/platforms/pseries/papr-sysparm.c | 201 +++++++-
arch/powerpc/platforms/pseries/papr-vpd.c | 522 +++++++++++++++++++++
tools/testing/selftests/powerpc/Makefile | 2 +
.../selftests/powerpc/papr_sysparm/.gitignore | 1 +
.../selftests/powerpc/papr_sysparm/Makefile | 12 +
.../selftests/powerpc/papr_sysparm/papr_sysparm.c | 164 +++++++
.../testing/selftests/powerpc/papr_vpd/.gitignore | 1 +
tools/testing/selftests/powerpc/papr_vpd/Makefile | 12 +
.../testing/selftests/powerpc/papr_vpd/papr_vpd.c | 352 ++++++++++++++
17 files changed, 1503 insertions(+), 34 deletions(-)
---
base-commit: 36e826b568e412f61d68fedc02a67b4d8b7583cc
change-id: 20230817-papr-sys_rtas-vs-lockdown-5c54505db792
Best regards,
--
Nathan Lynch <nathanl@linux.ibm.com>
next reply other threads:[~2023-10-26 3:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 3:24 Nathan Lynch via B4 Relay [this message]
2023-10-26 3:24 ` [PATCH v3 01/10] powerpc/rtas: Factor out function descriptor lookup Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 02/10] powerpc/rtas: Facilitate high-level call sequences Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 03/10] powerpc/rtas: Serialize firmware activation sequences Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 04/10] powerpc/rtas: Warn if per-function lock isn't held Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 05/10] powerpc/uapi: Export papr-miscdev.h header Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 06/10] powerpc/pseries: Add papr-vpd character driver for VPD retrieval Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 07/10] powerpc/pseries/papr-sysparm: Validate buffer object lengths Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 08/10] powerpc/pseries/papr-sysparm: Expose character device to user space Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 09/10] powerpc/selftests: Add test for papr-vpd Nathan Lynch via B4 Relay
2023-10-26 3:24 ` [PATCH v3 10/10] powerpc/selftests: Add test for papr-sysparm Nathan Lynch via B4 Relay
2023-10-26 23:56 ` [PATCH v3 00/10] powerpc/pseries: New character devices for system parameters and VPD Nathan Lynch
2023-11-13 9:16 ` Michal Suchánek
2023-11-13 13:44 ` Nathan Lynch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231025-papr-sys_rtas-vs-lockdown-v3-0-5eb04559e7d8@linux.ibm.com \
--to=devnull+nathanl.linux.ibm.com@kernel.org \
--cc=gcwilson@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=tyreld@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).