From patchwork Tue Jun 13 17:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 107497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp725806vqr; Tue, 13 Jun 2023 10:50:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4gAHpWzp24dgt0AKmy51an28vssvWk5wdOQfQRXDFvn9cXEbqn2C4R3UkyD8djJys/Cfyt X-Received: by 2002:a17:906:db0e:b0:975:bbd:d205 with SMTP id xj14-20020a170906db0e00b009750bbdd205mr12733005ejb.9.1686678637510; Tue, 13 Jun 2023 10:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686678637; cv=none; d=google.com; s=arc-20160816; b=wgDVEGBMKpMpVY0qeei1dyA8fTI3BGMoy5BG/kaBg0EL+aQmxPJ0Q3xEovnh2X262X rsAyVPk8f7wW/agJTOrZuQvfEkSjshZc6j8SErTjwDnaeQJohxGFP9+ZdRrhNOuASi0j /dXwpPiPO0utN2thWtrtFB7vephhDRhhgqrM1deZuJbF5ytBns265/FCt529BvD65O5L OhuhjALRcMRxCewNRLSAj78edapRs13r2mZCSv8LMQO8QczWpQbWKmZgLqkQWxi47zMM rRSadfId8RKMQ7UkMybLsGr0xgDcgJxYWO75CbvLvouM3XtEbYc1cD+jjJWr+0pJjbNi YZow== 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=KpyV3EhzZ8pJ/kL6sijT9Qng9r1uqgy3JJH17CB275I=; b=Blah+OsyryVocSQY1VkqtlJRNt6P0fun/QAhTFrwCoRjrxdjkNy7CHOUI2Hj3KE+Z5 4vUi0iFAhjO21jeF20IglPQVKaR7ZBceqfyDYCcG+8Fx1dEUU0kPFBHYo5aUPyLEzbY1 5RJNIU77EC1SEwqGrODhZysFSOWJc1M9ZoRIdgnWbE9x303ERxT1r/A8NNXWXPwLu8TV NsM3YaF5f0TdIQ+nTACqoSQnvtvTBGc/Ij/Pl0WiQZY6YNndRceMmANFpgiU8LfvEoLW 4tNql6KfU01BxFORX36k46H+zDwsZawgkmbzYnYLkaCs5XxRtBwccvDU/4/Ug4lxFqvt kn7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bX+BdKfL; 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 bu7-20020a170906a14700b0096f65c97148si7000463ejb.714.2023.06.13.10.50.12; Tue, 13 Jun 2023 10:50:37 -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=bX+BdKfL; 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 S239117AbjFMRW3 (ORCPT + 99 others); Tue, 13 Jun 2023 13:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238491AbjFMRWN (ORCPT ); Tue, 13 Jun 2023 13:22:13 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7357D173C; Tue, 13 Jun 2023 10:21:53 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35DEOtO6020171; Tue, 13 Jun 2023 17:21: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=KpyV3EhzZ8pJ/kL6sijT9Qng9r1uqgy3JJH17CB275I=; b=bX+BdKfL7I8vbYos+sRAo9fakd1FY6EqMmWlB0kkzgE0H0/VJkkK9saKpwk1DGmbBpW6 npR0nElYeuuSPekcmFUKcMlXtSMWQ9cTir4Drqns4H1R5IMPAr6cIeflfWdl0kyuwsZZ RcqECPfR6b/WkR6kgGcOuGavnp/NiwBeUKeC9F2in/ZR+MM+ALCVNeIUeDKcaMpB6gaf tgBUaqJ5rLsqL1adLtgDasBIpq7AM5At7ok8TaYbIHvtDT4pCYlrChWl01aoEIyFxOSj r2OAXVzT2yAJ8AQUbOHyWZ1PtPzlNx4CmP5ycX7ls21rVEloomRTI1ZqrbsY6Ze8HgTR Dg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r6amhj9dx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 17:21:24 +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 35DHLOV1004137 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 17:21: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.42; Tue, 13 Jun 2023 10:21:23 -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 , Conor Dooley , Jonathan Corbet , Bagas Sanjaya , Andy Gross , Jassi Brar , , , , , Subject: [PATCH v14 05/25] virt: gunyah: msgq: Add hypercalls to send and receive messages Date: Tue, 13 Jun 2023 10:20:33 -0700 Message-ID: <20230613172054.3959700-6-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230613172054.3959700-1-quic_eberman@quicinc.com> References: <20230613172054.3959700-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) 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: 24fQMNosgcZwy4FCvQaybYmgwVLv9Dgz X-Proofpoint-GUID: 24fQMNosgcZwy4FCvQaybYmgwVLv9Dgz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-13_20,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306130153 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, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,URIBL_BLOCKED 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?1768610738796959765?= X-GMAIL-MSGID: =?utf-8?q?1768610738796959765?= Add hypercalls to send and receive messages on a Gunyah message queue. Reviewed-by: Alex Elder Reviewed-by: Srinivas Kandagatla 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 ef48e0b8b5448..c5bf0dd468ec9 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -35,6 +35,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 @@ -54,5 +56,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 6b36cf4787efb..01a6f202d037e 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