Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp570141ybn; Thu, 3 Oct 2019 09:01:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh7XP0e1Hxp5EqmpnwVEcv/4OKJg72HLI3STwFuL2dzZuhA+F1wxuV+k6VFsuqEgA/PdHU X-Received: by 2002:ac2:4a8f:: with SMTP id l15mr6295243lfp.21.1570118490346; Thu, 03 Oct 2019 09:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570118490; cv=none; d=google.com; s=arc-20160816; b=R0tZSDhzxu34fjg6gD82vKMYEQjt0tN+m/y/XdT1Obr79uh9wCZUcfaPqgUHza+ZcQ 6exf8FAfyWV0trmPvOt4lXLfq/OdrJnSVn8I4he2/XpSTxp/pnCbRPkrNqK+NNNSWBVR sqy00AVsfgbhIEg6RlOjgRO0zsxiAgW0CW6PPxnP1pYzcaadZ9YrTLrevykpzOuMxEXm smfFaFaFrOvMzWASuCWaqeSAQWuoI7cxxrsMEGkJjckDvPozOPowkcPqJKQNj4RYFG98 2LStxBCZBSQIbAE5j7JZ8y3+jwCasQTK65zAciOzqi5JngFsL+NO8KvtFye8VZ7qg1QM 1UAA== 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=Bb8bnTWg555RCoM3B5jHrHEdwaBH5FH1Gb8HGQo7TMc=; b=osGNPtpj7VRSSH3jWQwVAGUzjIvUlKHEoeTBzK0MPY2ZhZy/Mi0jtgvPpUnLJEoRYx k5kbBtT0wYkJITmdUb47N0bMY4bvRZmK7zvPGONUe3vqzgZzH7TU3LwotI5XSQBsX/qa Hg3cvxydbJ9IYBpxr8jA9foiM9kAqoicGPgMnPmnxSh78l6FToqFf9WfdclGTTXdZb8b j7XboZMdHwOfGJGJ5cpv7ZN/lpe0T6W35AoiGPa3/lV1FKfhmfrUNxbt76BnvVKAPYez T5qge1aToJqI4ZzEN3y5j3yPexax6Xvr2539qVC7ejxMb/l5lDD2b5qxJqpmMJHZJbDm b11Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T7Fve3Bc; 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 ox10si1490337ejb.325.2019.10.03.09.01.04; Thu, 03 Oct 2019 09:01:30 -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=T7Fve3Bc; 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 S1729466AbfJCP5v (ORCPT + 99 others); Thu, 3 Oct 2019 11:57:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:40352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731022AbfJCP5q (ORCPT ); Thu, 3 Oct 2019 11:57: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 7D41E207FF; Thu, 3 Oct 2019 15:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118265; bh=Djd92TOnQuQnGWGjj7N+dlsVbu2NxvIUCPumOuYgz60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T7Fve3Bce2pPQJ9KnPjniN5OJgAc7BvsE/szo6aVoIapCDb6srdUJjgmuIdBPsoZZ tFIZKX9YA9L11HKXDJUWu+EcVAPYal4G4pWDUsbv56hb+Pumy5yKuEudBnhnUv8+ND sLhNKHU/iwZ6zowoTl2vfJy+zx8tyHbsoHZUvM8U= 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.4 42/99] x86/apic: Soft disable APIC before initializing it Date: Thu, 3 Oct 2019 17:53:05 +0200 Message-Id: <20191003154315.854324312@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154252.297991283@linuxfoundation.org> References: <20191003154252.297991283@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 834d1b5b43557..be3d4dcf3a10a 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1265,6 +1265,14 @@ 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