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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6464C32792 for ; Thu, 3 Oct 2019 16:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99B7B20865 for ; Thu, 3 Oct 2019 16:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120968; bh=unuKwpicSk29FKeSUfdYaEpXIULrQ/T9E4PrM81Rjt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zuyypfPMuh6pGe8Oo6+0esXbyUrVQbWTFn+2t1p+VCmZ6Xzv/eR780fS61GZ8armN ipfFk1lRSJFf0aFjLRDE3pPfVX2ZwXRCujsGvH/ayKK+ugTYYd+Vjjb3Q6ss9sFJNP Xdzv6yesR6ZFDCYHsY9Yjmhnk/dZEssyO2HlUkb8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392687AbfJCQmr (ORCPT ); Thu, 3 Oct 2019 12:42:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:53950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391394AbfJCQmq (ORCPT ); Thu, 3 Oct 2019 12:42:46 -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 A68E220867; Thu, 3 Oct 2019 16:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120966; bh=unuKwpicSk29FKeSUfdYaEpXIULrQ/T9E4PrM81Rjt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lidnUEAbg1VW/rDGY1qxx9BtjoBGCgeP+JqIAQ1uFJEilIKMuLroqJwxRgtcufN2f LfF/WkzlXiZAS8mmJ/utbdCGLyhbgAjd3sohqF6T0fz9wBIgkgYSbe2oX9Q6wm7HJE Xd4Ny+Zykg9vNoNzOOrZKXSm5tYePmH61yDfJLJM= 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 5.3 068/344] x86/apic: Soft disable APIC before initializing it Date: Thu, 3 Oct 2019 17:50:33 +0200 Message-Id: <20191003154546.825979984@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154540.062170222@linuxfoundation.org> References: <20191003154540.062170222@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 436d462dde715..ad0d5ced82b30 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1583,6 +1583,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