From: Wanpeng Li <wanpengli@tencent.com>
Date: Tue, 22 Feb 2022 01:02:03 -0800
Patch-mainline: v5.17-rc7
Subject: x86/kvm: Don't waste memory if kvmclock is disabled
Git-commit: 3c51d0a6c761c2025c6db1ed4d3a7273167bf899
References: bsc#1183682
Even if "no-kvmclock" is passed in cmdline parameter, the guest kernel
still allocates hvclock_mem which is scaled by the number of vCPUs,
let's check kvmclock enable in advance to avoid this memory waste.
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Message-Id: <1645520523-30814-1-git-send-email-wanpengli@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Olaf Hering <ohering@suse.de>
---
arch/x86/kernel/kvmclock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -239,6 +239,9 @@ static void __init kvmclock_init_mem(void)
static int __init kvm_setup_vsyscall_timeinfo(void)
{
+ if (!kvmclock)
+ return 0;
+
kvmclock_init_mem();
#ifdef CONFIG_X86_64