ANDROID: KVM: arm64: Add a fallback for pKVM module loading

Fallback to the default module path (/lib/modules/<uname>) 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 <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2023-04-11 14:38:38 +01:00
committed by Greg Kroah-Hartman
parent c8e53ed372
commit ba57835693

View File

@@ -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;