ANDROID: KVM: arm64: Redirect modprobe to /dev/kmsg

When using early loading for pKVM modules, redirect modprobe
stdout/stderr to /dev/kmsg to get logs. This is handy in case of
failure.

Bug: 357781595
Bug: 254835242
Bug: 415374827
Change-Id: I9d435071f5ec7b47a702ce5e9802b882a4ea9cb4
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2025-05-08 15:52:11 +01:00
committed by Treehugger Robot
parent 078ef75fa4
commit a8027abd1e

View File

@@ -927,11 +927,28 @@ static int __init early_pkvm_modules_cfg(char *arg)
}
early_param("kvm-arm.protected_modules", early_pkvm_modules_cfg);
static void free_modprobe_argv(struct subprocess_info *info)
static void __init free_modprobe_argv(struct subprocess_info *info)
{
kfree(info->argv);
}
static int __init init_modprobe(struct subprocess_info *info, struct cred *new)
{
struct file *file = filp_open("/dev/kmsg", O_RDWR, 0);
if (IS_ERR(file)) {
pr_warn("Warning: unable to open /dev/kmsg, modprobe will be silent.\n");
return 0;
}
init_dup(file);
init_dup(file);
init_dup(file);
fput(file);
return 0;
}
/*
* Heavily inspired by request_module(). The latest couldn't be reused though as
* the feature can be disabled depending on umh configuration. Here some
@@ -974,7 +991,7 @@ static int __init __pkvm_request_early_module(char *module_name,
argv[idx++] = NULL;
info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
NULL, free_modprobe_argv, NULL);
init_modprobe, free_modprobe_argv, NULL);
if (!info)
goto err;