powerpc/pseries: Add hypervisor pipe (HVPIPE) suport
Subsystems (2)
cover powerpc/pseries: Add hypervisor pipe (HVPIPE) suport
On powerPC systems, the Hardware Management Console (HMC) is used to create and manage logical partitions (LPAR) and both HMC and LPARs exchange information over Ethernet which can expose security implications. Hence the current method of communication is not viable for secure boot configuration. To overcome these concerns, the hypervisor introduced new inband hypervisor channel called “Hypervisor Pipe (HVPIPE)” which allows HMC and LPARs to exchange information with ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS calls. Sources can be any target that the hypervisor supports, but only HMC source is supported.
ibm,send-hvpipe-msg RTAS: Inputs such as Source ID indicator of which target the data is intended and the buffer list to hold the payload, and returns the status. Each target represented by source ID. For example, HMC1, HMC2 and etc.
ibm,receive-hvpipe-msg RTAS: Input buffer to hold the data and size of the buffer, and returns the source ID of identifier of the target providing the data, the bytes written in the buffer and the status.
The hypervisor defines HVPIPE with certain requirements and constraints:
- The OS can determine HVPIPE feature availability with “ibm,hypervisor-pipe-capable” property in the /rtas node of the device tree.
- One pipe is assigned per partition and for all sources.
- Success return status of send HVPIPE means the payload is delivered to source.
- Success return status of send HVPIPE as ACK to source.
- Generate HVPIPE event message interrupt if the status of pipe is changed in the hypervisor such as payload is pending or pipe to the specific source is closed
- Then the partition issue check exception handler to retrieve the message which defines source ID of the pipe and its status.
- The hypervisor will not generate another HVPIPE event message until the partition obtains the payload with recv HVPIPE RTAS.
- Supports only 4088 bytes of maximum payload right now,
This patch series adds HVPIPE support and provides interfaces to the user space to execute ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS calls. We already have RTAS calls execution such as ibm,get-indices, ibm,platform-dump, ibm,get/set-system-parameter, etc to the user space and following the similar interfaces foe send and recv HVPIPE RTAS functions.
- Create /dev/papr-hvpipe entry if HVPIPE is enabled
- devfd = open("/dev/papr-hvpipe", ..)
- fd = ioctl(fd,HVPIPE_IOC_CREATE_HANDLE, &srcID) for each source.
- size = write(fd, buf, size)
- Buffer contains papr_hvpipe_hdr and the payload and send the payload with ibm,send-hvpipe-msg
- Return the size if the RTAS is success, otherwise return the equivalent RTAS failure error code.
- ret = poll(fd,..)
- The user space waits for the payload from the source. OS wakes up FD whenever receives interrupt from the hypervisor
- size = read(fd, buf, size)
- Buffer should have the space to contain papr_hvpipe_hdr and the payload
- Each read() issue ibm,receive-hvpipe-msg and return the size for RTAS success. Otherwise return the equivalent RTAS failure error code.
This series consists of the following patches:
powerpc/pseries: Define papr-hvpipe ioctl
-provide HVPIPE_IOC_CREATE_HANDLE ioctl to the user space powerpc/pseries: Define HVPIPE specific macros
– Define RTAS macros needed for ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS
powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces
– Add devpapr-hvpipe user space interfaces powerpc/pseries: Send payload with ibm,send-hvpipe-msg RTAS
– Add send HVPIPE RTAS execution from user space powerpc/pseries: Receive payload with ibm,receive-hvpipe-msg RTAS
– Add recv HVPIPE RTAS execution from user space powerpc/pseries: Wakeup hvpipe FD when the payload is pending
– The kernel wakes up user space FD when the payload is pending from the corresponding source
powerpc/pseries: Enable HVPIPE event message interrupt
– Enable HVPIPE interrupt and adds the handler powerpc/pseries: Enable hvpipe with ibm,set-system-parameter RTAS
– Enable HVPIPE in the hypervisor
powerpc/pseries: HVPIPE changes to support migration
- LPM support
Haren Myneni (9):
powerpc/pseries: Define papr-hvpipe ioctl powerpc/pseries: Define HVPIPE specific macros powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces powerpc/pseries: Send payload with ibm,send-hvpipe-msg RTAS powerpc/pseries: Receive payload with ibm,receive-hvpipe-msg RTAS powerpc/pseries: Wakeup hvpipe FD when the payload is pending powerpc/pseries: Enable HVPIPE event message interrupt powerpc/pseries: Enable hvpipe with ibm,set-system-parameter RTAS powerpc/pseries: HVPIPE changes to support migration
.../userspace-api/ioctl/ioctl-number.rst | 2 + arch/powerpc/include/asm/papr-sysparm.h | 1 + arch/powerpc/include/asm/rtas.h | 9 + arch/powerpc/include/uapi/asm/papr-hvpipe.h | 33 + arch/powerpc/kernel/rtas.c | 24 + arch/powerpc/kernel/rtasd.c | 2 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/mobility.c | 3 + arch/powerpc/platforms/pseries/papr-hvpipe.c | 792 ++++++++++++++++++ arch/powerpc/platforms/pseries/papr-hvpipe.h | 42 + 10 files changed, 909 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-hvpipe.h create mode 100644 arch/powerpc/platforms/pseries/papr-hvpipe.c create mode 100644 arch/powerpc/platforms/pseries/papr-hvpipe.h
Signature · 1 line
2.43.5
RFC PATCH 1/9 powerpc/pseries: Define papr-hvpipe ioctl
PowerPC FW introduced HVPIPE RTAS calls such as ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg for the user space to exchange information with different sources such as Hardware Management Consoles (HMC).
HVPIPE_IOC_CREATE_HANDLE is defined to use /dev/papr-hvpipe interface for ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS calls.
Also defined papr_hvpipe_hdr which will added in the payload that is passed between the kernel and the user space.
--- .../userspace-api/ioctl/ioctl-number.rst | 2 ++ arch/powerpc/include/uapi/asm/papr-hvpipe.h | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/papr-hvpipe.h
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -0
@@ -371,6 +371,8 @@ Code Seq# Include File Comments <mailto:linuxppc-dev> 0xB2 08 powerpc/include/uapi/asm/papr-physical-attestation.h powerpc/pseries Physical Attestation API <mailto:linuxppc-dev> +0xB2 09 arch/powerpc/include/uapi/asm/papr-hvpipe.h powerpc/pseries HVPIPE API + <mailto:linuxppc-dev> 0xB3 00 linux/mmc/ioctl.h 0xB4 00-0F linux/gpio.h <mailto:[email protected]> 0xB5 00-0F uapi/linux/rpmsg.h <mailto:[email protected]>
arch/powerpc/include/uapi/asm/papr-hvpipe.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_PAPR_HVPIPE_H_ +#define _UAPI_PAPR_HVPIPE_H_ + +#include <linux/types.h> +#include <asm/ioctl.h> +#include <asm/papr-miscdev.h> + +/* +* This header is included in payload between OS and the user +* space. +* flags: OS notifies the user space whether the hvpipe is +* closed or the buffer has the payload. +*/ +struct papr_hvpipe_hdr { +u8 version; +u8 reserved[3 ]; +u32 flags; +u8 reserved2[40 ]; +}; + +/* +* ioctl for /dev/papr-hvpipe +*/ +#define PAPR_HVPIPE_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 9, __u32) + +/* +* hvpipe_hdr flags used for read() +*/ +#define HVPIPE_MSG_AVAILABLE 0x01/* Payload is available */ +#define HVPIPE_LOST_CONNECTION 0x02/* Pipe connection is closed/unavailable */ + +#endif /* _UAPI_PAPR_HVPIPE_H_ */
Signature · 1 line
2.43.5
RFC PATCH 2/9 powerpc/pseries: Define HVPIPE specific macros
In reply to Haren MyneniDefine HVPIPE specific macros which are needed to support ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS calls and used to handle HVPIPE message events.
--- arch/powerpc/include/asm/rtas.h | 9 +++++++++ arch/powerpc/kernel/rtas.c | 24 ++++++++++++++++++++++++ arch/powerpc/kernel/rtasd.c | 2 ++ 3 files changed, 35 insertions(+)
arch/powerpc/include/asm/rtas.h +9 -0
@@ -68,9 +68,11 @@ enum rtas_function_index {RTAS_FNIDX__IBM_READ_PCI_CONFIG ,RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE ,RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2 , +RTAS_FNIDX__IBM_RECEIVE_HVPIPE_MSG ,RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW ,RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW ,RTAS_FNIDX__IBM_SCAN_LOG_DUMP , +RTAS_FNIDX__IBM_SEND_HVPIPE_MSG ,RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR ,RTAS_FNIDX__IBM_SET_EEH_OPTION , RTAS_FNIDX__IBM_SET_SLOT_RESET,
@@ -163,9 +165,11 @@ typedef struct {#define RTAS_FN_IBM_READ_PCI_CONFIG rtas_fn_handle(RTAS_FNIDX__IBM_READ_PCI_CONFIG)#define RTAS_FN_IBM_READ_SLOT_RESET_STATE rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE)#define RTAS_FN_IBM_READ_SLOT_RESET_STATE2 rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2) +#define RTAS_FN_IBM_RECEIVE_HVPIPE_MSG rtas_fn_handle(RTAS_FNIDX__IBM_RECEIVE_HVPIPE_MSG)#define RTAS_FN_IBM_REMOVE_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW)#define RTAS_FN_IBM_RESET_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW)#define RTAS_FN_IBM_SCAN_LOG_DUMP rtas_fn_handle(RTAS_FNIDX__IBM_SCAN_LOG_DUMP) +#define RTAS_FN_IBM_SEND_HVPIPE_MSG rtas_fn_handle(RTAS_FNIDX__IBM_SEND_HVPIPE_MSG)#define RTAS_FN_IBM_SET_DYNAMIC_INDICATOR rtas_fn_handle(RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR)#define RTAS_FN_IBM_SET_EEH_OPTION rtas_fn_handle(RTAS_FNIDX__IBM_SET_EEH_OPTION)#define RTAS_FN_IBM_SET_SLOT_RESET rtas_fn_handle(RTAS_FNIDX__IBM_SET_SLOT_RESET)
@@ -217,6 +221,7 @@ typedef struct {#define RTAS_HARDWARE_ERROR -1/* Hardware or other unspecified error. */ #define RTAS_BUSY -2/* Retry immediately. */ #define RTAS_INVALID_PARAMETER -3/* Invalid indicator/domain/sensor etc. */ +#define RTAS_FUNC_NOT_SUPPORTED -5/* Function not supported */ #define RTAS_UNEXPECTED_STATE_CHANGE -7/* Seems limited to EEH and slot reset. */ #define RTAS_EXTENDED_DELAY_MIN 9900/* Retry after delaying for ~1ms. */ #define RTAS_EXTENDED_DELAY_MAX 9905/* Retry after delaying for ~100s. */
@@ -233,6 +238,7 @@ typedef struct {#define RTAS_EPOW_WARNING 0x40000000/* set bit 1 */ #define RTAS_HOTPLUG_EVENTS 0x10000000/* set bit 3 */ #define RTAS_IO_EVENTS 0x08000000/* set bit 4 */ +#define RTAS_HVPIPE_MSG_EVENTS 0x04000000/* set bit 5 */ #define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff/* RTAS event severity */
@@ -282,6 +288,7 @@ typedef struct {#define RTAS_TYPE_DEALLOC 0xE3#define RTAS_TYPE_DUMP 0xE4#define RTAS_TYPE_HOTPLUG 0xE5 +#define RTAS_TYPE_HVPIPE 0xE6/* I don't add PowerMGM events right now, this is a different topic */ #define RTAS_TYPE_PMGM_POWER_SW_ON 0x60#define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61
@@ -374,6 +381,7 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)#define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M')#define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P')#define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E') +#define PSERIES_ELOG_SECT_ID_HVPIPE_EVENT (('P' << 8) | 'E')#define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I')#define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')#define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D')
@@ -519,6 +527,7 @@ extern struct mutex rtas_ibm_get_indices_lock;extern struct mutex rtas_ibm_set_dynamic_indicator_lock;extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock;extern struct mutex rtas_ibm_physical_attestation_lock; +extern struct mutex rtas_ibm_send_hvpipe_msg_lock;#define GLOBAL_INTERRUPT_QUEUE 9005
arch/powerpc/kernel/rtas.c +24 -0
@@ -98,6 +98,8 @@ DEFINE_MUTEX(rtas_ibm_get_vpd_lock);DEFINE_MUTEX (rtas_ibm_get_indices_lock);DEFINE_MUTEX (rtas_ibm_set_dynamic_indicator_lock);DEFINE_MUTEX (rtas_ibm_get_dynamic_sensor_state_lock); +DEFINE_MUTEX (rtas_ibm_receive_hvpipe_msg_lock); +DEFINE_MUTEX (rtas_ibm_send_hvpipe_msg_lock);static struct rtas_function rtas_function_table[]__ro_after_init = { [RTAS_FNIDX__CHECK_EXCEPTION ] = {
@@ -373,6 +375,17 @@ static struct rtas_function rtas_function_table[] __ro_after_init = { [RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2] = { .name = "ibm,read-slot-reset-state2", }, + [RTAS_FNIDX__IBM_RECEIVE_HVPIPE_MSG] { + .name = "ibm,receive-hvpipe-msg", + .filter = &(const struct rtas_filter ) { + .buf_idx1 =0 , .size_idx1 =1 , + .buf_idx2 =-1 , .size_idx2 =-1 , + }, +/* +* PAPR+ v2.13 R1–7.3.32.1 +*/ + .lock = &rtas_ibm_receive_hvpipe_msg_lock, + }, [RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW] = { .name = "ibm,remove-pe-dma-window", },
@@ -391,6 +404,17 @@ static struct rtas_function rtas_function_table[] __ro_after_init = { .buf_idx2 = -1, .size_idx2 = -1, }, }, + [RTAS_FNIDX__IBM_SEND_HVPIPE_MSG ] { + .name = "ibm,send-hvpipe-msg", + .filter = &(const struct rtas_filter ) { + .buf_idx1 =1 , .size_idx1 =-1 , + .buf_idx2 =-1 , .size_idx2 =-1 , + }, +/* +* PAPR+ v2.13 R1–7.3.32.2 +*/ + .lock = &rtas_ibm_send_hvpipe_msg_lock, + }, [RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR] = { .name = "ibm,set-dynamic-indicator", .filter = &(const struct rtas_filter ) {
arch/powerpc/kernel/rtasd.c +2 -0
@@ -89,6 +89,8 @@ static char *rtas_event_type(int type)return "Platform Resource Reassignment Event" ;case RTAS_TYPE_HOTPLUG :return "Hotplug Event" ; +case RTAS_TYPE_HVPIPE : +return "Hypervisor Pipe Notification event" ; }return rtas_type[0 ];
Signature · 1 line
2.43.5
RFC PATCH 3/9 powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces
In reply to Haren MyneniThe hypervisor provides ibm,send-hvpipe-msg and ibm,receive-hvpipe-msg RTAS calls which can be used by the partition to communicate through an inband hypervisor channel with different external sources such as Hardware Management Console (HMC). The information exchanged, whether it be messages, raw or formatted data, etc., is only known to between applications in the OS and the source (HMC). This patch adds papr-hvpipe character driver and provides the standard interfaces such as open / ioctl/ read / write to user space for exchanging information with HMC using send/recevive HVPIPE RTAS functions.
PAPR (7.3.32 Hypervisor Pipe Information Exchange) defines the HVPIPE usage:
- The hypervisor has one HVPIPE per partition for all sources.
- OS can determine this feature’s availability by detecting the “ibm,hypervisor-pipe-capable” property in the /rtas node of the device tree.
- Each source is represented by the source ID which is used in send / recv HVPIPE RTAS. (Ex: source ID is the target for the payload in send RTAS).
- Return status of ibm,send-hvpipe-msg can be considered as delivered the payload.
- Return status of ibm,receive-hvpipe-msg can be considered as ACK to source.
- The hypervisor generates hvpipe message event interrupt when the partition has the payload to receive.
Provide the interfaces to the user space with /dev/papr-hvpipe character device using the following programming model:
int devfd = open("/dev/papr-hvpipe")
int fd = ioctl(devfd, PAPR_HVPIPE_IOC_CREATE_HANDLE, &srcID);
- Restrict the user space to use the same source ID and do not expect more than one process access with the same source.
char *buf = malloc(size);
- SIZE should be 4K and the buffer contains header and the payload.
length = write(fd, buf, size);
- OS issues ibm,send-hvpipe-msg RTAS and returns the RTAS status to the user space.
ret = poll(fd,...)
- The HVPIPE event message IRQ wakes up for any waiting FDs. length = read(fd, buf, size);
- OS issues ibm,receive-hvpipe-msg to receive payload from the hypervisor.
release(fd);
- OS issues ibm,receive-hvpipe-msg if any payload is pending so that pipe is not blocked.
The actual implementation of these calls are added in the next patches.
--- arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/papr-hvpipe.c | 274 +++++++++++++++++++ arch/powerpc/platforms/pseries/papr-hvpipe.h | 14 + 3 files changed, 289 insertions(+) create mode 100644 arch/powerpc/platforms/pseries/papr-hvpipe.c create mode 100644 arch/powerpc/platforms/pseries/papr-hvpipe.h
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y := lpar.o hvCall.o nvram.o reconfig.o \ of_helpers.o rtas-work-area.o papr-sysparm.o \ papr-rtas-common.o papr-vpd.o papr-indices.o \ papr-platform-dump.o papr-phy-attest.o \ + papr-hvpipe.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o \
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +274 -0
274 lines not on this page · raw message
arch/powerpc/platforms/pseries/papr-hvpipe.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _PAPR_HVPIPE_H +#define _PAPR_HVPIPE_H + +#define HVPIPE_HMC_ID_MASK 0x02000000/*02-HMC,00-reserved and HMC ID */ + +struct hvpipe_source_info { +struct list_head list;/* list of sources */ +u32 srcID; +wait_queue_head_t recv_wqh;/* wake up poll() waitq */ +struct task_struct *tsk; +}; + +#endif /* _PAPR_HVPIPE_H */
Signature · 1 line
2.43.5
Re: [PATCH RFC 3/9] powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces
arch/powerpc/platforms/pseries/papr-hvpipe.c line 258
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +11
-0+static struct miscdevice papr_hvpipe_dev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="papr-hvpipe" , + .fops = &papr_hvpipe_ops, +}; + +static int __init papr_hvpipe_init(void) +{ + int ret; + + if (!of_find_property(rtas.dev, "ibm,hypervisor-pipe-capable",
Where did you document the ABI? Anyway, so you just run it on x86 and every other arch? Why you cannot use proper devices and device driver matching/binding?
Review
Quoted 2 lines
(quoted diff) +2
-0+ NULL)) + return -ENODEV;
Totally odd wrapping.
arch/powerpc/platforms/pseries/papr-hvpipe.c line 263
Quoted 3 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +3
-0+ +if (!rtas_function_implemented (RTAS_FN_IBM_SEND_HVPIPE_MSG ) || + !rtas_function_implemented (RTAS_FN_IBM_RECEIVE_HVPIPE_MSG ))
Odd alignment.
arch/powerpc/platforms/pseries/papr-hvpipe.c line 273
Quoted 10 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +10
-0+return -ENODEV ; + + ret =misc_register (&papr_hvpipe_dev); +if (ret) { +pr_err ("misc-dev registration failed %d\n" , ret); +return ret; + } + +return 0 ; +}
Best regards,
Krzysztof
Re: [PATCH RFC 3/9] powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces
Quoted 16 lines · Krzysztof Kozlowski
arch/powerpc/platforms/pseries/papr-hvpipe.c line 258
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +11
-0+static struct miscdevice papr_hvpipe_dev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="papr-hvpipe" , + .fops = &papr_hvpipe_ops, +}; + +static int __init papr_hvpipe_init(void) +{ + int ret; + + if (!of_find_property(rtas.dev, "ibm,hypervisor-pipe-capable",Where did you document the ABI? Anyway, so you just run it on x86 and every other arch? Why you cannot use proper devices and device driver matching/binding?
HVPIPE is a new feature and is docucmented in new version of PAPR. This feature is available only on powerpc and not applicable to other archs. Following the same interfaces available in the existing misc driver code for RTAS calls such as ibm,get/set-system-parameter (papr- sysparm.c), ibm,get-indices, ibm,get-dynamic-sensor (papr-indices.c) and etc.
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ NULL)) + return -ENODEV;Totally odd wrapping.
Quoted 6 lines
Quoted 4 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +3
-0+ +if (!rtas_function_implemented (RTAS_FN_IBM_SEND_HVPIPE_MSG ) || + !rtas_function_implemented(RTAS_FN_IBM_RECEIVE_HVPIPE_MSG))
Odd alignment.
I did test with checkpatch and did not notices any issues. Also seeing with proper tab spaces. Will check again.
Thanks for your comments.
Haren
Quoted 14 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c line 273
Quoted 11 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +10
-0+return -ENODEV ; + + ret =misc_register (&papr_hvpipe_dev); +if (ret) { +pr_err ("misc-dev registration failed %d\n" , ret); +return ret; + } + +return 0 ; +}Best regards,
Krzysztof
Re: [PATCH RFC 3/9] powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces
Quoted 18 lines · Haren Myneni
Quoted 16 lines · Krzysztof Kozlowski
arch/powerpc/platforms/pseries/papr-hvpipe.c line 258
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c new file +11
-0+static struct miscdevice papr_hvpipe_dev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="papr-hvpipe" , + .fops = &papr_hvpipe_ops, +}; + +static int __init papr_hvpipe_init(void) +{ + int ret; + + if (!of_find_property(rtas.dev, "ibm,hypervisor-pipe-capable",Where did you document the ABI? Anyway, so you just run it on x86 and every other arch? Why you cannot use proper devices and device driver matching/binding?
Quoted 6 lines
HVPIPE is a new feature and is docucmented in new version of PAPR. This feature is available only on powerpc and not applicable to other archs. Following the same interfaces available in the existing misc driver code for RTAS calls such as ibm,get/set-system-parameter (papr-
sysparm.c), ibm,get-indices, ibm,get-dynamic-sensor (papr-indices.c) and etc.
I speak about the ABI, not the feature. Where is the new ABI documented?
Best regards,
Krzysztof
RFC PATCH 4/9 powerpc/pseries: Send payload with ibm,send-hvpipe-msg RTAS
In reply to Haren Myneniibm,send-hvpipe-msg RTAS call is used to send data to the source (Ex: Hardware Management Console) over the hypervisor pipe. The maximum data length of 4048 bytes is supported with this RTAS call right now. The user space uses write() to send this payload which invokes this RTAS. Then the write returns the buffer length (including papr_hvpipe_hdr length) to the user space for success or RTAS failure error.
ibm,send-hvpipe-msg call takes source ID as target and the buffer in the form of buffer list. The buffer list format consists of work area of size 4K to hold buffer list and number of 4K work areas depends on buffers is as follows:
Length of Buffer List in bytes
Address of 4K buffer 1
Length of 4K buffer 1 used
...
Address of 4K buffer n
Length of 4K buffer n used
Only one buffer is used right now because of max payload size is 4088 bytes. writev() can be used in future when supported more than one buffer.
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 120 ++++++++++++++++++- arch/powerpc/platforms/pseries/papr-hvpipe.h | 7 ++ 2 files changed, 126 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +119 -1
@@ -14,6 +14,7 @@#include <linux/of.h> #include <asm/machdep.h> #include <asm/rtas.h> +#include <asm/rtas-work-area.h> #include <uapi/asm/papr-hvpipe.h> #include "pseries.h" #include "papr-hvpipe.h"
@@ -59,6 +60,51 @@ static LIST_HEAD(hvpipe_src_list);* return code for failure. */ +/* +* ibm,send-hvpipe-msg RTAS call +* @area: Caller-provided work area buffer to send. +* @srcID: Target source for the send pipe message. +*/ +static int rtas_ibm_send_hvpipe_msg (struct rtas_work_area *area,u32 srcID) +{ +const s32 token =rtas_function_token (RTAS_FN_IBM_SEND_HVPIPE_MSG ); +s32 fwrc; +int ret; + +if (token ==RTAS_UNKNOWN_SERVICE ) +return -ENOENT ; + +do { + fwrc =rtas_call (token,2 ,1 ,NULL , srcID, +rtas_work_area_phys (area)); + + }while (rtas_busy_delay (fwrc)); + +switch (fwrc) { +case RTAS_SUCCESS : + ret =0 ; +break ; +case RTAS_HARDWARE_ERROR : + ret = -EIO ; +break ; +case RTAS_INVALID_PARAMETER : + ret = -EINVAL ; +break ; +case RTAS_HVPIPE_CLOSED : + ret = -EACCES ; +break ; +case RTAS_FUNC_NOT_SUPPORTED : + ret = -EOPNOTSUPP ; +break ; +default : + ret = -EIO ; +pr_err_ratelimited ("unexpected ibm,receive-hvpipe-msg status %d\n" , fwrc); +break ; + } + +return ret; +} +static struct hvpipe_source_info *hvpipe_find_source (u32 srcID) {struct hvpipe_source_info *src_info;
@@ -78,11 +124,83 @@ static ssize_t papr_hvpipe_handle_write(struct file *file, const char __user *buf, size_t size, loff_t *off) { struct hvpipe_source_info *src_info = file->private_data; +struct rtas_work_area *work_area, *work_buf; +unsigned long ret, len; +char *area_buf;if (!src_info)return -EIO ; -return 0 ; +/* +* Send HVPIPE RTAS is used to send payload to the specific +* source with the input parameters source ID and the payload +* as buffer list. Each entry in the buffer list contains +* address/length pair of the buffer. +* +* The buffer list format is as follows: +* +* Header (length of address/length pairs and the header length) +* Address of 4K buffer 1 +* Length of 4K buffer 1 used +* ... +* Address of 4K buffer n +* Length of 4K buffer n used +* +* See PAPR 7.3.32.2 ibm,send-hvpipe-msg +* +* Even though can support max 1MB payload, the hypervisor +* supports only 4048 bytes payload at present and also +* just one address/length entry. +* +* writev() interface can be added in future when the +* hypervisor supports multiple buffer list entries. +*/ +/* HVPIPE_MAX_WRITE_BUFFER_SIZE = 4048 bytes */ +if ((size > (HVPIPE_HDR_LEN +HVPIPE_MAX_WRITE_BUFFER_SIZE )) || + (size <=HVPIPE_HDR_LEN )) +return -EINVAL ; + +/* +* The length of (address + length) pair + the length of header +*/ + len = (2 *sizeof (u64)) +sizeof (u64); + size -=HVPIPE_HDR_LEN ; + buf +=HVPIPE_HDR_LEN ; +mutex_lock (&rtas_ibm_send_hvpipe_msg_lock); + work_area =rtas_work_area_alloc (SZ_4K ); +if (!work_area) { + ret = -ENOMEM ; + goto out; + } + area_buf =rtas_work_area_raw_buf (work_area); +/* header */ + *(u64 *)area_buf =cpu_to_be64 (len); + area_buf +=sizeof (u64); + + work_buf =rtas_work_area_alloc (SZ_4K ); +if (!area_buf) { + ret = -ENOMEM ; + goto out_work; + } +/* First buffer address */ + *(u64 *)area_buf =cpu_to_be64 (rtas_work_area_phys (work_buf)); + area_buf +=sizeof (u64); +/* First buffer address length */ + *(u64 *)area_buf =cpu_to_be64 (size); + +if (!copy_from_user (rtas_work_area_raw_buf (work_buf), buf, size)) { + ret =rtas_ibm_send_hvpipe_msg (work_area, src_info->srcID); +if (!ret) + ret = size +HVPIPE_HDR_LEN ; + }else + ret = -EPERM ; + +rtas_work_area_free (work_buf); +out_work: +rtas_work_area_free (work_area); +out: +mutex_unlock (&rtas_ibm_send_hvpipe_msg_lock); +return ret; }/*
arch/powerpc/platforms/pseries/papr-hvpipe.h +7 -0
@@ -3,6 +3,13 @@#define _PAPR_HVPIPE_H#define HVPIPE_HMC_ID_MASK 0x02000000/*02-HMC,00-reserved and HMC ID */ +#define HVPIPE_MAX_WRITE_BUFFER_SIZE 4048 +/* +* hvpipe specific RTAS return values +*/ +#define RTAS_HVPIPE_CLOSED -4 + +#define HVPIPE_HDR_LEN sizeof(struct papr_hvpipe_hdr)struct hvpipe_source_info {struct list_head list;/* list of sources */
Signature · 1 line
2.43.5
RFC PATCH 5/9 powerpc/pseries: Receive payload with ibm,receive-hvpipe-msg RTAS
In reply to Haren Myneniibm,receive-hvpipe-msg RTAS call is used to receive data from the source (Ex: Hardware Management Console) over the hypervisor pipe. The hypervisor will signal the OS via a Hypervisor Pipe Event external interrupt when data is available to be received from the pipe and the event message has the source ID and the message type such as payload or closed pipe to the specific source. The hypervisor will not generate another interrupt for the next payload until the partition reads the previous payload. It means the hvpipe is blocked and will not deliver other events for any source. The maximum data length of 4048 bytes is supported with this RTAS call right now.
The user space uses read() to receive data from HMC which issues ibm,receive-hvpipe-msg RTAS and the kernel returns the buffer length (including papr_hvpipe_hdr length) to the user space for success or RTAS failure error. If the message is regarding the pipe closed, kernel just returns the papr_hvpipe_hdr with flags = HVPIPE_LOST_CONNECTION and expects the user space to close FD for the corresponding source.
bm,receive-hvpipe-msg RTAS call passes the buffer and returns the source ID from where this payload is received and the payload length.
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 164 ++++++++++++++++++- arch/powerpc/platforms/pseries/papr-hvpipe.h | 1 + 2 files changed, 163 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +162 -2
@@ -60,6 +60,54 @@ static LIST_HEAD(hvpipe_src_list);* return code for failure. */ +/* +* ibm,receive-hvpipe-msg RTAS call. +* @area: Caller-provided work area buffer for results. +* @srcID: Source ID returned by the RTAS call. +* @bytesw: Bytes written by RTAS call to @area. +*/ +static int rtas_ibm_receive_hvpipe_msg (struct rtas_work_area *area, +u32 *srcID,u32 *bytesw) +{ +const s32 token =rtas_function_token (RTAS_FN_IBM_RECEIVE_HVPIPE_MSG ); +u32 rets[2 ]; +s32 fwrc; +int ret; + +if (token ==RTAS_UNKNOWN_SERVICE ) +return -ENOENT ; + +do { + fwrc =rtas_call (token,2 ,3 , rets, +rtas_work_area_phys (area), +rtas_work_area_size (area)); + + }while (rtas_busy_delay (fwrc)); + +switch (fwrc) { +case RTAS_SUCCESS : + *srcID = rets[0 ]; + *bytesw = rets[1 ]; + ret =0 ; +break ; +case RTAS_HARDWARE_ERROR : + ret = -EIO ; +break ; +case RTAS_INVALID_PARAMETER : + ret = -EINVAL ; +break ; +case RTAS_FUNC_NOT_SUPPORTED : + ret = -EOPNOTSUPP ; +break ; +default : + ret = -EIO ; +pr_err_ratelimited ("unexpected ibm,receive-hvpipe-msg status %d\n" , fwrc); +break ; + } + +return ret; +} +/* * ibm,send-hvpipe-msg RTAS call * @area: Caller-provided work area buffer to send.
@@ -116,9 +164,60 @@ static struct hvpipe_source_info *hvpipe_find_source(u32 srcID)return NULL ; } +/* +* This work function collects receive buffer with recv HVPIPE +* RTAS call. Called from read() +* @buf: User specified buffer to copy the payload that returned +* from recv HVPIPE RTAS. +* @size: Size of buffer user passed. +*/ +static int hvpipe_rtas_recv_msg (char __user *buf,int size) +{ +struct rtas_work_area *work_area; +u32 srcID, bytes_written; +int ret; + + work_area =rtas_work_area_alloc (SZ_4K ); +if (!work_area) { +pr_err ("Could not allocate RTAS buffer for recv pipe\n" ); +return -ENOMEM ; + } + + ret =rtas_ibm_receive_hvpipe_msg (work_area, &srcID, + &bytes_written); +if (!ret) { +/* +* Recv HVPIPE RTAS is successful. +* When releasing FD or no one is waiting on the +* specific source, issue recv HVPIPE RTAS call +* so that pipe is not blocked - this func is called +* with NULL buf. +*/ +if (buf) { +if (size < bytes_written) { +pr_err ("Received the payload size = %d, but the buffer size = %d\n" , + bytes_written, size); + bytes_written = size; + } + ret =copy_to_user (buf, +rtas_work_area_raw_buf (work_area), + bytes_written); +if (!ret) + ret = bytes_written; + } + }else { +pr_err ("ibm,receive-hvpipe-msg failed with %d\n" , + ret); + } + +rtas_work_area_free (work_area); +return ret; +} +/* * papr_hvpipe_handle_write - Issue send HVPIPE RTAS and return -* the RTAS status to the user space +* the size (payload + HVPIPE_HDR_LEN) for RTAS success. +* Otherwise returns the status of RTAS to the user space */ static ssize_t papr_hvpipe_handle_write (struct file *file,const char __user *buf,size_t size,loff_t *off)
@@ -217,11 +316,72 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, {struct hvpipe_source_info *src_info = file->private_data; +struct papr_hvpipe_hdr hdr; +long ret;if (!src_info)return -EIO ; -return 0 ; +/* +* Max payload is 4048 (HVPIPE_MAX_WRITE_BUFFER_SIZE) +*/ +if ((size > (HVPIPE_HDR_LEN +HVPIPE_MAX_WRITE_BUFFER_SIZE )) || + (size <HVPIPE_HDR_LEN )) +return -EINVAL ; + +/* +* Payload is not available to receive or source pipe +* is not closed. +*/ +if (!src_info->hvpipe_status) +return 0 ; + + hdr.version =0 ; + hdr.flags =0 ; + +/* +* In case if the hvpipe has payload and also the +* hypervisor closed the pipe to the source, retrieve +* the payload and return to the user space first and +* then notify the userspace about the hvpipe close in +* next read(). +*/ +if (src_info->hvpipe_status &HVPIPE_MSG_AVAILABLE ) + hdr.flags =HVPIPE_MSG_AVAILABLE ; +else if (src_info->hvpipe_status &HVPIPE_LOST_CONNECTION ) + hdr.flags =HVPIPE_LOST_CONNECTION ; +else +/* +* Should not be here without one of the above +* flags set +*/ +return -EIO ; + + ret =copy_to_user (buf, &hdr,HVPIPE_HDR_LEN ); +if (ret) +return ret; + +/* +* Message event has payload, so get the payload with +* recv HVPIPE RTAS. +*/ +if (hdr.flags &HVPIPE_MSG_AVAILABLE ) { + ret =hvpipe_rtas_recv_msg (buf +HVPIPE_HDR_LEN , + size -HVPIPE_HDR_LEN ); +if (ret >0 ) { + src_info->hvpipe_status &= ~HVPIPE_MSG_AVAILABLE ; + ret +=HVPIPE_HDR_LEN ; + } + }else if (hdr.flags &HVPIPE_LOST_CONNECTION ) { +/* +* Hypervisor is closing the pipe for the specific +* source. So notify user space. +*/ + src_info->hvpipe_status &= ~HVPIPE_LOST_CONNECTION ; + ret =HVPIPE_HDR_LEN ; + } + +return ret; }/*
arch/powerpc/platforms/pseries/papr-hvpipe.h +1 -0
@@ -14,6 +14,7 @@struct hvpipe_source_info {struct list_head list;/* list of sources */ u32 srcID; +u32 hvpipe_status;wait_queue_head_t recv_wqh;/* wake up poll() waitq */ struct task_struct *tsk; };
Signature · 1 line
2.43.5
RFC PATCH 6/9 powerpc/pseries: Wakeup hvpipe FD when the payload is pending
In reply to Haren MyneniThe user space polls on the wait_queue for the payload from the specific source. The hypervisor interrupts the OS when the pipe status for the specific source is changed such as payload is available for the partition or pipe to the source is closed. The OS retrieves the HVPIPE event message with check-exception RTAS and event message contains the source ID and the pipe status. Then wakes up all FDs waiting on the wait_queue so that the user space can read the payload or close the FD if the pipe to source in the hypervisor is closed.
The hypervisor assigns one pipe per partition for all sources. Hence issue ibm,receive-hvpipe-msg() to read the pending payload during release() before closing FD so that pipe to the partition will not be blocked.
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +27 -1
@@ -398,6 +398,21 @@ static unsigned int papr_hvpipe_handle_poll(struct file *filp,if (!src_info)return -EIO ; +/* +* If hvpipe already has pending payload, return so that +* the user space can issue read(). +*/ +if (src_info->hvpipe_status) +return POLLIN |POLLRDNORM ; + +/* +* Wait for the message event +* hvpipe_event_interrupt() wakes up this wait_queue +*/ +poll_wait (filp, &src_info->recv_wqh, wait); +if (src_info->hvpipe_status) +return POLLIN |POLLRDNORM ; +return 0 ; }
@@ -415,7 +430,18 @@ static int papr_hvpipe_handle_release(struct inode *inode, src_info = file->private_data;list_del (&src_info->list); file->private_data =NULL ; -spin_unlock (&hvpipe_src_list_lock); +/* +* If the pipe for this specific source has any pending +* payload, issue recv HVPIPE RTAS so that pipe will not +* be blocked. +*/ +if (src_info->hvpipe_status &HVPIPE_MSG_AVAILABLE ) { + src_info->hvpipe_status =0 ; +spin_unlock (&hvpipe_src_list_lock); +hvpipe_rtas_recv_msg (NULL ,0 ); + }else +spin_unlock (&hvpipe_src_list_lock); +kfree (src_info);return 0 ; }
Signature · 1 line
2.43.5
RFC PATCH 7/9 powerpc/pseries: Enable HVPIPE event message interrupt
In reply to Haren MyneniThe hypervisor signals the OS via a Hypervisor Pipe Event external interrupt when data is available to be received from the pipe. Then the OS should call RTAS check-exception and provide the input Event Mask as defined for the ‘ibm,hvpipe-msg-events’. In response, check-exception will return an event log containing an Pipe Events message. This message contains the source ID for which this message is intended to and the pipe status such as whether the payload is pending in the hypervisor or pipe to source is closed.
If there is any user space process waiting in the wait_queue for the payload from this source ID, wake up that process which can issue read() to obtain payload with ibm,receive-hvpipe-msg RTAS or close FD if the pipe to source is closed.
The hypervisor has one pipe per partition for all sources and it will not deliver another hvpipe event message until the partition reads the payload for the previous hvpipe event. So if the source ID is not found in the source list, issue the dummy ibm,receive-hvpipe-msg RTAS so that pipe will not blocked.
Register hvpipe event source interrupt based on entries from /proc/device-tree//event-sources/ibm,hvpipe-msg-events property.
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 144 ++++++++++++++++++- arch/powerpc/platforms/pseries/papr-hvpipe.h | 14 ++ 2 files changed, 153 insertions(+), 5 deletions(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +139 -5
@@ -22,6 +22,11 @@static DEFINE_SPINLOCK (hvpipe_src_list_lock);static LIST_HEAD (hvpipe_src_list); +static unsigned char hvpipe_ras_buf[RTAS_ERROR_LOG_MAX ]; +static struct workqueue_struct *papr_hvpipe_wq; +static struct work_struct *papr_hvpipe_work; +static int hvpipe_check_exception_token; +/* * New PowerPC FW provides support for partitions and various * sources (Ex: remote hardware management console (HMC)) to
@@ -545,6 +550,117 @@ static long papr_hvpipe_dev_ioctl(struct file *filp, unsigned int ioctl,return ret; } +/* +* papr_hvpipe_work_fn - called to issue recv HVPIPE RTAS for +* sources that are not monitored by user space so that pipe +* will not be blocked. +*/ +static void papr_hvpipe_work_fn (struct work_struct *work) +{ +hvpipe_rtas_recv_msg (NULL ,0 ); +} + +/* +* HVPIPE event message IRQ handler. +* The hypervisor sends event IRQ if the partition has payload +* and generates another event only after payload is read with +* recv HVPIPE RTAS. +*/ +static irqreturn_t hvpipe_event_interrupt (int irq,void *dev_id) +{ +struct hvpipe_event_buf *hvpipe_event; +struct pseries_errorlog *pseries_log; +struct hvpipe_source_info *src_info; +struct rtas_error_log *elog; +int rc; + + rc =rtas_call (hvpipe_check_exception_token,6 ,1 ,NULL , +RTAS_VECTOR_EXTERNAL_INTERRUPT ,virq_to_hw (irq), +RTAS_HVPIPE_MSG_EVENTS ,1 ,__pa (&hvpipe_ras_buf), +rtas_get_error_log_max ()); + +if (rc !=0 ) { +pr_err_ratelimited ("unexpected hvpipe-event-notification failed %d\n" , rc); +return IRQ_HANDLED ; + } + + elog = (struct rtas_error_log *)hvpipe_ras_buf; +if (unlikely (rtas_error_type (elog) !=RTAS_TYPE_HVPIPE )) { +pr_warn_ratelimited ("Unexpected event type %d\n" , +rtas_error_type (elog)); +return IRQ_HANDLED ; + } + + pseries_log =get_pseries_errorlog (elog, +PSERIES_ELOG_SECT_ID_HVPIPE_EVENT ); + hvpipe_event = (struct hvpipe_event_buf *)pseries_log->data; + +/* +* The hypervisor notifies partition when the payload is +* available to read with recv HVPIPE RTAS and it will not +* notify another event for any source until the previous +* payload is read. Means the pipe is blocked in the +* hypervisor until the payload is read. +* +* If the source is ready to accept payload and wakeup the +* corresponding FD. Hold lock and update hvpipe_status +* and this lock is needed in case the user space process +* is in release FD instead of poll() so that release() +* reads the payload to unblock pipe before closing FD. +* +* otherwise (means no other user process waiting for the +* payload, issue recv HVPIPE RTAS (papr_hvpipe_work_fn()) +* to unblock pipe. +*/ +spin_lock (&hvpipe_src_list_lock); + src_info =hvpipe_find_source (be32_to_cpu (hvpipe_event->srcID)); +if (src_info) { +u32 flags =0 ; + +if (hvpipe_event->event_type &HVPIPE_LOST_CONNECTION ) + flags =HVPIPE_LOST_CONNECTION ; +else if (hvpipe_event->event_type &HVPIPE_MSG_AVAILABLE ) + flags =HVPIPE_MSG_AVAILABLE ; + + src_info->hvpipe_status |= flags; +wake_up (&src_info->recv_wqh); +spin_unlock (&hvpipe_src_list_lock); + }else { +spin_unlock (&hvpipe_src_list_lock); +/* +* user space is not waiting on this source. So +* execute receive pipe RTAS so that pipe will not +* be blocked. +*/ +if (hvpipe_event->event_type &HVPIPE_MSG_AVAILABLE ) +queue_work (papr_hvpipe_wq, papr_hvpipe_work); + } + +return IRQ_HANDLED ; +} + +static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =rtas_function_token (RTAS_FN_CHECK_EXCEPTION ); +if (hvpipe_check_exception_token ==RTAS_UNKNOWN_SERVICE ) +return -ENODEV ; + +/* hvpipe events */ + np =of_find_node_by_path ("/event-sources/ibm,hvpipe-msg-events" ); +if (np !=NULL ) { +request_event_sources_irqs (np, hvpipe_event_interrupt, +"HPIPE_EVENT" ); +of_node_put (np); + }else { +pr_err ("Can not enable hvpipe event IRQ\n" ); +return -ENODEV ; + } + +return 0 ; +} +static const struct file_operations papr_hvpipe_ops = { .unlocked_ioctl = papr_hvpipe_dev_ioctl, };
@@ -567,12 +683,30 @@ static int __init papr_hvpipe_init(void) !rtas_function_implemented(RTAS_FN_IBM_RECEIVE_HVPIPE_MSG)) return -ENODEV; - ret =misc_register (&papr_hvpipe_dev); -if (ret) { -pr_err ("misc-dev registration failed %d\n" , ret); -return ret; + papr_hvpipe_work =kzalloc (sizeof (struct work_struct ),GFP_ATOMIC ); +if (!papr_hvpipe_work) +return -ENOMEM ; + +INIT_WORK (papr_hvpipe_work, papr_hvpipe_work_fn); + + papr_hvpipe_wq =alloc_ordered_workqueue ("papr hvpipe workqueue" ,0 ); +if (!papr_hvpipe_wq) { + ret = -ENOMEM ; + goto out; } -return 0 ; +if (!enable_hvpipe_IRQ ()) { + ret =misc_register (&papr_hvpipe_dev); +if (!ret) { +pr_info ("hvpipe feature is enabled\n" ); +return 0 ; + }else +pr_err ("misc-dev registration failed %d\n" , ret); + } + +destroy_workqueue (papr_hvpipe_wq); +out: +kfree (papr_hvpipe_work); +return ret; }machine_device_initcall (pseries, papr_hvpipe_init);
arch/powerpc/platforms/pseries/papr-hvpipe.h +14 -0
@@ -19,4 +19,18 @@ struct hvpipe_source_info { struct task_struct *tsk; }; +/* +* Source ID Format 0xCCRRQQQQ +* CC = indicating value is source type (ex: 0x02 for HMC) +* RR = 0x00 (reserved) +* QQQQ = 0x0000 – 0xFFFF indicating the source index indetifier +*/ +struct hvpipe_event_buf { +__be32 srcID;/* Source ID */ +u8 event_type;/* 0x01 for hvpipe message available */ +/* from specified src ID */ +/* 0x02 for loss of pipe connection */ +/* with specified src ID */ +}; +#endif /* _PAPR_HVPIPE_H */
Signature · 1 line
2.43.5
Re: [PATCH RFC 7/9] powerpc/pseries: Enable HVPIPE event message interrupt
arch/powerpc/platforms/pseries/papr-hvpipe.c static long papr_hvpipe_dev_ioctl(struct file *filp, unsigned int ioctl, · line 651
Quoted 10 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c +10
-0+static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =rtas_function_token (RTAS_FN_CHECK_EXCEPTION ); +if (hvpipe_check_exception_token ==RTAS_UNKNOWN_SERVICE ) +return -ENODEV ; + +/* hvpipe events */ + np =of_find_node_by_path ("/event-sources/ibm,hvpipe-msg-events" );
Undocumented ABI, NAK. Plus node names should not be used at all as ABI... and naming does not follow DT spec/style, not sure if you care about it, though.
arch/powerpc/platforms/pseries/papr-hvpipe.c static long papr_hvpipe_dev_ioctl(struct file *filp, unsigned int ioctl, · line 657
Quoted 6 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c +6
-0+if (np !=NULL ) { +request_event_sources_irqs (np, hvpipe_event_interrupt, +"HPIPE_EVENT" ); +of_node_put (np); + }else { +pr_err ("Can not enable hvpipe event IRQ\n" );
Best regards,
Krzysztof
Re: [PATCH RFC 7/9] powerpc/pseries: Enable HVPIPE event message interrupt
Quoted 17 lines · Krzysztof Kozlowski
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =
rtas_function_token(RTAS_FN_CHECK_EXCEPTION);arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+if (hvpipe_check_exception_token ==RTAS_UNKNOWN_SERVICE ) +return -ENODEV ; + +/* hvpipe events */ + np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-Quoted 1 line
events");
Undocumented ABI, NAK. Plus node names should not be used at all as ABI... and naming does not follow DT spec/style, not sure if you care about it, though.
These new interfaces are documented in new version of PAPR. Please note that /proc/device-tree/event-sources node is different which will not have ibm,phandle unlike in some other node. event-sources already has several event messages such as io, EPOW, hot-plug, internal-errors events and adding hvpipe-msg events now. We can see the similar of_find_node_by_path() usage in the current code.
io_event_irq.c: np = of_find_node_by_path("/event-sources/ibm,io-
events");ras.c: np = of_find_node_by_path("/event-sources/hot-plug-events");ras.c np = of_find_node_by_path("/event-sources/internal-errors");ras.c: np = of_find_node_by_path("/event-sources/epow-events");
Thanks
Haren
Quoted 11 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c static long papr_hvpipe_dev_ioctl(struct file *filp, unsigned int ioctl, · line 657
Quoted 8 lines
arch/powerpc/platforms/pseries/papr-hvpipe.c +6
-0+if (np !=NULL ) { +request_event_sources_irqs (np, hvpipe_event_interrupt, +"HPIPE_EVENT" ); +of_node_put (np); + }else { +pr_err ("Can not enable hvpipe event IRQ\n" );Best regards,
Krzysztof
Re: [PATCH RFC 7/9] powerpc/pseries: Enable HVPIPE event message interrupt
Quoted 19 lines · Haren Myneni
Quoted 17 lines · Krzysztof Kozlowski
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =
rtas_function_token(RTAS_FN_CHECK_EXCEPTION);arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+if (hvpipe_check_exception_token ==RTAS_UNKNOWN_SERVICE ) +return -ENODEV ; + +/* hvpipe events */ + np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-Quoted 1 line
events");
Undocumented ABI, NAK. Plus node names should not be used at all as ABI... and naming does not follow DT spec/style, not sure if you care about it, though.
Quoted 1 line
These new interfaces are documented in new version of PAPR. Please note
Which version? PAPR defines standard, but not the kernel ABI. You still need to document kernel ABI, just like every other OF usage.
Quoted 11 lines
that
/proc/device-tree/event-sourcesnode is different which will not have ibm,phandle unlike in some other node. event-sources already has several event messages such as io, EPOW, hot-plug, internal-errors events and adding hvpipe-msg events now. We can see the similarof_find_node_by_path()usage in the current code.
io_event_irq.c: np = of_find_node_by_path("/event-sources/ibm,io-
events");ras.c: np =of_find_node_by_path("/event-sources/hot-plug-events");ras.cnp =of_find_node_by_path("/event-sources/internal-errors");ras.c: np =of_find_node_by_path("/event-sources/epow-events");
So you find more issues. Are you going to fix them? What are such arguments proving? Nothing. If these are bugs, are you allowed to do the same? Obviously not.
Bring argument about the ABI - ABI is documented here or ABI is does not need documentation, because of something, or this is not ABI because of something (although it is). I don't see usage of these in DTS, so probably there is something I don't get, but your arguments are not helping at all.
Best regards,
Krzysztof
Re: [PATCH RFC 7/9] powerpc/pseries: Enable HVPIPE event message interrupt
Quoted 42 lines · Krzysztof Kozlowski
Quoted 19 lines · Haren Myneni
Quoted 17 lines · Krzysztof Kozlowski
Quoted 11 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =
rtas_function_token(RTAS_FN_CHECK_EXCEPTION);arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+if (hvpipe_check_exception_token ==RTAS_UNKNOWN_SERVICE ) +return -ENODEV ; + +/* hvpipe events */ + np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-Quoted 1 line
events");
Undocumented ABI, NAK. Plus node names should not be used at all as ABI... and naming does not follow DT spec/style, not sure if you care about it, though.
Quoted 1 line
These new interfaces are documented in new version of PAPR. Please note
Which version? PAPR defines standard, but not the kernel ABI. You still need to document kernel ABI, just like every other OF usage.
Quoted 11 lines
that
/proc/device-tree/event-sourcesnode is different which will not have ibm,phandle unlike in some other node. event-sources already has several event messages such as io, EPOW, hot-plug, internal-errors events and adding hvpipe-msg events now. We can see the similarof_find_node_by_path()usage in the current code.
io_event_irq.c: np = of_find_node_by_path("/event-sources/ibm,io-
events");ras.c: np =of_find_node_by_path("/event-sources/hot-plug-events");ras.cnp =of_find_node_by_path("/event-sources/internal-errors");ras.c: np =of_find_node_by_path("/event-sources/epow-events");So you find more issues. Are you going to fix them? What are such arguments proving? Nothing. If these are bugs, are you allowed to do the same? Obviously not.
Quoted 5 lines
Bring argument about the ABI - ABI is documented here or ABI is does not need documentation, because of something, or this is not ABI because of something (although it is). I don't see usage of these in DTS, so probably there is something I don't get, but your arguments are not helping at all.
Although probably if you do not have any DTS, or let's say in-kernel DTS for these, it is indeed enough that PAPR spec defines it and no need to document it twice.
Best regards,
Krzysztof
Re: [PATCH RFC 7/9] powerpc/pseries: Enable HVPIPE event message interrupt
Quoted 65 lines · Krzysztof Kozlowski
Quoted 56 lines · Krzysztof Kozlowski
Quoted 23 lines · Haren Myneni
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Haren Myneni
arch/powerpc/platforms/pseries/papr-hvpipe.c +5
-0+static int __init enable_hvpipe_IRQ (void ) +{ +struct device_node *np; + + hvpipe_check_exception_token =
rtas_function_token(RTAS_FN_CHECK_EXCEPTION);(quoted diff) +1
-0+ if (hvpipe_check_exception_token ==
RTAS_UNKNOWN_SERVICE)arch/powerpc/platforms/pseries/papr-hvpipe.c +4
-0+return -ENODEV ; + +/* hvpipe events */ + np = of_find_node_by_path("/event-sources/ibm,hvpipe-Quoted 8 lines
Quoted 2 lines
msg-
events");Undocumented ABI, NAK. Plus node names should not be used at all as
ABI... and naming does not follow DT spec/style, not sure if you care
about it, though.Quoted 2 lines
These new interfaces are documented in new version of PAPR. Please note
Which version? PAPR defines standard, but not the kernel ABI. You still
need to document kernel ABI, just like every other OF usage.Quoted 9 lines
that
/proc/device-tree/event-sourcesnode is different which will not
have ibm,phandle unlike in some other node. event-sources already has
several event messages such as io, EPOW, hot-plug, internal- errors
events and adding hvpipe-msg events now. We can see the similarof_find_node_by_path()usage in the current code.Quoted 9 lines
io_event_irq.c: np = of_find_node_by_path("/event-
sources/ibm,io-
events");ras.c: np = of_find_node_by_path("/event-sources/hot-plug-
events");ras.cnp = of_find_node_by_path("/event-sources/internal-
errors");ras.c: np = of_find_node_by_path("/event-sources/epow-
events");So you find more issues. Are you going to fix them? What are such arguments proving? Nothing. If these are bugs, are you allowed to do the
same? Obviously not.Quoted 7 lines
Bring argument about the ABI - ABI is documented here or ABI is does not
need documentation, because of something, or this is not ABI because of
something (although it is). I don't see usage of these in DTS, so probably there is something I don't get, but your arguments are not helping at all.
Quoted 5 lines
Although probably if you do not have any DTS, or let's say in-kernel DTS
for these, it is indeed enough that PAPR spec defines it and no need to
document it twice.
Yes, PAPR defines these interfaces.
Quoted 3 lines
Best regards,
Krzysztof
RFC PATCH 8/9 powerpc/pseries: Enable hvpipe with ibm,set-system-parameter RTAS
In reply to Haren MyneniThe partition uses “Hypervisor Pipe OS Enablement Notification” system parameter token (value = 64) to enable / disable hvpipe in the hypervisor. Once hvpipe is enabled, the hypervisor notifies OS if the payload is pending for that partition from any source. This system parameter token takes 1 byte length of data with 1 = Enable and 0 = Disable.
Enable hvpipe in the hypervisor with ibm,set-system-parameter RTAS after registering hvpipe event source interrupt.
--- arch/powerpc/include/asm/papr-sysparm.h | 1 + arch/powerpc/platforms/pseries/papr-hvpipe.c | 29 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/papr-sysparm.h +1 -0
@@ -21,6 +21,7 @@ typedef struct {#define PAPR_SYSPARM_COOP_MEM_OVERCOMMIT_ATTRS mk_papr_sysparm(44)#define PAPR_SYSPARM_TLB_BLOCK_INVALIDATE_ATTRS mk_papr_sysparm(50)#define PAPR_SYSPARM_LPAR_NAME mk_papr_sysparm(55) +#define PAPR_SYS_PARAM_HVPIPE_ENABLE mk_papr_sysparm(64)/** * struct papr_sysparm_buf - RTAS work area layout for system parameter functions.
arch/powerpc/platforms/pseries/papr-hvpipe.c +28 -1
@@ -15,6 +15,7 @@#include <asm/machdep.h> #include <asm/rtas.h> #include <asm/rtas-work-area.h> +#include <asm/papr-sysparm.h> #include <uapi/asm/papr-hvpipe.h> #include "pseries.h" #include "papr-hvpipe.h"
@@ -639,6 +640,32 @@ static irqreturn_t hvpipe_event_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } +/* +* Enable hvpipe by system parameter set with parameter +* token = 64 and with 1 byte buffer data: +* 0 = hvpipe not in use/disabled +* 1 = hvpipe in use/enabled +*/ +static int set_hvpipe_sys_param (u8 val) +{ +struct papr_sysparm_buf *buf; +int ret; + + buf =papr_sysparm_buf_alloc (); +if (!buf) +return -ENOMEM ; + + buf->len =cpu_to_be16 (1 ); + buf->val[0 ] = val; + ret =papr_sysparm_set (PAPR_SYS_PARAM_HVPIPE_ENABLE , buf); +if (!ret) +pr_err ("Can not enable hvpipe %d\n" , ret); + +papr_sysparm_buf_free (buf); + +return ret; +} +static int __init enable_hvpipe_IRQ (void ) {struct device_node *np;
@@ -695,7 +722,7 @@ static int __init papr_hvpipe_init(void) goto out; } -if (!enable_hvpipe_IRQ ()) { +if (!enable_hvpipe_IRQ () && !set_hvpipe_sys_param (1 )) { ret =misc_register (&papr_hvpipe_dev);if (!ret) {pr_info ("hvpipe feature is enabled\n" );
Signature · 1 line
2.43.5
RFC PATCH 9/9 powerpc/pseries: HVPIPE changes to support migration
In reply to Haren MyneniThe hypervisor assigns one pipe per partition for all sources and assigns new pipe after migration. Also the partition ID that is used by source as its target ID may be changed after the migration. So disable hvpipe during SUSPEND event with ‘hvpipe enable’ system parameter value = 0 and enable it after migration during RESUME event with hvpipe enable’ system parameter value = 1.
The user space calls such as ioctl()/ read() / write() / poll() returns -ENXIO between SUSPEND and RESUME events. The user space process can close FD and reestablish connection with new FD after migration if needed (Example: source IDs are changed).
--- arch/powerpc/platforms/pseries/mobility.c | 3 ++ arch/powerpc/platforms/pseries/papr-hvpipe.c | 53 ++++++++++++++++++++ arch/powerpc/platforms/pseries/papr-hvpipe.h | 6 +++ 3 files changed, 62 insertions(+)
arch/powerpc/platforms/pseries/mobility.c +3 -0
@@ -28,6 +28,7 @@#include <asm/rtas.h> #include "pseries.h" #include "vas.h" /* vas_migration_handler() */ +#include "papr-hvpipe.h" /* hvpipe_migration_handler() */ #include "../../kernel/cacheinfo.h" static struct kobject *mobility_kobj;
@@ -744,6 +745,7 @@ static int pseries_migrate_partition(u64 handle)* by closing VAS windows at the beginning of this function. */ vas_migration_handler (VAS_SUSPEND ); +hvpipe_migration_handler (HVPIPE_SUSPEND ); ret =wait_for_vasi_session_suspending (handle);if (ret)
@@ -770,6 +772,7 @@ static int pseries_migrate_partition(u64 handle) out:vas_migration_handler (VAS_RESUME ); +hvpipe_migration_handler (HVPIPE_RESUME );return ret; }
arch/powerpc/platforms/pseries/papr-hvpipe.c +53 -0
95 lines not on this page · raw message
arch/powerpc/platforms/pseries/papr-hvpipe.h +6 -0
@@ -11,6 +11,11 @@#define HVPIPE_HDR_LEN sizeof(struct papr_hvpipe_hdr) +enum hvpipe_migrate_action { +HVPIPE_SUSPEND , +HVPIPE_RESUME , +}; +struct hvpipe_source_info {struct list_head list;/* list of sources */ u32 srcID;
@@ -33,4 +38,5 @@ struct hvpipe_event_buf { /* with specified src ID */ }; +void hvpipe_migration_handler (int action);#endif /* _PAPR_HVPIPE_H */
Signature · 1 line
2.43.5