From patchwork Tue Jan 9 19:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 13515274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83589C4706C for ; Tue, 9 Jan 2024 19:38:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 394E76B007D; Tue, 9 Jan 2024 14:38:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 342738D0001; Tue, 9 Jan 2024 14:38:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00D6E6B00A4; Tue, 9 Jan 2024 14:38:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DC3B38D0003 for ; Tue, 9 Jan 2024 14:38:04 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A73D31209CA for ; Tue, 9 Jan 2024 19:38:04 +0000 (UTC) X-FDA: 81660783288.28.10AC470 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf19.hostedemail.com (Postfix) with ESMTP id 788DE1A0018 for ; Tue, 9 Jan 2024 19:38:02 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=bqDBYTlT; spf=pass (imf19.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704829082; a=rsa-sha256; cv=none; b=eev9GUcUkOVELGM4e8rmGC3ZIVXLb7ymRiXVjLoFZf/UdYHeLr0qMovUVzdSwsYRv/SMYO Zh2ALOAYVvZbkvafO6N0dZ7MB+vE+IdonJiCaY0UxXXci3foXENoMDEIucOyosT1cJcif8 KdQOTDR/Epw+AhDcg7aY5wkkvcBhf1M= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=bqDBYTlT; spf=pass (imf19.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704829082; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=icjWnj0mkCwFQ21u1pvtQcXcenrQAbg51OlUAoFY4js=; b=Ej2cBjYRHkzqKsQBFGKu/BkGYB1scy+8CGPkdnCWNy7PSYE6kEJFz26x2fvHfpuKV2hY5u I297rWXdQFH+Dz1xgLk+XC5u8LAaOrtXE1xoEMCReKUjohzaNHflaGJNPXV/xBmdEzSL/f 1vlTFdOCvm3l6ORlGbAZDy+gAdD7Cf4= Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 409Gashn012246; Tue, 9 Jan 2024 19:37:54 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=icjWnj0mkCwFQ21u1pvtQcXcenrQAbg51OlUAoFY4js =; b=bqDBYTlTznzQzDDe/plCWxNrXBj0C+AuBiF9nl2bWqlMa4C867i8U3UyhWg ftNcHS0TTD/PChYDLzXd1s3/lzOa4m8O8uh0Kzqnj1h3n3xcyfvBC7W85E//60A5 4L5MBJ2SbgfI46/u6FNCHd6/gV4r/TvTnlzhuYCR6RHVezFSf3f+1w3srNDzevO9 fbuIpK+Ea2ADnFDMspYMDE8v7eNkFtIp0zOo9KRXZVxtg4fA4yXeS08P8E2S6ef0 ArVuxvy++oFgiYVs6OE6IhJ2AmeQzXZDk1ChOFIWkSMH7B9wagruHaoyTU6Hqs7t nH8m6jW6Z1rrKtJweqGbJ27evvQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vh9ta0dw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 19:37:53 +0000 (GMT) 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 409Jbq3R024506 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jan 2024 19:37:52 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; Tue, 9 Jan 2024 11:37:51 -0800 From: Elliot Berman Date: Tue, 9 Jan 2024 11:37:43 -0800 Subject: [PATCH v16 05/34] virt: gunyah: Add hypervisor driver MIME-Version: 1.0 Message-ID: <20240109-gunyah-v16-5-634904bf4ce9@quicinc.com> References: <20240109-gunyah-v16-0-634904bf4ce9@quicinc.com> In-Reply-To: <20240109-gunyah-v16-0-634904bf4ce9@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.13-dev 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: Ig6iQvpCLqOoTnh4LaxOTKhPE4RmuWK3 X-Proofpoint-ORIG-GUID: Ig6iQvpCLqOoTnh4LaxOTKhPE4RmuWK3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401090158 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 788DE1A0018 X-Stat-Signature: kbj3bpqxawn7ngwy8rfeny6kjexbgyer X-Rspam-User: X-HE-Tag: 1704829082-214677 X-HE-Meta: U2FsdGVkX1+f56ZdXXPBGkeZ5CmGyqCoqb9gmjmtSHt1eH5t7BxrLpWFvLs4yvJEpnp94fBOGVsVdmyiYNWqK0CvtdZLp5Uz2bLfglRsPuQyKKFv1wEwBkvGbOsvvgU3x7qVaqcigx5nBlSen2QDKSZCU0dFGkiEYS+5f9TpZRsxtOs5NGaxwjCOnjN3UxVWkbylKkF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42hTWIO0nyxT0mH82iVpO1uSNLmV4g0VJ4RDdwUGN4AMSwfBF9Go/S0YbhLzJd7S3TR6u7QB8L+HeXyBPZib0RsVEnYS71Y8n6zUfBJBm+nz0etFA3EzxxGGDARBbhmZ10p1NohD9NT6szktcVJXlwYjE+AQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add driver to detect when running under Gunyah. It performs basic identification hypercall and populates the platform bus for resource manager to probe. Signed-off-by: Elliot Berman --- drivers/virt/Makefile | 1 + drivers/virt/gunyah/Makefile | 3 +++ drivers/virt/gunyah/gunyah.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile index f29901bd7820..ef6a3835d078 100644 --- a/drivers/virt/Makefile +++ b/drivers/virt/Makefile @@ -10,3 +10,4 @@ obj-y += vboxguest/ obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/ obj-$(CONFIG_ACRN_HSM) += acrn/ obj-y += coco/ +obj-y += gunyah/ diff --git a/drivers/virt/gunyah/Makefile b/drivers/virt/gunyah/Makefile new file mode 100644 index 000000000000..34f32110faf9 --- /dev/null +++ b/drivers/virt/gunyah/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_GUNYAH) += gunyah.o diff --git a/drivers/virt/gunyah/gunyah.c b/drivers/virt/gunyah/gunyah.c new file mode 100644 index 000000000000..ef8a85f27590 --- /dev/null +++ b/drivers/virt/gunyah/gunyah.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include + +static int gunyah_probe(struct platform_device *pdev) +{ + struct gunyah_hypercall_hyp_identify_resp gunyah_api; + + if (!arch_is_gunyah_guest()) + return -ENODEV; + + gunyah_hypercall_hyp_identify(&gunyah_api); + + pr_info("Running under Gunyah hypervisor %llx/v%u\n", + FIELD_GET(GUNYAH_API_INFO_VARIANT_MASK, gunyah_api.api_info), + gunyah_api_version(&gunyah_api)); + + /* Might move this out to individual drivers if there's ever an API version bump */ + if (gunyah_api_version(&gunyah_api) != GUNYAH_API_V1) { + pr_info("Unsupported Gunyah version: %u\n", + gunyah_api_version(&gunyah_api)); + return -ENODEV; + } + + return devm_of_platform_populate(&pdev->dev); +} + +static const struct of_device_id gunyah_of_match[] = { + { .compatible = "gunyah-hypervisor" }, + {} +}; +MODULE_DEVICE_TABLE(of, gunyah_of_match); + +/* clang-format off */ +static struct platform_driver gunyah_driver = { + .probe = gunyah_probe, + .driver = { + .name = "gunyah", + .of_match_table = gunyah_of_match, + } +}; +/* clang-format on */ +module_platform_driver(gunyah_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Gunyah Driver");