From patchwork Tue Feb 14 21:12:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 57198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3203504wrn; Tue, 14 Feb 2023 13:15:34 -0800 (PST) X-Google-Smtp-Source: AK7set/ABhp+54l3jUgQXhjjaqQ570cAPok242lP+7udEw++uhIBbvkJQH/7B8WJEcQ4fMNOCI93 X-Received: by 2002:a17:906:d9dd:b0:87b:d62c:d87 with SMTP id qk29-20020a170906d9dd00b0087bd62c0d87mr4154820ejb.1.1676409334511; Tue, 14 Feb 2023 13:15:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676409334; cv=none; d=google.com; s=arc-20160816; b=kCDtaIIA1+VleP3+wu8HQ77Jv/aI7u6C68vnhU003UZAxr5KYL0tbEK4dT3xaP/VIC iNgbI4C8eIKf/6wDp7HQDgC+D8biYCmRa7AdBRPtQDzxnmduL4iEQjj2Njq/h2YJBnyn cKFl9x45NROJk3w0Lv3sgy1kzbWwZ21GcbFxk00M7S9b8Un4NN//yZnDzA+FqADE2PZI pgukZ5KyLe2w9fnUEGK+XjcL7jEhsiWWapjgG9LORQbJ/jy4QyCxIxTG+UOm1DzI9eEh Lp5OiZfSSOXW1U6evCje8SdzXiYehfQrCZeZEENIQTWiB1nJPjfKzDpV+cxGuZY3IIlH r6Hg== 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=EQz62QlP3EQWVixifiQxj0DarW6BylLwo/2WAdRi3Nc=; b=Xzs4hiNZqlpD+poBEGiMg/jv1XmmGC9K6cv2mTeiJTdbeU7gfiONjYHbaLEF//bLB3 vsHVUi1nHrjJKerfdKke+tM1oGQ5oiAAqenKBz4otLrDheSu3uC8H2DdQyZ4xiAFZI8d 8fPYz3klEyxgljsiBcfYtZJgXHloWTRhQpKKlqyVszQpDXpvIkDkD2OOyM6HBojpO4dr aeZ1TR7eelyqPZjm65JDlwdBoTPsptdPaBkv2EJjQ71y3MguKeP3v6cDqxXiQQRBkVFI Nl42lQxSQ1omeZ0zZfT+mayTGAp0P1bvm8H2otIC4uLUsqhOirERNIpP/25PyH5f8oAI dVpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="Dxp2j0/U"; 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 cj18-20020a17090715d200b008b126048876si4408240ejc.244.2023.02.14.13.15.10; Tue, 14 Feb 2023 13:15:34 -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="Dxp2j0/U"; 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 S232267AbjBNVNv (ORCPT + 99 others); Tue, 14 Feb 2023 16:13:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232140AbjBNVNq (ORCPT ); Tue, 14 Feb 2023 16:13:46 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD0272CFE6; Tue, 14 Feb 2023 13:13:41 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31E8M69x014331; Tue, 14 Feb 2023 21:13:25 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=EQz62QlP3EQWVixifiQxj0DarW6BylLwo/2WAdRi3Nc=; b=Dxp2j0/UC4mpQxhmZOgvkU4BGBXUe3w3vsGtdUHjy6TBFsuXXTYN/kX7DFAustBZUYPg +C2NjSO2VRVE1fRiFT1G+I9wI63ARdZuas46C1jjpRKs23ff6ke8n1xh6vx5JKWOWPI6 eWKQQx/x1rRicnbQVX4aEgaCUlAO1bOx4QJzEtOPyP4vwzRts3h3uTed7WG1NKEm0zyv D+yhZCO/xv7P0QPsmXplT/ytotZfGK6LH9VmwInY0IkASHG4i7xKbLoNsCYLjc13Z4ke I1jpSNULhQZyDlp+jX4s6YvCrUS0VqVBh0/bOh+DsvGh4TCy3SaX7E26Mg3um/JtPOX3 Uw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nr6qkhwt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Feb 2023 21:13:25 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31ELDOmG024625 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Feb 2023 21:13:24 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.36; Tue, 14 Feb 2023 13:13:23 -0800 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 , Catalin Marinas , Jassi Brar , , , , , Subject: [PATCH v10 03/26] gunyah: Common types and error codes for Gunyah hypercalls Date: Tue, 14 Feb 2023 13:12:06 -0800 Message-ID: <20230214211229.3239350-4-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214211229.3239350-1-quic_eberman@quicinc.com> References: <20230214211229.3239350-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-GUID: dUZapiGEsROfkL2rjcuim9ImLirlkVgC X-Proofpoint-ORIG-GUID: dUZapiGEsROfkL2rjcuim9ImLirlkVgC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-14_15,2023-02-14_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=735 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302140183 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757842594178272628?= X-GMAIL-MSGID: =?utf-8?q?1757842594178272628?= 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 | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 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..59ef4c735ae8 --- /dev/null +++ b/include/linux/gunyah.h @@ -0,0 +1,82 @@ +/* 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_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: + case GH_ERROR_IRQ_BOUND: + case GH_ERROR_IRQ_UNBOUND: + case GH_ERROR_MSGQUEUE_FULL: + case GH_ERROR_MSGQUEUE_EMPTY: + return -EBUSY; + case GH_ERROR_UNIMPLEMENTED: + case GH_ERROR_RETRY: + return -EOPNOTSUPP; + default: + return -EINVAL; + } +} + +#endif