mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zelin Deng <zelin.deng@linux.alibaba.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Brijesh Singh <brijesh.singh@amd.com>,
	Artie Ding <artie.ding@linux.alibaba.com>,
	Caspar Zhang <caspar@linux.alibaba.com>,
	Zelin Deng <zelin.deng@linux.alibaba.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: x86: kvmclock_init_mem() should be called any way
Date: Mon, 17 Aug 2020 13:57:39 +0800	[thread overview]
Message-ID: <20200817055739.9994-1-zelin.deng@linux.alibaba.com> (raw)

pvclock data pointers of vCPUs >= HVC_BOOT_ARRAY_SIZE (64) are stored in
hvclock_mem wihch is initialized in kvmclock_init_mem().
Here're 3 scenarios in current implementation:
    - no-kvmclock is set in cmdline. kvm pv clock driver is disabled,
      no impact.
    - no-kvmclock-vsyscall is set in cmdline. kvmclock_init_mem() won't
      be called. No memory for storing pvclock data of vCPUs >= 64, vCPUs
      >= 64 can not be online or hotpluged.
    - tsc unstable. kvmclock_init_mem() won't be called. vCPUs >= 64 can
      not be online or hotpluged.
It's not reasonable that vCPUs hotplug have been impacted by last 2
scenarios. Hence move kvmclock_init_mem() to front, in case hvclock_mem
can not be initialized unexpectedly.

Fixes: 6a1cac56f41f9 (x86/kvm: Use __bss_decrypted attribute in shared variables)
Signed-off-by: Zelin Deng <zelin.deng@linux.alibaba.com>
---
 arch/x86/kernel/kvmclock.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 34b18f6eeb2c..1abbda25e037 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -271,7 +271,14 @@ static int __init kvm_setup_vsyscall_timeinfo(void)
 {
 #ifdef CONFIG_X86_64
 	u8 flags;
+#endif
+
+	if (!kvmclock)
+		return 0;
+
+	kvmclock_init_mem();
 
+#ifdef CONFIG_X86_64
 	if (!per_cpu(hv_clock_per_cpu, 0) || !kvmclock_vsyscall)
 		return 0;
 
@@ -282,8 +289,6 @@ static int __init kvm_setup_vsyscall_timeinfo(void)
 	kvm_clock.vdso_clock_mode = VDSO_CLOCKMODE_PVCLOCK;
 #endif
 
-	kvmclock_init_mem();
-
 	return 0;
 }
 early_initcall(kvm_setup_vsyscall_timeinfo);
-- 
2.20.1


                 reply	other threads:[~2020-08-17  5:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200817055739.9994-1-zelin.deng@linux.alibaba.com \
    --to=zelin.deng@linux.alibaba.com \
    --cc=artie.ding@linux.alibaba.com \
    --cc=brijesh.singh@amd.com \
    --cc=caspar@linux.alibaba.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®