From 2330c625c85be0a8ab46a0450a28e92062389286 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: 357781595 Bug: 301483379 Bug: 331152809 Change-Id: Ie56bd26d4575f69cb1f06ba6317a098649f6da44 Reported-by: Mankyum Kim Signed-off-by: Vincent Donnefort --- arch/arm64/kvm/pkvm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c index ab74515ca6fa..062f47b940bc 100644 --- a/arch/arm64/kvm/pkvm.c +++ b/arch/arm64/kvm/pkvm.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -30,6 +31,9 @@ #include +#include +#include + #include "hyp_constants.h" #include "hyp_trace.h" @@ -870,6 +874,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; @@ -901,6 +906,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);