From patchwork Thu Feb 22 23:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 13568299 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 663F7C47DD9 for ; Thu, 22 Feb 2024 23:21:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED8CC6B00C1; Thu, 22 Feb 2024 18:21:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E89016B00C7; Thu, 22 Feb 2024 18:21:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D29536B00C8; Thu, 22 Feb 2024 18:21:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C30B26B00C1 for ; Thu, 22 Feb 2024 18:21:31 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 91907121026 for ; Thu, 22 Feb 2024 23:21:31 +0000 (UTC) X-FDA: 81821013582.22.4022406 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf02.hostedemail.com (Postfix) with ESMTP id 6B0828000D for ; Thu, 22 Feb 2024 23:21:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=fOFR2rDW; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf02.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708644089; 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=zTKiLE99qoQyKhcmKq/otKW5FYYceuLhD8QduGBLZjM=; b=uR6q3TIhRZGW0zCG0W0uMQ0516HCPlQ6tJieHZ7d2yuD14ibdb9swGuO+/mLO77fVaOCzh JftthFmrgERJJJM+J0u1on0cOod61UvZ+sBAzjlOCh4Zf0mPyEuv7TiFqQS0NVJhdnI+Ff JJJ/tOYmBGgN0HCw0VUZxGjXhXn1B80= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=fOFR2rDW; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf02.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708644089; a=rsa-sha256; cv=none; b=GPmvhZ+U7U08ltg/2BhmSCtQCbilHTB8EKdawNgu/fnEL3bxJPngdUWe2jE+/uT0BD273X hEgQkE7fk9XLGrtW24wGDtMknVL1n+K4m+3DeBLRo8hD3AMMR8JmV8CegcnLzAhvrMdLpy V6VwYA/emWuUsmj056iA2OvMS8sjU0A= Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41MLfk2d024250; Thu, 22 Feb 2024 23:16:31 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=zTKiLE99qoQyKhcmKq/otKW5FYYceuLhD8QduGBLZjM =; b=fOFR2rDWSSrWriwlEV2Og5S38dW0zz5pIta8m/jYNUHxgIZcZQfHJrp2HBU MDVriFOUqEKz4KLM3CGvlHrpGq9D+lulPJ0X5EePnlLSK80OrEJvZqG30y0cTicP T78lGCM9mWtq00Kq96Ljaf35uAknk/odRRfK7diKtFLE0dhb7iuBbW7D9o8m0CId NgkLWyDAv0F7ESFkGxwIs3dLbzYYFFhM1N8GNbHe8w9we3rjlMkEsXVI+ielc4ZG mgAS+at1hVxio9fbXcC+49yIlbVcQi/vxhU6Z+z/a6GR2wdFdfkwsLiyNOPB8WIE 7SOd1/O0O/iwMp9xSb5o62i2cgQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3weedkr5eu-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 NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41MNGUjt025515 (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:29 -0800 From: Elliot Berman Date: Thu, 22 Feb 2024 15:16:28 -0800 Subject: [PATCH v17 05/35] virt: gunyah: Add hypervisor driver MIME-Version: 1.0 Message-ID: <20240222-gunyah-v17-5-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-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-ORIG-GUID: 3-_c8wKoLLhIAOm41mkJiy4fqOWdXiXm X-Proofpoint-GUID: 3-_c8wKoLLhIAOm41mkJiy4fqOWdXiXm 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 impostorscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402220178 X-Rspamd-Queue-Id: 6B0828000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 73chzh53u7z6cqz7bb6udtyak516wzi3 X-HE-Tag: 1708644089-258918 X-HE-Meta: U2FsdGVkX1+HnloAXa1tt/OYQL/2Kha0cWiGZDPUZM0tHQE5DhHtJ4NH4bi6RdtR43PfIstHEqMXHykcUTLB9o7VFPG9/a2dj4XZv1PCVZAVoxt80cv/PanvHoyhwCCaeAtriJw0iihXcpbt8Wy06vj51smXBaFn+yuePrFdUhf7G0j7Sy3IX4+WLRBbXm3+3QbO6RIJ0BuLoeeLYa+YW/r8Dsojj2Ph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Rz/AkGxfsTRbUtAmjrWSbJmDMZiTuE55+MICQ9uX9HS4DSTkyAKHHqJEywO5WLNcW0QL+axwqW806dyqup1jBfH3/vWsgataXF8zF5lJ92BzjEE4T0CZTFVjN25wrRQ== 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 Reviewed-by: Srivatsa Vaddagiri --- 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 f29901bd78205..ef6a3835d078c 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 0000000000000..34f32110faf9a --- /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 0000000000000..ef8a85f275905 --- /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");