Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp635350lqp; Wed, 22 May 2024 15:13:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOmnGBJfzuXggK5YRU+LBQkVkXDMAiesW7BpA77XB/VnEWTiPTiinfZNSZoi+Ef1z/sNDTXBU0pTp0/3ndgM9gciwEmPrToYISqfUvQg== X-Google-Smtp-Source: AGHT+IHLJXrSzVv3Ebj19AEHw7a6HfevcM+yA5wokvQJtPiSr3B4pfmpB2ykONroGhGQx5irseH8 X-Received: by 2002:a17:906:528c:b0:a5e:cdd:7783 with SMTP id a640c23a62f3a-a62280a0856mr226567566b.39.1716416000996; Wed, 22 May 2024 15:13:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716416000; cv=pass; d=google.com; s=arc-20160816; b=nvCDhDPFlfTyUUdFmd33vVR4K9naUhSX4E7xQsHzMQuUjQUtEraXpupawM6Ft4LM/R PDjwsl4QAujs206GQb6FWZcfFDDl7EA11SnvP15wnTUIB/fTQ07JMCLm0GuL7wENgYQY C+T1KaMDJQ5hTka1Q79MxVTaB1XkbTwg1wDf9gymhers7y4aQkDCdXwTmzymmf3ph9qx qq93dW6PtQGM8jEbaHiHsNL2TWH6DtOi4yLdV+dILKXK4wtNwjIt1XRzq8LicOPq3uZo Yb9RT3WRvryDnwrvUVpep0QAUiqcCbz2+THRU2bVonj4d8+hWhIQD5TKHkBiUbuw3a0L EGPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=U+uYNjBSstA2FYxrH4vlDNEEByHlM5YkexbOQbr0VrM=; fh=Q5lWp/rpa/bXskOzk1Uh/3XRQPqvv03dviLsBbBI/i8=; b=nakS+6JEAKmMXEj5L+hK0aPNClgDFAvOth2/g582+a1vs4UKpJQMT1JvypY9pHpf0q rHRIuVV4rvLdDnnxamOdUXfmTLxXJjWLieYuyXUFwTIsLsRufrj2ofXfaAWev5jlMvnD GmYmi5CrxXTq7oQ6gzEtjum5gW2L1TbaIPDm5j1mSJ1/M7Q39jrXt6v2n/Gv07qmnPWd MZbbnXq7cTQE7/wvzeUxcKPA0bFQv7Nve7/dckDUwWGCAA/xO+Tfk8aYrY3iaTQzspPt oxBxZE6GXh4rVLdctuNPI7g/fil0McMvK++xyMCBWTAkPqIcAE4HJDmCh/X2ckj4QuSJ c06A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=L2iztdgy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-186769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1797c8f6si1556288166b.240.2024.05.22.15.13.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 15:13:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=L2iztdgy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-186769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186769-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E76071F22AC7 for ; Wed, 22 May 2024 22:13:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CAC6F146A91; Wed, 22 May 2024 22:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="L2iztdgy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sLvsKOZJ" 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 17D575812B for ; Wed, 22 May 2024 22:12:50 +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=1716415972; cv=none; b=moHv8JPNKp+d9MzMdTT2hgK+gVLlyVi0RIHzRM2KNVTlR3N6VxC84DgXENK2k3jgdQ437ZvURsIdwC+vd0xzbxor904FBZ83tF6NVJnLRMi11uUJ/oUMteIRzzFaYP/22SHDRG9+hWFKsIS32BH64T0EVY6WWrOXy6iqbVurhf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716415972; c=relaxed/simple; bh=noX44XBYEvX4GMdI/hKOMAQfeMnaIys1OJvIUNWhBMI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=mYM0kXaTSRpVsOPacy52DFRjtjPZjZUQTlKuUC6zK+oouz96/R2vqMm9x5MCnrR6TYHwLMgre/tVAdTbmUvSB1QAv+jaUqTqCK6O0kuuqkMGFRtESEZ9rG78wzrNz6qIrwc1rT1vIurDUZEomkvhHX4qOJe1j3QDW3g3ctWdqcU= 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=L2iztdgy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sLvsKOZJ; 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 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716415968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U+uYNjBSstA2FYxrH4vlDNEEByHlM5YkexbOQbr0VrM=; b=L2iztdgymNVBacdWXs+KN/RKo5Ox8oRtGXlFoQomH9bYFElFfI90PgLlmMO2APar/h7Sqe LkC5S4efnd3uY2h/P3S+arxi+WwJgUG4yPeSXvrOhOl5UMOa0WrAcRQk12bu8sjZrKGeVC gtsz3LmavebMPU7zUhwfs7i9+ZnNfsbSiYi1u/ezX3Y9Qhb5ScXignZyh0cbrtxQ4FBNM8 e/sfHHk+chEvN/cb69aIAIa7w8JqnaQuWPJck3FuA9X4ZgvCXAbDO7/VOiMk5r1JOreK9Z PF37OM3/C76ilqOLxVkzg8jPAmU9/jb0vF4uKUkpgC3lkAWJAw2wA4uZDGnvAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716415968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U+uYNjBSstA2FYxrH4vlDNEEByHlM5YkexbOQbr0VrM=; b=sLvsKOZJIaUn24FOn9G+EFsk/CRt0EIKNzJUbcmtYAPCfFsclmKmW1ORhA1M5u29/j2V20 9wHF0dqvG0Y56uBw== To: Lyude Paul , "Linux regression tracking (Thorsten Leemhuis)" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Mario Limonciello , Borislav Petkov , Linux kernel regressions list Subject: Re: Early boot regression from f0551af0213 ("x86/topology: Ignore non-present APIC IDs in a present package") In-Reply-To: References: <3d77cb89857ee43a9c31249f4eab7196013bc4b4.camel@redhat.com> <87plumxz4x.ffs@tglx> <87le59vw1y.ffs@tglx> <3a0afe545747e5314a9cb6bbaa9ce90b259ddfac.camel@redhat.com> <87edautcmz.ffs@tglx> <3b1d16e357c1f9badeef405366492f05af26c085.camel@redhat.com> <878r11t8zu.ffs@tglx> <016902d9-3858-4c65-b3ec-f7a5103af63c@amd.com> <51d0dff8-2888-463c-95ab-71b491f12a8f@leemhuis.info> <877cg4ppd5.ffs@tglx> <87jzjxn6s5.ffs@tglx> <97bd95480a8b9951edc9ee2d2648d1b9c574e3b0.camel@redhat.com> <87bk58n6le.ffs@tglx> <2fd6009d21d606d13f0c472dbaa754a21f3105d9.camel@redhat.com> <87wmntkhak.ffs@tglx> Date: Thu, 23 May 2024 00:12:47 +0200 Message-ID: <874japh4ww.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Lyude! On Wed, May 22 2024 at 15:35, Lyude Paul wrote: Thank for testing! > Awesome! This patch does seem to make the system boot, thank you for > your help The only thing what's awesome here is that it confirms my analysis of the underlying problem. I offered Borislav a bet on that, but he politely declined :( The not so awesome part is the question what to do with that insight. The first issue is that we don't know whether that's only a problem on your particular system or if there is an underlying systematic problem on that particular CPU variant (model/stepping). Unless the AMD folks can give an authoritative answer we have three options: 1) Targeted via quirk As you are so far the only one complaining about this, it might be sufficient to enforce the physical flat mode for your particular machine via a DMI quirk or on the actual CPU model/stepping. 2) Tie it to interrupt remapping That's the patch I provided you for testing 3) Remove the default logical destination mode on 64bit completely My favourite #1 is stupid IMO because it's likely that other systems are affected by this nonsense and I don't want to end up adding quirks over and over #2 is silly because it effectively enforces physical destination mode on any system which has interrupt remapping available in hardware. That's pretty much everything halfways modern. #3 makes a lot of sense because: - it reduces the amount of code Given the trend of the last decade this actually removes code which will be used less frequently as the number of logical CPUs keeps increasing. - the only benefit of logical destination mode over physical destination mode is the ability to send IPIs to multiple CPUs in one operation. The question is whether this still matters. IMO it does not matter because anything which is IPI sensitive is running on machines which have more than 8 CPUs today. The time where 8 CPU (threads) workstations and servers were state of the art are long gone. - physical destination mode is guaranteed to work because it's the only way to get a CPU up and running via the INIT/INIT/STARTUP sequence, while obvioulsy logical destination mode has its issues not only on the system at hand (see physflat_acpi_madt_oem_check()). Patch for this below. Thanks, tglx --- arch/x86/kernel/apic/apic_flat_64.c | 116 ------------------------------------ 1 file changed, 3 insertions(+), 113 deletions(-) --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -18,126 +18,19 @@ #include "local.h" static struct apic apic_physflat; -static struct apic apic_flat; -struct apic *apic __ro_after_init = &apic_flat; +struct apic *apic __ro_after_init = &apic_phys_flat; EXPORT_SYMBOL_GPL(apic); -static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id) -{ - return 1; -} - -static void _flat_send_IPI_mask(unsigned long mask, int vector) -{ - unsigned long flags; - - local_irq_save(flags); - __default_send_IPI_dest_field(mask, vector, APIC_DEST_LOGICAL); - local_irq_restore(flags); -} - -static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector) -{ - unsigned long mask = cpumask_bits(cpumask)[0]; - - _flat_send_IPI_mask(mask, vector); -} - -static void -flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) -{ - unsigned long mask = cpumask_bits(cpumask)[0]; - int cpu = smp_processor_id(); - - if (cpu < BITS_PER_LONG) - __clear_bit(cpu, &mask); - - _flat_send_IPI_mask(mask, vector); -} - -static u32 flat_get_apic_id(u32 x) -{ - return (x >> 24) & 0xFF; -} - -static int flat_probe(void) -{ - return 1; -} - -static struct apic apic_flat __ro_after_init = { - .name = "flat", - .probe = flat_probe, - .acpi_madt_oem_check = flat_acpi_madt_oem_check, - - .dest_mode_logical = true, - - .disable_esr = 0, - - .init_apic_ldr = default_init_apic_ldr, - .cpu_present_to_apicid = default_cpu_present_to_apicid, - - .max_apic_id = 0xFE, - .get_apic_id = flat_get_apic_id, - - .calc_dest_apicid = apic_flat_calc_apicid, - - .send_IPI = default_send_IPI_single, - .send_IPI_mask = flat_send_IPI_mask, - .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, - .send_IPI_allbutself = default_send_IPI_allbutself, - .send_IPI_all = default_send_IPI_all, - .send_IPI_self = default_send_IPI_self, - .nmi_to_offline_cpu = true, - - .read = native_apic_mem_read, - .write = native_apic_mem_write, - .eoi = native_apic_mem_eoi, - .icr_read = native_apic_icr_read, - .icr_write = native_apic_icr_write, - .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, -}; - -/* - * Physflat mode is used when there are more than 8 CPUs on a system. - * We cannot use logical delivery in this case because the mask - * overflows, so use physical mode. - */ -static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id) -{ -#ifdef CONFIG_ACPI - /* - * Quirk: some x86_64 machines can only use physical APIC mode - * regardless of how many processors are present (x86_64 ES7000 - * is an example). - */ - if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && - (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL)) { - printk(KERN_DEBUG "system APIC only can use physical flat"); - return 1; - } - - if (!strncmp(oem_id, "IBM", 3) && !strncmp(oem_table_id, "EXA", 3)) { - printk(KERN_DEBUG "IBM Summit detected, will use apic physical"); - return 1; - } -#endif - - return 0; -} - static int physflat_probe(void) { - return apic == &apic_physflat || num_possible_cpus() > 8 || jailhouse_paravirt(); + return 1; } static struct apic apic_physflat __ro_after_init = { .name = "physical flat", .probe = physflat_probe, - .acpi_madt_oem_check = physflat_acpi_madt_oem_check, .dest_mode_logical = false, @@ -167,7 +60,4 @@ static struct apic apic_physflat __ro_af .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; -/* - * We need to check for physflat first, so this order is important. - */ -apic_drivers(apic_physflat, apic_flat); +apic_drivers(apic_physflat);