xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Varad Gautam <vrd@amazon.de>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Hongyan Xia <hongyxia@amazon.com>,
	xen-devel@lists.xenproject.org,
	Paul Durrant <pdurrant@amazon.co.uk>
Subject: Re: [Xen-devel] [PATCH 1/8] x86/smp: reset x2apic_enabled in smp_send_stop()
Date: Mon, 3 Feb 2020 17:18:29 +0100	[thread overview]
Message-ID: <20200203161829.GC4679@Air-de-Roger> (raw)
In-Reply-To: <20200201003303.2363081-1-dwmw2@infradead.org>

On Sat, Feb 01, 2020 at 12:32:56AM +0000, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> 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=n   Not tainted ]----
> (XEN) CPU:    0
> (XEN) RIP:    e008:[<ffff82d08026c139>] apic_timer_interrupt+0x29/0x40
> (XEN) RFLAGS: 0000000000010046   CONTEXT: hypervisor
> (XEN) rax: 0000000000000000   rbx: 00000000000000fa   rcx: 000000000000080b
> …
> (XEN) Xen code around <ffff82d08026c139> (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
> …
> (XEN) Xen call trace:
> (XEN)    [<ffff82d08026c139>] R apic_timer_interrupt+0x29/0x40
> (XEN)    [<ffff82d080283825>] S do_IRQ+0x95/0x750
> …
> (XEN)    [<ffff82d0802a0ad2>] 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 <dwmw@amazon.co.uk>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks!

> ---
>  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 = (current_local_apic_mode() == APIC_MODE_X2APIC);

You could do this only when kexecing, but it's safe to do
unconditionally, and might be helpful if we also decide to play with
the lapic mode even when not kexecing.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-02-03 16:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-01  0:32 [Xen-devel] [PATCH 0/8] Early cleanups and bug fixes in preparation for live update David Woodhouse
2020-02-01  0:32 ` [Xen-devel] [PATCH 1/8] x86/smp: reset x2apic_enabled in smp_send_stop() David Woodhouse
2020-02-03 16:18   ` Roger Pau Monné [this message]
2020-02-01  0:32 ` [Xen-devel] [PATCH 2/8] x86/setup: Fix badpage= handling for memory above HYPERVISOR_VIRT_END David Woodhouse
2020-02-03 10:57   ` Julien Grall
2020-02-20 15:38   ` Jan Beulich
2020-03-06 22:52   ` Julien Grall
2020-02-01  0:32 ` [Xen-devel] [PATCH 3/8] x86/setup: Don't skip 2MiB underneath relocated Xen image David Woodhouse
2020-02-01  0:32 ` [Xen-devel] [PATCH 4/8] xen/vmap: allow vm_init_type to be called during early_boot David Woodhouse
2020-02-13 10:36   ` Julien Grall
2020-02-21 16:42   ` Jan Beulich
2020-02-01  0:33 ` [Xen-devel] [PATCH 5/8] xen/vmap: allow vmap() to be called during early boot David Woodhouse
2020-02-03 14:00   ` Julien Grall
2020-02-03 16:37     ` David Woodhouse
2020-02-04 11:00       ` George Dunlap
2020-02-04 11:06         ` David Woodhouse
2020-02-04 11:18           ` David Woodhouse
2020-02-09 18:19       ` Julien Grall
2020-02-21 16:46   ` Jan Beulich
2020-02-01  0:33 ` [Xen-devel] [PATCH 6/8] x86/setup: move vm_init() before end_boot_allocator() David Woodhouse
2020-02-03 11:10   ` Xia, Hongyan
2020-02-03 14:03     ` David Woodhouse
2020-02-21 16:48   ` Jan Beulich
2020-02-01  0:33 ` [Xen-devel] [PATCH 7/8] x86/setup: simplify handling of initrdidx when no initrd present David Woodhouse
2020-02-13 10:47   ` Julien Grall
2020-02-21 16:59   ` Jan Beulich
2020-02-24 13:31     ` Julien Grall
2020-02-25 12:34       ` Jan Beulich
2020-02-26  7:13         ` Julien Grall
2020-02-26  8:37           ` Jan Beulich
2020-02-01  0:33 ` [Xen-devel] [PATCH 8/8] x86/setup: lift dom0 creation out into create_dom0() function David Woodhouse
2020-02-03 14:28   ` Julien Grall
2020-02-03 15:03     ` David Woodhouse
2020-02-21 17:06   ` Jan Beulich
2020-03-17 23:45     ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200203161829.GC4679@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dwmw2@infradead.org \
    --cc=hongyxia@amazon.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=pdurrant@amazon.co.uk \
    --cc=sstabellini@kernel.org \
    --cc=vrd@amazon.de \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).