Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3982266ybl; Mon, 26 Aug 2019 03:41:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4E1b684RYwOPdZtSi4ccWpKxUMRzvoLiFKmRqrYMnQSrWb8I6iwyRXMNQ4FojJB2oc4iV X-Received: by 2002:a65:4243:: with SMTP id d3mr5846046pgq.119.1566816112274; Mon, 26 Aug 2019 03:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566816112; cv=none; d=google.com; s=arc-20160816; b=bdXLhW2i5D34m3g04r00FdzLpL+X2bWZJcl4OENYjRUm+GVq0iC2YvVxkX4GwH5Ur7 YDUITGYD9OIdv2NHmbIsYKmcNzVzp//tF94p+2+Lzuq0yLif8XdRR38RVIrUc2+Yz8JB u7tVqhxFQQCfrfnxdhn6kfbVgGbO2yqFbWu3+t3QLVqZcyGooYlx0KezO+0BjIZYLl9m npAQ/ctnjdPNxBMJODNfdr/DkDjJ54Ltx+avD57RV2gipt9iIDJsx82y5xEvsixuib76 0ne+xvvegAMZRFU/tvf1+QVtToUcXowgNReMHDqXBgEg8YHsmf/FYsVsKhkpUJ42kdnv s7+Q== 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=fUn15xUproUdfXHtDbO3dCkhxdn+z0pKLXUSqWaQS9A=; b=0ux7Fj3e5wYccMyJx9Hgy4lDzmED+yqrMfa29VR1zy0B7O+Ptz5KSLVXUuuz5ri/hZ XgG0IEPX1vF80YOpjSLYVAPHFuFUmxeXT+C2s4U6ZcCZ+ps2DmLMYhLsTZU/rc4X7846 bJa27mfdRBn0mFePgZ9AvEF6xqZmxuzhLqEkdsC+Sfdeu+YeZkJsbYigNliHXp34g6kt k7Qln1cZTJLtj7o0dzgcJ2/HV5ryLUUWFcEGJcIVUIupDWuMdnK+tHsjXpSNgNfrRQzr 7pYh7ME01BwnETwSnrDXXDgBjdMrRh+vM0zr+HrvVP/0xJNk+fiyNTjElU9wX1WBoYFy Ov9g== 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 x6si9031749plm.396.2019.08.26.03.41.37; Mon, 26 Aug 2019 03:41:52 -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 S1730815AbfHZKPy (ORCPT + 99 others); Mon, 26 Aug 2019 06:15:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730790AbfHZKPu (ORCPT ); Mon, 26 Aug 2019 06:15:50 -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 88ACA883C2; Mon, 26 Aug 2019 10:15:50 +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 EAFED60920; Mon, 26 Aug 2019 10:15:49 +0000 (UTC) From: Bandan Das To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] x86/apic: Do not initialize LDR and DFR for bigsmp Date: Mon, 26 Aug 2019 06:15:12 -0400 Message-Id: <20190826101513.5080-2-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.26]); Mon, 26 Aug 2019 10:15:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Legacy apic init uses bigsmp for > 8 smp systems. In these cases, PhysFlat will invariably be used and there is no point in initializing apic LDR and DFR. Furthermore, calculate_ldr() helper function was incorrectly setting multiple bits in the LDR. This was discovered with a 32 bit KVM guest loading the kdump kernel. Owing to the multiple bits being incorrectly set in the LDR, KVM hit a buggy "if" condition in the kvm lapic implementation that creates the logical destination map for vcpus - it ends up overwriting and existing valid entry and as a result, apic calibration hangs in the guest during kdump initialization. Note that this change isn't intended to workaround the kvm lapic bug; bigsmp should correctly stay away from initializing LDR. Suggested-by: Thomas Gleixner Signed-off-by: Bandan Das --- arch/x86/kernel/apic/bigsmp_32.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c index afee386ff711..caedd8d60d36 100644 --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -38,32 +38,12 @@ static int bigsmp_early_logical_apicid(int cpu) return early_per_cpu(x86_cpu_to_apicid, cpu); } -static inline unsigned long calculate_ldr(int cpu) -{ - unsigned long val, id; - - val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; - id = per_cpu(x86_bios_cpu_apicid, cpu); - val |= SET_APIC_LOGICAL_ID(id); - - return val; -} - /* - * Set up the logical destination ID. - * - * Intel recommends to set DFR, LDR and TPR before enabling - * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel - * document number 292116). So here it goes... + * bigsmp enables physical destination mode + * and doesn't use LDR and DFR */ static void bigsmp_init_apic_ldr(void) { - unsigned long val; - int cpu = smp_processor_id(); - - apic_write(APIC_DFR, APIC_DFR_FLAT); - val = calculate_ldr(cpu); - apic_write(APIC_LDR, val); } static void bigsmp_setup_apic_routing(void) -- 2.20.1