Add support for Graviton TRNG
Subsystems (4)
cover Add support for Graviton TRNG
AWS Graviton based systems provide an Arm SMC call in the vendor defined hypervisor region to read random numbers from a HW TRNG and return them to the guest.
We've observed slower guest boot and especially reboot times due to lack of entropy and providing access to a TRNG is meant to address this.
Ali Saidi (3):
arm/arm64: Add smccc hypervisor service identifiers
arm64: export acpi_psci_use_hvc
hwrng: Add support for AWS Graviton TRNG
MAINTAINERS | 6 ++ arch/arm64/kernel/acpi.c | 1 + drivers/char/hw_random/Kconfig | 13 ++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/graviton-rng.c | 123 ++++++++++++++++++++++++++++++++++ include/linux/arm-smccc.h | 2 + 6 files changed, 146 insertions(+) create mode 100644 drivers/char/hw_random/graviton-rng.c
Signature · 7 lines
2.15.3.AMZN _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/3 arm/arm64: Add smccc hypervisor service identifiers
The SMC calling convention defines service identifiers for generic and vendor specific hypervisor services. This patch adds those services to the list of existing service identifiers.
--- include/linux/arm-smccc.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/arm-smccc.h +2 -0
@@ -54,6 +54,8 @@#define ARM_SMCCC_OWNER_SIP 2#define ARM_SMCCC_OWNER_OEM 3#define ARM_SMCCC_OWNER_STANDARD 4 +#define ARM_SMCCC_OWNER_STANDARD_HV 5 +#define ARM_SMCCC_OWNER_VENDOR_HV 6#define ARM_SMCCC_OWNER_TRUSTED_APP 48#define ARM_SMCCC_OWNER_TRUSTED_APP_END 49#define ARM_SMCCC_OWNER_TRUSTED_OS 50
Signature · 1 line
2.15.3.AMZN
PATCH 2/3 arm64: export acpi_psci_use_hvc
In reply to Ali SaidiAllow a module that wants to make SMC calls to detect if it should be using smc or hvc.
--- arch/arm64/kernel/acpi.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/acpi.c +1 -0
@@ -119,6 +119,7 @@ bool acpi_psci_use_hvc(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; } +EXPORT_SYMBOL_GPL (acpi_psci_use_hvc);/* * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity
Signature · 1 line
2.15.3.AMZN
Re: [PATCH 2/3] arm64: export acpi_psci_use_hvc
Quoted 13 lines · Ali Saidi
Allow a module that wants to make SMC calls to detect if it should be using smc or hvc.
Signed-off-by Ali Saidi <[email protected]>--- arch/arm64/kernel/acpi.c | 1 + 1 file changed, 1 insertion(+)arch/arm64/kernel/acpi.c +0
-0
arch/arm64/kernel/acpi.c bool acpi_psci_use_hvc(void) · line 123
Quoted 5 lines
arch/arm64/kernel/acpi.c +1
-0@@ -119,6 +119,7 @@ bool acpi_psci_use_hvc(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; } +EXPORT_SYMBOL_GPL (acpi_psci_use_hvc);
I would rather have this in drivers/firmware/psci/psci.c checking the value of psci_ops.conduit so that it's not just ACPI specific and can be used on DT platforms too if required.
--
Regards,
Sudeep
Mark Rutland
maintainerRe: [PATCH 2/3] arm64: export acpi_psci_use_hvc
Quoted 9 lines · Sudeep Holla
Quoted 8 lines · Ali Saidi
Allow a module that wants to make SMC calls to detect if it should be using smc or hvc.
Signed-off-by Ali Saidi <[email protected]>--- arch/arm64/kernel/acpi.c | 1 + 1 file changed, 1 insertion(+)
Quoted 14 lines
arch/arm64/kernel/acpi.c bool acpi_psci_use_hvc(void) · line 123
Quoted 10 lines
arch/arm64/kernel/acpi.c +1
-0@@ -119,6 +119,7 @@ bool acpi_psci_use_hvc(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; } +EXPORT_SYMBOL_GPL (acpi_psci_use_hvc);I would rather have this in
drivers/firmware/psci/psci.cchecking the value of psci_ops.conduit so that it's not just ACPI specific and can be used on DT platforms too if required.
I'd also like this to not hook into PSCI internals. This code cares about SMCCC, not PSCI. We also really shouldn't need to spread the conduit management everywhere, too. We should be abel to have probe code do:
if (!is_smccc_1_1_available()) goto fail_probe;
... and runtime code do:
res = arm_smccc_1_1_call(...);
... which is much clearner.
I'd started cleaning that up [1], but I haven't had the chance to rebase and repost it.
Ali, I assume your firmware has SMCCCv1.1+. Is that the case?
Thanks,
Mark.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=arm64/smccc-cleanup
Re: [PATCH 2/3] arm64: export acpi_psci_use_hvc
Quoted 25 lines · Mark Rutland
Quoted 9 lines · Sudeep Holla
Quoted 8 lines · Ali Saidi
Allow a module that wants to make SMC calls to detect if it should be using smc or hvc.
Signed-off-by Ali Saidi <[email protected]>--- arch/arm64/kernel/acpi.c | 1 + 1 file changed, 1 insertion(+)Quoted 14 lines
arch/arm64/kernel/acpi.c bool acpi_psci_use_hvc(void) · line 123
Quoted 10 lines
arch/arm64/kernel/acpi.c +1
-0@@ -119,6 +119,7 @@ bool acpi_psci_use_hvc(void) {return acpi_gbl_FADT.arm_boot_flags &ACPI_FADT_PSCI_USE_HVC ; } +EXPORT_SYMBOL_GPL (acpi_psci_use_hvc);I would rather have this in
drivers/firmware/psci/psci.cchecking the value of psci_ops.conduit so that it's not just ACPI specific and can be used on DT platforms too if required.
Quoted 3 lines
I'd also like this to not hook into PSCI internals. This code cares about SMCCC, not PSCI. We also really shouldn't need to spread the conduit management everywhere, too.
I agree. I remember suggesting the same to Xilinx a while ago but I didn't see your patches in the mainline.
--
Regards,
Sudeep
Re: [PATCH 2/3] arm64: export acpi_psci_use_hvc
In reply to Mark RutlandOn 6/5/19, 5:40 AM, "Mark Rutland" <[email protected]> wrote:
Ali, I assume your firmware has SMCCCv1.1+. Is that the case?
Yes, it does. I'm happy to be able to call a generic function instead of having to figure out which conduit to use.
Ali
PATCH 3/3 hwrng: Add support for AWS Graviton TRNG
In reply to Ali SaidiAWS Graviton based systems provide an Arm SMC call in the vendor defined hypervisor region to read random numbers from a TRNG and return them to the guest.
--- MAINTAINERS | 6 ++ drivers/char/hw_random/Kconfig | 13 ++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/graviton-rng.c | 130 ++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 drivers/char/hw_random/graviton-rng.c
MAINTAINERS +6 -0
@@ -2771,6 +2771,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/adc/avia-hx711.txt F: drivers/iio/adc/hx711.c +AWS GRAVITON TRNG DRIVER +M: Ali Saidi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/char/hw_random/graviton-rng.c + AX.25 NETWORK LAYER M: Ralf Baechle <[email protected]> L: [email protected]
drivers/char/hw_random/Kconfig +13 -0
@@ -439,6 +439,19 @@ config HW_RANDOM_OPTEE If unsure, say Y. +config HW_RANDOM_GRAVITON + tristate "AWS Graviton Random Number Generator support" + depends on HW_RANDOM && ACPI && (ARM64 || COMPILE_TEST) + default HW_RANDOM + help + This driver provides kernel-side support for the Random Number + Generator SMC found on AWS Graviton systems. + + To compile this driver as a module, choose M here: the + module will be called graviton-rng. + + If unsure, say Y. + endif # HW_RANDOM config UML_RANDOM
drivers/char/hw_random/Makefile +1 -0
@@ -39,3 +39,4 @@ obj-$(CONFIG_HW_RANDOM_MTK) += mtk-rng.o obj-$(CONFIG_HW_RANDOM_S390) += s390-trng.o obj-$(CONFIG_HW_RANDOM_KEYSTONE) += ks-sa-rng.o obj-$(CONFIG_HW_RANDOM_OPTEE) += optee-rng.o +obj-$(CONFIG_HW_RANDOM_GRAVITON) += graviton-rng.o
drivers/char/hw_random/graviton-rng.c new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.15.3.AMZN
Quoted 6 lines · Ali Saidi
AWS Graviton based systems provide an Arm SMC call in the vendor defined hypervisor region to read random numbers from a HW TRNG and return them to the guest.
We've observed slower guest boot and especially reboot times due to lack of entropy and providing access to a TRNG is meant to address this.
Curious, but why this over something like virtio-rng?
Will
On 6/5/19, 7:20 AM, "Will Deacon" <[email protected]> wrote:
On Tue, Jun 04, 2019 at 08:30:57PM +0000, Ali Saidi wrote:
> AWS Graviton based systems provide an Arm SMC call in the vendor defined > hypervisor region to read random numbers from a HW TRNG and return them to the > guest.
>
> We've observed slower guest boot and especially reboot times due to lack of > entropy and providing access to a TRNG is meant to address this.
Curious, but why this over something like virtio-rng?
This interface allows us to provide the functionality from both EL2 and EL3 and support multiple different types of our instances which we unfortunately can't do with virt-io.
Ali
On 6/7/19, 7:59 AM, " Ali Saidi" <[email protected]> wrote:
On 6/5/19, 7:20 AM, "Will Deacon" <[email protected]> wrote:
On Tue, Jun 04, 2019 at 08:30:57PM +0000, Ali Saidi wrote:
> AWS Graviton based systems provide an Arm SMC call in the vendor defined > hypervisor region to read random numbers from a HW TRNG and return them to the > guest.
>
> We've observed slower guest boot and especially reboot times due to lack of > entropy and providing access to a TRNG is meant to address this.
Curious, but why this over something like virtio-rng?
This interface allows us to provide the functionality from both EL2 and EL3 and support multiple different types of our instances which we unfortunately can't do with virt-io.
Will,
Any additional comments?
Mark,
Do you know when you'll have a chance to rebase arm64/smccc-cleanup?
Thanks,
Ali
Will Deacon
maintainer[Note: this was in my spam folder]
Quoted 10 lines · Ali
On 6/7/19, 7:59 AM, " Ali Saidi" <[email protected]> wrote:
On 6/5/19, 7:20 AM, "Will Deacon" <[email protected]> wrote:
On Tue, Jun 04, 2019 at 08:30:57PM +0000, Ali Saidi wrote:
> AWS Graviton based systems provide an Arm SMC call in the vendor defined > hypervisor region to read random numbers from a HW TRNG and return them to the > guest.
>
> We've observed slower guest boot and especially reboot times due to lack of > entropy and providing access to a TRNG is meant to address this.
Quoted 8 lines
Curious, but why this over something like virtio-rng?
This interface allows us to provide the functionality from both EL2 and EL3 and support multiple different types of our instances which we unfortunately can't do with virt-io.
Any additional comments?
Do you know when you'll have a chance to rebase arm64/smccc-cleanup?
Sorry, Ali, this slipped through the cracks. Marc and I will chat today and look at respinning what we had before; it should then hopefully be straightforward enough for you to take that as a base for what you want to do.
Will
Will Deacon
maintainer[+Marc]
Quoted 19 lines · Will Deacon
[Note: this was in my spam folder]
Quoted 16 lines · Ali
On 6/7/19, 7:59 AM, " Ali Saidi" <[email protected]> wrote:
On 6/5/19, 7:20 AM, "Will Deacon" <[email protected]> wrote:
On Tue, Jun 04, 2019 at 08:30:57PM +0000, Ali Saidi wrote:
> AWS Graviton based systems provide an Arm SMC call in the vendor defined > hypervisor region to read random numbers from a HW TRNG and return them to the > guest.
>
> We've observed slower guest boot and especially reboot times due to lack of > entropy and providing access to a TRNG is meant to address this.Curious, but why this over something like virtio-rng?
This interface allows us to provide the functionality from both EL2 and EL3 and support multiple different types of our instances which we unfortunately can't do with virt-io.
Quoted 7 lines
Quoted 2 lines
Any additional comments?
Do you know when you'll have a chance to rebase arm64/smccc-cleanup?Sorry, Ali, this slipped through the cracks. Marc and I will chat today and look at respinning what we had before; it should then hopefully be straightforward enough for you to take that as a base for what you want to do.
Ok, I hacked on this a bit today and hopefully you can use this as a starting point:
https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=kvm/hvc
I haven't given it any real testing, so apologies for the bugs.
Will