From patchwork Tue Oct 24 14:53:40 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: 13434709 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 C9E27C00A8F for ; Tue, 24 Oct 2023 14:54:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.622084.969248 (Exim 4.92) (envelope-from ) id 1qvInB-0002fh-3I; Tue, 24 Oct 2023 14:54:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 622084.969248; Tue, 24 Oct 2023 14:54:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qvInA-0002fa-VK; Tue, 24 Oct 2023 14:54:00 +0000 Received: by outflank-mailman (input) for mailman id 622084; Tue, 24 Oct 2023 14:53:59 +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 1qvIn8-0002fO-Tl for xen-devel@lists.xenproject.org; Tue, 24 Oct 2023 14:53:59 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 271a1db0-727d-11ee-98d5-6d05b1d4d9a1; Tue, 24 Oct 2023 16:53:56 +0200 (CEST) Received: from mail-dm6nam12lp2169.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.169]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Oct 2023 10:53:53 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by BLAPR03MB5554.namprd03.prod.outlook.com (2603:10b6:208:290::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Tue, 24 Oct 2023 14:53:51 +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; Tue, 24 Oct 2023 14:53:51 +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: 271a1db0-727d-11ee-98d5-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1698159236; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=ydfUgI7OL2QhFNk+VZp7KnOdMneSICIy2rXDdd+Pz4U=; b=Bz5k+/N63Qub/SPTz55CSOjcb3mns2obA0PZFjzKh4AzC56Pu79iwMxd OS/etb7W+tw+Ti5MJ/hdDcCkfIS77hR6LVOqX8dpLuSMHWY6d3VSIaWQp FftaV7PkrowgK0gweFzGWsusgj8j1V36ezzFJZ7Hsk0ixiYilOLadNXNt U=; X-CSE-ConnectionGUID: 0UYFrCghSXKYj0Y2MMYeQg== X-CSE-MsgGUID: AXtfemz+RGORZBdyY9J6KA== X-IronPort-RemoteIP: 104.47.59.169 X-IronPort-MID: 126493008 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:fo/9WakRB8zU/iY3kiW62BPo5gynJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xIYWGvTa6zfamb9f9B0b4618EtQucfRndNlSwU6pHxnQyMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+e6UKicfHkpGWeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE0p5K+aVA8w5ARkPqkT5gOGzRH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 aQlGR4XRR+DvNKV8bDje7NJo/UuFca+aevzulk4pd3YJdAPZMmZBonvu5pf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkV03iea8WDbWUoXiqcF9hEGXq 3iA523kKhobKMae2XyO9XfEaurnxHmlBNNJTOXonhJsqHSj2mIeDQ9Vb3Scm8uThl+PCvABC GVBr0LCqoB3riRHVOLVTxC+5XKJoBMYc95RCPEhrhGAzLLO5ASUDXRCSSROAPQkvsIrQT0h1 neSgsjkQzdotdW9Vna15rqS6zSoNkAowXQqYCYFSU4J5oflqYRq1BbXFI89Qeiyk8H/Hiz2z 3aSti8iir4PjMkNkaKm4VTAhDHqrZ/MJuIo2jjqsquexlsRTOaYi0aAsDA3Md4owF6lc2S8 IronPort-HdrOrdr: A9a23:uN7rCqm+EMaMklbT9GXXe99kxDfpDfIV3DAbv31ZSRFFG/Fw9v re5cjzsCWftN9/YgBEpTntAtjjfZqYz+8X3WBzB9aftWvdyQ+VxehZhOOI/9SjIU3DH4VmpM BdmsZFebvN5JtB4foSIjPULz/t+ra6GWmT69vj8w== X-Talos-CUID: 9a23:K14pMmtemAJvtjNhWozh9bpw6It9T0zz1lzfI3SIKldrEIzPbHqh9Zprxp8= X-Talos-MUID: 9a23:iuSy3QjHlmCVRMJ8RgM+YMMpHfd07amrGgM3vrI8ieOIJB0hGWm+pWHi X-IronPort-AV: E=Sophos;i="6.03,248,1694750400"; d="scan'208";a="126493008" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dfNVPry+U0fiJJJTQyuu0UoIiU9QvOXtKjlaSmtd4JsX30wPobH+jrvy37dpnKyhFfL5Bxt/guwoc/w7Ikn8E4qvGstG1t5gnvXUz8cBP6FcBJrRVyexvKwIDTRw9lapH4OEMrXbAmC8Bb//BNeOUkmc+eKyLKC+JGmvFYX75XNC22sjpXOxccFsyR+ldJlp7+1YIU5C5NeJu38t4s9UffRrOGsoc7ChpQBTsHOqYcnNFz7cvtTTxtMuCyuijBEOHr+O2ZEEz2XyVwzNmNIYAzcypP+QAlHN3KXdKsu5ikaxIlK8EEAleoaJwE7bikbKwhXYvxkG1kySHI4BC7hbbQ== 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=2HSyzWlTE/SNTqD/am7gdAgKLTJRO0Or0pCFadzKOp4=; b=Ypc1rfNGqyI/FvpNuBsxstU82QNyv1TW/1Vz96ow/+ME9UQI5vV/GPQQkyGNfFZUUARrkpWcwjzoSnw2/3gz96PHsZqZqKZkqxKitNymykQ1FzD9RC6qLGPDqIlEE7KTOcpzJLFrF1lFe3c/y7RqndlZnjpJ57+WDTrqfVRkE4CowehBwGlB+lOP9IKl3NWgG0ziaLRMwZ6eybba258Fmvo9sYutcNsrzkKVW8VN/7j8AXLAqxAfR6gAmKBMkvVp18tavUxBrzQYSQFbaCw0aEd5VHkoalkLVJL305K2+s+VD/qlWKy7/9c+YuKgUqZeNZnsqJRaHD64xxHG843/hA== 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=2HSyzWlTE/SNTqD/am7gdAgKLTJRO0Or0pCFadzKOp4=; b=Vj+llzf+eSxBi/bPPbhgeYkMGfiq0Za3ZlYVI/Y+h2/iFXBAm58rNJd1zczD3ZvI2QmrN2HAbr0HaCus/Z6JmBvHKszxGPmYVbX3eRCnk+bO4b5DhLxpybDdOIUGGVeaHnIDYg2Z20keQq+AtR1AgHF6Yqy/dBSd/GK5abCb6ug= 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 v3] x86/i8259: do not assume interrupts always target CPU0 Date: Tue, 24 Oct 2023 16:53:40 +0200 Message-ID: <20231024145340.49829-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: LO2P265CA0512.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::19) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|BLAPR03MB5554:EE_ X-MS-Office365-Filtering-Correlation-Id: f14e526a-8521-4765-c1ee-08dbd4a108da 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: Na2X4/XCue8CHVac4ml/BWdzu6oilBDjSxLrvIxBWNa49ElEfstxgl7dywZsTx0SeLW0S3n4ZHRYsP+ezBsMf3SSJKl1MDlxnxsAOxhre3LYDmJ5vedPlPz5NKBpA4XFCUl2yrEPyLUCTHCVG1SauR2N8caohDacBxZbDtpMSTDnb1WWDXXxw9nZ9/X5UM4L4vXgKH2bPH8L1OAdtQ0JpXz2pSF7eI1+KwXleg5gloI2+mKiGk4vIP3DHqX1OOI93IS4A6woXnHHkJu1SzdyK0ks/Y3lPE14Z+YPIxkryO41DeoymDQe6KLRWw6OetPWymNUjfF844IBh5vG3TTFmDDYcObYVzj/Zki2vP7LcqxWsOeauLSf9JWLHV+X87cpVN5Y5XrYkRwpRZbiZ1MF4GdhzbpDOC+smm+xz70u9jn4tt/1j8Wc2wZb9Kcm/XUb6LwmpsRdZzW8MGd02Pxx5oW6RtSMsqoQE2HNKSR9fsLzx42TkGhWkZJDPcgfusLPxnSMF1tfMcOJYW3cJU10ICC1qehEEgfd0FazVPjoSMrc26BpefG1kswiHvsAgeWX 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)(1800799009)(186009)(64100799003)(451199024)(38100700002)(6512007)(316002)(54906003)(66476007)(66946007)(6916009)(66556008)(2906002)(478600001)(36756003)(86362001)(6486002)(6666004)(82960400001)(6506007)(1076003)(83380400001)(4326008)(8936002)(5660300002)(26005)(41300700001)(2616005)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hx1JD+7EPTrGJ3kGGnp/NAVNZGV/?= =?utf-8?q?QwQ8l3KBUn/Dw7gf2/Q76KVujI04ODgExHDtFFNB1Od/xmSCauD0R3tOSEyWX4RTe?= =?utf-8?q?HX7n3BSD7/jeFjLzZgJH6o/9nLlkpyltwCGPxBvyWTN7/vJKfQ/hL2TwpYU+or7bz?= =?utf-8?q?FWLN4XuztUDO/E/XN3Iikn/Kj6dLHjqMl5uKNkjy5hIaFNOgWhLRmKVACOQs7vqbQ?= =?utf-8?q?GfSK8W7aq7ni1ip5L12f5pmgyogAU5F02xxkfJpDlKdSSn8nrU2xqy1aU95ZoMqLl?= =?utf-8?q?BRisNauwyp2xoDcwr8dZFJWouzT/LIgW6sdnz0hkGbgVMms5idnKwZm5tZKgOPywj?= =?utf-8?q?cCYq3fF7+xhDmktSp5CR39rvJx2nRHSaxqVGs9vYkKwv/IxrdCMMIJbn35sIrPzZa?= =?utf-8?q?BvuU8fRuxH8uSWEGPDUX17QreIW5Mor2r3jsXFKLfub4rUC6fxFeJITKwpNTlmkdf?= =?utf-8?q?SIgztdBfo0d5C5tPnOvA23DFX5hX3gxGGOSwyxj0y7kpJe4ctYSnjzrcVb3OwQ7BB?= =?utf-8?q?nMDlruZZ8CYD8poCxupxIFBbc3SCUo1nXNrW4tqqAeCTcR03LI2lcAiePNq5fsvgr?= =?utf-8?q?AhrIk+BpQVdlYk5/NKhtHM8EXkKi+tqwpZsRwJWGXa7jVQmek9ErtaUgUNv/uwXMe?= =?utf-8?q?4E+XUOQqT1YHDLLcDxc96I4AvuWXF/bqC9rIMVLwtAJzUlJNR8BcNOcqfyHiZRDtV?= =?utf-8?q?rsxLZLFs8p+Fu6l+QTzRrFvcUIPKIJ/RIQRS5uzk6b82a5f7NtYKQNHGPVOrh7uis?= =?utf-8?q?FkPinLjsByo9RLaTK72huH8mjeYmS60bg5upQ4+D6gOLfIN8MwYoROq1t5NaDvxMz?= =?utf-8?q?gXfHsRRgAp12lldOlcdXc6muN6Cod+Oqj/U7P+cItn1jz6m8efKUo98OPoarRaREH?= =?utf-8?q?YaQLbT28dcz0QNq4htV52nMwE+iQNJ1FOXcqOVWBtCfOoSm+n5e5GiTM9qLy4M/6E?= =?utf-8?q?1+3TpCVcb6uWtzzDYUNC28Iu5SeQ6glfgfNsS9n4IV0UJH2sIKd4IbauRWoi+DACK?= =?utf-8?q?rTNK3dLBfyBPbCk6IrmTFGyz2g2KRKKqLUaPtSy7cvmVXNg/zZNnD0YbfRDSXx8nX?= =?utf-8?q?x5hyWHU3MVgfJnxX9c0V//0WSWAW+wBSmL04wuXT2VCMzFYnUHDzTRmXvEIU+Lubu?= =?utf-8?q?qmboeWkMakElzDlB+R/Zin+3uwEykWYB53aIKgQbn4K4+SVIQAzQK8YNZNGSUyQjL?= =?utf-8?q?wNfY8t04fVvaCoCyVa3/+fCua/ftnamH+L1vNVzy5JjJMozeffWAN9i/UX2zvnwpL?= =?utf-8?q?iDfqz0QZd6mToQaJ7WhZUsnApOeswugqDlNDfyK1rUUDkuNaCXLbkDDXeMWe0nHpH?= =?utf-8?q?fXsFtQPc9Xut4ieTKGsVW0hxDlLQBoCb/l6xGvvp8Lm1jpNlDRv0ecfHnOpaGMGEj?= =?utf-8?q?hfXnB1fwoWF5QYEXJqlRkxv2pYxN/fxilb7v0XaDTNRuq8k/T/XYYi3VW0YwAYWmH?= =?utf-8?q?lgSsAy1Ppox3M4NsJgZTL7gifolE95X9VVPgERDF3ETw84vcGoNigR44NrB5ZkIpq?= =?utf-8?q?Po/JsuBxY7ShjJT7THgePm5dcOLt1cLWiw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6iwRBriVZtrHfvEeKHIxjZ5jNu/2AGFMvK9NNYz1OkGQC6YsqZll0Sz0fWGTScHIibynKwXPPC/cmGStMsi37XAdRaTBis0w/hRmh6R2R3Gcj0AeRXHLShSluq1x2C2Pgg1N5YLP5d02dZTO2qclSpl99jlRcRvILpm7H1Cve8CK73E77OAMM0icX2bCz8JNtcySSpu9SGDRNS4pKEsEJaanoYfG7ROyiDnlITG401Av6aGWJaNZMPEHphKWZB+s3PhI9rSV/oAgV39/MeojresrxcZdqOIlmZC6NhBQPypkMtFa9Ba1+rX46wGdTedbj3N4pK/smo+1UdwH9EeQsqsZA30zoVwOmSdh1Ft44PMOetIkmmbKf3sRfZ0rPxJc+PAIoT+mANf0debqIPj8iuYwaz9ON94N97UXT49Ec0OhnQUyaYhYAVg4QJmoDls0GJfGCsOYk4SpwzLoaHMPPCxm8AjvjvVYGKR5T+Id1ndt8iukaxoHMRg48zVuP5fwu/MVuMVogWNP+fFfvrUVqDLDzTlNW0e4+J1ogEJfNhQW6CrdFNnVQ0gdexFL/CDUNier4+JZ0fqZQd5uU6+FECU8jgfCWNF0U4U0UtKCGkbHXyg1S46ofBx8b5PboDBvD33iMbiWIlAxBFaOdRHrWVYvY9DD1tva9NYPS0CrZWwNnHmbUjYoMwB8mtcPv3fGbhk68jRFbwEeW4OzPrU4gzu64eAA2wsUOH9bQkM8oxhago698kOa+vZDpAPpwE2pp7R8qAUWs0P/KnYiBY2WicmeWc57Q0kXXOnWem3QJ+tVZN+WPEXQ6qvhQXzzy+/KCnnMUtDFb0qKFbtUyo8OVA== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: f14e526a-8521-4765-c1ee-08dbd4a108da X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2023 14:53:51.0311 (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: gPj6pOJtb5wFTsZR1LolaYklbAi0EOB4Z718ypD24QG5hTva9QSZyCQmEph+pAFbElyiro2f8CZpFC1j43W1Yw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR03MB5554 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. Continue to reserve PIC vectors on CPU0 only, 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 driver should be able to cope with spurious interrupts. 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 Amends: 3fba06ba9f8b ('x86/IRQ: re-use legacy vector ranges on APs') Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Changes since v2: - Put the AMD vendor checks in do_IRQ() instead of bogus_8259A_irq(). - Re-indent cpumask_copy() call in init_IRQ(). - Reword one sentence in the commit message. Changes since v1: - Do not reserved spurious PIC vectors on APs, but still check for spurious PIC interrupts. - Reword commit message. --- xen/arch/x86/i8259.c | 21 +++++++++++++++++++-- xen/arch/x86/irq.c | 11 ++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/i8259.c b/xen/arch/x86/i8259.c index ed9f55abe51e..e0fa1f96b4f2 100644 --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -222,7 +222,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 +350,23 @@ 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..c31e9b42a567 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1920,7 +1920,16 @@ void do_IRQ(struct cpu_user_regs *regs) kind = ""; if ( !(vector >= FIRST_LEGACY_VECTOR && vector <= LAST_LEGACY_VECTOR && - !smp_processor_id() && + (!smp_processor_id() || + /* + * 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. + */ + (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | + X86_VENDOR_HYGON))) && bogus_8259A_irq(vector - FIRST_LEGACY_VECTOR)) ) { printk("CPU%u: No irq handler for vector %02x (IRQ %d%s)\n",