Re: [PATCH v5 06/13] virt: gunyah: Identify hypervisor version

From: Elliot Berman
Date: Thu Oct 13 2022 - 19:00:25 EST


On 10/10/2022 11:13 PM, Greg Kroah-Hartman wrote:
On Mon, Oct 10, 2022 at 05:08:33PM -0700, Elliot Berman wrote:

EXPORT_SYMBOL_GPL()? I have to ask.

typo only :)


But why is it exported at all? No one is using it in this patch.

It's used later in the series by the message queue driver. The idea here now is that gunyah.ko is capable of identifying Gunyah and other drivers can check if they are individually compatible with the reported version of Gunyah.

From Patch 9:

+static int __init gh_msgq_init(void)
+{
+ if (GH_API_INFO_API_VERSION(gunyah_api.api_info) != GUNYAH_API_V1) {
+ pr_warn("Unrecognized gunyah version: %llu. Currently supported: %d\n",
+ GH_API_INFO_API_VERSION(gunyah_api.api_info), GUNYAH_API_V1);
+ return -ENODEV;
+ }
+
+ return 0;
+}

+
+static int __init gunyah_init(void)
+{
+ u32 uid[4];
+
+ gh_hypercall_get_uid(uid);
+
+ if (!(gh_uid_matches(GUNYAH, uid) || gh_uid_matches(QC_HYP, uid)))
+ return 0;

Why return success if this is not true? Shouldn't you return an error
and fail to load?

That's fair -- easy to fix.

+
+ gh_hypercall_hyp_identify(&gunyah_api);
+
+ pr_info("Running under Gunyah hypervisor %llx/v%lld\n",
+ GH_API_INFO_VARIANT(gunyah_api.api_info),
+ GH_API_INFO_API_VERSION(gunyah_api.api_info));
+
+ return 0;
+}
+arch_initcall(gunyah_init);
+
+static void __exit gunyah_exit(void)
+{
+}
+module_exit(gunyah_exit);

Why do you need a module_exit() call?


I can remove.

+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Gunyah Hypervisor Driver");

What will cause this module to be properly automatically loaded? I do
not see that happening here at all.

diff --git a/include/asm-generic/gunyah.h b/include/asm-generic/gunyah.h
index 86eb59e203ef..8f9d4c649ba8 100644
--- a/include/asm-generic/gunyah.h
+++ b/include/asm-generic/gunyah.h
@@ -85,6 +85,8 @@ static inline int gh_remap_error(int gh_error)
((uid)[0] == prefix ## _UID0 && (uid)[1] == prefix ## _UID1 && \
(uid)[2] == prefix ## _UID2 && (uid)[3] == prefix ## _UID3)
+#define GUNYAH_API_V1 1

You do not use this define anywhere in this patch.


+
#define GH_API_INFO_API_VERSION(x) (((x) >> 0) & 0x3fff)
#define GH_API_INFO_BIG_ENDIAN(x) (((x) >> 14) & 1)
#define GH_API_INFO_IS_64BIT(x) (((x) >> 15) & 1)
@@ -103,6 +105,7 @@ struct gh_hypercall_hyp_identify_resp {
u64 api_info;
u64 flags[3];
};
+extern struct gh_hypercall_hyp_identify_resp gunyah_api;

Again, not used.

thanks,

greg k-h