On 23.06.2023 16:41, Shawn Anastasio wrote:
> On 6/23/23 1:34 AM, Jan Beulich wrote:
>> On 23.06.2023 03:26, Shawn Anastasio wrote:
>>> On 6/22/23 5:49 PM, Andrew Cooper wrote:
>>>> On 22/06/2023 9:57 pm, Shawn Anastasio wrote:
>>>>> --- /dev/null
>>>>> +++ b/xen/arch/ppc/setup.c
>>>>> @@ -0,0 +1,13 @@
>>>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>>>> +#include <xen/init.h>
>>>>> +
>>>>> +void __init noreturn start_xen(unsigned long r3, unsigned long r4,
>>>>> +                               unsigned long r5, unsigned long r6,
>>>>> +                               unsigned long r7)
>>>>> +{
>>>>> +    for ( ;; )
>>>>> +        /* Set current hardware thread to very low priority */
>>>>> +        asm volatile("or %r31, %r31, %r31");
>>>>
>>>> Is there something magic about the OR instruction, or something magic
>>>> about %r31?
>>>
>>> Using the OR instruction with all three operands equal is of course a
>>> no-op, but when using certain registers it can have a separate magic
>>> side effect.
>>>
>>> `or r31,31,31` is one such form that sets the Program Priority Register
>>> to "very low" priority. Of course here where we don't have SMP going
>>> there's not much point in using this over the standard side effect-less
>>> no-op (`or r0,r0,r0` or just `nop`).
>>>
>>> For a table of these magic OR forms, you can see page 836 of the Power
>>> ISA 3.0B:
>>> https://wiki.raptorcs.com/w/images/c/cb/PowerISA_public.v3.0B.pdf
>>
>> I have 3.1 to hand, and it looks like they were dropped from there?
>> Otherwise I was meaning to say that it's a shame gas doesn't support
>> these.
> 
> No, they're still present in ISA 3.1B. See page 1084, Book II Chapter
> 3 Section 2.

Ah, I see. I was searching for the pseudo mnemonics that I had
found elsewhere at some point (which are what I would hope gas
could support, but then of course they first need to be
mentioned in the doc).

>> Finally, as a nit: Style above is lacking several blanks. One
>> between the two semicolons, and a total of three in the asm().
> 
> Just to be sure, would the following be correct?
> 
>     for ( ; ; )
>         /* Set current hardware thread to very low priority */
>         asm volatile ( "or %r31, %r31, %r31" );
> 
> Not including the refactor of that instruction to a macro, of course.

Yes, this looks correct now. Our style is perhaps a little
unusual; at least I'm not aware of another project using the
same, although I have the vague feeling that someone once
mentioned a possible origin.

Jan

Reply via email to