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 <mankyum.kim@samsung-slsi.corp-partner.google.com>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
(cherry picked from commit 7d5843b59548672c23c977b4666c3779d31695fb)
This commit is contained in:
Vincent Donnefort 2024-04-04 09:51:05 +01:00 committed by Treehugger Robot
parent 4744b3a4ed
commit 6364d59412

View File

@ -4,6 +4,8 @@
* Author: Quentin Perret <qperret@google.com>
*/
#include <linux/init.h>
#include <linux/initrd.h>
#include <linux/io.h>
#include <linux/kmemleak.h>
#include <linux/kvm_host.h>
@ -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, ",");