From patchwork Mon Apr 24 23:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 87211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3062607vqo; Mon, 24 Apr 2023 16:28:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZA13AOl3z3z7MMjzHMjH9qMRFCVPtiF3r3q5//NgVr3KxvV/2L7YFmxFNOcJ8eNCWD2aJW X-Received: by 2002:a05:6a00:a92:b0:63b:2102:a1d4 with SMTP id b18-20020a056a000a9200b0063b2102a1d4mr19804566pfl.13.1682378918291; Mon, 24 Apr 2023 16:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682378918; cv=none; d=google.com; s=arc-20160816; b=yACN0kNPGCYaZRsrmsIC1/90wnDa+yfL/j19RGeHfQycbLxfNMEagHItgl/3DjpcXY G2Xy4Pe+xG/iuYtLhfoMhqN7pOVTI2h91jf/ddnfZHAzAnpEm8ys7hZ6ub+gjP9hCZ0b 2Nf2wZ6OSRVeVE320EUrDQ9OTlJhGUqS+vEERMVbUKBhgaKXjDlN6zQELZ9vZCa/Pjk9 Xdv52yhsvZsdclcM9Y5V/atZyqYaxCCFfgSsb2dz7lPtUJ05CUiIfannhIVJO4WStwEa dQj0akROWfojLS8sTta4pZjnhtUN6w80hVkdBEc28Z6oZ9zG4j8ROlANkaUFxEKdxmCJ Ph4g== 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=9Yy4nHPY9EKfC+xqdaroqLJS59AyPuRTpd+wvWGD+ZI=; b=qjKRj6o/hZbCQEkotkyDq3lNCDmE7JJkj7OpfNrq7yPcF1CK4FheoOIM7xaQMerDkr avbMzsQzvpoTx0mMBot9ObzjbYYAt8SZG3ifjOtnTK/1+IvL8s17aIqFyj/4FulXqKAi /U1RYBpY6dU/VSw20YM6eCqnHSVE13StiaIB5Ir7p7s+aL2A3nXYNwe/U/DQe083vZG+ Q3/XaFu9mR1pT3aPBAusInu92lRj8S0Hb4pDDwS3VQ+LHtUuPX1NnLOpqFdhim+aUuQd fKX4+7QuvhJo2cZz6Is9Kt4BOD1Vrhn/lGG8PJAoJ4E2JL9fT6jaXTcEWL0lB3MawLh3 hF7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XUmpSrSf; 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 n127-20020a632785000000b0051b7f0d0df3si13146144pgn.895.2023.04.24.16.28.23; Mon, 24 Apr 2023 16:28:38 -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=XUmpSrSf; 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 S233190AbjDXXRH (ORCPT + 99 others); Mon, 24 Apr 2023 19:17:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233115AbjDXXQs (ORCPT ); Mon, 24 Apr 2023 19:16:48 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD3AE9ED6; Mon, 24 Apr 2023 16:16:46 -0700 (PDT) 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 33OLBlTI028510; Mon, 24 Apr 2023 23:16:35 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=9Yy4nHPY9EKfC+xqdaroqLJS59AyPuRTpd+wvWGD+ZI=; b=XUmpSrSfM0JOU+KH5995bwI+qW/+iRonRA/NbSE7Tj/SBce5D8fbcm2KrgCgSHhXE3/Y cGGtkg31Tbu5dKQvZWclWrUpO4Wds3ofqcNzoqnvvpbPld+n+0kzoFwPvToTSbnPere5 WgeY1Ed218lf2VyiWJHsJXAi/nS3jAJjVk0A/E5bfvZdw9qnViyf0ayUY9uWAHLjRe8B rCHeH92ulY5WNckeIsnWAtsvJX+QtnDz3pkzyazLanznbzv90JKRalZ4SuPqANyJc8pg T6I9oIQuX8WZbbbyONlSz7On9IJJXnoC5jioWyUgD73AkgfiAhHC1gB+24XpNHygj9Y9 uQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q5qv6sjm4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 23:16:34 +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 33ONGXan024290 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 23:16:33 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:32 -0700 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 v12 05/25] virt: gunyah: msgq: Add hypercalls to send and receive messages Date: Mon, 24 Apr 2023 16:15:38 -0700 Message-ID: <20230424231558.70911-6-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-GUID: bTBKAexie_WhmCKxt43VK-dxjATBm1lX X-Proofpoint-ORIG-GUID: bTBKAexie_WhmCKxt43VK-dxjATBm1lX 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 clxscore=1015 spamscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304240211 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, 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?1764102156616773835?= X-GMAIL-MSGID: =?utf-8?q?1764102156616773835?= Add hypercalls to send and receive messages on a Gunyah message queue. Signed-off-by: Elliot Berman --- 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 2166d5dab869..2b2a63e9b9e5 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -33,6 +33,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 @@ -52,5 +54,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, u64 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 6b36cf4787ef..01a6f202d037 100644 --- a/include/linux/gunyah.h +++ b/include/linux/gunyah.h @@ -111,4 +111,10 @@ static inline u16 gh_api_version(const struct gh_hypercall_hyp_identify_resp *gh 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, u64 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