powerpc/pseries: Add a char driver for physical-attestation RTAS
authorHaren Myneni <haren@linux.ibm.com>
Wed, 16 Apr 2025 22:57:42 +0000 (15:57 -0700)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Thu, 17 Apr 2025 06:12:30 +0000 (11:42 +0530)
commit86900ab620a42396a749b506d4a187820fc3fabe
treeecb54fc9c52410b526ab5f45928791e8353a78c8
parent8aa9efc0be667f5b982acffaf256100e97bcff03
powerpc/pseries: Add a char driver for physical-attestation RTAS

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 <haren@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250416225743.596462-8-haren@linux.ibm.com
Documentation/userspace-api/ioctl/ioctl-number.rst
arch/powerpc/include/asm/rtas.h
arch/powerpc/include/uapi/asm/papr-physical-attestation.h [new file with mode: 0644]
arch/powerpc/kernel/rtas.c
arch/powerpc/platforms/pseries/Makefile
arch/powerpc/platforms/pseries/papr-phy-attest.c [new file with mode: 0644]