Commit 0db89fa2 authored by Chen Yu's avatar Chen Yu Committed by Rafael J. Wysocki

ACPI: Introduce Platform Firmware Runtime Update device driver

Introduce the pfr_update driver which can be used for Platform Firmware
Runtime code injection and driver update [1].

The user is expected to provide the EFI capsule, and pass it to the
driver by writing the capsule to a device special file. The capsule
is transferred by the driver to the platform firmware with the help
of an ACPI _DSM method under the special ACPI Platform Firmware
Runtime Update device (INTC1080), and the actual firmware update is
carried out by the low-level Management Mode code in the platform
firmware.

This change allows certain pieces of the platform firmware to be
updated on the fly while the system is running (runtime) without the
need to restart it, which is key in the cases when the system needs to
be available 100% of the time and it cannot afford the downtime related
to restarting it, or when the work carried out by the system is
particularly important, so it cannot be interrupted, and it is not
practical to wait until it is complete.

Link: https://uefi.org/sites/default/files/resources/Intel_MM_OS_Interface_Spec_Rev100.pdf # [1]
Tested-by: default avatarHongyu Ning <hongyu.ning@intel.com>
Signed-off-by: default avatarChen Yu <yu.c.chen@intel.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1882de7f
......@@ -367,6 +367,7 @@ Code Seq# Include File Comments
<mailto:aherrman@de.ibm.com>
0xE5 00-3F linux/fuse.h
0xEC 00-01 drivers/platform/chrome/cros_ec_dev.h ChromeOS EC driver
0xEE 00-09 uapi/linux/pfrut.h Platform Firmware Runtime Update and Telemetry
0xF3 00-3F drivers/usb/misc/sisusbvga/sisusb.h sisfb (in development)
<mailto:thomas@winischhofer.net>
0xF6 all LTTng Linux Trace Toolkit Next Generation
......
......@@ -517,6 +517,24 @@ config ACPI_CONFIGFS
userspace. The configurable ACPI groups will be visible under
/config/acpi, assuming configfs is mounted under /config.
config ACPI_PFRUT
tristate "ACPI Platform Firmware Runtime Update and Telemetry"
depends on 64BIT
help
This mechanism allows certain pieces of the platform firmware
to be updated on the fly while the system is running (runtime)
without the need to restart it, which is key in the cases when
the system needs to be available 100% of the time and it cannot
afford the downtime related to restarting it, or when the work
carried out by the system is particularly important, so it cannot
be interrupted, and it is not practical to wait until it is complete.
The existing firmware code can be modified (driver update) or
extended by adding new code to the firmware (code injection).
To compile this driver as module, choose M here:
the module will be called pfr_update.
if ARM64
source "drivers/acpi/arm64/Kconfig"
......
......@@ -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_PFRUT) += pfr_update.o
# processor has its own "processor." module_param namespace
processor-y := processor_driver.o
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Platform Firmware Runtime Update header
*
* Copyright(c) 2021 Intel Corporation. All rights reserved.
*/
#ifndef __PFRUT_H__
#define __PFRUT_H__
#include <linux/ioctl.h>
#include <linux/types.h>
#define PFRUT_IOCTL_MAGIC 0xEE
/**
* PFRU_IOC_SET_REV - _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
*
* Return:
* * 0 - success
* * -EFAULT - fail to read the revision id
* * -EINVAL - user provides an invalid revision id
*
* Set the Revision ID for Platform Firmware Runtime Update.
*/
#define PFRU_IOC_SET_REV _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
/**
* PFRU_IOC_STAGE - _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
*
* Return:
* * 0 - success
* * -EINVAL - stage phase returns invalid result
*
* Stage a capsule image from communication buffer and perform authentication.
*/
#define PFRU_IOC_STAGE _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
/**
* PFRU_IOC_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
*
* Return:
* * 0 - success
* * -EINVAL - activate phase returns invalid result
*
* Activate a previously staged capsule image.
*/
#define PFRU_IOC_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
/**
* PFRU_IOC_STAGE_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
*
* Return:
* * 0 - success
* * -EINVAL - stage/activate phase returns invalid result.
*
* Perform both stage and activation action.
*/
#define PFRU_IOC_STAGE_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
/**
* PFRU_IOC_QUERY_CAP - _IOR(PFRUT_IOCTL_MAGIC, 0x05,
* struct pfru_update_cap_info)
*
* Return:
* * 0 - success
* * -EINVAL - query phase returns invalid result
* * -EFAULT - the result fails to be copied to userspace
*
* Retrieve information on the Platform Firmware Runtime Update capability.
* The information is a struct pfru_update_cap_info.
*/
#define PFRU_IOC_QUERY_CAP _IOR(PFRUT_IOCTL_MAGIC, 0x05, struct pfru_update_cap_info)
/**
* struct pfru_payload_hdr - Capsule file payload header.
*
* @sig: Signature of this capsule file.
* @hdr_version: Revision of this header structure.
* @hdr_size: Size of this header, including the OemHeader bytes.
* @hw_ver: The supported firmware version.
* @rt_ver: Version of the code injection image.
* @platform_id: A platform specific GUID to specify the platform what
* this capsule image support.
*/
struct pfru_payload_hdr {
__u32 sig;
__u32 hdr_version;
__u32 hdr_size;
__u32 hw_ver;
__u32 rt_ver;
__u8 platform_id[16];
};
enum pfru_dsm_status {
DSM_SUCCEED = 0,
DSM_FUNC_NOT_SUPPORT = 1,
DSM_INVAL_INPUT = 2,
DSM_HARDWARE_ERR = 3,
DSM_RETRY_SUGGESTED = 4,
DSM_UNKNOWN = 5,
DSM_FUNC_SPEC_ERR = 6,
};
/**
* struct pfru_update_cap_info - Runtime update capability information.
*
* @status: Indicator of whether this query succeed.
* @update_cap: Bitmap to indicate whether the feature is supported.
* @code_type: A buffer containing an image type GUID.
* @fw_version: Platform firmware version.
* @code_rt_version: Code injection runtime version for anti-rollback.
* @drv_type: A buffer containing an image type GUID.
* @drv_rt_version: The version of the driver update runtime code.
* @drv_svn: The secure version number(SVN) of the driver update runtime code.
* @platform_id: A buffer containing a platform ID GUID.
* @oem_id: A buffer containing an OEM ID GUID.
* @oem_info_len: Length of the buffer containing the vendor specific information.
*/
struct pfru_update_cap_info {
__u32 status;
__u32 update_cap;
__u8 code_type[16];
__u32 fw_version;
__u32 code_rt_version;
__u8 drv_type[16];
__u32 drv_rt_version;
__u32 drv_svn;
__u8 platform_id[16];
__u8 oem_id[16];
__u32 oem_info_len;
};
/**
* struct pfru_com_buf_info - Communication buffer information.
*
* @status: Indicator of whether this query succeed.
* @ext_status: Implementation specific query result.
* @addr_lo: Low 32bit physical address of the communication buffer to hold
* a runtime update package.
* @addr_hi: High 32bit physical address of the communication buffer to hold
* a runtime update package.
* @buf_size: Maximum size in bytes of the communication buffer.
*/
struct pfru_com_buf_info {
__u32 status;
__u32 ext_status;
__u64 addr_lo;
__u64 addr_hi;
__u32 buf_size;
};
/**
* struct pfru_updated_result - Platform firmware runtime update result information.
* @status: Indicator of whether this update succeed.
* @ext_status: Implementation specific update result.
* @low_auth_time: Low 32bit value of image authentication time in nanosecond.
* @high_auth_time: High 32bit value of image authentication time in nanosecond.
* @low_exec_time: Low 32bit value of image execution time in nanosecond.
* @high_exec_time: High 32bit value of image execution time in nanosecond.
*/
struct pfru_updated_result {
__u32 status;
__u32 ext_status;
__u64 low_auth_time;
__u64 high_auth_time;
__u64 low_exec_time;
__u64 high_exec_time;
};
#endif /* __PFRUT_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment