From patchwork Mon Apr 24 23:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 87199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3058359vqo; Mon, 24 Apr 2023 16:18:11 -0700 (PDT) X-Google-Smtp-Source: AKy350bO4jPMWFtu9eMF7M73zoig+yi+3ME4jL6FuXVlBFaEfc/TwnorORwWNeVz+SmK4b+rlwcG X-Received: by 2002:a17:902:e5c5:b0:1a6:48e6:ea8e with SMTP id u5-20020a170902e5c500b001a648e6ea8emr24144756plf.4.1682378290883; Mon, 24 Apr 2023 16:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682378290; cv=none; d=google.com; s=arc-20160816; b=c7vOYeRGomrKlz2HtUdxGqFpwFcaSJlGOXa77Q331Pxp4XCICD7d3Jcps7SZ/zndTn Nw3VuLCazPeu5ypb+nf9fis65dHQNhxsczP97oKIqNwxKnIGQ1G/XMew9vjUpIO6MWcJ TYuLZFxcnL+VG6hBzmhaq6WtoykPtTjadtT/t/5z2bCO2l21bUjbBD7dRHfYfpHwm2dd Yspr1nev3ojwQt7gAqNW5cyg+enyrIWfeaLCzAGDZ3i/E5OgYs/bXLR7x4I3K+bqFK0N B5T3/mOcu2sIWtR5nuv/qxLf22JveMw/4mqENaMbYFo6TGFldsVuYDesqlZGr+lZ/8LJ HrEQ== 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=iChxHUwc1b8vxtzP0eqLNCTiVeQ5CJJAGkNRJGeoG5c=; b=RE0PZ+M1UHegpZ/NGprMApgRm1a8qK+7A4Y0g8nA/nFEjmKPWCyE1g8HECVdvtIcDI HmRJl0ueYlDziNl64H6E4SjAm0WnB6T4znYlW5cDyN7s1Z9vy+xk/iVM4XdZjNfVeKmE aYv7zQbuZyRFa3Ul5YBTU2jwaU8vK1Yk6A915RgcS8i3M6PCkBV/Kw6g0g0wdrftUn0a eFttH9VwcIik0Kp+OFXxHLhMyWpAB8hHl/jx7dH45/9fZ6DaFHc7ZppGYGrZNubughD3 zkQvgrCasfcY36o6UnC8XDGMtii9fQ9ej2Vy9CsoWRBaDaAVNn8YPqSEjMXs4Thkdr71 c10Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=fW0H5Vdl; 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 o16-20020a63f150000000b0051ae6c4084dsi9589508pgk.512.2023.04.24.16.17.55; Mon, 24 Apr 2023 16:18:10 -0700 (PDT) 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=fW0H5Vdl; 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 S232071AbjDXXRB (ORCPT + 99 others); Mon, 24 Apr 2023 19:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbjDXXQr (ORCPT ); Mon, 24 Apr 2023 19:16:47 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67963126; Mon, 24 Apr 2023 16:16:45 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33OLSKIu005015; Mon, 24 Apr 2023 23:16:32 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=iChxHUwc1b8vxtzP0eqLNCTiVeQ5CJJAGkNRJGeoG5c=; b=fW0H5Vdl2UMIaQKlfvo9hgqrgPum0y89mBJtRUdLccH72wgEuWb2NMqZQejK0yxnwxhY b/MCtjttnA3EQ5Rp2Jfyh6jGmRS8fRDCaZt7XztujqUNk1edM8FP5IrDuzox71gwx5aL CeJOVbwgzFnaSKKuV5mFNYeywPd9qumn3qmGwS4xAcH4LYszCvHqDEe8+shV/otcK/gV Xt8dvA+dxQO+81NlaEMoW2a0xJITueZ97yGDyFyFHWL61CjiMAdoJ9FH1Th//eR7DFeG hJWieALEXImnjCgWvzTlg19cCriekBiA3F9N19AwUTe7kPlKCmVQ7tVMvLyYk+hZnMQO 4g== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q5uwj10f0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 23:16:31 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33ONGUfa029757 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 23:16:30 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.42; Mon, 24 Apr 2023 16:16:30 -0700 From: Elliot Berman To: Alex Elder , Srinivas Kandagatla , Elliot Berman , Prakruthi Deepak Heragu CC: Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , "Konrad Dybcio" , Arnd Bergmann , "Greg Kroah-Hartman" , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Will Deacon , Andy Gross , Catalin Marinas , Jassi Brar , , , , , Subject: [PATCH v12 03/25] gunyah: Common types and error codes for Gunyah hypercalls Date: Mon, 24 Apr 2023 16:15:36 -0700 Message-ID: <20230424231558.70911-4-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424231558.70911-1-quic_eberman@quicinc.com> References: <20230424231558.70911-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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-ORIG-GUID: IW3rWyUoSzaex_EAJXMhshD2hmhAMvOy X-Proofpoint-GUID: IW3rWyUoSzaex_EAJXMhshD2hmhAMvOy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-24_11,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 spamscore=0 mlxlogscore=712 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304240211 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,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764101498836768692?= X-GMAIL-MSGID: =?utf-8?q?1764101498836768692?= Add architecture-independent standard error codes, types, and macros for Gunyah hypercalls. Reviewed-by: Dmitry Baryshkov Signed-off-by: Elliot Berman --- 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..a4e8ec91961d --- /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 +#include + +/******************************************************************************/ +/* 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_error_remap() - Remap Gunyah hypervisor errors into a Linux error code + * @gh_error: Gunyah hypercall return value + */ +static inline int gh_error_remap(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