From patchwork Sat Mar 4 01:06:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 64124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp710909wrd; Fri, 3 Mar 2023 17:09:22 -0800 (PST) X-Google-Smtp-Source: AK7set+nGGIVFH5oN3wZ4URL6Z7nK26muEfIteybdUXSeYODTg+iOi8m1OayK9IAaOTZw77kRAfE X-Received: by 2002:a05:6402:350:b0:4be:d2f9:35a7 with SMTP id r16-20020a056402035000b004bed2f935a7mr3704168edw.21.1677892162625; Fri, 03 Mar 2023 17:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677892162; cv=none; d=google.com; s=arc-20160816; b=yQe2GzikKO7fJ5bfQiGfxs6anlUKatnCKNfuS3mtmMhCvlpcWjVP+xIwMchITNStey 4OpuRP4KZShfJZg1f/arQK8v26phD1JZw46TY1PfB3c/mdyhuXP2yuclMVrqzk97QeFc Uqx852srgVpyOYH52DL1iEulLtDm3TyZQ98qVa3EgbMbNINmrqAgsK5gJeIp+8dGaVes KqI2PqdmnU7WA+yCo+aBrz+SLCbu6keSVBW3e3F/8fVwYmc0teOU2i4+lgwWDLGTjmpU tkNJ+mioFNKY9Ro4iEezBn5PX9vAHCfGInNoxZa0ueoIoxeRl9QgM4VeicqGqMNqoz59 yh9g== 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=YsGuT96YuV6TmpZAGW8EVXUgQ910oBDQs5Ss5XxgyFk=; b=w2tCEuy9gcwcWrY8BSDELnA0hSh7fS6YJ6mWicb5qnpIZLoWqgyTq7PqreY23LWRfg lRsyszQfrUl76FfZfPG1Sw+t5gljndqMYIcVRtq0a4h9o8VpHNaMNwiaaxe96pdHZ3S9 PB4evgsV9Al4qpdxIebhgDMm63suM1w5d/Je9gythUzuzOFTBVRVZ0qy7XPnYT+omJOv L08alZQfxJ91vLvVDEoslII4ZifJYVBnji4LTZ4YTlFq2QP1vvCv5GNJ4GRT74Tk9oOP PM+ix3QS6s8BUwdr3zOPLgv9D9dyQBf2X31jZmRJ6E5B/CwtG7YL9rX5hXOc6pgCWI/9 5UYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QccQw1y9; 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 v26-20020aa7cd5a000000b004acd46cc731si1109712edw.460.2023.03.03.17.08.58; Fri, 03 Mar 2023 17:09:22 -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=QccQw1y9; 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 S229854AbjCDBH2 (ORCPT + 99 others); Fri, 3 Mar 2023 20:07:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbjCDBHG (ORCPT ); Fri, 3 Mar 2023 20:07:06 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79A760D71; Fri, 3 Mar 2023 17:07:05 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3240NDCo010557; Sat, 4 Mar 2023 01:06:53 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=YsGuT96YuV6TmpZAGW8EVXUgQ910oBDQs5Ss5XxgyFk=; b=QccQw1y9PYbK9t9AXUCSaMzx9hY/iKnowqV8QwKTp6jMQ1ROXiSeExx4RlWqg6TpfKGl LZCM5Qu+M0w9euY4AXJWFgLnszE71Vlqc1PUh1pf21wKSr2ALdcRxjacKagpO/TPD+Jr YW1dFVSFGxcdoP4+1EUqfwLh3wdHbFxX58ofVR7HH2aF4co+zxPT8x9TDs/1tgCMwNGN IiQ7VAod78Dqo6ohBF4q1KxcQtF1bwl5RvfTxw6oSz612aTxRUXKQtfJtjy2FphK56Sk 0bM2SrFF+8w3iAIpNZAmv2fmd9IaxHiDyzodGjDMaBQ+2AgG0NRiNE3L883310l9nqIq 7g== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3p3ph4rpde-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 04 Mar 2023 01:06:53 +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 32416qbp018614 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 4 Mar 2023 01:06:52 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:51 -0800 From: Elliot Berman To: Alex Elder , Srinivas Kandagatla , Elliot Berman , Prakruthi Deepak Heragu , Catalin Marinas , Will Deacon 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 , Andy Gross , Jassi Brar , , , , , Subject: [PATCH v11 06/26] virt: gunyah: msgq: Add hypercalls to send and receive messages Date: Fri, 3 Mar 2023 17:06:12 -0800 Message-ID: <20230304010632.2127470-7-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 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-ORIG-GUID: 19W5F3kn0fDshEJNBOuMQ_lADrjVT29I X-Proofpoint-GUID: 19W5F3kn0fDshEJNBOuMQ_lADrjVT29I 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 malwarescore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303040004 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?1759397452511865182?= X-GMAIL-MSGID: =?utf-8?q?1759397452511865182?= Add hypercalls to send and receive messages on a Gunyah message queue. Signed-off-by: Elliot Berman Reviewed-by: Srinivas Kandagatla --- arch/arm64/gunyah/gunyah_hypercall.c | 31 ++++++++++++++++++++++++++++ include/linux/gunyah.h | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c index 0d14e767e2c8..3420d8f286a9 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -41,6 +41,8 @@ EXPORT_SYMBOL_GPL(arch_is_gh_guest); fn) #define GH_HYPERCALL_HYP_IDENTIFY GH_HYPERCALL(0x8000) +#define GH_HYPERCALL_MSGQ_SEND GH_HYPERCALL(0x801B) +#define GH_HYPERCALL_MSGQ_RECV GH_HYPERCALL(0x801C) /** * gh_hypercall_hyp_identify() - Returns build information and feature flags @@ -60,5 +62,34 @@ void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identi } EXPORT_SYMBOL_GPL(gh_hypercall_hyp_identify); +enum gh_error gh_hypercall_msgq_send(u64 capid, size_t size, void *buff, int tx_flags, bool *ready) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc(GH_HYPERCALL_MSGQ_SEND, capid, size, (uintptr_t)buff, tx_flags, 0, &res); + + if (res.a0 == GH_ERROR_OK) + *ready = !!res.a1; + + return res.a0; +} +EXPORT_SYMBOL_GPL(gh_hypercall_msgq_send); + +enum gh_error gh_hypercall_msgq_recv(u64 capid, void *buff, size_t size, size_t *recv_size, + bool *ready) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc(GH_HYPERCALL_MSGQ_RECV, capid, (uintptr_t)buff, size, 0, &res); + + if (res.a0 == GH_ERROR_OK) { + *recv_size = res.a1; + *ready = !!res.a2; + } + + return res.a0; +} +EXPORT_SYMBOL_GPL(gh_hypercall_msgq_recv); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Gunyah Hypervisor Hypercalls"); diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h index bd080e3a6fc9..18cfbf5ee48b 100644 --- a/include/linux/gunyah.h +++ b/include/linux/gunyah.h @@ -108,4 +108,10 @@ struct gh_hypercall_hyp_identify_resp { void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identity); +#define GH_HYPERCALL_MSGQ_TX_FLAGS_PUSH BIT(0) + +enum gh_error gh_hypercall_msgq_send(u64 capid, size_t size, void *buff, int tx_flags, bool *ready); +enum gh_error gh_hypercall_msgq_recv(u64 capid, void *buff, size_t size, size_t *recv_size, + bool *ready); + #endif