Skip to content

Commit ff8d004

Browse files
author
CKI KWF Bot
committed
Merge: Hypervisor pipe (HVPIPE) character driver to support HVPIPE RTAS calls
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7562 Description: Hypervisor pipe (HVPIPE) character driver to support HVPIPE RTAS calls JIRA: https://issues.redhat.com/browse/RHEL-101849 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=69010252 Tested: Verified Brew build test kernel RPMs and confirmed issue is resovled Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 328bbe2 + 375f4d7 commit ff8d004

File tree

10 files changed

+922
-5
lines changed

10 files changed

+922
-5
lines changed

Documentation/userspace-api/ioctl/ioctl-number.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,17 @@ Code Seq# Include File Comments
347347
0xB1 00-1F PPPoX
348348
<mailto:mostrows@styx.uwaterloo.ca>
349349
0xB2 00 arch/powerpc/include/uapi/asm/papr-vpd.h powerpc/pseries VPD API
350-
<mailto:linuxppc-dev>
350+
<mailto:linuxppc-dev@lists.ozlabs.org>
351351
0xB2 01-02 arch/powerpc/include/uapi/asm/papr-sysparm.h powerpc/pseries system parameter API
352-
<mailto:linuxppc-dev>
352+
<mailto:linuxppc-dev@lists.ozlabs.org>
353353
0xB2 03-05 arch/powerpc/include/uapi/asm/papr-indices.h powerpc/pseries indices API
354-
<mailto:linuxppc-dev>
354+
<mailto:linuxppc-dev@lists.ozlabs.org>
355355
0xB2 06-07 arch/powerpc/include/uapi/asm/papr-platform-dump.h powerpc/pseries Platform Dump API
356-
<mailto:linuxppc-dev>
356+
<mailto:linuxppc-dev@lists.ozlabs.org>
357357
0xB2 08 powerpc/include/uapi/asm/papr-physical-attestation.h powerpc/pseries Physical Attestation API
358-
<mailto:linuxppc-dev>
358+
<mailto:linuxppc-dev@lists.ozlabs.org>
359+
0xB2 09 arch/powerpc/include/uapi/asm/papr-hvpipe.h powerpc/pseries HVPIPE API
360+
<mailto:linuxppc-dev@lists.ozlabs.org>
359361
0xB3 00 linux/mmc/ioctl.h
360362
0xB4 00-0F linux/gpio.h <mailto:linux-gpio@vger.kernel.org>
361363
0xB5 00-0F uapi/linux/rpmsg.h <mailto:linux-remoteproc@vger.kernel.org>

