BACKPORT: FROMLIST: virt: gunyah: Add hypervisor driver
Add driver to detect when running under Gunyah. It performs basic identification hypercall and populates the platform bus for resource manager to probe. Bug: 338347082 Link: https://lore.kernel.org/all/20240222-gunyah-v17-5-1e9da6763d38@quicinc.com/ Change-Id: Ie18fa6bf01f0d9b66c0e657abf8581d9ef186056 Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> Signed-off-by: Sreenad Menon <quic_sreemeno@quicinc.com> [Elliot: resolve trivial conflicts in drivers/virt/Makefile] Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
This commit is contained in:
committed by
Treehugger Robot
parent
0088b8fd93
commit
1b2c6fdb1d
@@ -10,3 +10,4 @@ obj-y += vboxguest/
|
||||
obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
|
||||
obj-$(CONFIG_ACRN_HSM) += acrn/
|
||||
obj-y += coco/
|
||||
obj-y += gunyah/
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
obj-$(CONFIG_GUNYAH) += gunyah.o
|
||||
@@ -0,0 +1,52 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/gunyah.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
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");
|
||||
Reference in New Issue
Block a user