From nobody Tue Feb 10 02:00:35 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517241069313.09626545315666; Fri, 31 Jan 2020 16:34:01 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgj7-0006Ls-20; Sat, 01 Feb 2020 00:33:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgj5-0006Ke-3M for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:31 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aebf9fe-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:08 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007nw-0B; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009uks-6M; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 6aebf9fe-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lqMSMeVhKSgPkcVvfREuVIy712hBBzMUz6KHWtaUJ6o=; b=VNjT65H8BTvvScEhCYnSNWyjs8 s7+jsssKumAgt3XOQJL3P4rgH6yuyixBpBxIFNrAsAu+peJme8cPwMz3wL9KP1ianREkmyxnWGC02 qxbJT/Ke3Hrrr1rhg0nS266EO3nwAqFPKNt6GQH83sFFY+2OppMSDBziSRPZG0qV4YrsqvqYI0UWO yLo/IytfJkHcgtvpt+ZfakHECZN+VF6lMgo4B5UZb/QWG7qrFL2QSzI4uTUj7bIoccpxqkw+OUgcz o+RkYlFO0FAymArBv8+5IFzk6049nD4eUGnXCUXM6mgbhuQHyGQ+gQpPnp+vE+y6oBvXqDt0U9KlX +NiPQpYw==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:32:56 +0000 Message-Id: <20200201003303.2363081-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 1/8] x86/smp: reset x2apic_enabled in smp_send_stop() 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Woodhouse Just before smp_send_stop() re-enables interrupts when shutting down for reboot or kexec, it calls __stop_this_cpu() which in turn calls disable_local_APIC(), which puts the APIC back in to the mode Xen found it in at boot. If that means turning x2APIC off and going back into xAPIC mode, then a timer interrupt occurring just after interrupts come back on will lead to a GP# when apic_timer_interrupt() attempts to ack the IRQ through the EOI register in x2APIC MSR 0x80b: (XEN) Executing kexec image on cpu0 (XEN) ----[ Xen-4.14-unstable x86_64 debug=3Dn Not tainted ]---- (XEN) CPU: 0 (XEN) RIP: e008:[] apic_timer_interrupt+0x29/0x40 (XEN) RFLAGS: 0000000000010046 CONTEXT: hypervisor (XEN) rax: 0000000000000000 rbx: 00000000000000fa rcx: 000000000000080b =E2=80=A6 (XEN) Xen code around (apic_timer_interrupt+0x29/0x40): (XEN) c0 b9 0b 08 00 00 89 c2 <0f> 30 31 ff e9 0e c9 fb ff 0f 1f 40 00 66 = 2e 0f =E2=80=A6 (XEN) Xen call trace: (XEN) [] R apic_timer_interrupt+0x29/0x40 (XEN) [] S do_IRQ+0x95/0x750 =E2=80=A6 (XEN) [] S smp_send_stop+0x42/0xd0 We can't clear the global x2apic_enabled variable in disable_local_APIC() itself because that runs on each CPU. Instead, correct it (by using current_local_apic_mode()) in smp_send_stop() while interrupts are still disabled immediately after calling __stop_this_cpu() for the boot CPU, after all other CPUs have been stopped. cf: d639bdd9bbe ("x86/apic: Disable the LAPIC later in smp_send_stop()") ... which didn't quite fix it completely. Signed-off-by: David Woodhouse Reviewed-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/smp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index 65eb7cbda8..fac295fa6f 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -354,6 +354,7 @@ void smp_send_stop(void) disable_IO_APIC(); hpet_disable(); __stop_this_cpu(); + x2apic_enabled =3D (current_local_apic_mode() =3D=3D APIC_MODE_X2A= PIC); local_irq_enable(); } } --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel