All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Marc Zyngier <maz@kernel.org>, "Theodore Ts'o" <tytso@mit.edu>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Mark Brown <broonie@kernel.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	kvmarm <kvmarm@lists.cs.columbia.edu>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 3/5] ARM: implement support for SMCCC TRNG entropy source
Date: Mon, 15 Mar 2021 13:02:35 +0100	[thread overview]
Message-ID: <CAMj1kXENEpQMWXCxDa28mC0qqNubVFE42VvLPm-NDWTOpRtUiQ@mail.gmail.com> (raw)
In-Reply-To: <20210106103453.152275-4-andre.przywara@arm.com>

On Wed, 6 Jan 2021 at 11:35, Andre Przywara <andre.przywara@arm.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Implement arch_get_random_seed_*() for ARM based on the firmware
> or hypervisor provided entropy source described in ARM DEN0098.
>
> This will make the kernel's random number generator consume entropy
> provided by this interface, at early boot, and periodically at
> runtime when reseeding.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> [Andre: rework to be initialised by the SMCCC firmware driver]
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I think this one could be dropped into rmk's patch tracker now, right?


> ---
>  arch/arm/Kconfig                  |  4 ++
>  arch/arm/include/asm/archrandom.h | 64 +++++++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 138248999df7..bfe642510b0a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1644,6 +1644,10 @@ config STACKPROTECTOR_PER_TASK
>           Enable this option to switch to a different method that uses a
>           different canary value for each task.
>
> +config ARCH_RANDOM
> +       def_bool y
> +       depends on HAVE_ARM_SMCCC_DISCOVERY
> +
>  endmenu
>
>  menu "Boot options"
> diff --git a/arch/arm/include/asm/archrandom.h b/arch/arm/include/asm/archrandom.h
> index a8e84ca5c2ee..f3e96a5b65f8 100644
> --- a/arch/arm/include/asm/archrandom.h
> +++ b/arch/arm/include/asm/archrandom.h
> @@ -2,9 +2,73 @@
>  #ifndef _ASM_ARCHRANDOM_H
>  #define _ASM_ARCHRANDOM_H
>
> +#ifdef CONFIG_ARCH_RANDOM
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/kernel.h>
> +
> +#define ARM_SMCCC_TRNG_MIN_VERSION     0x10000UL
> +
> +extern bool smccc_trng_available;
> +
> +static inline bool __init smccc_probe_trng(void)
> +{
> +       struct arm_smccc_res res;
> +
> +       arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_VERSION, &res);
> +       if ((s32)res.a0 < 0)
> +               return false;
> +       if (res.a0 >= ARM_SMCCC_TRNG_MIN_VERSION) {
> +               /* double check that the 32-bit flavor is available */
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_FEATURES,
> +                                    ARM_SMCCC_TRNG_RND32,
> +                                    &res);
> +               if ((s32)res.a0 >= 0)
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_long(unsigned long *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_int(unsigned int *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
> +{
> +       struct arm_smccc_res res;
> +
> +       if (smccc_trng_available) {
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_RND32, 8 * sizeof(*v), &res);
> +
> +               if (res.a0 != 0)
> +                       return false;
> +
> +               *v = res.a3;
> +               return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
> +{
> +       return arch_get_random_seed_long((unsigned long *)v);
> +}
> +
> +
> +#else /* !CONFIG_ARCH_RANDOM */
> +
>  static inline bool __init smccc_probe_trng(void)
>  {
>         return false;
>  }
>
> +#endif /* CONFIG_ARCH_RANDOM */
>  #endif /* _ASM_ARCHRANDOM_H */
> --
> 2.17.1
>

WARNING: multiple messages have this Message-ID (diff)
From: Ard Biesheuvel <ardb@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Marc Zyngier <maz@kernel.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Theodore Ts'o <tytso@mit.edu>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Russell King <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Will Deacon <will@kernel.org>,
	kvmarm <kvmarm@lists.cs.columbia.edu>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 3/5] ARM: implement support for SMCCC TRNG entropy source
Date: Mon, 15 Mar 2021 13:02:35 +0100	[thread overview]
Message-ID: <CAMj1kXENEpQMWXCxDa28mC0qqNubVFE42VvLPm-NDWTOpRtUiQ@mail.gmail.com> (raw)
In-Reply-To: <20210106103453.152275-4-andre.przywara@arm.com>

On Wed, 6 Jan 2021 at 11:35, Andre Przywara <andre.przywara@arm.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Implement arch_get_random_seed_*() for ARM based on the firmware
> or hypervisor provided entropy source described in ARM DEN0098.
>
> This will make the kernel's random number generator consume entropy
> provided by this interface, at early boot, and periodically at
> runtime when reseeding.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> [Andre: rework to be initialised by the SMCCC firmware driver]
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I think this one could be dropped into rmk's patch tracker now, right?


> ---
>  arch/arm/Kconfig                  |  4 ++
>  arch/arm/include/asm/archrandom.h | 64 +++++++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 138248999df7..bfe642510b0a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1644,6 +1644,10 @@ config STACKPROTECTOR_PER_TASK
>           Enable this option to switch to a different method that uses a
>           different canary value for each task.
>
> +config ARCH_RANDOM
> +       def_bool y
> +       depends on HAVE_ARM_SMCCC_DISCOVERY
> +
>  endmenu
>
>  menu "Boot options"
> diff --git a/arch/arm/include/asm/archrandom.h b/arch/arm/include/asm/archrandom.h
> index a8e84ca5c2ee..f3e96a5b65f8 100644
> --- a/arch/arm/include/asm/archrandom.h
> +++ b/arch/arm/include/asm/archrandom.h
> @@ -2,9 +2,73 @@
>  #ifndef _ASM_ARCHRANDOM_H
>  #define _ASM_ARCHRANDOM_H
>
> +#ifdef CONFIG_ARCH_RANDOM
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/kernel.h>
> +
> +#define ARM_SMCCC_TRNG_MIN_VERSION     0x10000UL
> +
> +extern bool smccc_trng_available;
> +
> +static inline bool __init smccc_probe_trng(void)
> +{
> +       struct arm_smccc_res res;
> +
> +       arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_VERSION, &res);
> +       if ((s32)res.a0 < 0)
> +               return false;
> +       if (res.a0 >= ARM_SMCCC_TRNG_MIN_VERSION) {
> +               /* double check that the 32-bit flavor is available */
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_FEATURES,
> +                                    ARM_SMCCC_TRNG_RND32,
> +                                    &res);
> +               if ((s32)res.a0 >= 0)
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_long(unsigned long *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_int(unsigned int *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
> +{
> +       struct arm_smccc_res res;
> +
> +       if (smccc_trng_available) {
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_RND32, 8 * sizeof(*v), &res);
> +
> +               if (res.a0 != 0)
> +                       return false;
> +
> +               *v = res.a3;
> +               return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
> +{
> +       return arch_get_random_seed_long((unsigned long *)v);
> +}
> +
> +
> +#else /* !CONFIG_ARCH_RANDOM */
> +
>  static inline bool __init smccc_probe_trng(void)
>  {
>         return false;
>  }
>
> +#endif /* CONFIG_ARCH_RANDOM */
>  #endif /* _ASM_ARCHRANDOM_H */
> --
> 2.17.1
>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Ard Biesheuvel <ardb@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 Russell King <linux@armlinux.org.uk>,
	Marc Zyngier <maz@kernel.org>, "Theodore Ts'o" <tytso@mit.edu>,
	 Sudeep Holla <sudeep.holla@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	 Mark Brown <broonie@kernel.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 kvmarm <kvmarm@lists.cs.columbia.edu>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 3/5] ARM: implement support for SMCCC TRNG entropy source
Date: Mon, 15 Mar 2021 13:02:35 +0100	[thread overview]
Message-ID: <CAMj1kXENEpQMWXCxDa28mC0qqNubVFE42VvLPm-NDWTOpRtUiQ@mail.gmail.com> (raw)
In-Reply-To: <20210106103453.152275-4-andre.przywara@arm.com>

On Wed, 6 Jan 2021 at 11:35, Andre Przywara <andre.przywara@arm.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Implement arch_get_random_seed_*() for ARM based on the firmware
> or hypervisor provided entropy source described in ARM DEN0098.
>
> This will make the kernel's random number generator consume entropy
> provided by this interface, at early boot, and periodically at
> runtime when reseeding.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> [Andre: rework to be initialised by the SMCCC firmware driver]
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I think this one could be dropped into rmk's patch tracker now, right?


> ---
>  arch/arm/Kconfig                  |  4 ++
>  arch/arm/include/asm/archrandom.h | 64 +++++++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 138248999df7..bfe642510b0a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1644,6 +1644,10 @@ config STACKPROTECTOR_PER_TASK
>           Enable this option to switch to a different method that uses a
>           different canary value for each task.
>
> +config ARCH_RANDOM
> +       def_bool y
> +       depends on HAVE_ARM_SMCCC_DISCOVERY
> +
>  endmenu
>
>  menu "Boot options"
> diff --git a/arch/arm/include/asm/archrandom.h b/arch/arm/include/asm/archrandom.h
> index a8e84ca5c2ee..f3e96a5b65f8 100644
> --- a/arch/arm/include/asm/archrandom.h
> +++ b/arch/arm/include/asm/archrandom.h
> @@ -2,9 +2,73 @@
>  #ifndef _ASM_ARCHRANDOM_H
>  #define _ASM_ARCHRANDOM_H
>
> +#ifdef CONFIG_ARCH_RANDOM
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/kernel.h>
> +
> +#define ARM_SMCCC_TRNG_MIN_VERSION     0x10000UL
> +
> +extern bool smccc_trng_available;
> +
> +static inline bool __init smccc_probe_trng(void)
> +{
> +       struct arm_smccc_res res;
> +
> +       arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_VERSION, &res);
> +       if ((s32)res.a0 < 0)
> +               return false;
> +       if (res.a0 >= ARM_SMCCC_TRNG_MIN_VERSION) {
> +               /* double check that the 32-bit flavor is available */
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_FEATURES,
> +                                    ARM_SMCCC_TRNG_RND32,
> +                                    &res);
> +               if ((s32)res.a0 >= 0)
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_long(unsigned long *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_int(unsigned int *v)
> +{
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
> +{
> +       struct arm_smccc_res res;
> +
> +       if (smccc_trng_available) {
> +               arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_RND32, 8 * sizeof(*v), &res);
> +
> +               if (res.a0 != 0)
> +                       return false;
> +
> +               *v = res.a3;
> +               return true;
> +       }
> +
> +       return false;
> +}
> +
> +static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
> +{
> +       return arch_get_random_seed_long((unsigned long *)v);
> +}
> +
> +
> +#else /* !CONFIG_ARCH_RANDOM */
> +
>  static inline bool __init smccc_probe_trng(void)
>  {
>         return false;
>  }
>
> +#endif /* CONFIG_ARCH_RANDOM */
>  #endif /* _ASM_ARCHRANDOM_H */
> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-15 12:03 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 10:34 [PATCH v6 0/5] ARM: arm64: Add SMCCC TRNG entropy service Andre Przywara
2021-01-06 10:34 ` Andre Przywara
2021-01-06 10:34 ` Andre Przywara
2021-01-06 10:34 ` [PATCH v6 1/5] firmware: smccc: Add SMCCC TRNG function call IDs Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34 ` [PATCH v6 2/5] firmware: smccc: Introduce SMCCC TRNG framework Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34 ` [PATCH v6 3/5] ARM: implement support for SMCCC TRNG entropy source Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-03-15 12:02   ` Ard Biesheuvel [this message]
2021-03-15 12:02     ` Ard Biesheuvel
2021-03-15 12:02     ` Ard Biesheuvel
2021-01-06 10:34 ` [PATCH v6 4/5] arm64: Add " Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 13:10   ` Mark Brown
2021-01-06 13:10     ` Mark Brown
2021-01-06 13:10     ` Mark Brown
2021-01-06 10:34 ` [PATCH v6 5/5] KVM: arm64: implement the TRNG hypervisor call Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-06 10:34   ` Andre Przywara
2021-01-20 13:01 ` [PATCH v6 0/5] ARM: arm64: Add SMCCC TRNG entropy service Will Deacon
2021-01-20 13:01   ` Will Deacon
2021-01-20 13:01   ` Will Deacon
2021-01-20 13:15   ` Ard Biesheuvel
2021-01-20 13:15     ` Ard Biesheuvel
2021-01-20 13:15     ` Ard Biesheuvel
2021-01-21 17:54     ` Will Deacon
2021-01-21 17:54       ` Will Deacon
2021-01-21 17:54       ` Will Deacon
2021-01-20 13:26   ` Marc Zyngier
2021-01-20 13:26     ` Marc Zyngier
2021-01-20 13:26     ` Marc Zyngier
2021-01-20 13:45     ` Andre Przywara
2021-01-20 13:45       ` Andre Przywara
2021-01-20 13:45       ` Andre Przywara
2021-01-20 13:49       ` Will Deacon
2021-01-20 13:49         ` Will Deacon
2021-01-20 13:49         ` Will Deacon
2021-01-20 13:54         ` Marc Zyngier
2021-01-20 13:54           ` Marc Zyngier
2021-01-20 13:54           ` Marc Zyngier
2021-01-25 22:25 ` (subset) " Marc Zyngier
2021-01-25 22:25   ` Marc Zyngier
2021-01-25 22:25   ` Marc Zyngier

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=CAMj1kXENEpQMWXCxDa28mC0qqNubVFE42VvLPm-NDWTOpRtUiQ@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=tytso@mit.edu \
    --cc=will@kernel.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 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.