Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1324746lqa; Mon, 29 Apr 2024 05:38:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOkWBcEiamGEd+N1Un0C+CCcdGr87PtFM35/Tg4zJs+8nQgQVzQJNue2drmYKXbqUkqHxxPFpYBlIq1wTSI/tm1LRg2+cmNCjKg0ncxw== X-Google-Smtp-Source: AGHT+IHpEV+g6c//7f4OACD16w1EoV78ikJifyp/pLYRvuBENIEQ9SLRrQftTA+cgM/xZWu47MUt X-Received: by 2002:a05:6a20:6f8b:b0:1a7:4b40:96db with SMTP id gv11-20020a056a206f8b00b001a74b4096dbmr12289697pzb.10.1714394307256; Mon, 29 Apr 2024 05:38:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714394307; cv=pass; d=google.com; s=arc-20160816; b=T7sxUzD3jcMRsWSdgTuxub+tSwLwkYjvs3SW6bik8aNhmKbkvinxegvvjlFn7D+xqT ue4xMVcy6sGCQLuygxUijyycU5mCs0DkptQAu1DwVD6k5n91rzplIMs1rR68jbaGUuJN iR2PUAbGgfU/dZEJmaPZIMbsUZ/xx3sh7wEKMCsG/wNx3nmkRSEev7MahlPOpiiabAbS yiomCUqZY+ySz1ZKpuah5qWMYV/A9Jh0JrH3beA0QcXrz+cnWHSERQCKALoCXiHQM/GA J+HlbzXu+BBOfde154pPP7Q7piaYw8ziwm4fOrK9ofSfqRx4QJGMbS9lMtmQ9jUNys+o X1cQ== ARC-Message-Signature: i=2; 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=IE/HEyswWWxEYsgZH5K3MXvim58TtiuexS9UWmxw+jw=; fh=NQ/82FLwLvZRJFy2YskQctT0GSw1Q8lA+qBZdXCljco=; b=EIB0xJWgT5UKe5Y8k/oDTfP6RDkNZ1St2ozQQXcYYu4B1nhcwzyhXjzXtjdiS9gbyS frRbTYp2au4432zQ+q4WS/06bAaO4B9R/osOQDSvIJrr3ssABphP4CA6hJJG1akrv85T mxKnhFBc9xduL2ec7hXd/SVseLawpAon8SKHsnpz14+XaBuzYcGyLYnwCME2DWGfHxPO wUkM/ZYkPznW965WY1rl903jTJDLk44w0ebzjVy2zlp5PJUuxR1MFiXoSc5UrdBDp1JY tCuRCanbCTljINmJ69sgLLUIiVHNViFbqVZecZTptyNbnnCweGojgBLyoQ/7uwPeCtOm kylg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1nVjbE7G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Op/UpWeU"; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-162256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162256-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q9-20020a170902f78900b001eb58ac4710si4134710pln.253.2024.04.29.05.38.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 05:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1nVjbE7G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Op/UpWeU"; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-162256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162256-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 16A3028988D for ; Mon, 29 Apr 2024 12:35:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 839D08487; Mon, 29 Apr 2024 12:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1nVjbE7G"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Op/UpWeU" 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 2F00110A1B; Mon, 29 Apr 2024 12:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714394149; cv=none; b=R9h5J7uo0VRzUu+qzbiTvxnDvRuwqhbn/gGjRQOmc3rQn/uvXUkecV6sUl5QZNPe91mFXNTQMDbJklgUTIX1yS+DVziwd2US9GXvttLbigoXPK6D3xz/KTLkiihMQcHCi60SPOIYtf5uirl4rpMci6aVyrXi1LqorMAv6vEdSqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714394149; c=relaxed/simple; bh=W++bsTCgt8Ak/qvxrG28b6/jckWokkT+K0XZBHvpYNY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=tF1foAOO0aidj+Ub51wAz4kzllcxAIlfcR4vo/AOaQjdSEhO2dmu/GX+NHpuC7D5ZgTJkAr+q5vG/VI+64+SP/fgOv5cI2VvWCpbiENW6ngFhiPLLZeH4NMMYVdjOpwNREvFDbrZXpSFhdCDOv8M5fjz9HmWRcbg31or5oHHfRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1nVjbE7G; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Op/UpWeU; arc=none smtp.client-ip=193.142.43.55 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: Mon, 29 Apr 2024 12:35:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714394142; 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=IE/HEyswWWxEYsgZH5K3MXvim58TtiuexS9UWmxw+jw=; b=1nVjbE7GDK5i6kstvTxUkjO1i1NkzrRTq2ygDvVGTl8MGfagyCfkCbEKh2fFw1zrY8xRQ5 evphsVltqGWX38J3Adf6BTRkKpw3PqdgtYakI3RX/G+ESJniMdX2h2aUg7cboIwTJo5Daz +qKIGrvXEJB407M3inFCp2jiH00CqXa/IslUx4PnlVX/2MHgPeJLgF49HzRlg8/CTURrr1 CSu/id18r/O2SqhfRIm/+Dg6rpxooAUZLH8Mz4HSXUjVHA7ufCiz6NnURZSZlTCkZXk+0x YK+AWSEdWLlWxJpWopx6Jrt7XArQFkjWuF8/21+7oVkK/rmYq+iS3t4LWrhJ2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714394142; 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=IE/HEyswWWxEYsgZH5K3MXvim58TtiuexS9UWmxw+jw=; b=Op/UpWeUKWL1SvQmd+tE+QaxNnWFtqdVphGs6Onss3RGuIHtoVJv+hgL9H2Hr/D+Kv8JCp gflEsaNOAapiqzBg== 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/apic: Don't access the APIC when disabling X2APIC Cc: Adrian Huang , Thomas Gleixner , "Borislav Petkov (AMD)" , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <875xw5t6r7.ffs@tglx> References: <875xw5t6r7.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171439414186.10875.17224463643261311678.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 1e1dd773644e9de88f54386f7147c1068375fc75 Gitweb: https://git.kernel.org/tip/1e1dd773644e9de88f54386f7147c1068375fc75 Author: Thomas Gleixner AuthorDate: Fri, 26 Apr 2024 00:30:36 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 29 Apr 2024 12:08:07 +02:00 x86/apic: Don't access the APIC when disabling X2APIC With 'iommu=off' on the kernel command line and X2APIC enabled by the BIOS the code which disables the X2APIC triggers an unchecked MSR access error: RDMSR from 0x802 at rIP: 0xffffffff94079992 (native_apic_msr_read+0x12/0x50) This is happens because default_acpi_madt_oem_check() selects an X2APIC driver before the X2APIC is disabled. When the X2APIC is disabled because interrupt remapping cannot be enabled due to 'iommu=off' on the command line, x2apic_disable() invokes apic_set_fixmap() which in turn tries to read the APIC ID. This triggers the MSR warning because X2APIC is disabled, but the APIC driver is still X2APIC based. Prevent that by adding an argument to apic_set_fixmap() which makes the APIC ID read out conditional and set it to false from the X2APIC disable path. That's correct as the APIC ID has already been read out during early discovery. Fixes: d10a904435fa ("x86/apic: Consolidate boot_cpu_physical_apicid initialization sites") Reported-by: Adrian Huang Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Tested-by: Adrian Huang Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/875xw5t6r7.ffs@tglx --- arch/x86/kernel/apic/apic.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index c342c4a..b229648 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1771,7 +1771,7 @@ void x2apic_setup(void) __x2apic_enable(); } -static __init void apic_set_fixmap(void); +static __init void apic_set_fixmap(bool read_apic); static __init void x2apic_disable(void) { @@ -1793,7 +1793,12 @@ static __init void x2apic_disable(void) } __x2apic_disable(); - apic_set_fixmap(); + /* + * Don't reread the APIC ID as it was already done from + * check_x2apic() and the apic driver still is a x2APIC variant, + * which fails to do the read after x2APIC was disabled. + */ + apic_set_fixmap(false); } static __init void x2apic_enable(void) @@ -2057,13 +2062,14 @@ void __init init_apic_mappings(void) } } -static __init void apic_set_fixmap(void) +static __init void apic_set_fixmap(bool read_apic) { set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr); apic_mmio_base = APIC_BASE; apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", apic_mmio_base, mp_lapic_addr); - apic_read_boot_cpu_id(false); + if (read_apic) + apic_read_boot_cpu_id(false); } void __init register_lapic_address(unsigned long address) @@ -2073,7 +2079,7 @@ void __init register_lapic_address(unsigned long address) mp_lapic_addr = address; if (!x2apic_mode) - apic_set_fixmap(); + apic_set_fixmap(true); } /*