Message ID | 20230304010632.2127470-4-quic_eberman@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp710890wrd; Fri, 3 Mar 2023 17:09:20 -0800 (PST) X-Google-Smtp-Source: AK7set8BWjcrDHDcQyWd0CfakbrTVA0lDjOV1z9PpThm44OdxMZe9+9YsBueisMWQSmQbp6gLOC3 X-Received: by 2002:aa7:cb58:0:b0:4af:62ad:a36 with SMTP id w24-20020aa7cb58000000b004af62ad0a36mr3156605edt.27.1677892160798; Fri, 03 Mar 2023 17:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677892160; cv=none; d=google.com; s=arc-20160816; b=ndBfyRFivlnCRmS+J9Stb/Z6G4cuyWbJnmVj+MGDM7Gdj76odXbYN2raaTXbQCD694 oml2QSLmnlB9QozZOg+9Rdc0659rj7L4h0/vZsn/fsbB7K27+YniboZstJLWRbiIMSlA y7VnhizayjhOwhr0P0Sp0G+cxg9kOPPRjxVvcxnYnZP8O9XGFqD8FvGXBpmrLEsSObCH 9YMhYTy55b712px024pSGRd29516n9UzObatCjJcWss0Qd5qq+U9SDlWQrct4ykaZNat SE3dR4nxPRjU4WBZtAe46EQju214e6HQ+yq9+0CY+k9OJoiq/AltgZ0NAUYdO3SJCTgv F1kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jEyk4HliMxKi4wE8CsySZn3iDFHDSO6CVbaXJWg6y1Y=; b=0vx03n0E97ecSSX5lN8nrJ1DiRSLMikK3KyKjPtrWHqKbnFqTm71xEX8PpsnzP5Ssh 5f7Jj0TXClhUuJYyZUriGcxInqj+nFZ0KnJZ8MpaRKJdkSMW8w8jfOTgOYXN2d+eR+cU eGNfHUqL2MUa4eWrgy/zg2PU8bvkWcH5zpSnS5DynoGHLJL1dHaPL0FHPa8CCVpAn991 wB/B3W13zh7i6PMj9FXo1SX9cXHFKgtJmnvK8/TcydbWx/GJuJOU6M1Brbr2RQ803s4I 6V2kbIiAO6rxeK9hbQAsWV4I5Ty52eW0NGtkUsqunaLenY+QcV02szhvJ5lPbl5fhYEL syQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LhklqIu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a056402078400b004c2a319672dsi277779edy.354.2023.03.03.17.08.57; Fri, 03 Mar 2023 17:09:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LhklqIu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjCDBHW (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Fri, 3 Mar 2023 20:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjCDBHG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 20:07:06 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1713F60D7F; Fri, 3 Mar 2023 17:07:05 -0800 (PST) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32400LVG003536; Sat, 4 Mar 2023 01:06:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=jEyk4HliMxKi4wE8CsySZn3iDFHDSO6CVbaXJWg6y1Y=; b=LhklqIu95JDioJYSYlEdh5A+06GuAWOC+YwCHMoTddsFxGk8NCKPxEJbsBex/NuK7xcm ZSjIi46OPCkIxqTDabDagYlTlHqboQcP3oiwsGdqJzDp+usGu8zyiRSO+do6sQYJkWAd ktZuVxAEn5edX2J8q63ZWu4GQsQHbtpsDJYBr1srOXEnQ7oUY4E9VogvyRsLkKl7HyIr 9B/Dz5K6FYJNbECMJ+AODL+oIQl1aBu4Cd1OwmPj7XTnWXe14bQH0Ch7t5IUs/MS4svz uD8yMruyq6e42/TRABxgbr0LjTH06dR5ulpdzY6GyMUpiGnP3j1rS6Ax89r2MhX2++g8 5Q== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3p3dfrjf3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 04 Mar 2023 01:06:48 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32416mvx018575 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 4 Mar 2023 01:06:48 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 3 Mar 2023 17:06:47 -0800 From: Elliot Berman <quic_eberman@quicinc.com> To: Alex Elder <elder@linaro.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Elliot Berman <quic_eberman@quicinc.com>, Prakruthi Deepak Heragu <quic_pheragu@quicinc.com> CC: Murali Nalajala <quic_mnalajal@quicinc.com>, Trilok Soni <quic_tsoni@quicinc.com>, Srivatsa Vaddagiri <quic_svaddagi@quicinc.com>, Carl van Schaik <quic_cvanscha@quicinc.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Bjorn Andersson <andersson@kernel.org>, "Konrad Dybcio" <konrad.dybcio@linaro.org>, Arnd Bergmann <arnd@arndb.de>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Jonathan Corbet <corbet@lwn.net>, Bagas Sanjaya <bagasdotme@gmail.com>, Will Deacon <will@kernel.org>, Andy Gross <agross@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Jassi Brar <jassisinghbrar@gmail.com>, <linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org> Subject: [PATCH v11 03/26] gunyah: Common types and error codes for Gunyah hypercalls Date: Fri, 3 Mar 2023 17:06:09 -0800 Message-ID: <20230304010632.2127470-4-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230304010632.2127470-1-quic_eberman@quicinc.com> References: <20230304010632.2127470-1-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: j_boKn3Ets6Sh33sceCLbPTuf9hMuIC6 X-Proofpoint-ORIG-GUID: j_boKn3Ets6Sh33sceCLbPTuf9hMuIC6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-03_07,2023-03-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 impostorscore=0 bulkscore=0 mlxlogscore=719 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303040005 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759397450369716052?= X-GMAIL-MSGID: =?utf-8?q?1759397450369716052?= |
Series |
Drivers for gunyah hypervisor
|
|
Commit Message
Elliot Berman
March 4, 2023, 1:06 a.m. UTC
Add architecture-independent standard error codes, types, and macros for Gunyah hypercalls. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> --- include/linux/gunyah.h | 83 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 include/linux/gunyah.h
Comments
On 04/03/2023 01:06, Elliot Berman wrote: > Add architecture-independent standard error codes, types, and macros for > Gunyah hypercalls. > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> > --- Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > include/linux/gunyah.h | 83 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > create mode 100644 include/linux/gunyah.h > > diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h > new file mode 100644 > index 000000000000..54b4be71caf7 > --- /dev/null > +++ b/include/linux/gunyah.h > @@ -0,0 +1,83 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#ifndef _LINUX_GUNYAH_H > +#define _LINUX_GUNYAH_H > + > +#include <linux/errno.h> > +#include <linux/limits.h> > + > +/******************************************************************************/ > +/* Common arch-independent definitions for Gunyah hypercalls */ > +#define GH_CAPID_INVAL U64_MAX > +#define GH_VMID_ROOT_VM 0xff > + > +enum gh_error { > + GH_ERROR_OK = 0, > + GH_ERROR_UNIMPLEMENTED = -1, > + GH_ERROR_RETRY = -2, > + > + GH_ERROR_ARG_INVAL = 1, > + GH_ERROR_ARG_SIZE = 2, > + GH_ERROR_ARG_ALIGN = 3, > + > + GH_ERROR_NOMEM = 10, > + > + GH_ERROR_ADDR_OVFL = 20, > + GH_ERROR_ADDR_UNFL = 21, > + GH_ERROR_ADDR_INVAL = 22, > + > + GH_ERROR_DENIED = 30, > + GH_ERROR_BUSY = 31, > + GH_ERROR_IDLE = 32, > + > + GH_ERROR_IRQ_BOUND = 40, > + GH_ERROR_IRQ_UNBOUND = 41, > + > + GH_ERROR_CSPACE_CAP_NULL = 50, > + GH_ERROR_CSPACE_CAP_REVOKED = 51, > + GH_ERROR_CSPACE_WRONG_OBJ_TYPE = 52, > + GH_ERROR_CSPACE_INSUF_RIGHTS = 53, > + GH_ERROR_CSPACE_FULL = 54, > + > + GH_ERROR_MSGQUEUE_EMPTY = 60, > + GH_ERROR_MSGQUEUE_FULL = 61, > +}; > + > +/** > + * gh_remap_error() - Remap Gunyah hypervisor errors into a Linux error code > + * @gh_error: Gunyah hypercall return value > + */ > +static inline int gh_remap_error(enum gh_error gh_error) > +{ > + switch (gh_error) { > + case GH_ERROR_OK: > + return 0; > + case GH_ERROR_NOMEM: > + return -ENOMEM; > + case GH_ERROR_DENIED: > + case GH_ERROR_CSPACE_CAP_NULL: > + case GH_ERROR_CSPACE_CAP_REVOKED: > + case GH_ERROR_CSPACE_WRONG_OBJ_TYPE: > + case GH_ERROR_CSPACE_INSUF_RIGHTS: > + case GH_ERROR_CSPACE_FULL: > + return -EACCES; > + case GH_ERROR_BUSY: > + case GH_ERROR_IDLE: > + return -EBUSY; > + case GH_ERROR_IRQ_BOUND: > + case GH_ERROR_IRQ_UNBOUND: > + case GH_ERROR_MSGQUEUE_FULL: > + case GH_ERROR_MSGQUEUE_EMPTY: > + return -EIO; > + case GH_ERROR_UNIMPLEMENTED: > + case GH_ERROR_RETRY: > + return -EOPNOTSUPP; > + default: > + return -EINVAL; > + } > +} > + > +#endif
On 3/3/23 7:06 PM, Elliot Berman wrote: > Add architecture-independent standard error codes, types, and macros for > Gunyah hypercalls. > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> See a few comments below. -Alex > --- > include/linux/gunyah.h | 83 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > create mode 100644 include/linux/gunyah.h > > diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h > new file mode 100644 > index 000000000000..54b4be71caf7 > --- /dev/null > +++ b/include/linux/gunyah.h > @@ -0,0 +1,83 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#ifndef _LINUX_GUNYAH_H > +#define _LINUX_GUNYAH_H > + > +#include <linux/errno.h> > +#include <linux/limits.h> > + > +/******************************************************************************/ > +/* Common arch-independent definitions for Gunyah hypercalls */ > +#define GH_CAPID_INVAL U64_MAX > +#define GH_VMID_ROOT_VM 0xff The above definition doesn't seem to be used anywhere, but seeing it begs the question to me of what type it is expected to have. If it were used, where would it be used in an 8 bit field? > + > +enum gh_error { > + GH_ERROR_OK = 0, > + GH_ERROR_UNIMPLEMENTED = -1, > + GH_ERROR_RETRY = -2, There might be nothing fundamentally wrong with this, but I dislike seeing negative values assigned to enums. These error values are returned from the hypervisor, and it looks like they'll likely truncated from a 64-bit unsigned value. Are they *sent* from the hypervisor as 64-bit signed values? Or 32-bit signed values? (In that case, the I just wonder if you can use 0xffffffff or 0xffff for example rather than -1, depending on the actual value that gets passed. > + > + GH_ERROR_ARG_INVAL = 1, > + GH_ERROR_ARG_SIZE = 2, > + GH_ERROR_ARG_ALIGN = 3, > + > + GH_ERROR_NOMEM = 10, > + > + GH_ERROR_ADDR_OVFL = 20, > + GH_ERROR_ADDR_UNFL = 21, > + GH_ERROR_ADDR_INVAL = 22, > + > + GH_ERROR_DENIED = 30, > + GH_ERROR_BUSY = 31, > + GH_ERROR_IDLE = 32, > + > + GH_ERROR_IRQ_BOUND = 40, > + GH_ERROR_IRQ_UNBOUND = 41, > + > + GH_ERROR_CSPACE_CAP_NULL = 50, > + GH_ERROR_CSPACE_CAP_REVOKED = 51, > + GH_ERROR_CSPACE_WRONG_OBJ_TYPE = 52, > + GH_ERROR_CSPACE_INSUF_RIGHTS = 53, > + GH_ERROR_CSPACE_FULL = 54, > + > + GH_ERROR_MSGQUEUE_EMPTY = 60, > + GH_ERROR_MSGQUEUE_FULL = 61, > +}; > + > +/** > + * gh_remap_error() - Remap Gunyah hypervisor errors into a Linux error code > + * @gh_error: Gunyah hypercall return value > + */ > +static inline int gh_remap_error(enum gh_error gh_error) Since you're remapping a gh_error, I would have named this gh_error_remap(). > +{ > + switch (gh_error) { > + case GH_ERROR_OK: > + return 0; > + case GH_ERROR_NOMEM: > + return -ENOMEM; > + case GH_ERROR_DENIED: > + case GH_ERROR_CSPACE_CAP_NULL: > + case GH_ERROR_CSPACE_CAP_REVOKED: > + case GH_ERROR_CSPACE_WRONG_OBJ_TYPE: > + case GH_ERROR_CSPACE_INSUF_RIGHTS: > + case GH_ERROR_CSPACE_FULL: > + return -EACCES; > + case GH_ERROR_BUSY: > + case GH_ERROR_IDLE: > + return -EBUSY; > + case GH_ERROR_IRQ_BOUND: > + case GH_ERROR_IRQ_UNBOUND: > + case GH_ERROR_MSGQUEUE_FULL: > + case GH_ERROR_MSGQUEUE_EMPTY: > + return -EIO; > + case GH_ERROR_UNIMPLEMENTED: > + case GH_ERROR_RETRY: > + return -EOPNOTSUPP; > + default: > + return -EINVAL; > + } > +} > + > +#endif
On 3/31/2023 7:24 AM, Alex Elder wrote: > On 3/3/23 7:06 PM, Elliot Berman wrote: >> Add architecture-independent standard error codes, types, and macros for >> Gunyah hypercalls. >> >> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> > > See a few comments below. -Alex > >> --- >> include/linux/gunyah.h | 83 ++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 83 insertions(+) >> create mode 100644 include/linux/gunyah.h >> >> diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h >> new file mode 100644 >> index 000000000000..54b4be71caf7 >> --- /dev/null >> +++ b/include/linux/gunyah.h >> @@ -0,0 +1,83 @@ >> +/* SPDX-License-Identifier: GPL-2.0-only */ >> +/* >> + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All >> rights reserved. >> + */ >> + >> +#ifndef _LINUX_GUNYAH_H >> +#define _LINUX_GUNYAH_H >> + >> +#include <linux/errno.h> >> +#include <linux/limits.h> >> + >> +/******************************************************************************/ >> +/* Common arch-independent definitions for Gunyah >> hypercalls */ >> +#define GH_CAPID_INVAL U64_MAX >> +#define GH_VMID_ROOT_VM 0xff > > The above definition doesn't seem to be used anywhere, but seeing > it begs the question to me of what type it is expected to have. > If it were used, where would it be used in an 8 bit field? > VMIDs are u16, the root VM (Resource Manager) VMID is 0xff. I think this definition snuck in from the downstream code and is indeed not being needed/used anywhere. I'll remove it. >> + >> +enum gh_error { >> + GH_ERROR_OK = 0, >> + GH_ERROR_UNIMPLEMENTED = -1, >> + GH_ERROR_RETRY = -2, > > There might be nothing fundamentally wrong with this, but I > dislike seeing negative values assigned to enums. > > These error values are returned from the hypervisor, and it > looks like they'll likely truncated from a 64-bit unsigned > value. Are they *sent* from the hypervisor as 64-bit signed > values? Or 32-bit signed values? (In that case, the > > I just wonder if you can use 0xffffffff or 0xffff for example > rather than -1, depending on the actual value that gets passed. > They are sent from the hypervisor as 64-bit signed values (it's filling a register). I think truncating should be OK because Gunyah wants to maintain capability with 32-bit architectures and we would not see an error number that truly requires more than 32 bits to represent. >> + >> + GH_ERROR_ARG_INVAL = 1, >> + GH_ERROR_ARG_SIZE = 2, >> + GH_ERROR_ARG_ALIGN = 3, >> + >> + GH_ERROR_NOMEM = 10, >> + >> + GH_ERROR_ADDR_OVFL = 20, >> + GH_ERROR_ADDR_UNFL = 21, >> + GH_ERROR_ADDR_INVAL = 22, >> + >> + GH_ERROR_DENIED = 30, >> + GH_ERROR_BUSY = 31, >> + GH_ERROR_IDLE = 32, >> + >> + GH_ERROR_IRQ_BOUND = 40, >> + GH_ERROR_IRQ_UNBOUND = 41, >> + >> + GH_ERROR_CSPACE_CAP_NULL = 50, >> + GH_ERROR_CSPACE_CAP_REVOKED = 51, >> + GH_ERROR_CSPACE_WRONG_OBJ_TYPE = 52, >> + GH_ERROR_CSPACE_INSUF_RIGHTS = 53, >> + GH_ERROR_CSPACE_FULL = 54, >> + >> + GH_ERROR_MSGQUEUE_EMPTY = 60, >> + GH_ERROR_MSGQUEUE_FULL = 61, >> +}; >> + >> +/** >> + * gh_remap_error() - Remap Gunyah hypervisor errors into a Linux >> error code >> + * @gh_error: Gunyah hypercall return value >> + */ >> +static inline int gh_remap_error(enum gh_error gh_error) > > Since you're remapping a gh_error, I would have named this > gh_error_remap(). > Done. >> +{ >> + switch (gh_error) { >> + case GH_ERROR_OK: >> + return 0; >> + case GH_ERROR_NOMEM: >> + return -ENOMEM; >> + case GH_ERROR_DENIED: >> + case GH_ERROR_CSPACE_CAP_NULL: >> + case GH_ERROR_CSPACE_CAP_REVOKED: >> + case GH_ERROR_CSPACE_WRONG_OBJ_TYPE: >> + case GH_ERROR_CSPACE_INSUF_RIGHTS: >> + case GH_ERROR_CSPACE_FULL: >> + return -EACCES; >> + case GH_ERROR_BUSY: >> + case GH_ERROR_IDLE: >> + return -EBUSY; >> + case GH_ERROR_IRQ_BOUND: >> + case GH_ERROR_IRQ_UNBOUND: >> + case GH_ERROR_MSGQUEUE_FULL: >> + case GH_ERROR_MSGQUEUE_EMPTY: >> + return -EIO; >> + case GH_ERROR_UNIMPLEMENTED: >> + case GH_ERROR_RETRY: >> + return -EOPNOTSUPP; >> + default: >> + return -EINVAL; >> + } >> +} >> + >> +#endif >
diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h new file mode 100644 index 000000000000..54b4be71caf7 --- /dev/null +++ b/include/linux/gunyah.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _LINUX_GUNYAH_H +#define _LINUX_GUNYAH_H + +#include <linux/errno.h> +#include <linux/limits.h> + +/******************************************************************************/ +/* Common arch-independent definitions for Gunyah hypercalls */ +#define GH_CAPID_INVAL U64_MAX +#define GH_VMID_ROOT_VM 0xff + +enum gh_error { + GH_ERROR_OK = 0, + GH_ERROR_UNIMPLEMENTED = -1, + GH_ERROR_RETRY = -2, + + GH_ERROR_ARG_INVAL = 1, + GH_ERROR_ARG_SIZE = 2, + GH_ERROR_ARG_ALIGN = 3, + + GH_ERROR_NOMEM = 10, + + GH_ERROR_ADDR_OVFL = 20, + GH_ERROR_ADDR_UNFL = 21, + GH_ERROR_ADDR_INVAL = 22, + + GH_ERROR_DENIED = 30, + GH_ERROR_BUSY = 31, + GH_ERROR_IDLE = 32, + + GH_ERROR_IRQ_BOUND = 40, + GH_ERROR_IRQ_UNBOUND = 41, + + GH_ERROR_CSPACE_CAP_NULL = 50, + GH_ERROR_CSPACE_CAP_REVOKED = 51, + GH_ERROR_CSPACE_WRONG_OBJ_TYPE = 52, + GH_ERROR_CSPACE_INSUF_RIGHTS = 53, + GH_ERROR_CSPACE_FULL = 54, + + GH_ERROR_MSGQUEUE_EMPTY = 60, + GH_ERROR_MSGQUEUE_FULL = 61, +}; + +/** + * gh_remap_error() - Remap Gunyah hypervisor errors into a Linux error code + * @gh_error: Gunyah hypercall return value + */ +static inline int gh_remap_error(enum gh_error gh_error) +{ + switch (gh_error) { + case GH_ERROR_OK: + return 0; + case GH_ERROR_NOMEM: + return -ENOMEM; + case GH_ERROR_DENIED: + case GH_ERROR_CSPACE_CAP_NULL: + case GH_ERROR_CSPACE_CAP_REVOKED: + case GH_ERROR_CSPACE_WRONG_OBJ_TYPE: + case GH_ERROR_CSPACE_INSUF_RIGHTS: + case GH_ERROR_CSPACE_FULL: + return -EACCES; + case GH_ERROR_BUSY: + case GH_ERROR_IDLE: + return -EBUSY; + case GH_ERROR_IRQ_BOUND: + case GH_ERROR_IRQ_UNBOUND: + case GH_ERROR_MSGQUEUE_FULL: + case GH_ERROR_MSGQUEUE_EMPTY: + return -EIO; + case GH_ERROR_UNIMPLEMENTED: + case GH_ERROR_RETRY: + return -EOPNOTSUPP; + default: + return -EINVAL; + } +} + +#endif