From ba5783569305f4ef5a7a670896f99f04dc4ef5b7 Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Tue, 11 Apr 2023 14:38:38 +0100 Subject: [PATCH] ANDROID: KVM: arm64: Add a fallback for pKVM module loading Fallback to the default module path (/lib/modules/) if module loading failed for the selected path in CONFIG_PKVM_MODULE_PATH. This intends to follow the same mechanism as Android init. Bug: 254835242 Change-Id: Ia7764d57fe71521e4a1fe6d2c85ba057790069a8 Signed-off-by: Vincent Donnefort --- arch/arm64/kvm/pkvm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c index aa240bae0f51..a51725ab1861 100644 --- a/arch/arm64/kvm/pkvm.c +++ b/arch/arm64/kvm/pkvm.c @@ -615,7 +615,8 @@ static void free_modprobe_argv(struct subprocess_info *info) * security is enforced by making sure this can be called only when pKVM is * enabled, not yet completely initialized. */ -static int __init pkvm_request_early_module(char *module_name, char *module_path) +static int __init __pkvm_request_early_module(char *module_name, + char *module_path) { char *modprobe_path = CONFIG_MODPROBE_PATH; struct subprocess_info *info; @@ -663,6 +664,23 @@ err: return -ENOMEM; } +static int __init pkvm_request_early_module(char *module_name, char *module_path) +{ + int err = __pkvm_request_early_module(module_name, module_path); + + if (!err) + return 0; + + /* Already tried the default path */ + if (*module_path == '\0') + return err; + + pr_info("loading %s from %s failed, fallback to the default path\n", + module_name, module_path); + + return __pkvm_request_early_module(module_name, ""); +} + int __init pkvm_load_early_modules(void) { char *token, *buf = early_pkvm_modules;