arch/powerpc/include/asm/papr-sysparm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef struct {
2121
#define PAPR_SYSPARM_COOP_MEM_OVERCOMMIT_ATTRS mk_papr_sysparm(44)
2222
#define PAPR_SYSPARM_TLB_BLOCK_INVALIDATE_ATTRS mk_papr_sysparm(50)
2323
#define PAPR_SYSPARM_LPAR_NAME mk_papr_sysparm(55)
24+
#define PAPR_SYSPARM_HVPIPE_ENABLE mk_papr_sysparm(64)
2425

2526
/**
2627
* struct papr_sysparm_buf - RTAS work area layout for system parameter functions.

arch/powerpc/include/asm/rtas.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define RTAS_HARDWARE_ERROR -1 /* Hardware Error */
2828
#define RTAS_BUSY -2 /* RTAS Busy */
2929
#define RTAS_INVALID_PARAMETER -3 /* Invalid indicator/domain/sensor etc. */
30+
#define RTAS_FUNC_NOT_SUPPORTED -5 /* Function not supported */
3031
#define RTAS_EXTENDED_DELAY_MIN 9900
3132
#define RTAS_EXTENDED_DELAY_MAX 9905
3233

@@ -56,6 +57,7 @@
5657
#define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */
5758
#define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */
5859
#define RTAS_IO_EVENTS 0x08000000 /* set bit 4 */
60+
#define RTAS_HVPIPE_MSG_EVENTS 0x04000000 /* set bit 5 */
5961
#define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff
6062

6163
/* RTAS event severity */
@@ -105,6 +107,7 @@
105107
#define RTAS_TYPE_DEALLOC 0xE3
106108
#define RTAS_TYPE_DUMP 0xE4
107109
#define RTAS_TYPE_HOTPLUG 0xE5
110+
#define RTAS_TYPE_HVPIPE 0xE6
108111
/* I don't add PowerMGM events right now, this is a different topic */
109112
#define RTAS_TYPE_PMGM_POWER_SW_ON 0x60
110113
#define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61
@@ -197,6 +200,7 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
197200
#define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M')
198201
#define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P')
199202
#define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E')
203+
#define PSERIES_ELOG_SECT_ID_HVPIPE_EVENT (('P' << 8) | 'E')
200204
#define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I')
201205
#define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')
202206
#define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D')
@@ -341,6 +345,7 @@ extern struct mutex rtas_ibm_get_indices_lock;
341345
extern struct mutex rtas_ibm_set_dynamic_indicator_lock;
342346
extern struct mutex rtas_ibm_get_dynamic_sensor_state_lock;
343347
extern struct mutex rtas_ibm_physical_attestation_lock;
348+
extern struct mutex rtas_ibm_send_hvpipe_msg_lock;
344349

345350
#define GLOBAL_INTERRUPT_QUEUE 9005
346351

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI_PAPR_HVPIPE_H_
3+
#define _UAPI_PAPR_HVPIPE_H_
4+
5+
#include <linux/types.h>
6+
#include <asm/ioctl.h>
7+
#include <asm/papr-miscdev.h>
8+
9+
/*
10+
* This header is included in payload between OS and the user
11+
* space.
12+
* flags: OS notifies the user space whether the hvpipe is
13+
* closed or the buffer has the payload.
14+
*/
15+
struct papr_hvpipe_hdr {
16+
__u8 version;
17+
__u8 reserved[3];
18+
__u32 flags;
19+
__u8 reserved2[40];
20+
};
21+
22+
/*
23+
* ioctl for /dev/papr-hvpipe
24+
*/
25+
#define PAPR_HVPIPE_IOC_CREATE_HANDLE _IOW(PAPR_MISCDEV_IOC_ID, 9, __u32)
26+
27+
/*
28+
* hvpipe_hdr flags used for read()
29+
*/
30+
#define HVPIPE_MSG_AVAILABLE 0x01 /* Payload is available */
31+
#define HVPIPE_LOST_CONNECTION 0x02 /* Pipe connection is closed/unavailable */
32+
33+
#endif /* _UAPI_PAPR_HVPIPE_H_ */

arch/powerpc/kernel/rtas.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ DEFINE_MUTEX(rtas_ibm_get_vpd_lock);
8181
DEFINE_MUTEX(rtas_ibm_get_indices_lock);
8282
DEFINE_MUTEX(rtas_ibm_set_dynamic_indicator_lock);
8383
DEFINE_MUTEX(rtas_ibm_get_dynamic_sensor_state_lock);
84+
DEFINE_MUTEX(rtas_ibm_receive_hvpipe_msg_lock);
85+
DEFINE_MUTEX(rtas_ibm_send_hvpipe_msg_lock);
8486

8587
/* RTAS use home made raw locking instead of spin_lock_irqsave
8688
* because those can be called from within really nasty contexts
@@ -1012,6 +1014,8 @@ static struct rtas_filter rtas_filters[] __ro_after_init = {
10121014
{ "ibm,update-properties", -1, 0, -1, -1, -1, 4096 },
10131015
#endif
10141016
{ "ibm,physical-attestation", -1, 0, 1, -1, -1 },
1017+
{ "ibm,receive-hvpipe-msg", -1, 0, 1, -1, -1 },
1018+
{ "ibm,send-hvpipe-msg", -1, 1, -1, -1, -1 },
10151019
};
10161020

10171021
static bool in_rmo_buf(u32 base, u32 end)
@@ -1134,6 +1138,12 @@ static struct mutex *find_rtas_mutex(int token)
11341138
if (token == rtas_token("ibm,physical-attestation"))
11351139
return &rtas_ibm_physical_attestation_lock;
11361140

1141+
if (token == rtas_token("ibm,receive-hvpipe-msg"))
1142+
return &rtas_ibm_receive_hvpipe_msg_lock;
1143+
1144+
if (token == rtas_token("ibm,send-hvpipe-msg"))
1145+
return &rtas_ibm_send_hvpipe_msg_lock;
1146+
11371147
return NULL;
11381148
}
11391149

arch/powerpc/kernel/rtasd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static char *rtas_event_type(int type)
8989
return "Platform Resource Reassignment Event";
9090
case RTAS_TYPE_HOTPLUG:
9191
return "Hotplug Event";
92+
case RTAS_TYPE_HVPIPE:
93+
return "Hypervisor Pipe Notification event";
9294
}
9395

9496
return rtas_type[0];

arch/powerpc/platforms/pseries/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ obj-y := lpar.o hvCall.o nvram.o reconfig.o \
66
of_helpers.o rtas-work-area.o papr-sysparm.o \
77
papr-rtas-common.o papr-vpd.o papr-indices.o \
88
papr-platform-dump.o papr-phy-attest.o \
9+
papr-hvpipe.o \
910
setup.o iommu.o event_sources.o ras.o \
1011
firmware.o power.o dlpar.o mobility.o rng.o \
1112
pci.o pci_dlpar.o eeh_pseries.o msi.o \

arch/powerpc/platforms/pseries/mobility.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <asm/rtas.h>
2828
#include "pseries.h"
2929
#include "vas.h" /* vas_migration_handler() */
30+
#include "papr-hvpipe.h" /* hvpipe_migration_handler() */
3031
#include "../../kernel/cacheinfo.h"
3132

3233
static struct kobject *mobility_kobj;
@@ -752,6 +753,7 @@ static int pseries_migrate_partition(u64 handle)
752753
* by closing VAS windows at the beginning of this function.
753754
*/
754755
vas_migration_handler(VAS_SUSPEND);
756+
hvpipe_migration_handler(HVPIPE_SUSPEND);
755757

756758
ret = wait_for_vasi_session_suspending(handle);
757759
if (ret)
@@ -778,6 +780,7 @@ static int pseries_migrate_partition(u64 handle)
778780

779781
out:
780782
vas_migration_handler(VAS_RESUME);
783+
hvpipe_migration_handler(HVPIPE_RESUME);
781784

782785
return ret;
783786
}

0 commit comments

Comments
 (0)