[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190718195850.GU20882@gate.crashing.org>
Date: Thu, 18 Jul 2019 14:58:50 -0500
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Alexey Kardashevskiy <aik@...abs.ru>
Cc: Thiago Jung Bauermann <bauerman@...ux.ibm.com>,
linuxppc-dev@...ts.ozlabs.org,
Anshuman Khandual <anshuman.linux@...il.com>,
Mike Anderson <andmike@...ux.ibm.com>,
Ram Pai <linuxram@...ibm.com>, linux-kernel@...r.kernel.org,
Claudio Carvalho <cclaudio@...ux.ibm.com>,
Paul Mackerras <paulus@...ba.org>,
Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v2 03/13] powerpc/prom_init: Add the ESM call to prom_init
(Sorry to hijack your reply).
On Thu, Jul 18, 2019 at 06:11:48PM +1000, Alexey Kardashevskiy wrote:
> On 13/07/2019 16:00, Thiago Jung Bauermann wrote:
> >From: Ram Pai <linuxram@...ibm.com>
> >+static int enter_secure_mode(unsigned long kbase, unsigned long fdt)
> >+{
> >+ register uint64_t func asm("r3") = UV_ESM;
> >+ register uint64_t arg1 asm("r4") = (uint64_t)kbase;
> >+ register uint64_t arg2 asm("r5") = (uint64_t)fdt;
>
> What does UV do with kbase and fdt precisely? Few words in the commit
> log will do.
>
> >+
> >+ asm volatile("sc 2\n"
> >+ : "=r"(func)
> >+ : "0"(func), "r"(arg1), "r"(arg2)
> >+ :);
> >+
> >+ return (int)func;
>
> And why "func"? Is it "function"? Weird name. Thanks,
Maybe the three vars should just be called "r3", "r4", and "r5" --
r3 is used as return value as well, so "func" isn't a great name for it.
Some other comments about this inline asm:
The "\n" makes the generated asm look funny and has no other function.
Instead of using backreferences you can use a "+" constraint, "inout".
Empty clobber list is strange.
Casts to the return type, like most other casts, are an invitation to
bugs and not actually useful.
So this can be written
static int enter_secure_mode(unsigned long kbase, unsigned long fdt)
{
register uint64_t r3 asm("r3") = UV_ESM;
register uint64_t r4 asm("r4") = kbase;
register uint64_t r4 asm("r5") = fdt;
asm volatile("sc 2" : "+r"(r3) : "r"(r4), "r"(r5));
return r3;
}
(and it probably should use u64 instead of both uint64_t and unsigned long?)
Segher
Powered by blists - more mailing lists