Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4023704ybl; Mon, 26 Aug 2019 04:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzE+pDm0Kxw45bESV5uarPuBVdLyUgUJopDU/J1qvr4L8dKF1qO/3AGULMSgKMP8XZO3FKp X-Received: by 2002:a63:20d:: with SMTP id 13mr16246144pgc.253.1566818640701; Mon, 26 Aug 2019 04:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566818640; cv=none; d=google.com; s=arc-20160816; b=vBQlffbYcCzI4kmHsl3AAXaBQFpgj0NgSQGBBpJnqQ/8+4SkJ+B02WDfq7aek98vFs 4+bvrDBGdFuVXmUVzbpDfktSaEx2aD/d/RE4LSQqrZGYGgLFzwUXM6ywV1Q51pJleLk0 vTBDvKtKQLiOKSRLUJogcO1D7ia7dzebZbnhYTAK3SiKW4yBtU4oPPeKrRnnPjlcQmso TxLXwPBu0zUVkKjQTttOlYJULVZJY9sXCJrgoed7vSO/WqDpSbd82U6XoapacuyrtU42 DgDOAcWgKiL7voKNgRRScbwzrRZS3n5U1VT25y3rbYMGzK+HENncghcPE+V6SNheh6f5 71/g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Az8KMNfgxC3uvPYrjhVRpHPPZEVBW18er2RriilAHOI=; b=iUZyB0RDWM1pCKPVTzf3ZJwc0doppAaQLRI6RL8FfFXSlLk53TP3UzDNKcxRnCbA9u Bi8MOoIjwQxGmVkPiSoaCVeY7bif5hyMFHoUpd2RV3jjW9iEW0bM5SwD/oKOD7FgCC2o oIO4CM9KvtquGmwxiZzZJ/8rj7AajUI4Koxw1bGlEFBTUZYxyZbfbyC2v1gwjcqzN162 eckuej5W6V11FBSybhvPtrV4ATM2UnVptVpLGyyB5f7KKVsS6B3iCTHVu/1dk8x7iKCA IZLW4PKupLyCaGGsem5qcy8PojYAB4CzeHXKibBYyynxeyjp0hmyjADQmi3Pv2O+M66x 8DIQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si8693091pgp.250.2019.08.26.04.23.44; Mon, 26 Aug 2019 04:24:00 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730856AbfHZKPz (ORCPT + 99 others); Mon, 26 Aug 2019 06:15:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39876 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbfHZKPv (ORCPT ); Mon, 26 Aug 2019 06:15:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C4EA30821AE; Mon, 26 Aug 2019 10:15:51 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA630608C1; Mon, 26 Aug 2019 10:15:50 +0000 (UTC) From: Bandan Das To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] x86/apic: include the LDR when clearing out apic registers Date: Mon, 26 Aug 2019 06:15:13 -0400 Message-Id: <20190826101513.5080-3-bsd@redhat.com> In-Reply-To: <20190826101513.5080-1-bsd@redhat.com> References: <20190826101513.5080-1-bsd@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 26 Aug 2019 10:15:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 loading the kdump kernel. Stale bits in the LDR exposed a bug in the kvm lapic code that creates logical destination maps for vcpus. If multiple bits are set, kvm could potentially overwrite a valid logical destination with an invalid one. Note that this fix isn't intended to paper over the kvm lapic bug; clear_local_APIC() should correctly clear out any set bits in the LDR when resetting apic registers. Signed-off-by: Bandan Das --- arch/x86/kernel/apic/apic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index aa5495d0f478..e75f3782b915 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1179,6 +1179,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); -- 2.20.1