From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: tegra: add basic SecureOS support
Date: Mon, 10 Jun 2013 12:20:50 +0100 [thread overview]
Message-ID: <20130610112050.GB3674@localhost.localdomain> (raw)
In-Reply-To: <CAAVeFuKsa=GsxexQOSOYPYvkAXaEZXfW1+zRmv25CtFEY=T_GQ@mail.gmail.com>
On Mon, Jun 10, 2013 at 05:05:04PM +0900, Alexandre Courbot wrote:
> On Sat, Jun 8, 2013 at 3:13 AM, Dave Martin <Dave.Martin@arm.com> wrote:
> > One way to make the backend generic would be to have something like
> > one of the following (some syntax omitted due to laziness):
> >
> > u32 __naked __call_smc(u32 r0, ...)
> > {
> > asm volatile (
> > stmfd sp!, {r4-r11,lr}
> > smc #0
> > ldmfd sp!, {r4-r11,pc}
> > ::: "memory"
> > );
> > }
> >
> > /* The above works for up to 4 u32 arguments */
> >
> > u32 __naked __call_smc(u32 r0, ...)
> > {
> > asm volatile (
> > mov ip, sp
> > stmfd sp!, {r4-r11,lr}
> > ldmia ip, {r4-r11}
> > smc #0
> > ldmfd sp!, {r4-r11,pc}
> > ::: "memory"
> > );
> > }
> >
> > /*
> > * Works for up to 13 u32 arguments, provided the stack is deep
> > * enough to provide suitable garbage data to fill the registers
> > * if the caller supplied fewer arguments (a bit of a hack)
> > */
> >
> > u32 __naked __call_smc(struct pt_regs *regs) {
> >
> > asm(
> > stmfd sp!, {r4-r11,lr}
> > /* load regs from <regs> */
> > smc #0
> > /* save regs back to <regs> */
> > ldmfd sp!, {r4-r11,pc}
> > );
> > }
> >
> > /*
> > * Most generic, least-efficient version.
> > * Can return up to 13 u32 results instead of just one.
> > * For convenience, the r0 value returned by the SMC could be
> > * left in r0 so that it also determines the return value of the
> > * function.
> > *
> > * Most of the time, SMC shouldn't be called on any hot path,
> > * otherwise the performance battle is already lost -- so it may
> > * not be crucial to reach the maximum possible efficiency for
> > * these calls.
> > */
> >
> >
> > A particular firmware's Linux glue code might have to put extra stuff
> > around calls to generic_smc, but at least generic_smc itself wouldn't
> > need to be reinvented, and the firmware-specific glue code could usually
> > avoid asm.
> >
> >> Another example is the function that Tomasz shown
> >> (https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/mach-exynos/exynos-smc.S?id=refs/tags/next-20130606
> >> ), which preserves r4-r11 but also assumes r3 is an argument - that's
> >> again another slightly different convention.
> >
> > ... for which the above implementations of __call_smc() should work too.
> >
> >> All in all the needs of the various firmwares might end up being just
> >> different enough that we need to have a different backend for each of
> >> them. The firmware_ops defined in arch/arm/include/asm/firmware.h
> >> perform the abstraction at a higher level, which seems more fit here
> >> IMHO.
> >>
> >> Alex.
> >
> > Indeed. If you think you could work with one of the above generics, we
> > could try it and see what it looks like though.
> >
> > If it's an awkward fit, I might be being too optimistic.
>
> I agree that your versions would most likely work in our (and probably
> many others) case. But I wonder if individual platforms will not
> prefer to sacrifice the ease of use of a generic version for the
> ability to write faster code that will just preserve what is needed
> (whether that performance gain is justified or not is of course
> subject to debate). I don't have enough hindsight to decide which
> approach is the best, but until we have more examples of firmwares
> that would justify such a factorization, I think I'd like to go with
> our own version first - for there is already more than enough to fix
> in this patch. :)
Sure, I'll have another think based on your repost.
Cheers
---Dave
next prev parent reply other threads:[~2013-06-10 11:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 7:28 [PATCH] ARM: tegra: add basic SecureOS support Alexandre Courbot
2013-06-06 9:35 ` Russell King - ARM Linux
2013-06-06 10:23 ` Alex Courbot
2013-06-06 10:17 ` Tomasz Figa
2013-06-06 10:37 ` Alex Courbot
2013-06-06 16:28 ` Stephen Warren
2013-06-06 11:11 ` Dave Martin
2013-06-06 11:02 ` Dave Martin
2013-06-07 7:25 ` Alexandre Courbot
2013-06-07 17:30 ` Dave Martin
2013-06-10 7:47 ` Alexandre Courbot
2013-06-10 9:10 ` Russell King - ARM Linux
2013-06-06 12:26 ` Jassi Brar
2013-06-07 7:13 ` Alexandre Courbot
2013-06-07 8:52 ` Jassi Brar
2013-06-06 16:44 ` Stephen Warren
2013-06-06 18:08 ` Dave Martin
2013-06-06 18:29 ` Stephen Warren
2013-06-07 17:47 ` Dave Martin
2013-06-07 9:03 ` Alexandre Courbot
2013-06-07 18:13 ` Dave Martin
2013-06-10 8:05 ` Alexandre Courbot
2013-06-10 11:20 ` Dave Martin [this message]
2013-06-07 8:11 ` Alexandre Courbot
2013-06-07 16:33 ` Stephen Warren
2013-06-10 8:11 ` Alexandre Courbot
2013-06-10 9:14 ` Russell King - ARM Linux
2013-06-10 16:35 ` Stephen Warren
2013-06-10 11:16 ` Dave Martin
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=20130610112050.GB3674@localhost.localdomain \
--to=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.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