Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp650687rdb; Thu, 22 Feb 2024 15:26:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWIiFeRIKpCeu/zPOFbwKLxdHkHMzmWnPXTn2uOrG2pZ+ibpOOLhhh+DHJxr2GahX2fDhGKXUS+qv5LKPtXk6NHQgrnBGLBXFva2gfsKg== X-Google-Smtp-Source: AGHT+IGNgIrmMMKOchF5D/FJpA/vuBuBxBdBAY/Z19DBV2ugft4l/2JI4U6p1nIfX4s4kktEm4X/ X-Received: by 2002:a05:620a:b87:b0:787:a750:b963 with SMTP id k7-20020a05620a0b8700b00787a750b963mr927916qkh.5.1708644365289; Thu, 22 Feb 2024 15:26:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708644365; cv=pass; d=google.com; s=arc-20160816; b=fCzwr0nawFAgQAzn59LjYAtiP3POY7FbhD8WvVwl2ufNuFOH92DP+m8IHQbXPcuyMt COTSsjacut5GeUcUotlSzlt5LeRokAeAVT/kVRIqO/gQRZHaF9wu/MstjqOv7weQu9kC M7MnyjD/vtWGFp2h5NqTpKYxujwXGe3M1ITa5ch9Evyri9ej9GJqOBvcsWk3nsMouaq6 fre0zWclm3m2CZKBIsuB5Wt7ddQWgwdx+vE5brnmES787hPnsWIcV9wb32nh8bdPfEOy 4q5E0wRtH9ESzqxW+zpKlg5fepq0zG+aBGA92qRDgcUSQXxnH5hnz3gV60815FiQ1AVn Jw4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=83pzBajTRslKt0o1B0FwsmcpCOmVlVgR5SA87/iFxjI=; fh=j53ffieBeHmuArQHAkiXDczYOIriM+Jf92hqYE3BW8U=; b=ctkF99P8GpMu4K9iLTs9EZ5ryoe4ITTvES550zQCHHw7mcQN4RuQYa7/DiWDznR+S0 o3XfTI2+Wsbmdj+1QHnyWvwjMsM2dnOg8EpHLoWbSyBVtCDxxX+lPcvnUDjDYJ5DLFFO n51RYIIWAIwBXV7X7C5smA/uVCgg9abEZbVZ2rs6w71QNu8Du32z0EXNFEof7O6IjaAb kqbSMVGWTO60wQkSpqqscYEu5W38cmeQaERvhafBSVdnx0Gq6ntGnLu7ClyRypwjJ5Vq +yswsWgYl+ulYPut50h4sPmTiyLs9Nr/6IjJJm5+aX0tT7Nex6A9Kzjgwbi5HgDd+O21 hZag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=P79kJxu3; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-77528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pb11-20020a05620a838b00b0078784bc4e64si5102533qkn.615.2024.02.22.15.26.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:26:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=P79kJxu3; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-77528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 045F21C2252F for ; Thu, 22 Feb 2024 23:26:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E6656E612; Thu, 22 Feb 2024 23:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="P79kJxu3" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCA68225B2; Thu, 22 Feb 2024 23:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708643869; cv=none; b=eWidPDNn8ovTXhjK67Na0uv7770lKeWTs5dZBeUpVh2i45vSmzluXkC+8oM+NE0pB2ZqwPC3Y/LOA85bwEQSLZLFjInUM5EyvlfUt/N3c0bvnCMOcMb+a7owcybyNl7os7hr0LPQrU4tmAnzcfF+OqzTk1DB+1VwnLdQs7V1QDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708643869; c=relaxed/simple; bh=gyPHTGMdxBaoOUk6YAi+4jOxgg1IxhU91eFvKjDuzC4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=lRBxVOlE9zWlhaWwMh4WwVW4fQn6+bkMeVyOskgnSzQ5557E5KFDcI0Jc+yeIfGX4BQE6hBytxSo82PMvVmB5rSvgNo12Rr4VaEo2EBt3nblHdeGNTsjp1ypZgeHsFM2VxB9QS+er/cwguN3FBvCQQkaWhV/J5ARtsKZqvzMHKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=P79kJxu3; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41MMFNlW018116; Thu, 22 Feb 2024 23:16:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:date:subject:mime-version:content-type :content-transfer-encoding:message-id:references:in-reply-to:to :cc; s=qcppdkim1; bh=83pzBajTRslKt0o1B0FwsmcpCOmVlVgR5SA87/iFxjI =; b=P79kJxu3zXYn+BomJ0td4R5hcDW8siUXNVPRCQOI4JebfMSoULPHooGLMw9 kE4m36hM0QSzCZ2gCa9b/zFEJ9kpytKYFHWrxHs4rcvGOOM7vTr2gZvD9ulyqSaF Z7T8GFLPCFNbc2wJVcFELaPbDirfLfrShIoPAeBaFbEy8KIenTCewyLvLjEQL98p MpBwVkxzkOhWI7xPHO6HwiLrEsDWr6+x3aOuFpbT1Y4mihZUVKGZgxc+LwjeZWtE 4aJabcRkxa24KIyjtGuBrEG/DN0KklIlSp1x8hfLQ6sdKQed5dFxaO8XW5/RCEvE Ph8TRhNu36j5t7xAC5YBr2iQIAQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3we97tgf88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 23:16:31 +0000 (GMT) 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 41MNGUVJ027669 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 23:16:30 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.1118.40; Thu, 22 Feb 2024 15:16:30 -0800 From: Elliot Berman Date: Thu, 22 Feb 2024 15:16:29 -0800 Subject: [PATCH v17 06/35] virt: gunyah: msgq: Add hypercalls to send and receive messages Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240222-gunyah-v17-6-1e9da6763d38@quicinc.com> References: <20240222-gunyah-v17-0-1e9da6763d38@quicinc.com> In-Reply-To: <20240222-gunyah-v17-0-1e9da6763d38@quicinc.com> To: Alex Elder , Srinivas Kandagatla , Murali Nalajal , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Philip Derrin , Prakruthi Deepak Heragu , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Konrad Dybcio , Bjorn Andersson , Dmitry Baryshkov , "Fuad Tabba" , Sean Christopherson , "Andrew Morton" CC: , , , , , , Elliot Berman X-Mailer: b4 0.12.4 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: VfnP53t9g2l9KuenPJEO6MN8h2KOj3Pm X-Proofpoint-ORIG-GUID: VfnP53t9g2l9KuenPJEO6MN8h2KOj3Pm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-22_15,2024-02-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 adultscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 mlxlogscore=965 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402220179 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 | 55 ++++++++++++++++++++++++++++++++++++ include/linux/gunyah.h | 8 ++++++ 2 files changed, 63 insertions(+) diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c index d44663334f381..1302e128be6e9 100644 --- a/arch/arm64/gunyah/gunyah_hypercall.c +++ b/arch/arm64/gunyah/gunyah_hypercall.c @@ -37,6 +37,8 @@ EXPORT_SYMBOL_GPL(arch_is_gunyah_guest); /* clang-format off */ #define GUNYAH_HYPERCALL_HYP_IDENTIFY GUNYAH_HYPERCALL(0x8000) +#define GUNYAH_HYPERCALL_MSGQ_SEND GUNYAH_HYPERCALL(0x801B) +#define GUNYAH_HYPERCALL_MSGQ_RECV GUNYAH_HYPERCALL(0x801C) /* clang-format on */ /** @@ -58,5 +60,58 @@ void gunyah_hypercall_hyp_identify( } EXPORT_SYMBOL_GPL(gunyah_hypercall_hyp_identify); +/** + * gunyah_hypercall_msgq_send() - Send a buffer on a message queue + * @capid: capability ID of the message queue to add message + * @size: Size of @buff + * @buff: Address of buffer to send + * @tx_flags: See GUNYAH_HYPERCALL_MSGQ_TX_FLAGS_* + * @ready: If the send was successful, ready is filled with true if more + * messages can be sent on the queue. If false, then the tx IRQ will + * be raised in future when send can succeed. + */ +enum gunyah_error gunyah_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(GUNYAH_HYPERCALL_MSGQ_SEND, capid, size, + (uintptr_t)buff, tx_flags, 0, &res); + + if (res.a0 == GUNYAH_ERROR_OK) + *ready = !!res.a1; + + return res.a0; +} +EXPORT_SYMBOL_GPL(gunyah_hypercall_msgq_send); + +/** + * gunyah_hypercall_msgq_recv() - Send a buffer on a message queue + * @capid: capability ID of the message queue to add message + * @buff: Address of buffer to copy received data into + * @size: Size of @buff + * @recv_size: If the receive was successful, recv_size is filled with the + * size of data received. Will be <= size. + * @ready: If the receive was successful, ready is filled with true if more + * messages are ready to be received on the queue. If false, then the + * rx IRQ will be raised in future when recv can succeed. + */ +enum gunyah_error gunyah_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(GUNYAH_HYPERCALL_MSGQ_RECV, capid, (uintptr_t)buff, + size, 0, &res); + + if (res.a0 == GUNYAH_ERROR_OK) { + *recv_size = res.a1; + *ready = !!res.a2; + } + + return res.a0; +} +EXPORT_SYMBOL_GPL(gunyah_hypercall_msgq_recv); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Gunyah Hypervisor Hypercalls"); diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h index 33bcbd22d39f7..acd70f9824253 100644 --- a/include/linux/gunyah.h +++ b/include/linux/gunyah.h @@ -141,4 +141,12 @@ gunyah_api_version(const struct gunyah_hypercall_hyp_identify_resp *gunyah_api) void gunyah_hypercall_hyp_identify( struct gunyah_hypercall_hyp_identify_resp *hyp_identity); +/* Immediately raise RX vIRQ on receiver VM */ +#define GUNYAH_HYPERCALL_MSGQ_TX_FLAGS_PUSH BIT(0) + +enum gunyah_error gunyah_hypercall_msgq_send(u64 capid, size_t size, void *buff, + u64 tx_flags, bool *ready); +enum gunyah_error gunyah_hypercall_msgq_recv(u64 capid, void *buff, size_t size, + size_t *recv_size, bool *ready); + #endif -- 2.34.1