From patchwork Fri Jan 20 22:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 46694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp473747wrn; Fri, 20 Jan 2023 15:11:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXvdf9gWQBrVmBOm1LxSMA2M6SvbB0R5UVasUdbGtx7au8niwa4UdCIXTQtoBnrikj517Ae5 X-Received: by 2002:a05:6402:c41:b0:499:d0e3:7745 with SMTP id cs1-20020a0564020c4100b00499d0e37745mr20260051edb.14.1674256286866; Fri, 20 Jan 2023 15:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674256286; cv=none; d=google.com; s=arc-20160816; b=HeJQOll93RrTbocNhg6K0Py1XEq6kO/V0h8UJ0AzDPrNUysr4ukJu0guzaA4Rx0Ryr bYjuKuz67IxdbfvK6G/hSoi+23oh1JKpdtEvP/qPhy4fhwqCZeTnhdOYsidCJqnuk3Io 7+mi9idDcg3iSjmWPiD242yAeHC5bKGJYR1538r8Xtm+KM2+GfHpSmRoETNYzDKGMqmP 1CEWWfkY+OcfMLXkHRWkpD5h/mAUYJX3ThSVmsXRokxBLiwv1zDo04adZJyc0TjsSdIX Qy7G7jqkoTcJeFw2yooD91a6pT3B7DN9mul6VqR7+9lsNkFelwdhQUvFQ9ObKD9YPjXu 4QaA== 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=+z0xlUlEWhGDHObbmbwPzHrQHX6Yp1OolxLxSjxGCHk=; b=IOKSu0/7Aa/K+vCmCim3z0ALgpPVCTVIuk/cJdTdgqnHMG2zZ3ekBZy1tKKFUaN3qv R3Urck/vYa+3Ut47XsOXfqkh/7jB2e36sEHGO+kqPTEpE9cJGpGkA+l+feOTkA044V5c gqxP3nUgjrtAzmXzim4u3P83eEO+ydlQ/f/YOnXrp4IPhwFjqiVIXk2yPs3DjN6JUoag RzLn3HKEQF35K+/nsNZH8hY/RdsIxrSvhEz4eq4ECb3Hk3+28LqqujIadS2UdOx0hzem EpL9GpyXiYJ+VZ5OGATdTptwEVm2jAcAMT5O+RNLoahFmHG/Ub2vWendRdsNetoPIT7E C6WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NKEGv+dy; 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 em8-20020a056402364800b0048ec063ea63si20617802edb.396.2023.01.20.15.11.02; Fri, 20 Jan 2023 15:11:26 -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=NKEGv+dy; 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 S229949AbjATXJA (ORCPT + 99 others); Fri, 20 Jan 2023 18:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjATXI6 (ORCPT ); Fri, 20 Jan 2023 18:08:58 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC1085E515; Fri, 20 Jan 2023 15:08:49 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30KLAU7O022403; Fri, 20 Jan 2023 22:48:10 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=+z0xlUlEWhGDHObbmbwPzHrQHX6Yp1OolxLxSjxGCHk=; b=NKEGv+dyCkLx4R4NImhfxqLObWHfEokgkG+G26vuRoQBPbPGdRBBqeECm1mrm01zoaPX uEnkgMcvyDMgI0AI4G7xqtQbJZ3/nVsGrGTCLHQxCPs7N8s+UKXlIGkiR4mM2sZrCYCk ywGHj4sA6luFOsPzuSksUz0IU31zW/SiGop5gELpmJGxVqvam73uUQsdA7ME5977JexD IWQYigACJKTREtvW9O3kyC7bhXQlggnlUw42AoNxZ5o37s0tH3JteVS1ln3282upnwi/ WVXwXN8t+VATmhAghzEvrZBJdgczmWG9hLyz7XFSCib8M/TzRA6B0IW+DjRUzJdjL+G6 0Q== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n7xt7rjwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:48:10 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30KMm9w7029470 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:48:09 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:48:08 -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 25/27] virt: gunyah: Add hypercalls for sending doorbell Date: Fri, 20 Jan 2023 14:46:24 -0800 Message-ID: <20230120224627.4053418-26-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: PEWX8HQrH9KTkKaoy7akz9laQMWtl8eX X-Proofpoint-ORIG-GUID: PEWX8HQrH9KTkKaoy7akz9laQMWtl8eX 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 clxscore=1015 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=964 phishscore=0 bulkscore=0 adultscore=0 malwarescore=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?1755584960443346656?= X-GMAIL-MSGID: =?utf-8?q?1755584960443346656?= Gunyah doorbells allow two virtual machines to signal each other using interrupts. Add the hypercalls needed to assert the interrupt. Signed-off-by: Elliot Berman --- arch/arm64/gunyah/gunyah_hypercall.c | 39 ++++++++++++++++++---------- include/linux/gunyah.h | 3 +++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c index 17d87a130a3e..057e127f2b4d 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -12,19 +12,7 @@ static const uint32_t gunyah_known_uuids[][4] = { {0x673d5f14, 0x9265ce36, 0xa4535fdb, 0xc1d58fcd}, /* GUNYAH (open source build) */ }; -#define GH_HYPERCALL_HYP_IDENTIFY GH_HYPERCALL(0x0000) -#define GH_HYPERCALL_MSGQ_SEND GH_HYPERCALL(0x001B) -#define GH_HYPERCALL_MSGQ_RECV GH_HYPERCALL(0x001C) -#define GH_HYPERCALL_VCPU_RUN GH_HYPERCALL(0x0065) - -/** - * gh_hypercall_get_uid() - Returns a UID when running under a Gunyah hypervisor - * @uid: An array of 4 u32's (u32 uid[4];) - * - * Caller should compare the resulting UID to a list of known Gunyah UIDs to - * confirm that Linux is running as a guest of Gunyah. - */ -void gh_hypercall_get_uid(u32 uid[4]) +bool arch_is_gunyah_guest(void) { struct arm_smccc_res res; u32 uid[4]; @@ -74,6 +62,31 @@ void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identi } EXPORT_SYMBOL_GPL(gh_hypercall_hyp_identify); +int gh_hypercall_dbl_send(u64 capid, u64 new_flags, u64 *old_flags) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc(GH_HYPERCALL_DBL_SEND, capid, new_flags, 0, &res); + + if (res.a0) + return res.a0; + + *old_flags = res.a1; + + return res.a0; +} +EXPORT_SYMBOL_GPL(gh_hypercall_dbl_send); + +int gh_hypercall_dbl_set_mask(u64 capid, u64 enable_mask, u64 ack_mask) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc(GH_HYPERCALL_DBL_SET_MASK, capid, enable_mask, ack_mask, 0, &res); + + return res.a0; +} +EXPORT_SYMBOL_GPL(gh_hypercall_dbl_set_mask); + int gh_hypercall_msgq_send(u64 capid, size_t size, uintptr_t buff, int tx_flags, bool *ready) { struct arm_smccc_res res; diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h index feeab01bff30..ac4879940c10 100644 --- a/include/linux/gunyah.h +++ b/include/linux/gunyah.h @@ -164,6 +164,9 @@ struct gh_hypercall_hyp_identify_resp { void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identity); +int gh_hypercall_dbl_send(u64 capid, u64 new_flags, u64 *old_flags); +int gh_hypercall_dbl_set_mask(u64 capid, u64 enable_mask, u64 ack_mask); + #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);