Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp98714ybp; Thu, 3 Oct 2019 10:44:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzb1z5f7TUVoHs7e4hjAv5LIcIfjaZ6DXWhvg7+Lta623Nn0ohaOGjoDO2k3iLWhuxtCIa X-Received: by 2002:a17:906:828c:: with SMTP id h12mr8775537ejx.155.1570124641838; Thu, 03 Oct 2019 10:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570124641; cv=none; d=google.com; s=arc-20160816; b=kI/PbnV9FDENlCzzqsWBrf71Z+iM+Co477Z69aSmYLpuY0AxgpPx5/BYa8ru57owuj MyRlaABQZpd2xKMf4j9Hu5czopDDWkEllKpj+GpdXN3ZeWRqtevBCoR7EbrBobCVmek7 Ua8prIMMoRqv1Y2y9/sWcS8CQy0BuX/kb8qcCTU0k+HhrmfGLdIAp1IeAeyR3ESeZei6 74qFsjgN7fypJTiLJur6q4lMu5HPNOEcMMHCV+cJOjcn9n0aF1pfgfOH1+/iDd2S/vVC tvGt6mYlkecTAUlHqWplBBR7GTcqoy/3+pNKd8KZIy37WFM2M0VukqVyhrya9/sLBBY1 Zo+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uhvgi2WEbVJs/ChPhAd2/qiX1wC5FrJhG55t2rSMtJw=; b=ohaKPwSm3ymHvbp7h//cCojouo29p1nKZlJFLzdTVTzpYyOWCj4CT+kqEDCc9/RFZq 70btRF/0RPVTY23qzV+dBW2VFnkWw5dR+A5I593TEbb8u19t85q5HEFqbiX7hA2VJbSM SaIzUzJYWczQrYj/S3QygG7cnD3CcJUbfRrlWBNv3+20+LO31wEQb6MFFQb7GLS9jyrS 6ZN8txnt8nP8xr1XLIxmglaIfZwtur6o2Jss7XRNiMf4zwVOKPsX336cHMuGn6UER1OM jOWkPXteuvThz6tsY916XilOAcaIs4jbnnAbumNZWkOVDvZsFI5YuqV8uwVH4Hu1HUDW xiag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uQdfMJr0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26si1878598edy.108.2019.10.03.10.43.37; Thu, 03 Oct 2019 10:44:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uQdfMJr0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388963AbfJCQQV (ORCPT + 99 others); Thu, 3 Oct 2019 12:16:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:41130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732434AbfJCQQQ (ORCPT ); Thu, 3 Oct 2019 12:16:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D5F802133F; Thu, 3 Oct 2019 16:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119376; bh=E+8DDLBbjMszKWIYzvh2j4yfRBKcj4KQ5wwXpznjhCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQdfMJr0wCK7i5qVaJu8q6Dj5MRrC3Rs5GftIgfdYWkL6bs7I140J9gzrU85kYMme IGIufBi3aldGZAYalOh2pJAYAgOA/X/Tof8sykgWQGBlpwR9d2pt64lVxpbNJqxKil w74OXrj3YwoS1iubOusfkuhtfpdswKscEN6XKklI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 4.19 043/211] x86/apic: Soft disable APIC before initializing it Date: Thu, 3 Oct 2019 17:51:49 +0200 Message-Id: <20191003154457.710618197@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 2640da4cccf5cc613bf26f0998b9e340f4b5f69c ] If the APIC was already enabled on entry of setup_local_APIC() then disabling it soft via the SPIV register makes a lot of sense. That masks all LVT entries and brings it into a well defined state. Otherwise previously enabled LVTs which are not touched in the setup function stay unmasked and might surprise the just booting kernel. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20190722105219.068290579@linutronix.de Signed-off-by: Sasha Levin --- arch/x86/kernel/apic/apic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 9bfbe1fa0339c..dfdd1caf0d55d 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1538,6 +1538,14 @@ static void setup_local_APIC(void) return; } + /* + * If this comes from kexec/kcrash the APIC might be enabled in + * SPIV. Soft disable it before doing further initialization. + */ + value = apic_read(APIC_SPIV); + value &= ~APIC_SPIV_APIC_ENABLED; + apic_write(APIC_SPIV, value); + #ifdef CONFIG_X86_32 /* Pound the ESR really hard over the head with a big hammer - mbligh */ if (lapic_is_integrated() && apic->disable_esr) { -- 2.20.1