From patchwork Sat Dec 16 12:58:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 179845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp202884dyi; Sat, 16 Dec 2023 04:59:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqH6jxBzp7W/d2gGvqpl+6SsOFS9ctpLo4nBv+ta6Eej6CfbbMerB4Gwwgka48rlnlWeAO X-Received: by 2002:a0c:fd24:0:b0:67a:c1cc:107b with SMTP id i4-20020a0cfd24000000b0067ac1cc107bmr17281763qvs.19.1702731587197; Sat, 16 Dec 2023 04:59:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702731587; cv=none; d=google.com; s=arc-20160816; b=cVRfkDQjpApFPbGKyCpgST+wLyyiM3rQTttZPMzKfSFKYTu9FUDz7k9WTezRrYoy6T PzfNu/rNklG2KBMqIv/9YWB9HwemTurCxZTAjd9J3j4MY5Fa9cVomsw2eGmmQYxlmjWJ JB7Mwzax5qiYt4Yw51IMwRnsgMbAqIxwRSfXCbH6BEdrnRRj0ZVAgJ8iVGsCFQJjIWq+ EpvIdlt6yroZ+HILTi+XlkqjZbQbVR2i58ngKQvJbDAMIUHIkGE177AnHOTljkzJUK8i WR8EnKaHGA0lokHZ2d8BAAHth8WlLYedWYW6zK0Z0GQwNuSXn1fAdd0OLvNkPv2zCE9l SMrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=sCmp3T+knp1U2hYoByK4bhCzVso6/l7XB1ru7MM2DrQ=; fh=/ZD48C6jACdX82xEM0INQlbYbY+GgJdMr/h6Jxoyn+8=; b=nBlKGdATs1o5/8eSX2ivbBb8RcHitjyY9ZA0XjEuACqW04uSLVDhyDTfhaPVQwFqLo HRNV05DJca3yKnrgForbkp0aUi05fH1YuO6KahwO2ZEObG3uopgRhJ2wcBOfNgEISp8Z E6fQuGzY1MFyfwwws2a8E0vf7JC9pHbpDK96mQVOttYRig+ct1OIQX1UXhT1UK3etqQc 2Or3nz8kv8Fx4K0p1gHzrnkG+pS8mtqJbFWVuvgciBy/4BP+NWCALaIonEQP3+k3Dw3J oQS48Nl+zBHG7hWWFlocE+tkVjlcwsU9cq/rVYHo7RU17SzEUJGlSzdbMOKqmFV6Edtt m4lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PKY4+2ul; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rP9aWcIK; spf=pass (google.com: domain of linux-kernel+bounces-2190-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2190-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m3-20020a0cbf03000000b0067ee84abca1si10638127qvi.105.2023.12.16.04.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 04:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2190-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PKY4+2ul; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rP9aWcIK; spf=pass (google.com: domain of linux-kernel+bounces-2190-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2190-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 01C881C214D7 for ; Sat, 16 Dec 2023 12:59:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F43F2FE0E; Sat, 16 Dec 2023 12:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PKY4+2ul"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rP9aWcIK" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A82AA18EB1; Sat, 16 Dec 2023 12:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sat, 16 Dec 2023 12:58:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702731532; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sCmp3T+knp1U2hYoByK4bhCzVso6/l7XB1ru7MM2DrQ=; b=PKY4+2ulXfJyLbM5w9zxB9NXj8L+74iucfszlreFdltcQVxcaXZ2JM/4WZ+NbOfHWCJztA 1BRjVcoRQDzmFlVpUObL1c3xHdnfVo2Co8j48M/s3YkVMt/Hic24bwkBbGW5EgGIldb+2f MzTWTt1GREYtn9V2U9r7+8Abd88M3VfY5QFi616f35vivQBeL4NKy6NPsli+iQUmeBJCAK 3PPAz8C/UizCaeOAOmSNgrl+fiHuKxDQDcLtcGcyLmVns73VFDEAA+xBZrqMnItRvAy40C ZgX3NVyFSuMidabyXJt4w+HzMPSS6kwbvoZT+q7D/gT4hkSWACFW8++m3K+kfA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702731532; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sCmp3T+knp1U2hYoByK4bhCzVso6/l7XB1ru7MM2DrQ=; b=rP9aWcIK8/zyVZJZStGABzJ+I0KpnsaIuHbAxJfKYz/tiXkdXHfMtWVyv2FaVkWjuPhEe3 9dX+snpD0cCgCPBA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully Cc: Chris Lindee , Thomas Gleixner , "Borislav Petkov (AMD)" , Ashok Raj , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170273153180.398.6629279525112148301.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785443476760310411 X-GMAIL-MSGID: 1785443476760310411 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 69a7386c1ec25476a0c78ffeb59de08a2a08f495 Gitweb: https://git.kernel.org/tip/69a7386c1ec25476a0c78ffeb59de08a2a08f495 Author: Thomas Gleixner AuthorDate: Fri, 15 Dec 2023 09:58:58 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 15 Dec 2023 19:33:54 +01:00 x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully Chris reported that a Dell PowerEdge T340 system stopped to boot when upgrading to a kernel which contains the parallel hotplug changes. Disabling parallel hotplug on the kernel command line makes it boot again. It turns out that the Dell BIOS has x2APIC enabled and the boot CPU comes up in X2APIC mode, but the APs come up inconsistently in xAPIC mode. Parallel hotplug requires that the upcoming CPU reads out its APIC ID from the local APIC in order to map it to the Linux CPU number. In this particular case the readout on the APs uses the MMIO mapped registers because the BIOS failed to enable x2APIC mode. That readout results in a page fault because the kernel does not have the APIC MMIO space mapped when X2APIC mode was enabled by the BIOS on the boot CPU and the kernel switched to X2APIC mode early. That page fault can't be handled on the upcoming CPU that early and results in a silent boot failure. If parallel hotplug is disabled the system boots because in that case the APIC ID read is not required as the Linux CPU number is provided to the AP in the smpboot control word. When the kernel uses x2APIC mode then the APs are switched to x2APIC mode too slightly later in the bringup process, but there is no reason to do it that late. Cure the BIOS bogosity by checking in the parallel bootup path whether the kernel uses x2APIC mode and if so switching over the APs to x2APIC mode before the APIC ID readout. Fixes: 0c7ffa32dbd6 ("x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it") Reported-by: Chris Lindee Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Ashok Raj Tested-by: Chris Lindee Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/CA%2B2tU59853R49EaU_tyvOZuOTDdcU0RshGyydccp9R1NX9bEeQ@mail.gmail.com --- arch/x86/kernel/head_64.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 086a2c3..0f81032 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -255,6 +255,22 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL) testl $X2APIC_ENABLE, %eax jnz .Lread_apicid_msr +#ifdef CONFIG_X86_X2APIC + /* + * If system is in X2APIC mode then MMIO base might not be + * mapped causing the MMIO read below to fault. Faults can't + * be handled at that point. + */ + cmpl $0, x2apic_mode(%rip) + jz .Lread_apicid_mmio + + /* Force the AP into X2APIC mode. */ + orl $X2APIC_ENABLE, %eax + wrmsr + jmp .Lread_apicid_msr +#endif + +.Lread_apicid_mmio: /* Read the APIC ID from the fix-mapped MMIO space. */ movq apic_mmio_base(%rip), %rcx addq $APIC_ID, %rcx