From patchwork Tue Aug 6 13:13:46 2019 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: 11078903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8A4C14E5 for ; Tue, 6 Aug 2019 13:15:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFB90287BD for ; Tue, 6 Aug 2019 13:15:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3ED62899D; Tue, 6 Aug 2019 13:15:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C6C12899E for ; Tue, 6 Aug 2019 13:15:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1huzI6-00057Y-Ru; Tue, 06 Aug 2019 13:14:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1huzI5-00057S-3q for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 13:14:13 +0000 X-Inumbo-ID: 134184aa-b84c-11e9-b7c9-9710ebf7bdda Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 134184aa-b84c-11e9-b7c9-9710ebf7bdda; Tue, 06 Aug 2019 13:14:09 +0000 (UTC) Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: hkI9n7x6IVE0lGqJ7xtXQ0h/ZOC1cD9MmTK/OCDeGbOTgXjYIB/5+5BqwjUapgVxPyQlMxnrQJ mr5xPWMIbaZRJb00UEcbZbmy/zyEas3Yqv/kuWK33uMgJw62/fZup3i4Cj41YmXHJheB3zTytW fVk8n2hO11AFwEOHmg45dM7KovDIkn2zQedKKx83+1qCqEl6SUvG6lrH0ZYi9Rco9zoF9T1A+X v0jq4VJG61owFI2frToB/57w7RlrML6QOkML0I6iqGMd+64YwUrDnhaeO7cluPlHzHZMmvSQtb iRA= X-SBRS: 2.7 X-MesageID: 4087361 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,353,1559534400"; d="scan'208";a="4087361" From: Roger Pau Monne To: Date: Tue, 6 Aug 2019 15:13:46 +0200 Message-ID: <20190806131346.50881-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/apic: enable x2APIC mode before doing any setup X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Current code calls apic_x2apic_probe which does some initialization and setup before having enabled x2APIC mode (if it's not already enabled by the firmware). This can lead to issues if the APIC ID doesn't match the x2APIC ID, as apic_x2apic_probe calls init_apic_ldr_x2apic_cluster which depending on the APIC mode might set cpu_2_logical_apicid using the APIC ID instead of the x2APIC ID (because x2APIC might not be enabled yet). Fix this by enabling x2APIC before calling apic_x2apic_probe. As a remark, this was discovered while I was trying to figure out why one of my test boxes didn't report any iommu faults. The root cause was that the iommu MSI address field was set using the stale value in cpu_2_logical_apicid, and thus the iommu fault interrupt would get lost. Even if the MSI address field gets sets to a correct value afterwards as soon as a single iommu fault is pending no further interrupts would get injected, so losing a single iommu fault interrupt is fatal. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu --- xen/arch/x86/apic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index 9c3c998d34..bd69299a27 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -952,17 +952,17 @@ void __init x2apic_bsp_setup(void) force_iommu = 1; - orig_name = genapic.name; - genapic = *apic_x2apic_probe(); - if ( genapic.name != orig_name ) - printk("Switched to APIC driver %s\n", genapic.name); - if ( !x2apic_enabled ) { x2apic_enabled = true; __enable_x2apic(); } + orig_name = genapic.name; + genapic = *apic_x2apic_probe(); + if ( genapic.name != orig_name ) + printk("Switched to APIC driver %s\n", genapic.name); + restore_out: restore_IO_APIC_setup(ioapic_entries); unmask_8259A();