From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Tim Deegan <tim@xen.org>, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 3/3] x86/nmi: Fix shootdown of pcpus running in VMX non-root mode
Date: Wed, 11 Feb 2015 12:13:07 +0000 [thread overview]
Message-ID: <54DB4753.6010102@citrix.com> (raw)
In-Reply-To: <54DB44EE020000780005EF90@mail.emea.novell.com>
On 11/02/15 11:02, Jan Beulich wrote:
>>>> On 10.02.15 at 18:12, <andrew.cooper3@citrix.com> wrote:
>> @@ -127,38 +128,26 @@ static void nmi_shootdown_cpus(void)
>>
>> cpumask_andnot(&waiting_to_crash, &cpu_online_map, cpumask_of(cpu));
>>
>> - /* Change NMI trap handlers. Non-crashing pcpus get nmi_crash which
>> - * invokes do_nmi_crash (above), which cause them to write state and
>> - * fall into a loop. The crashing pcpu gets the nop handler to
>> - * cause it to return to this function ASAP.
>> + /*
>> + * Disable IST for MCEs to avoid stack corruption race conditions, and
>> + * change the NMI hanlder to a nop to avoid deviation from this codepath.
> handler
>
>> */
>> - for ( i = 0; i < nr_cpu_ids; i++ )
>> - {
>> - if ( idt_tables[i] == NULL )
>> - continue;
>> -
>> - if ( i == cpu )
>> - {
>> - /*
>> - * Disable the interrupt stack tables for this cpu's MCE and NMI
>> - * handlers, and alter the NMI handler to have no operation.
>> - * Disabling the stack tables prevents stack corruption race
>> - * conditions, while changing the handler helps prevent cascading
>> - * faults; we are certainly going to crash by this point.
>> - *
>> - * This update is safe from a security point of view, as this pcpu
>> - * is never going to try to sysret back to a PV vcpu.
>> - */
>> - _set_gate_lower(&idt_tables[i][TRAP_nmi],
>> - SYS_DESC_irq_gate, 0, &trap_nop);
>> - set_ist(&idt_tables[i][TRAP_machine_check], IST_NONE);
>> - }
>> - else
>> - {
>> - /* Do not update stack table for other pcpus. */
>> - _update_gate_addr_lower(&idt_tables[i][TRAP_nmi], &nmi_crash);
>> - }
>> - }
>> + _set_gate_lower(&idt_tables[cpu][TRAP_nmi],
>> + SYS_DESC_irq_gate, 0, &trap_nop);
>> + set_ist(&idt_tables[cpu][TRAP_machine_check], IST_NONE);
>> +
>> + /*
>> + * Ideally would be:
>> + * exception_table[TRAP_nmi] = &do_nmi_crash;
>> + *
>> + * but the exception_table is read only. Borrow and unused fixmap entry
> ... an unused ...
>
>> + * to construct a writable mapping.
>> + */
>> + set_fixmap(FIX_TBOOT_MAP_ADDRESS, __pa(&exception_table[TRAP_nmi]));
>> + write_atomic((unsigned long *)
>> + (fix_to_virt(FIX_TBOOT_MAP_ADDRESS) +
>> + ((unsigned long)&exception_table[TRAP_nmi] & ~PAGE_MASK)),
>> + (unsigned long)&do_nmi_crash);
> By converting the first cast to (void **) or even
> (typeof(do_nmi_crash) **) it would seem possible to drop the last
> cast altogether. While at it you could also drop the unnecessary &.
None of these casts can be dropped, because write_atomic() uses explicit
uint??_t casts. Gcc objects because of -Werror=pointer-to-int-cast.
~Andrew
next prev parent reply other threads:[~2015-02-11 12:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 17:12 [PATCH 0/3] Fixes to NMI shootdown Andrew Cooper
2015-02-10 17:12 ` [PATCH 1/3] x86/traps: Export the exception_table[] function pointer table to C Andrew Cooper
2015-02-10 17:12 ` [PATCH 2/3] x86/traps: Use write_atomic() when updating potentially-live descriptors Andrew Cooper
2015-02-11 10:46 ` Jan Beulich
2015-02-11 15:06 ` [PATCH v2 2/3] x86/traps: Avoid interleaved writes " Andrew Cooper
2015-02-10 17:12 ` [PATCH 3/3] x86/nmi: Fix shootdown of pcpus running in VMX non-root mode Andrew Cooper
2015-02-11 11:02 ` Jan Beulich
2015-02-11 12:13 ` Andrew Cooper [this message]
2015-02-11 13:22 ` Jan Beulich
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=54DB4753.6010102@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.