Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp650086rdb; Thu, 22 Feb 2024 15:24:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvu0I1dsA+SA/TeH9Rn+0MZhH8ryHuWvkBumF8CogR+NLRjyB0EYCv9fR3oH09n4IBvMiuQI7vzJYYWlxjhXvnqG46tM8ROTDSEArs+A== X-Google-Smtp-Source: AGHT+IG+Hoq1CBh1NU175LU4Rz7os0bjId7zF9CCXOpwGRd1MgX8QwPXjeYGz7DWPCTyQhXRmpga X-Received: by 2002:a05:6a21:3102:b0:19e:a873:9253 with SMTP id yz2-20020a056a21310200b0019ea8739253mr420561pzb.10.1708644261121; Thu, 22 Feb 2024 15:24:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708644261; cv=pass; d=google.com; s=arc-20160816; b=gNUH4D7WVpY0ua/zRusYnmyj3oGLvXCIj4QN//ce/57mNYRBk86reHbgpoK1y7x8yJ H4dyKXE/AbnwDgYVnO7ANfsOqqxeLrfByS0j0fPP8BLFIb4v1WttVRbAfHSfnB/LNM9W B4YeES0ovIHV19rwQlD+majIr2CBv2+AQSHsEwH+CQJBfO3wHMngTQUuWnGX44BJi5d7 +s39ZqkjNepOnVwJFuxtvevyHzqUfwBCXypo8mMnh77tkszlx2eUdDUc3r07cp9ytW7t uoioZqksIbD4fbeuwHwvWSDLcU1mt1xNuDxigaYfuJOFTNpJrdidG/ytkG8q9q6NY1lg u/cA== 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=zTKiLE99qoQyKhcmKq/otKW5FYYceuLhD8QduGBLZjM=; fh=j53ffieBeHmuArQHAkiXDczYOIriM+Jf92hqYE3BW8U=; b=cyzWiOv0ZQ+eEB1oZ4y+vWJWIwfXOq+pxW4yTACUI1PR8mChZv+JP8ASpdOADPgCv2 wI+oDYBchKZrykHoeE310cpyweTL3QYAKzYfK4SAe9mb/eZtXkwc21FoPs7KCOXsHBfw x7TKgQ7urV1pWBnL+ri4OV4OiHIJ0Hw7vLlPRQBIb+yjQrqjfHEbb1vt5PA3T1hqgHx8 tY0jG3E8eKX2Z7i4MMblTW3oR5645JDEoOxeLoHUaUle3gCmQ4UfKoK0Z6gRwcebFg2z dVlBKXdBHldhAUaeWWylLvsYtvrsticvOuUH/b6UarCkUuR0FNnl02RsRdAYP2kjnngW Ry9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=fOFR2rDW; 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-77521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id om11-20020a17090b3a8b00b00299d91bdeecsi69178pjb.46.2024.02.22.15.24.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:24:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=fOFR2rDW; 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-77521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77521-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C8B1D287CED for ; Thu, 22 Feb 2024 23:24:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC58C156962; Thu, 22 Feb 2024 23:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="fOFR2rDW" 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 F008114F974; Thu, 22 Feb 2024 23:17:21 +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=1708643843; cv=none; b=ifF7zFeKZ1NIW8s256cJMwpxhYqCEPXuDq7OXv7S2aD6UzgZ7v+0OqhcLKaT0DMS6qRD7s9euqTMaaZMv/qf8xet2RshPKBfxqMxq/Z0yjqXnymvVUiTpfq9i7zihlvjiJOnsjDFKx7E0wijxg1DzCQdG7ES8GmSy8v4DEh1FDY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708643843; c=relaxed/simple; bh=lgxLux/miHdvn/sxNBqmTAmiPacO0LZX2rhzZVRBY08=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=F2MsL3Ubz+lYnpEZDeesK81cm91vnlNcfAf9057mDc9u0XFrfaNx/9r5Gq7uqJhB8zQkB0e83YOvw5iX6pI7XPNQxAqjLKYzUUn9jBqj67p24IB5MzJaA1R5yOXV3JyUE1fxyyGuxfnx6uU+iVWbmqZ8cvc5VgMn3qSif8dJwQ8= 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=fOFR2rDW; 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 (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 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-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-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 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 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"); -- 2.34.1