From: "Leif Lindholm" <leif@nuviainc.com>
To: Rebecca Cran <rebecca@nuviainc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: devel@edk2.groups.io, Sami Mujawar <sami.mujawar@arm.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Subject: Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
Date: Tue, 9 Nov 2021 11:57:51 +0000 [thread overview]
Message-ID: <20211109115751.5inrccjr2ze4ql63@leviathan> (raw)
In-Reply-To: <bca0a4eb-a8a0-5e71-e705-428ec00ecde4@nuviainc.com>
On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
> Could I have some reviews on this please?
I'm all for it. It's clunky, but less clunky than the situation
without, and it improves readability at call sites.
Ard had some reservations for v1 not actually adding any users.
Ard - do you like it any better now Rebecca's added some?
/
Leif
> Rebecca Cran
>
>
> On 11/1/21 4:11 PM, Rebecca Cran wrote:
> > Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> > arguments.
> > The functions return up to 3 values.
> >
> > Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> > ---
> > ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> > ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> > ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> > ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> > 4 files changed, 283 insertions(+)
> >
> > diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> > index ced60b3c1147..343ae7f40ad2 100644
> > --- a/ArmPkg/Include/Library/ArmSmcLib.h
> > +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> > @@ -1,5 +1,6 @@
> > /** @file
> > *
> > +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> > *
> > * SPDX-License-Identifier: BSD-2-Clause-Patent
> > @@ -37,4 +38,76 @@ ArmCallSmc (
> > IN OUT ARM_SMC_ARGS *Args
> > );
> > +/** Trigger an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > #endif // ARM_SMC_LIB_H_
> > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > new file mode 100644
> > index 000000000000..d596003a857e
> > --- /dev/null
> > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > @@ -0,0 +1,122 @@
> > +/** @file
> > + SMC helper functions.
> > +
> > + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Library/ArmSmcLib.h>
> > +
> > +/** Triggers an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + )
> > +{
> > + ARM_SMC_ARGS Args;
> > + UINTN ErrorCode;
> > +
> > + Args.Arg0 = Function;
> > +
> > + if (Arg1 != NULL) {
> > + Args.Arg1 = *Arg1;
> > + }
> > + if (Arg2 != NULL) {
> > + Args.Arg2 = *Arg2;
> > + }
> > + if (Arg3 != NULL) {
> > + Args.Arg3 = *Arg3;
> > + }
> > +
> > + ArmCallSmc (&Args);
> > +
> > + ErrorCode = Args.Arg0;
> > +
> > + if (Arg1 != NULL) {
> > + *Arg1 = Args.Arg1;
> > + }
> > + if (Arg2 != NULL) {
> > + *Arg2 = Args.Arg2;
> > + }
> > + if (Arg3 != NULL) {
> > + *Arg3 = Args.Arg3;
> > + }
> > +
> > + return ErrorCode;
> > +}
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > index 4f4b09f4528a..a89f9203fb7e 100644
> > --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > @@ -20,6 +20,9 @@
> > [Sources.AARCH64]
> > AArch64/ArmSmc.S
> > +[Sources]
> > + ArmSmc.c
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> > ArmPkg/ArmPkg.dec
> > diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > index 2d79aadaf1fa..ca1b8830a119 100644
> > --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > @@ -1,4 +1,5 @@
> > //
> > +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> > // Copyright (c) 2016, Linaro Limited. All rights reserved.
> > //
> > // SPDX-License-Identifier: BSD-2-Clause-Patent
> > @@ -7,6 +8,7 @@
> > #include <Base.h>
> > #include <Library/ArmSmcLib.h>
> > +#include <IndustryStandard/ArmStdSmc.h>
> > VOID
> > ArmCallSmc (
> > @@ -14,3 +16,86 @@ ArmCallSmc (
> > )
> > {
> > }
> > +
> > +/** Triggers an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
next prev parent reply other threads:[~2021-11-09 11:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 22:11 [PATCH v2 0/2] ArmPkg: Add SMC helper functions Rebecca Cran
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
2021-11-09 1:56 ` Rebecca Cran
2021-11-09 11:57 ` Leif Lindholm [this message]
2021-11-09 12:15 ` Ard Biesheuvel
2021-12-09 22:54 ` Rebecca Cran
2021-12-13 11:49 ` Ard Biesheuvel
2021-12-13 12:26 ` Sami Mujawar
2021-12-13 12:31 ` Sami Mujawar
2021-11-01 22:11 ` [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions Rebecca Cran
2021-12-13 12:26 ` Sami Mujawar
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-list 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=20211109115751.5inrccjr2ze4ql63@leviathan \
--to=devel@edk2.groups.io \
/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