From 6364d594125d5489b4f160c055505ec08c68c4eb Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Thu, 4 Apr 2024 09:51:05 +0100 Subject: [PATCH] ANDROID: KVM: arm64: wait_for_initramfs for pKVM module loading procfs Of course, the initramfs needs to be ready before procfs can be mounted... in the initramfs. While at it, only mount if a pKVM module must be loaded and only print a warning in case of failure. Bug: 278749606 Bug: 301483379 Bug: 331152809 Change-Id: Ie56bd26d4575f69cb1f06ba6317a098649f6da44 Reported-by: Mankyum Kim Signed-off-by: Vincent Donnefort (cherry picked from commit 7d5843b59548672c23c977b4666c3779d31695fb) --- arch/arm64/kvm/pkvm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c index 10b899483d43..08ce8d77fe3d 100644 --- a/arch/arm64/kvm/pkvm.c +++ b/arch/arm64/kvm/pkvm.c @@ -4,6 +4,8 @@ * Author: Quentin Perret */ +#include +#include #include #include #include @@ -627,6 +629,7 @@ static int __init __pkvm_request_early_module(char *module_name, "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; + static bool proc; char **argv; int idx = 0; @@ -658,6 +661,15 @@ static int __init __pkvm_request_early_module(char *module_name, /* Even with CONFIG_STATIC_USERMODEHELPER we really want this path */ info->path = modprobe_path; + if (!proc) { + wait_for_initramfs(); + if (init_mount("proc", "/proc", "proc", + MS_SILENT | MS_NOEXEC | MS_NOSUID, NULL)) + pr_warn("Couldn't mount /proc, pKVM module parameters will be ignored\n"); + + proc = true; + } + return call_usermodehelper_exec(info, UMH_WAIT_PROC | UMH_KILLABLE); err: kfree(argv); @@ -686,11 +698,7 @@ int __init pkvm_load_early_modules(void) { char *token, *buf = early_pkvm_modules; char *module_path = CONFIG_PKVM_MODULE_PATH; - int err = init_mount("proc", "/proc", "proc", - MS_SILENT | MS_NOEXEC | MS_NOSUID, NULL); - - if (err) - return err; + int err; while (true) { token = strsep(&buf, ",");