Introduce Platform Firmware Runtime Update and Telemetry drivers
Subsystems (4)
v9 cover Introduce Platform Firmware Runtime Update and Telemetry drivers
The PFRU (Platform Firmware Runtime Update) kernel interface is designed to interact with the platform firmware interface defined in the `Management Mode Firmware Runtime Update
<https://uefi.org/sites/default/files/resources/Intel_MM_OS_Interface_Spec_Rev100.pdf>`
specification. The primary function of PFRU is to carry out runtime updates of the platform firmware, which doesn't require the system to be restarted. It also allows telemetry data to be retrieved from the platform firmware.
=============
- Change from v8 to v9:
- Use GUID_INIT() instead of guid_parse() during boot up.
(Andy Shevchenko)
- Drop uuid, code_uuid, drv_uuid in struct pfru_device as they
are not needed. (Andy Shevchenko)
- Drop type casting from void * in valid_version().
(Andy Shevchenko)
- Use kfree() instead of ACPI_FREE() in non-ACPICA usage.
(Andy Shevchenko)
- Use sizeof(rev) instead of sizeof(u32) in copy_from_user(). (Andy Shevchenko)
- Generate physical address from MSB part to LSB.
(Andy Shevchenko)
- Use devm_add_action_or_reset() to add ida release into dev resource management. (Andy Shevchenko)
- Use devm_kasprintf() instead of kasprintf() to format the pfru_dev name.(Andy Shevchenko)
- Remove redundant 0 in acpi_pfru_ids. (Andy Shevchenko)
- Adjust the order of included headers in pfru.h.
(Andy Shevchenko)
- Replace PFRU_MAGIC with PFRU_MAGIC_FOR_IOCTL in uapi file.
(Andy Shevchenko)
Use devm_kasprintf() instead of kasprintf() to format the pfru_log_dev name.(Andy Shevchenko)
Remove redundant 0 in acpi_pfru_log_ids. (Andy Shevchenko)
- Change from v7 to v8:
- Remove the variable-length array in struct pfru_update_cap_info, and copy the non-variable-length struct pfru_update_cap_info to userspace directly. (Greg Kroah-Hartman)
- Use efi_guid_t instead of guid_t when parsing capsule file. (Andy Shevchenko)
- Change the type of rev_id from int to u32, because this data will be copied between kernel and userspace. (Greg Kroah-Hartman)
- Add a prefix for dev in struct pfru_device to parent_dev, so as to indicate that this filed is the parent of the created miscdev. (Greg Kroah-Hartman)
- Use blank lines between different macro sections. (Greg Kroah-Hartman) Illusatrate the possible errno for each ioctl interface.
(Greg Kroah-Hartman)
- Remove pfru_valid_revid() from uapi header to avoid poluting the global namespace.(Greg Kroah-Hartman)
- Assign the value to the enum type explicitly.(Greg Kroah-Hartman)
- Change the guid_t to efi_guid_t when parsing image header in get_image_type() (Greg Kroah-Hartman)
- Remove the void * to other type casting in valid_version(). (Andy Shevchenko)
- Combined the assignment of variables with definitions. (Andy Shevchenko)
- Define this magic for revision ID. (Andy Shevchenko)
- Make the labeling consistent for error handling. (Andy Shevchenko)
- Replace the UUID_SIZE in uapi with 16 directly. (Andy Shevchenko)
- Add blank line between generic include header and uapi header. (Andy Shevchenko)
- Arrange the order between devm_kzalloc() and normal allocation in acpi_pfru_probe() that, the former should always be ahead of the latter. (Andy Shevchenko)
- Change from v6 to v7:
- Use __packed instead of pragma pack(1).
(Greg Kroah-Hartman, Ard Biesheuve)
- Use ida_alloc() to allocate a ID, and release the ID when
device is removed. (Greg Kroah-Hartman)
- Check the _DSM method at early stage, before allocate or parse anything in acpi_pfru_[log_]probe(). (Greg Kroah-Hartman)
- Set the parent of the misc device. (Greg Kroah-Hartman)
- Use module_platform_driver() instead of platform_driver_register() in module_init(). Separate pfru driver and pfru_telemetry driver to two files. (Greg Kroah-Hartman)
- Change from v5 to v6:
- Use Link: tag to add the specification download address.
(Andy Shevchenko)
- Drop comma for each terminator entry in the enum structure. (Andy Shevchenko)
- Remove redundant 'else' in get_image_type().
(Andy Shevchenko)
- Directly return results from the switch cases in adjust_efi_size() and pfru_ioctl().(Andy Shevchenko)
- Keep comment style consistency by removing the period for
one line comment.
(Andy Shevchenko)
- Remove devm_kfree() if .probe() failed.
(Andy Shevchenko)
- Remove linux/uuid.h and use raw buffers to contain uuid.
(Andy Shevchenko)
- Include types.h in pfru.h. (Andy Shevchenko)
- Use __u8[16] instead of uuid_t. (Andy Shevchenko)
- Replace enum in pfru.h with __u32 as enum size is not the
same size on all possible architectures.
(Andy Shevchenko)
- Simplify the userspace tool to use while loop for getopt_long(). (Andy Shevchenko)
- Change from v4 to v5:
- Remove Documentation/ABI/pfru, and move the content to kernel doc in include/uapi/linux/pfru.h (Greg Kroah-Hartman)
- Shrink the range of ioctl numbers declared in Documentation/userspace-api/ioctl/ioctl-number.rst
from 16 to 8. (Greg Kroah-Hartman)
- Change global variable struct pfru_device *pfru_dev to
per PFRU device. (Greg Kroah-Hartman)
- Unregister the misc device in acpi_pfru_remove().
(Greg Kroah-Hartman)
- Convert the kzalloc() to devm_kzalloc() in the driver so
as to avoid freeing the memory. (Greg Kroah-Hartman)
- Fix the compile warning by declaring the pfru_log_ioctl() as static. (kernel test robot LKP)
- Change to global variable misc_device to per PFRU device.
(Greg Kroah-Hartman)
- Remove the telemetry output in commit log. (Greg Kroah-Hartman)
- Add link for corresponding userspace tool in the commit log. (Greg Kroah-Hartman)
- Replace the telemetry .read() with .mmap() so that the userspace could mmap once, and read multiple times. (Greg Kroah-Hartman)
- Change from v3 to v4:
- Add Documentation/ABI/testing/pfru to document the ABI and remove Documentation/x86/pfru.rst (Rafael J. Wysocki)
- Replace all pr_err() with dev_dbg() (Greg Kroah-Hartman,
Rafael J. Wysocki)
- returns ENOTTY rather than ENOIOCTLCMD if invalid ioctl command is provided. (Greg Kroah-Hartman)
- Remove compat ioctl. (Greg Kroah-Hartman)
- Rename /dev/pfru/pfru_update to /dev/acpi_pfru (Greg Kroah-Hartman)
- Simplify the check for element of the package in query_capability() (Rafael J. Wysocki)
- Remove the loop in query_capability(), query_buffer() and query the package elemenet directly. (Rafael J. Wysocki)
- Check the number of elements in case the number of package elements is too small. (Rafael J. Wysocki)
- Doing the assignment as initialization in get_image_type(). Meanwhile, returns the type or a negative error code in get_image_type(). (Rafael J. Wysocki)
- Put the comments inside the function. (Rafael J. Wysocki)
- Returns the size or a negative error code in adjust_efi_size() (Rafael J. Wysocki)
- Fix the return value from EFAULT to EINVAL if pfru_valid_revid() does not pass. (Rafael J. Wysocki)
- Change the write() to be the code injection/update, the read() to be telemetry retrieval and all of the rest to be ioctl()s under one special device file.(Rafael J. Wysocki)
- Remove redundant parens. (Rafael J. Wysocki)
- Putting empty code lines after an if () statement that is not followed by a block. (Rafael J. Wysocki)
- Remove "goto" tags to make the code more readable. (Rafael J. Wysocki)
- Change from v2 to v3:
- Use valid types for structures that cross the user/kernel boundary in the uapi header. (Greg Kroah-Hartman)
- Rename the structure in uapi to start with a prefix pfru so as to avoid confusing in the global namespace. (Greg Kroah-Hartman)
- Change from v1 to v2:
- Add a spot in index.rst so it becomes part of the docs build (Jonathan Corbet).
- Sticking to the 80-column limit(Jonathan Corbet).
- Underline lengths should match the title text(Jonathan Corbet).
- Use literal blocks for the code samples(Jonathan Corbet).
- Add sanity check for duplicated instance of ACPI device.
- Update the driver to work with allocated pfru_device objects. (Mike Rapoport)
- For each switch case pair, get rid of the magic case numbers
and add a default clause with the error handling.(Mike Rapoport)
- Move the obj->type checks outside the switch to reduce redundancy. (Mike Rapoport)
- Parse the code_inj_id and drv_update_id at driver initialization time to reduce the re-parsing at runtime. (Mike Rapoport)
- Explain in detail how the size needs to be adjusted when doing version check. (Mike Rapoport)
- Rename parse_update_result() to dump_update_result()
(Mike Rapoport)
- Remove redundant return.(Mike Rapoport)
- Do not expose struct capsulate_buf_info to uapi, since it is
not needed in userspace. (Mike Rapoport)
- Do not allow non-root user to run this test.(Shuah Khan)
- Test runs on platform without pfru_telemetry should skip
instead of reporting failure/error.(Shuah Khan)
- Reuse uapi/linux/pfru.h instead of copying it into the test directory. (Mike Rapoport)
Chen Yu (4):
efi: Introduce EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and
corresponding structures
drivers/acpi: Introduce Platform Firmware Runtime Update device driver drivers/acpi: Introduce Platform Firmware Runtime Update Telemetry
tools: Introduce power/acpi/tools/pfru
.../userspace-api/ioctl/ioctl-number.rst | 1 + drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/pfru/Kconfig | 13 + drivers/acpi/pfru/Makefile | 2 + drivers/acpi/pfru/pfru_telemetry.c | 458 ++++++++++++++ drivers/acpi/pfru/pfru_update.c | 598 ++++++++++++++++++ include/linux/efi.h | 46 ++ include/uapi/linux/pfru.h | 262 ++++++++ tools/power/acpi/.gitignore | 1 + tools/power/acpi/Makefile | 16 +- tools/power/acpi/Makefile.rules | 2 +- tools/power/acpi/man/pfru.8 | 137 ++++ tools/power/acpi/tools/pfru/Makefile | 23 + tools/power/acpi/tools/pfru/pfru.c | 417 ++++++++++++ 15 files changed, 1969 insertions(+), 9 deletions(-) create mode 100644 drivers/acpi/pfru/Kconfig create mode 100644 drivers/acpi/pfru/Makefile create mode 100644 drivers/acpi/pfru/pfru_telemetry.c create mode 100644 drivers/acpi/pfru/pfru_update.c create mode 100644 include/uapi/linux/pfru.h create mode 100644 tools/power/acpi/man/pfru.8 create mode 100644 tools/power/acpi/tools/pfru/Makefile create mode 100644 tools/power/acpi/tools/pfru/pfru.c
Signature · 1 line
2.25.1
PATCH v9 1/4 efi: Introduce EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and corresponding structures
Platform Firmware Runtime Update image starts with UEFI headers, and the headers are defined in UEFI specification, but some of them have not been defined in the kernel yet.
For example, the header layout of a capsule file looks like this:
EFI_CAPSULE_HEADEREFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADEREFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADEREFI_FIRMWARE_IMAGE_AUTHENTICATION
These structures would be used by the Platform Firmware Runtime Update driver to parse the format of capsule file to verify if the corresponding version number is valid. The EFI_CAPSULE_HEADER has been defined in the kernel, however the rest are not, thus introduce corresponding UEFI structures accordingly. Besides, EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER are required to be packed in the uefi specification. Ard has pointed out that, the __packed attribute does indicate to the compiler that the entire thing can appear misaligned in memory. So if one follows the other in the capsule header, the __packed attribute may be appropriate to ensure that the second one is not accessed using misaligned loads and stores.
---
v9: No change since v8.
v8: Use efi_guid_t instead of guid_t. (Andy Shevchenko)
v7: Use __packed instead of pragma pack(1). (Greg Kroah-Hartman, Ard Biesheuve)
v6: No change since v5.
v5: No change since v4.
v4: Revise the commit log to make it more clear. (Rafael J. Wysocki)
--- include/linux/efi.h | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
include/linux/efi.h +46 -0
@@ -148,6 +148,52 @@ typedef struct {u32 imagesize; } efi_capsule_header_t; +/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER */ +struct efi_manage_capsule_header { +u32 ver; +u16 emb_drv_cnt; +u16 payload_cnt; +/* +* Variable array indicated by number of +* (emb_drv_cnt + payload_cnt) +*/ +u64 offset_list[]; +} __packed; + +/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER */ +struct efi_manage_capsule_image_header { +u32 ver; +efi_guid_t image_type_id; +u8 image_index; +u8 reserved_bytes[3 ]; +u32 image_size; +u32 vendor_code_size; +/* ver = 2. */ +u64 hw_ins; +/* ver = v3. */ +u64 capsule_support; +} __packed; + +/* WIN_CERTIFICATE */ +struct win_cert { +u32 len; +u16 rev; +u16 cert_type; +}; + +/* WIN_CERTIFICATE_UEFI_GUID */ +struct win_cert_uefi_guid { +struct win_cert hdr; +efi_guid_t cert_type; +u8 cert_data[]; +}; + +/* EFI_FIRMWARE_IMAGE_AUTHENTICATIO */ +struct efi_image_auth { +u64 mon_count; +struct win_cert_uefi_guid auth_info; +}; +/* * EFI capsule flags */
Signature · 1 line
2.25.1
PATCH v9 2/4 drivers/acpi: Introduce Platform Firmware Runtime Update device driver
In reply to Chen YuIntroduce the pfru_update driver which can be used for Platform Firmware Runtime code injection and driver update [1]. The user is expected to provide the update firmware in the form of capsule file, and pass it to the driver via ioctl. Then the driver would hand this capsule file to the Platform Firmware Runtime Update via the ACPI device _DSM method. At last the low level Management Mode would do the firmware update.
The corresponding userspace tool and man page will be introduced at tools/power/acpi/tools/pfru.
---
v9: Use GUID_INIT() instead of guid_parse() during boot up.
(Andy Shevchenko)
Drop uuid, code_uuid, drv_uuid in struct pfru_device as they
are not needed. (Andy Shevchenko)
Drop type casting from void * in valid_version().
(Andy Shevchenko)
Use kfree() instead of ACPI_FREE() in non-ACPICA usage.
(Andy Shevchenko)
Use sizeof(rev) instead of sizeof(u32) in copy_from_user(). (Andy Shevchenko)
Generate physical address from MSB part to LSB.
(Andy Shevchenko)
Use devm_add_action_or_reset() to add ida release into dev resource management. (Andy Shevchenko)
Use devm_kasprintf() instead of kasprintf() to format the pfru_dev name.(Andy Shevchenko)
Remove redundant 0 in acpi_pfru_ids. (Andy Shevchenko)
Adjust the order of included headers in pfru.h.
(Andy Shevchenko)
Replace PFRU_MAGIC with PFRU_MAGIC_FOR_IOCTL in uapi file.
(Andy Shevchenko)
v8: Remove the variable-length array in struct pfru_update_cap_info, and
copy the non-variable-length struct pfru_update_cap_info to userspace directly. (Greg Kroah-Hartman)
Change the type of rev_id from int to u32, because this data will be copied between kernel and userspace. (Greg Kroah-Hartman)
Add a prefix for dev in struct pfru_device to parent_dev, so as to indicate that this filed is the parent of the created miscdev. (Greg Kroah-Hartman)
Use blank lines between different macro sections. (Greg Kroah-Hartman) Illusatrate the possible errno for each ioctl interface.
(Greg Kroah-Hartman)
Remove pfru_valid_revid() from uapi header to avoid poluting the global namespace.(Greg Kroah-Hartman)
Assign the value to the enum type explicitly.(Greg Kroah-Hartman) Change the guid_t to efi_guid_t when parsing image header in get_image_type() (Greg Kroah-Hartman)
Remove the void * to other type casting in valid_version(). (Andy Shevchenko) Combined the assignment of variables with definitions. (Andy Shevchenko) Define this magic for revision ID. (Andy Shevchenko)
Make the labeling consistent for error handling. (Andy Shevchenko) Replace the UUID_SIZE in uapi with 16 directly. (Andy Shevchenko) Add blank line between generic include header and uapi header. (Andy Shevchenko)
Arrange the order between devm_kzalloc() and normal allocation in acpi_pfru_probe() that, the former should always be ahead of the latter. (Andy Shevchenko)
Move the UUID from uapi header to the c file. (Andy Shevchenko)
v7: Use ida_alloc() to allocate a ID, and release the ID when
device is removed. (Greg Kroah-Hartman)
Check the _DSM method at early stage, before allocate or parse anything in acpi_pfru_probe(). (Greg Kroah-Hartman)
Set the parent of the misc device. (Greg Kroah-Hartman)
Use module_platform_driver() instead of platform_driver_register() in module_init(). Separate pfru driver and pfru_telemetry driver to two files. (Greg Kroah-Hartman)
v6: Use Link: tag to add the specification download address.
(Andy Shevchenko)
Remove linux/uuid.h and use raw buffers to contain uuid.
(Andy Shevchenko)
Drop comma for each terminator entry in the enum structure. (Andy Shevchenko)
Remove redundant 'else' in get_image_type().
(Andy Shevchenko)
Directly return results from the switch cases in adjust_efi_size() and pfru_ioctl().(Andy Shevchenko)
Keep comment style consistent by removing the period for
one line comment.
(Andy Shevchenko)
Remove devm_kfree() if .probe() failed.
(Andy Shevchenko)
v5: Remove Documentation/ABI/pfru, and move the content to kernel doc
in include/uapi/linux/pfru.h (Greg Kroah-Hartman)
Shrink the range of ioctl numbers declared in Documentation/userspace-api/ioctl/ioctl-number.rst
from 16 to 8. (Greg Kroah-Hartman)
Change global variable struct pfru_device *pfru_dev to
per ACPI device. (Greg Kroah-Hartman)
Unregister the misc device in acpi_pfru_remove().
(Greg Kroah-Hartman)
Convert the kzalloc() to devm_kzalloc() in the driver so
as to avoid freeing the memory. (Greg Kroah-Hartman)
Fix the compile error by declaring the pfru_log_ioctl() as static. (kernel test robot LKP)
Change to global variable misc_device to per ACPI device.
(Greg Kroah-Hartman)
v4: Replace all pr_err() with dev_dbg() (Greg Kroah-Hartman,
Rafael J. Wysocki)
Returns ENOTTY rather than ENOIOCTLCMD if invalid ioctl command is provided. (Greg Kroah-Hartman)
Remove compat ioctl. (Greg Kroah-Hartman)
Rename /dev/pfru/pfru_update to /dev/acpi_pfru (Greg Kroah-Hartman) Simplify the check for element of the package in query_capability() (Rafael J. Wysocki)
Remove the loop in query_capability(), query_buffer() and query the package elemenet directly. (Rafael J. Wysocki)
Check the the number of elements in case the number of package elements is too small. (Rafael J. Wysocki)
Doing the assignment as initialization in get_image_type(). Meanwhile, returns the type or a negative error code in get_image_type(). (Rafael J. Wysocki)
Put the comments inside the function. (Rafael J. Wysocki) Returns the size or a negative error code in adjust_efi_size() (Rafael J. Wysocki)
Fix the return value from EFAULT to EINVAL if pfru_valid_revid() does not pass. (Rafael J. Wysocki)
Change the write() to be the code injection/update, the read() to be telemetry retrieval and all of the rest to be ioctl()s under one special device file.(Rafael J. Wysocki)
Putting empty code lines after an if () statement that is not followed by a block. (Rafael J. Wysocki)
Remove "goto" tags to make the code more readable. (Rafael J. Wysocki)
v3: Use __u32 instead of int and __64 instead of unsigned long
in include/uapi/linux/pfru.h (Greg Kroah-Hartman)
Rename the structure in uapi to start with a prefix pfru so as to avoid confusing in the global namespace. (Greg Kroah-Hartman)
v2: Add sanity check for duplicated instance of ACPI device.
Update the driver to work with allocated pfru_device objects. (Mike Rapoport)
For each switch case pair, get rid of the magic case numbers
and add a default clause with the error handling.
(Mike Rapoport)
Move the obj->type checks outside the switch to reduce redundancy. (Mike Rapoport)
Parse the code_inj_id and drv_update_id at driver initialization time to reduce the re-parsing at runtime.(Mike Rapoport)
Explain in detail how the size needs to be adjusted when doing version check.(Mike Rapoport)
Rename parse_update_result() to dump_update_result()(Mike Rapoport) Remove redundant return.(Mike Rapoport)
Do not expose struct capsulate_buf_info to uapi, since it is
not needed in userspace.(Mike Rapoport)
--- .../userspace-api/ioctl/ioctl-number.rst | 1 + drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/pfru/Kconfig | 13 + drivers/acpi/pfru/Makefile | 2 + drivers/acpi/pfru/pfru_update.c | 598 ++++++++++++++++++ include/uapi/linux/pfru.h | 174 +++++ 7 files changed, 790 insertions(+) create mode 100644 drivers/acpi/pfru/Kconfig create mode 100644 drivers/acpi/pfru/Makefile create mode 100644 drivers/acpi/pfru/pfru_update.c create mode 100644 include/uapi/linux/pfru.h
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -0
@@ -366,6 +366,7 @@ Code Seq# Include File Comments <mailto:[email protected]> 0xE5 00-3F linux/fuse.h 0xEC 00-01 drivers/platform/chrome/cros_ec_dev.h ChromeOS EC driver +0xEE 00-09 uapi/linux/pfru.h Platform Firmware Runtime Update and Telemetry 0xF3 00-3F drivers/usb/misc/sisusbvga/sisusb.h sisfb (in development) <mailto:[email protected]> 0xF6 all LTTng Linux Trace Toolkit Next Generation
drivers/acpi/Kconfig +1 -0
@@ -482,6 +482,7 @@ source "drivers/acpi/nfit/Kconfig" source "drivers/acpi/numa/Kconfig" source "drivers/acpi/apei/Kconfig" source "drivers/acpi/dptf/Kconfig" +source "drivers/acpi/pfru/Kconfig" config ACPI_WATCHDOG bool
drivers/acpi/Makefile +1 -0
@@ -102,6 +102,7 @@ obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o +obj-$(CONFIG_ACPI_PFRU) += pfru/ # processor has its own "processor." module_param namespace processor-y := processor_driver.o
drivers/acpi/pfru/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +config ACPI_PFRU + tristate "ACPI Platform Firmware Runtime Update (PFRU)" + depends on 64BIT + help + In order to reduce the system reboot times and update the platform firmware + in time, Platform Firmware Runtime Update is leveraged to patch the system + without reboot. This driver supports Platform Firmware Runtime Update, + which is composed of two parts: code injection and driver update. It also + allows telemetry data to be retrieved from the platform firmware. + + To compile this driver as module, choose M here: + the modules will be called pfru_update and pfru_telemetry.
drivers/acpi/pfru/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_ACPI_PFRU) += pfru_update.o
drivers/acpi/pfru/pfru_update.c new file +598 -0
598 lines not on this page · raw message
include/uapi/linux/pfru.h new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 3/4 drivers/acpi: Introduce Platform Firmware Runtime Update Telemetry
In reply to Chen YuPlatform Firmware Runtime Update(PFRU) Telemetry Service is part of RoT (Root of Trust), which allows PFRU handler and other PFRU drivers to produce telemetry data to upper layer OS consumer at runtime.
The Linux kernel provides interfaces for the user to query the parameters of telemetry data, and the user could read out the telemetry data accordingly.
PFRU and PFRU Telemetry both invoke _DSM to trigger the low level actions. However the input parameters and ACPI package result as well as the functions are different from each other. It is hard to extract the common code between them, so introduce separated files for them.
The corresponding userspace tool and man page will be introduced at tools/power/acpi/tools/pfru.
---
v9: Use GUID_INIT() instead of guid_parse() during boot up.
(Andy Shevchenko)
Drop uuid from struct pfru_log_device.(Andy Shevchenko)
Use kfree() instead of ACPI_FREE() in non-ACPICA usage. (Andy Shevchenko)
Use devm_add_action_or_reset() to add ida release into dev resource management. (Andy Shevchenko)
Use devm_kasprintf() instead of kasprintf() to format the pfru_log_dev name.(Andy Shevchenko)
Remove redundant 0 in acpi_pfru_log_ids. (Andy Shevchenko)
v8: Add blank line between generic include header and uapi header.
(Andy Shevchenko)
Arrange the order between devm_kzalloc() and normal allocation in acpi_pfru_log_probe() that, the former should always be ahead of the latter. (Andy Shevchenko)
Amend commit message to elaborate the reason why PFRU and PRFU_Telemetry drivers look the same. (Andy Shevchenko)
v7: Use ida_alloc() to allocate a ID, and release the ID when
device is removed. (Greg Kroah-Hartman)
Check the _DSM method at early stage, before allocate or parse anything in acpi_pfru_log_probe(). (Greg Kroah-Hartman)
Set the parent of the misc device. (Greg Kroah-Hartman)
Use module_platform_driver() instead of platform_driver_register() in module_init(). Separate pfru driver and pfru_telemetry driver to two files. (Greg Kroah-Hartman)
v6: Remove linux/uuid.h and use raw buffers to contain uuid.
(Andy Shevchenko)
Include types.h in pfru.h. (Andy Shevchenko)
Use __u8[16] instead of uuid_t. (Andy Shevchenko)
Replace enum in pfru.h with __u32 as enum size is not the same on all possible architectures.
(Andy Shevchenko)
Directly return results from the switch cases in pfru_log_ioctl(). (Andy Shevchenko)
v5: Remove the log output sample in commit log. (Greg Kroah-Hartman)
Add link for corresponding userspace tool in the commit log. (Greg Kroah-Hartman)
Replace the telemetry .read() with .mmap() so that the userspace could mmap once, and read multiple times. (Greg Kroah-Hartman) Fix the compile warning by declaring the pfru_log_ioctl() as static. (kernel test robot LKP)
v4: Change the write() to be the code injection/update, the read() to
be telemetry retrieval and all of the rest to be ioctl()s under one special device file.(Rafael J. Wysocki)
Remove redundant parens. (Rafael J. Wysocki)
Putting empty code lines after an if () statement that is not followed by a block. (Rafael J. Wysocki)
Remove "goto" tags to make the code more readable. (Rafael J. Wysocki)
v3: Use __u32 instead of int and __64 instead of unsigned long
in include/uapi/linux/pfru.h (Greg Kroah-Hartman)
Rename the structure in uapi to start with a prefix pfru so as to avoid confusing in the global namespace. (Greg Kroah-Hartman)
v2: Do similar clean up as pfru_update driver:
Add sanity check for duplicated instance of ACPI device. Update the driver to work with allocated telem_device objects. (Mike Rapoport)
For each switch case pair, get rid of the magic case numbers and add a default clause with the error handling.
(Mike Rapoport)
--- drivers/acpi/pfru/Makefile | 2 +- drivers/acpi/pfru/pfru_telemetry.c | 457 +++++++++++++++++++++++++++++ include/uapi/linux/pfru.h | 88 ++++++ 3 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/pfru/pfru_telemetry.c
drivers/acpi/pfru/Makefile +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_ACPI_PFRU) += pfru_update.o +obj-$(CONFIG_ACPI_PFRU) += pfru_update.o pfru_telemetry.o
drivers/acpi/pfru/pfru_telemetry.c new file +457 -0
457 lines not on this page · raw message
include/uapi/linux/pfru.h +88 -0
92 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 4/4 tools: Introduce power/acpi/tools/pfru
In reply to Chen YuIntroduce a user space tool to make use of the interface exposed by Platform Firmware Runtime Update and Telemetry drivers. The users can use this tool to do firmware code injection, driver update and to retrieve the telemetry data.
---
v9: Add this tool into tools/power/acpi build infrastructure.
(Andy Shevchenko)
v8: Print the length of OEM information if requested.
v7: No change since v6.
v6: Simplify the userspace tool to use while loop for getopt_long().
(Andy Shevchenko)
v5: Replace the read() with mmap() so that the userspace
could mmap once, and read multiple times. (Greg Kroah-Hartman)
--- tools/power/acpi/.gitignore | 1 + tools/power/acpi/Makefile | 16 +- tools/power/acpi/Makefile.rules | 2 +- tools/power/acpi/man/pfru.8 | 137 +++++++++ tools/power/acpi/tools/pfru/Makefile | 23 ++ tools/power/acpi/tools/pfru/pfru.c | 417 +++++++++++++++++++++++++++ 6 files changed, 587 insertions(+), 9 deletions(-) create mode 100644 tools/power/acpi/man/pfru.8 create mode 100644 tools/power/acpi/tools/pfru/Makefile create mode 100644 tools/power/acpi/tools/pfru/pfru.c
tools/power/acpi/.gitignore +1 -0
@@ -2,4 +2,5 @@ /acpidbg /acpidump /ec +/pfru /include/
tools/power/acpi/Makefile +8 -8
@@ -9,18 +9,18 @@ include ../../scripts/Makefile.include .NOTPARALLEL: -all: acpidbg acpidump ec -clean: acpidbg_clean acpidump_clean ec_clean -install: acpidbg_install acpidump_install ec_install -uninstall: acpidbg_uninstall acpidump_uninstall ec_uninstall +all: acpidbg acpidump ec pfru +clean: acpidbg_clean acpidump_clean ec_clean pfru_clean +install: acpidbg_install acpidump_install ec_install pfru_install +uninstall: acpidbg_uninstall acpidump_uninstall ec_uninstall pfru_uninstall -acpidbg acpidump ec: FORCE +acpidbg acpidump ec pfru: FORCE $(call descend,tools/$@,all) -acpidbg_clean acpidump_clean ec_clean: +acpidbg_clean acpidump_clean ec_clean pfru_clean: $(call descend,tools/$(@:_clean=),clean) -acpidbg_install acpidump_install ec_install: +acpidbg_install acpidump_install ec_install pfru_install: $(call descend,tools/$(@:_install=),install) -acpidbg_uninstall acpidump_uninstall ec_uninstall: +acpidbg_uninstall acpidump_uninstall ec_uninstall pfru_uninstall: $(call descend,tools/$(@:_uninstall=),uninstall) .PHONY: FORCE
tools/power/acpi/Makefile.rules +1 -1
@@ -9,7 +9,7 @@ objdir := $(OUTPUT)tools/$(TOOL)/ toolobjs := $(addprefix $(objdir),$(TOOL_OBJS)) $(OUTPUT)$(TOOL): $(toolobjs) FORCE $(ECHO) " LD " $(subst $(OUTPUT),,$@) - $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(toolobjs) -L$(OUTPUT) -o $@ + $(QUIET) $(LD) $(CFLAGS) $(toolobjs) $(LDFLAGS) -L$(OUTPUT) -o $@ $(ECHO) " STRIP " $(subst $(OUTPUT),,$@) $(QUIET) $(STRIPCMD) $@
tools/power/acpi/man/pfru.8 new file +137 -0
137 lines not on this page · raw message
tools/power/acpi/tools/pfru/Makefile new file +23 -0
@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0+ + +include ../../Makefile.config + +TOOL = pfru +EXTRA_INSTALL = install-man +EXTRA_UNINSTALL = uninstall-man + +CFLAGS += -Wall -O2 +CFLAGS += -DPFRU_HEADER='"../../../../../include/uapi/linux/pfru.h"' +LDFLAGS += -luuid + +TOOL_OBJS = \ + pfru.o + +include ../../Makefile.rules + +install-man: $(srctree)/man/pfru.8 + $(ECHO) " INST " pfru.8 + $(QUIET) $(INSTALL_DATA) -D $< $(DESTDIR)$(mandir)/man8/pfru.8 +uninstall-man: + $(ECHO) " UNINST " pfru.8 + $(QUIET) rm -f $(DESTDIR)$(mandir)/man8/pfru.8
tools/power/acpi/tools/pfru/pfru.c new file +417 -0
417 lines not on this page · raw message
Signature · 1 line
2.25.1