All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Nathan Lynch <nathanl@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, anton@samba.org,
	npiggin@gmail.com, dja@axtens.net
Subject: Re: [PATCH 1/2] powerpc/64s: Fix crashes when toggling stf barrier
Date: Wed, 05 May 2021 12:48:57 +1000	[thread overview]
Message-ID: <87zgx999pi.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <878s4uf79w.fsf@linux.ibm.com>

Nathan Lynch <nathanl@linux.ibm.com> writes:
> Michael Ellerman <mpe@ellerman.id.au> writes:
>> -void do_stf_barrier_fixups(enum stf_barrier_type types)
>> +static int __do_stf_barrier_fixups(void *data)
>>  {
>> +	enum stf_barrier_type types = (enum stf_barrier_type)data;
>> +
>>  	do_stf_entry_barrier_fixups(types);
>>  	do_stf_exit_barrier_fixups(types);
>> +
>> +	return 0;
>> +}
>> +
>> +void do_stf_barrier_fixups(enum stf_barrier_type types)
>> +{
>> +	/*
>> +	 * The call to the fallback entry flush, and the fallback/sync-ori exit
>> +	 * flush can not be safely patched in/out while other CPUs are executing
>> +	 * them. So call __do_stf_barrier_fixups() on one CPU while all other CPUs
>> +	 * spin in the stop machine core with interrupts hard disabled.
>> +	 */
>> +	stop_machine_cpuslocked(__do_stf_barrier_fixups, (void *)types, NULL);
>
> Would it be preferable to avoid the explicit casts:
>
> 	stop_machine_cpuslocked(__do_stf_barrier_fixups, &types, NULL);
>
> ...
>
> static int __do_stf_barrier_fixups(void *data)
> {
> 	enum stf_barrier_type *types = data;
>
>  	do_stf_entry_barrier_fixups(*types);
>  	do_stf_exit_barrier_fixups(*types);
>
> ?

Yes.

That will also avoid the pesky issue of undefined behaviour :facepalm:

> post_mobility_fixup() does cpus_read_unlock() before calling
> pseries_setup_security_mitigations(), I think that will need to be
> changed?

I don't think so.

I'm using stop_machine_cpuslocked() but that's because I'm a goose and
forgot to switch to stop_machine() after I reworked the code to not take
cpus_read_lock() by hand. I really shouldn't send patches after 11pm.

I don't think it's important to keep the cpus lock held from where we
take it in post_mobility_fixup(). If some CPUs come or go between there
and here that's fine.

I'll send a v2.

cheers

  reply	other threads:[~2021-05-05  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 13:42 [PATCH 1/2] powerpc/64s: Fix crashes when toggling stf barrier Michael Ellerman
2021-05-04 13:42 ` [PATCH 2/2] powerpc/64s: Fix crashes when toggling entry flush barrier Michael Ellerman
2021-05-05 20:44   ` kernel test robot
2021-05-04 22:44 ` [PATCH 1/2] powerpc/64s: Fix crashes when toggling stf barrier Nathan Lynch
2021-05-05  2:48   ` Michael Ellerman [this message]
2021-05-05  2:55     ` Nathan Lynch
2021-05-05 19:37 ` kernel test robot

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=87zgx999pi.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=anton@samba.org \
    --cc=dja@axtens.net \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nathanl@linux.ibm.com \
    --cc=npiggin@gmail.com \
    /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.