From patchwork Mon Oct 23 12:46:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13432863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F04C7CDB474 for ; Mon, 23 Oct 2023 13:32:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.621462.967907 (Exim 4.92) (envelope-from ) id 1quv2J-0007Hl-CD; Mon, 23 Oct 2023 13:32:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 621462.967907; Mon, 23 Oct 2023 13:32:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quv2J-0007He-9O; Mon, 23 Oct 2023 13:32:03 +0000 Received: by outflank-mailman (input) for mailman id 621462; Mon, 23 Oct 2023 13:32:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1quv2H-0007HY-9X for xen-devel@lists.xenproject.org; Mon, 23 Oct 2023 13:32:01 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 89695bd5-71a8-11ee-98d5-6d05b1d4d9a1; Mon, 23 Oct 2023 15:31:59 +0200 (CEST) Received: from mail-co1nam11lp2169.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.169]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Oct 2023 09:31:43 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by DM8PR03MB6248.namprd03.prod.outlook.com (2603:10b6:8:25::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.16; Mon, 23 Oct 2023 13:31:40 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::acf0:ce2b:1634:5aee]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::acf0:ce2b:1634:5aee%6]) with mapi id 15.20.6933.011; Mon, 23 Oct 2023 13:31:40 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 89695bd5-71a8-11ee-98d5-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1698067919; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=a/HsEo6LR3iHkGEIna76xOPj1PvZEM/62oHAgdqWUHw=; b=FC+1ZaJbpDeKLQXJuR2bbAnb47AY3oxXDlhyrijRdc/JvW+4u9lSswDK cwm3QRmrnye/NEidNuzjEHQOEwSaabhgcLrneU9Eag4yC0eS6xToFosHD dJ66Zj+Lcv+1PzfmF0vYajTpqc3GMYge21y7tItNlGwF4p7Vaji7Ngwi0 E=; X-CSE-ConnectionGUID: Gz1Yup/nTQebIx1dQlf+Zg== X-CSE-MsgGUID: iUd9Wbp5SLOR8m+zdKxOLw== X-IronPort-RemoteIP: 104.47.56.169 X-IronPort-MID: 125616366 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatSc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ftLqUwLzM2dKYRJd 653I5qtjCgcXMYYoCSAWQEZfHKo5nmhY/rehkPAj8g8U2rgSmz4LD3PhCE1lNGOgk/iosKwC zgqUjU96+ju/a0xlv10HLS1Y1fnJ/M28ZOH8uFj+kSM3HJhhyzbIpsdrWetHQeof2p6nwtjN 7Qyi1Qd/hb2jf0RCWYsBHt0w7v3HIH7GLj80aRhT/GrdbiTDw3JsJdjcYBGyGponYIjZVZ6u ZmzmiZv51YAVfpmzn83cHBU1VPmlCvqXQvvOYPhzh0UJcYapVWsYsDlXklZqsoLWbf0sQKAe NuBMbT6LJ/dk6bVWnQui1VzNmlTh0Ib2W7a3lHnvbQ/yldnXh/wUdd7tcYhG08+JU0TIQBz/ jYM4xz/Ys+AfM+XOZYPqMsUMG3AmvCTVbnK2SJO2nqE6kBJjbkt4P32rMo/+unEaZ4gKfaoK 6xEW+wiFRCO34HUaa1rd52G1H2MSiAtA3Wu49jD8MTgMy/eFLpWRfzO2zG3fHQ5sn3OferJc pbCKgmf8MLElGeZrqhpzeOPaW6CUNuJfH96exLL26mk4bsFrDAkND9XbL6GIfNeAxUKl8XRE FzFgTOGA== X-Talos-CUID: 9a23:OTUsc2C20wzFJSj6EwZ1rX8JAocjTkTQxlbAekOBDWgqerLAHA== X-Talos-MUID: 9a23:hE0+rgVc74idoU7q/D7RiGBdPt812ICJMhAI0ocKmNmjETMlbg== X-IronPort-AV: E=Sophos;i="6.03,244,1694750400"; d="scan'208";a="125616366" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S9N2IvJ4B/McY9XaiHM3p/MVpo6t6EikL+FruyRbYeCXOocNe2l5MmErYg3cInngWgVe0TzSiDQUsrixIH9XUUTW2MuDTOGhiW80Sg+aR7x+RFH+34C5tZk9lNIhsIIiyeBQB9NsgKkTcdY9PkxVvIsiApkyAEbzZir7CItZmQrJ+do5XOvRNov7kGSKp57zNSftKQKY0vUS5fWHGz/xcfk3IOn/xB5GAm70lQJSe3j5gp9BUFzQO31+KYfKBRKXzOoBSTtsbEFqid/0h6roNlqfu5gOyXuxIJHlRAMnUUt+ButhKCP2MxZliCaZp41omywada+Xq0GAE9Yf8Bf5VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QSXlqjPToKHgQULyC976CQxyVan704f+/BpCJVPz8xg=; b=jyVVZxU0tVR3cuI/gUtcqO0FFmG9PHE4rigFQ+bt5FTVxhRsXYfgGdTTztGRAwGlyeYYHESOncLTr8+LTrbsnNlEgcWcxqlCWlkmEDFZKYrkBRZlhTYuXeN6i3Y8zYhy/ix1aeuaebsngwRmXNAZygdRqb5sgFOSY7PKJeGe7I/pcVT+/hNBq4FCf4QIgeZT+H0CDvIhqFt8hcTxm8YyGM4DR+zV1oIiJDLWr0EjMtNEs9F/g86/gWnmMqwLpv0K7XOqoP3+OsDUM99auXSBuxKI04c0Hgl9jrrg3AP2dkgMbNV7Qk6kkHk5/tvujdx5VrtTzel3czTQyOKx4RP5Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QSXlqjPToKHgQULyC976CQxyVan704f+/BpCJVPz8xg=; b=rccTDWb06JvCmhwIWSCnjkRbGsrJmN7E9DLSy8kVrC9nxeOLvhs9ireoSywCGqgA8zP0B59WfNzzhRlTYBrnFXM1yfNQ9o+raTm2O4nhp6RYBPpw9FTkkhz9WykmhncoHtv60ZtYl6Rg1Le48XCgGMfUV6lAXcOq1felMh7uDOc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2] x86/i8259: do not assume interrupts always target CPU0 Date: Mon, 23 Oct 2023 14:46:35 +0200 Message-ID: <20231023124635.44266-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: LO0P265CA0010.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:355::7) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|DM8PR03MB6248:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ba19280-761d-4eaa-95eb-08dbd3cc6385 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oWR6w+XLTmNehRAshv2Txhud+gt398oNgZzvuhs4Q8zj8WW5drZQsNrxJbsgbNkyNGTMrsa5p9IzCf1n/iFa6biEcQUxadiyyGQTxS8RoXXtf7+XIWsyRINK+U18qFdEB3nkPeBpe2LH3SAobqVkKGar9SkXaHyHmor55tLS9x/14WNJqbaLgCANkjOdC5USH5HUjtce71gE12Gmh5xb7nuxUHUKeWS/JmboSG8vdjXTBLWGUQWzJmSEckNNDz3vWR4pMCiQqXBACp8Zch1FqKJYr4ZznJuzboN/OZiz6g+Rd/Csmnbps2xBEXohxE97+v1HD3IngE8u6PgUWpp0QNQ4sgQa7MvFZUDnRFaQ/6T/PMEOIeqwXB3JNLrknnl1bxOD2yQPLSVl7Z3HX3k8wYHK2mV8kfIU+SFY1DzgEhhaDphWEaijcQFhts+nyZnxyDBlR165uSVfXM7ymX+MbAEObIIB06cCM8ZKskPf74538yAlr5PNZZ7s0NrbsOo4FMdM2365TsviVKoiCW4y0ukZTANtzCuLIpMsH4dm5gVhEiAzpRFAOQQE0kLEZe2+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(376002)(366004)(396003)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(36756003)(2906002)(316002)(41300700001)(86362001)(66946007)(66556008)(54906003)(6916009)(66476007)(5660300002)(4326008)(8936002)(8676002)(82960400001)(478600001)(6512007)(6506007)(38100700002)(6666004)(83380400001)(6486002)(26005)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?iCaxRuo1zk4FD8wV4uV508NpGT6I?= =?utf-8?q?3p9L4ulAoPN1ooRE8HU31onpKFZ47Uo0T1UphQKrl93ZCrXck/bfHxxqXC/60PjCJ?= =?utf-8?q?Z2YJOYWzJVx8LGUK+WKHTXC3DthcNn/BscPVEH9db84L1DlLq/eGnXnOtV59tk649?= =?utf-8?q?P+KqpSNFpEGv11Nvj4+S0D1HbmwYSTD2I1AbsacJGOtlhMauqNPfsyRAj5YVfjQij?= =?utf-8?q?kZVWimRSOkKElmp9JpuEZXorI4L7P6pxOo6dyC69G9etQW37x7+GNjo3epy0psFsi?= =?utf-8?q?4e16fB4zEjkW4/RO06scwCw+l5fcJgfwl+cHwOC+bXgT8pxbBYrUC2cc8OofCjSa/?= =?utf-8?q?VMj2ZpSzr2j0xHOm7piRkH/YzgdcEWsDVwEGpNJtxFAU2SXJMqbjD1iaNanCiy0UC?= =?utf-8?q?ung7h0S86oUrIBdQ1/znoz80JRkl/bkm4c8EHbPwm0wZ0b71FjSdUIEub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R/c?= =?utf-8?q?Q0RGJ1CuT5FHZcCsPukUVzrDQMS50xwMbj2tWoQB0X8aei34F0OqLGngRO5b/B6GE?= =?utf-8?q?G5MGK3uRo/i3wiK2504F08zh5LMG8W5TUTqlDdDrYLMq99Rgp6n9grYGQ96qSjy70?= =?utf-8?q?0I2iJZ93Jn1iXxv/lRDveHw0INcBjD3H56uXpgPS7yOrt3Ky1GKuQQ5fWuBSPGoPG?= =?utf-8?q?D9yk+LeSBJgP?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8wK18cePZkxnD60SVMhCK4OMGZNG9TmtzV90q7TPnVEAJJtprcb9zDJAUcSXqraLTRxtgKmTs3HvChdhYl9dRwLPVS4dhFO2lEs89kWEcG2EEpVWyRc8WlNU35OBiWh9B7ptmDJx5SWctnFpp7BztE4qL3yWWfmW1MzF7xkgBddYiJm2FMt59fBXCpsyv4cWga1XciiWnHM2CuZWn4VBpfwkB2bqfANNYyllb/lsZIxa4N6cckF/xb0iljic4D2Os+Lt+5br7iBC867T7sJv9cegv+8gT4RgMYYF/cXneYJJtoWL7ocOK3G9tfsPhc1aGqifF73xxUZzwbGaqttiQ834XEr8v88Op08IVyHymLawDJSoO2VDzIeCxqcDkIMkG0Vyx7fSh+Wy/6MPlZugBMx00NQSy7RHLGpOKzsNNM46kfd2V5pA0I8bHx9JncN9dRpUzahmSCDO+UtSKwLcrFpfKzQNHCa7L+kAx9vkur0DRki4rn+9MLvc3tHSdYKTgvye8m/ozFH4/W1b4/Mb9OnYTS2MFQ8qjTWB1V280mJ53sf+32/2Ya4TBBOswJPF0PKF+XEA8JE66mUqde8ag3IShqvH7LAturwRT+i6p/se154y+CZguwso4HvELwMYzkqEPoj1buxVzkl61FwwRx7KlzHmHbzklQXa+2TRAvGEGNaodUlGU+h4VeQK3bpWVaQi3zNDTHkpZDuTwvdnLaWaSG9H4H/KLJ5SSmv0i9vB9rlSYKKEaG1AsLIOH3+CxYkrlAJ3qyaaGlWn76+1LiBN2vgs23s+Ie+oqmBJPhInlNLFwt488aNPjZLxCBmNCXIok7vdiOfLM11NXWfQuA== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ba19280-761d-4eaa-95eb-08dbd3cc6385 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2023 13:31:40.2722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mh5f1wcckZRMfQKHFHEaVeoA8VBk+rElJRzo1KvBq9RnJbMYSlSB5XBIG+mXKvvvlvaaG9hGUYer0yYc6oCiSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR03MB6248 Sporadically we have seen the following during AP bringup on AMD platforms only: microcode: CPU59 updated from revision 0x830107a to 0x830107a, date = 2023-05-17 microcode: CPU60 updated from revision 0x830104d to 0x830107a, date = 2023-05-17 CPU60: No irq handler for vector 27 (IRQ -2147483648) microcode: CPU61 updated from revision 0x830107a to 0x830107a, date = 2023-05-17 This is similar to the issue raised on Linux commit 36e9e1eab777e, where they observed i8259 (active) vectors getting delivered to CPUs different than 0. On AMD or Hygon platforms adjust the target CPU mask of i8259 interrupt descriptors to contain all possible CPUs, so that APs will reserve the vector at startup if any legacy IRQ is still delivered through the i8259. Note that if the IO-APIC takes over those interrupt descriptors the CPU mask will be reset. Spurious i8259 interrupt vectors however (IRQ7 and IRQ15) can be injected even when all i8259 pins are masked, and hence would need to be handled on all CPUs. Do not reserve the PIC spurious vectors on all CPUs, but do check for such spurious interrupts on all CPUs if the vendor is AMD or Hygon. Note that once the vectors get used by devices detecting PIC spurious interrupts will no longer be possible, however the device should be able to cope with spurious interrupt. Such PIC spurious interrupts occurring when the vector is in use by a local APIC routed source will lead to an extra EOI, which might unintentionally clear a different vector from ISR. Note this is already the current behavior, so assume it's infrequent enough to not cause real issues. Finally, adjust the printed message to display the CPU where the spurious interrupt has been received, so it looks like: microcode: CPU1 updated from revision 0x830107a to 0x830107a, date = 2023-05-17 cpu1: spurious 8259A interrupt: IRQ7 microcode: CPU2 updated from revision 0x830104d to 0x830107a, date = 2023-05-17 Fixes: 3fba06ba9f8b ('x86/IRQ: re-use legacy vector ranges on APs') Signed-off-by: Roger Pau Monné --- Changes since v1: - Do not reserved spurious PIC vectors on APs, but still check for spurious PIC interrupts. - Reword commit message. --- Not sure if the Fixes tag is the most appropriate here, since AFAICT this is a hardware glitch, but it makes it easier to see to which versions the fix should be backported, because Xen previous behavior was to reserve all legacy vectors on all CPUs. --- xen/arch/x86/i8259.c | 29 +++++++++++++++++++++++++++-- xen/arch/x86/irq.c | 1 - 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/i8259.c b/xen/arch/x86/i8259.c index ed9f55abe51e..0935cdf07b65 100644 --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -37,6 +37,15 @@ static bool _mask_and_ack_8259A_irq(unsigned int irq); bool bogus_8259A_irq(unsigned int irq) { + if ( smp_processor_id() && + !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ) + /* + * For AMD/Hygon do spurious PIC interrupt detection on all CPUs, as it + * has been observed that during unknown circumstances spurious PIC + * interrupts have been delivered to CPUs different than the BSP. + */ + return false; + return !_mask_and_ack_8259A_irq(irq); } @@ -222,7 +231,8 @@ static bool _mask_and_ack_8259A_irq(unsigned int irq) is_real_irq = false; /* Report spurious IRQ, once per IRQ line. */ if (!(spurious_irq_mask & irqmask)) { - printk("spurious 8259A interrupt: IRQ%d.\n", irq); + printk("cpu%u: spurious 8259A interrupt: IRQ%u\n", + smp_processor_id(), irq); spurious_irq_mask |= irqmask; } /* @@ -349,7 +359,22 @@ void __init init_IRQ(void) continue; desc->handler = &i8259A_irq_type; per_cpu(vector_irq, cpu)[LEGACY_VECTOR(irq)] = irq; - cpumask_copy(desc->arch.cpu_mask, cpumask_of(cpu)); + + /* + * The interrupt affinity logic never targets interrupts to offline + * CPUs, hence it's safe to use cpumask_all here. + * + * Legacy PIC interrupts are only targeted to CPU0, but depending on + * the platform they can be distributed to any online CPU in hardware. + * Note this behavior has only been observed on AMD hardware. In order + * to cope install all active legacy vectors on all CPUs. + * + * IO-APIC will change the destination mask if/when taking ownership of + * the interrupt. + */ + cpumask_copy(desc->arch.cpu_mask, boot_cpu_data.x86_vendor & + (X86_VENDOR_AMD | X86_VENDOR_HYGON) ? + &cpumask_all : cpumask_of(cpu)); desc->arch.vector = LEGACY_VECTOR(irq); } diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index f42ad539dcd5..a2f9374f5deb 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1920,7 +1920,6 @@ void do_IRQ(struct cpu_user_regs *regs) kind = ""; if ( !(vector >= FIRST_LEGACY_VECTOR && vector <= LAST_LEGACY_VECTOR && - !smp_processor_id() && bogus_8259A_irq(vector - FIRST_LEGACY_VECTOR)) ) { printk("CPU%u: No irq handler for vector %02x (IRQ %d%s)\n",