From patchwork Fri Jan 20 22:46: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: 46668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp465455wrn; Fri, 20 Jan 2023 14:49:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvBKIwokKA3SglPpQjnt4x+zgqzFY2tlHT3UdQnwSDAhTKwljR5k1rdeGIu9Y+OdhF1S/Y7 X-Received: by 2002:a17:902:e5d2:b0:194:516b:2d91 with SMTP id u18-20020a170902e5d200b00194516b2d91mr21725649plf.20.1674254988387; Fri, 20 Jan 2023 14:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674254988; cv=none; d=google.com; s=arc-20160816; b=mI7vFz/gfQZ9TwY8QsmFB90Ij5qqbpfhv5DbH38eeB3eVdr2PoJBgsngzxGQfLieJ6 vp9tm9JdGAhKog+zrRhPXzZzMiTzNzHrMGifVKr0wRwCdIuJR4hGNJAcg4zoF/jPhCGd 1nW2oIHZLlt3Ha0vDx8lX8Ys36RT3I4361azWvsDSpEam/TpN2z+wRwMKiT+0wIhrzVh eFw5cjsIROSWZmCwqbBG15RVliJ1RL+b1ao4hSSTTQksC489eFGcvq/P57MEDP12KmMh q8p8f8euMgmpE+yDdfgOE5Th0LxXE3vjE/zWkBblIiNNJkbKnfYD6ltBltG6rme3vZRi y5Hg== 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=ovIk7K18fTf8BAB1Q7TgDJbm1HCEqrh/BQIJHr0vR7Q=; b=xcKGW01RzvOSw+Z9Wl9JIuuF0fGbLznnQHrbAlgN8h5DiUdFwIP/KhXPLc/odyqqLy SnUTqDBtg8sHgQHEFgXLZKEPBzrdXyO+WOOiJHrWdgHmtlI4sqquLqbKqxYfDOJTaJXS J+LXSxi4agDzS/KBpLDhgdeGsiQaI20C1Ij8spcYuZTXQ5oxEg+UEXnTWAX/Fc/SyquJ CiX+auTrzV3FgVGsQS6xKWVBL8orGjJGIyJGp2xDwNnps69mZTrMU/hNr88W7OyUtNsm SgQtnwIOU2Ma5RS+A9uJtNpVYUAY4Vn9o15Amat5QslvY+XmGNdHlibjFzhveZK6APCT E+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="aF/evuq0"; 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 q4-20020a170902eb8400b0019497503cf9si15959631plg.259.2023.01.20.14.49.36; Fri, 20 Jan 2023 14:49:48 -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="aF/evuq0"; 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 S229992AbjATWsO (ORCPT + 99 others); Fri, 20 Jan 2023 17:48:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjATWsG (ORCPT ); Fri, 20 Jan 2023 17:48:06 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37D237F09; Fri, 20 Jan 2023 14:47:50 -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 30KM03ch024187; Fri, 20 Jan 2023 22:47:40 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=ovIk7K18fTf8BAB1Q7TgDJbm1HCEqrh/BQIJHr0vR7Q=; b=aF/evuq0EMXoKA3Yr8jd5gdoFm9yEp3hfyCgGYnB06+oIzRodnukvdfk+8HpKpQLlsxI H/tasgrMptG1vC1JjUSLqQRLNsrez3j/JyiZMAUTSWaWf5l02wUjvrNlVd7JQLmg6Nux +LQ+g8bdaNSGuKP+sIanXo96UWFJUwaWi6y1bjhJpl2kApIGhMNApQs1Qs5z09Bb3HCk hAMaH82ff52MlO+KmlE63+mR1fZK+uLIqQbwg+U80VlbLihjsOVoqS2KRn24zL+LOcU5 wbH5Lt1YEJg9LkmtJugneBrnJbgaSKZtcQqDdHcRwUdEcCSKrsj7k6Svh1Lk6T7xmCTo gA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n7c28jrer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:47:39 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30KMlcYK030181 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:47:38 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; Fri, 20 Jan 2023 14:47:38 -0800 From: Elliot Berman To: Bjorn Andersson , Alex Elder , Elliot Berman , Murali Nalajala , Catalin Marinas , "Will Deacon" CC: Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Prakruthi Deepak Heragu , Dmitry Baryshkov , Arnd Bergmann , "Greg Kroah-Hartman" , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Marc Zyngier , Jassi Brar , Sudeep Holla , , , , , Subject: [PATCH v9 07/27] virt: gunyah: msgq: Add hypercalls to send and receive messages Date: Fri, 20 Jan 2023 14:46:06 -0800 Message-ID: <20230120224627.4053418-8-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120224627.4053418-1-quic_eberman@quicinc.com> References: <20230120224627.4053418-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-GUID: -j1pKOQnNXgVbsFDIKQgxAlfSA6Hzwfc X-Proofpoint-ORIG-GUID: -j1pKOQnNXgVbsFDIKQgxAlfSA6Hzwfc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-20_11,2023-01-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301200218 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?1755583598963034458?= X-GMAIL-MSGID: =?utf-8?q?1755583598963034458?= Add hypercalls to send and receive messages on a Gunyah message queue. Signed-off-by: Elliot Berman --- arch/arm64/gunyah/gunyah_hypercall.c | 33 ++++++++++++++++++++++++++++ include/linux/gunyah.h | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c index ffed4b71641f..d93ad2c08479 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -13,6 +13,8 @@ static const uint32_t gunyah_known_uuids[][4] = { }; #define GH_HYPERCALL_HYP_IDENTIFY GH_HYPERCALL(0x0000) +#define GH_HYPERCALL_MSGQ_SEND GH_HYPERCALL(0x001B) +#define GH_HYPERCALL_MSGQ_RECV GH_HYPERCALL(0x001C) /** * gh_hypercall_get_uid() - Returns a UID when running under a Gunyah hypervisor @@ -71,5 +73,36 @@ void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identi } EXPORT_SYMBOL_GPL(gh_hypercall_hyp_identify); +int gh_hypercall_msgq_send(u64 capid, size_t size, uintptr_t buff, int tx_flags, bool *ready) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc(GH_HYPERCALL_MSGQ_SEND, capid, size, buff, tx_flags, 0, &res); + + if (res.a0) + return res.a0; + + *ready = res.a1; + + return res.a0; +} +EXPORT_SYMBOL_GPL(gh_hypercall_msgq_send); + +int gh_hypercall_msgq_recv(u64 capid, uintptr_t 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, buff, size, 0, &res); + + if (res.a0) + return res.a0; + + *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 6724d1264d58..b5f61c14ec1e 100644 --- a/include/linux/gunyah.h +++ b/include/linux/gunyah.h @@ -104,4 +104,9 @@ 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) + +int gh_hypercall_msgq_send(u64 capid, size_t size, uintptr_t buff, int tx_flags, bool *ready); +int gh_hypercall_msgq_recv(u64 capid, uintptr_t buff, size_t size, size_t *recv_size, bool *ready); + #endif