Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1025143ybe; Wed, 4 Sep 2019 11:19:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEP9LMcldA2hi5yZNdL89N9wrCScBNYpcqp2m3/QY4nyiIlA9NX5hTY3P3bOIhIBRkRBUf X-Received: by 2002:a63:c107:: with SMTP id w7mr23107457pgf.283.1567621181044; Wed, 04 Sep 2019 11:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621181; cv=none; d=google.com; s=arc-20160816; b=lf/m9C2GlWyOUOcpR6G5u4awmp5XEM7bBhx8ZKmrAn9RigD2/JoPc3CwwNz5wsjF+G x3Po4xCf6gt026UlOrrvBQx0JILpWjXR40dn25CzRvyN4g61rurIxqqv2fXPB6582xpV CDkvm4GhQn93eHDJqEGEprCXXdB1IPBHSej6MOi7Pz3QyrAqnwPYgV6Wmx+o6UrqWFVY pfAlxzF+VOI/OCe0eHJYGKbTmaSAXimXipgPvOX7R7RJZANOx88ftfaySs7/J1BgTkcj vLvCb9gNEbTr6EwzBkWm5ZKsIojkJHmJiGZ1wbXjXF7htKZj/J+sEbJ+r5hT/VC0JQHF EZyw== 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=TDevZx1X+9BaoOQ6BaKdbjCu8028KYd5av3bYyhPRoo=; b=S6ekpPJ/1WYCZBxEM/2GANIBIxa3fUenz54aS6Cq2lb9j8cULyA62ZYQz/Cm0gOzJQ YRKpYoWWwsGaQGq4njhzZGpaijJS2NlL8DqOSszDIJyGU9Phsw9UgKQrEvZ1G1hkquXF jODukEZjvU5PQihrWbJEIcjIkRHh5aalu/PjmAMe/mvR/rgnCEbmlivgiesyhcyCcAg0 mS/KR0zjlgQtS2RIAA1csNgm4gdr5OUTQym70HrZ1CgXlfkdJGT/m8EYMHgfROgxWTOZ otjiVL5GYDQOQwAULytRjyRcXyJYGpJFX6RgxXEp1ZJ17YD1hucBrQjaiWkwloDFrjXo qkFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KntBZLug; 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 z27si14133734pfk.81.2019.09.04.11.19.25; Wed, 04 Sep 2019 11:19:41 -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=KntBZLug; 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 S2389634AbfIDSRx (ORCPT + 99 others); Wed, 4 Sep 2019 14:17:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389848AbfIDSMG (ORCPT ); Wed, 4 Sep 2019 14:12:06 -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 986142339E; Wed, 4 Sep 2019 18:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620726; bh=LUeoebDSkEmkqPZKQIgyABnmVp4brEV6jnYkhq/O4BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KntBZLugfoTdxV59w8na1C7LmiuqJ/BZR91nhO8ZseKUELnQ0yoFyZ+2u5vCYmzEu YNOHiqUjz8XTO33aWbRE8TVZXz19FQ9ugnoum7aYDxbcvyJC+DITkwJV918zOUqwS/ 1Mg8CF51WaXvBS01+rOOiDqHKp6RyiX6VtnqRr7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bandan Das , Thomas Gleixner Subject: [PATCH 5.2 073/143] x86/apic: Include the LDR when clearing out APIC registers Date: Wed, 4 Sep 2019 19:53:36 +0200 Message-Id: <20190904175316.912884373@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@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: Bandan Das commit 558682b5291937a70748d36fd9ba757fb25b99ae upstream. Although APIC initialization will typically clear out the LDR before setting it, the APIC cleanup code should reset the LDR. This was discovered with a 32-bit KVM guest jumping into a kdump kernel. The stale bits in the LDR triggered a bug in the KVM APIC implementation which caused the destination mapping for VCPUs to be corrupted. Note that this isn't intended to paper over the KVM APIC bug. The kernel has to clear the LDR when resetting the APIC registers except when X2APIC is enabled. This lacks a Fixes tag because missing to clear LDR goes way back into pre git history. [ tglx: Made x2apic_enabled a function call as required ] Signed-off-by: Bandan Das Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20190826101513.5080-3-bsd@redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/apic/apic.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1152,6 +1152,10 @@ void clear_local_APIC(void) apic_write(APIC_LVT0, v | APIC_LVT_MASKED); v = apic_read(APIC_LVT1); apic_write(APIC_LVT1, v | APIC_LVT_MASKED); + if (!x2apic_enabled()) { + v = apic_read(APIC_LDR) & ~APIC_LDR_MASK; + apic_write(APIC_LDR, v); + } if (maxlvt >= 4) { v = apic_read(APIC_LVTPC); apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);