From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4133E9370D for ; Thu, 5 Oct 2023 13:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sG38+4yjxIfnhovULa1SKgzJ7ypdLrUIsMg+c95+GSI=; b=wyML3kNKap38XY APq2Zvo7upki8Wo/65y/5zKlgoVgqoo3hoUbEyjX4eOdwUW0kHqvJUaO3TvKnOFfF9UMaVu3JL7sw txnAb5/VBYiiKg0cuL3rqmCReX0zZ1Rn/Pq8YY3U6P7VJbKp5DlVzkBFLzPUBcr7+YIYZvZ5cnf5U egSxOR43/DQOzn0QPJJ6piIvDXzzOk78/VNzJhLgl9QdhFB58TeQGVHrRJp3htPDfZD5AA0dW7CHA mzv5V1EF2FObIHMWicOuuO0rC4Vt0D+a3PC9QEm9BKwOk/hzJaUAfMJTjRHDnpOKBsiYmuZqsk7Ez v/bZNQuhN/0vYu2SjfPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoODp-003GwD-19; Thu, 05 Oct 2023 13:16:57 +0000 Received: from mgamail.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoODj-003GlX-1S for kexec@lists.infradead.org; Thu, 05 Oct 2023 13:16:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696511811; x=1728047811; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6jCOPtPHdWrnAAWeulGySr3RPESjo4P/hViU3qiYp2Q=; b=kMsZJqQCZK54SOOaRZHkO9O8H3Y5OwPfPx/zR1Rb0Uft+ScslcQadHB+ 1tnyGgFaPwIQTBqgOUXZ2ClSJS/3LmObY2Q3KtKSI2sh7ZZVrMJ3cdmJ+ L0PN8WMMDmc+X4miUwbhiAi+azawTNcJuv/z3bf7QYO2i2cL5ZXyja0Iz OixHpb/CwkgU0BQ9UeYQYbmHtlVwLxKCidAZfc/+bE9PyXi3CH0IMqCba t5zX3A4eHWBPSC1gmhRqxhOXar/rw/twAWnlR46RvrNDx2PDCitptl9jn SFAStK4v/2eFPGEBz64EXmZiiG0Tx0UIIIlh5Fs5zeMsGux7t5kYxIOA3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="382357446" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="382357446" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="817564301" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="817564301" Received: from skwasnia-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.222.71]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:16 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 35E2A10A14C; Thu, 5 Oct 2023 16:14:14 +0300 (+03) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 04/13] x86/kvm: Do not try to disable kvmclock if it was not enabled Date: Thu, 5 Oct 2023 16:13:53 +0300 Message-ID: <20231005131402.14611-5-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231005_061651_663124_F63D908B X-CRM114-Status: GOOD ( 14.02 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org kvm_guest_cpu_offline() tries to disable kvmclock regardless if it is present in the VM. It leads to write to a MSR that doesn't exist on some configurations, namely in TDX guest: unchecked MSR access error: WRMSR to 0x12 (tried to write 0x0000000000000000) at rIP: 0xffffffff8110687c (kvmclock_disable+0x1c/0x30) kvmclock enabling is gated by CLOCKSOURCE and CLOCKSOURCE2 KVM paravirt features. Do not disable kvmclock if it was not enumerated or disabled by user from kernel command line. Signed-off-by: Kirill A. Shutemov Fixes: c02027b5742b ("x86/kvm: Disable kvmclock on all CPUs on shutdown") --- 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 fb8f52149be9..cba2e732e53f 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -22,7 +22,7 @@ #include #include -static int kvmclock __initdata = 1; +static int kvmclock __ro_after_init = 1; static int kvmclock_vsyscall __initdata = 1; static int msr_kvm_system_time __ro_after_init = MSR_KVM_SYSTEM_TIME; static int msr_kvm_wall_clock __ro_after_init = MSR_KVM_WALL_CLOCK; @@ -195,7 +195,12 @@ static void kvm_setup_secondary_clock(void) void kvmclock_disable(void) { - native_write_msr(msr_kvm_system_time, 0, 0); + if (!kvm_para_available() || !kvmclock) + return; + + if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE) || + kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE2)) + native_write_msr(msr_kvm_system_time, 0, 0); } static void __init kvmclock_init_mem(void) -- 2.41.0 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec