Commit Graph

27 Commits

Author SHA1 Message Date
Ruslan Bukin
7722d8c7c0 Add generic arm/arm64 secure-monitor SMCCC interface and switch
PSCI code to use it.

This interface will also be used by Intel Stratix 10 platform.

This was not tested on arm due to lack of PSCI-enabled arm hardware
lying around.

Reviewed by:	andrew
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D21439
2019-09-13 15:56:33 +00:00
Michal Meloun
91e4401364 PSCI: Don't take missing implementation of psci get_version() as fatal.
Minimalistic PSCI implementation in U-Boot doesn't implement get_version()
method for some SoC. In this case, use PSCI version declared by 'psci' node
in DT as fallback.

MFC after:	2 weeks
2019-03-19 15:42:11 +00:00
Luiz Otavio O Souza
217643e7da Fix a typo on the PSCI smc call wrapper.
Looks good from:	andrew
Sponsored by:	Rubicon Communications, LLC (Netgate)
2018-08-14 13:56:49 +00:00
Andrew Turner
100a6d1905 Use int for the pcpu_ssbd argument. This is included from userland and may
not include the needed headers to get the bool definition.

Reported by:	manu
Pointy hat to:	andrew
Sponsored by:	DARPA, AFRL
2018-07-31 15:08:02 +00:00
Andrew Turner
0594061ee6 Implement the SSBD (CVE-2018-3639) workaround on arm64
This calls into the Arm Trusted Firmware to enable and disable the
workaround for the Speculative Store Bypass Disable (SSBD) issue, also
known as Spectre Variant 4.

As this may have a large performance overhead, and how exploitable SSBD is
is unknown we follow the Linux lead of allowing the administrator to select
between always on, always off, or only enabled in the kernel, with the
latter being the default.

PR:		228955
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15819
2018-07-31 12:53:27 +00:00
Emmanuel Vadot
85ab1415ff psci: Add \n at the end of printf
Add a \n at the end of the printf if no PSCI function was found otherwise
it mess up the console log.
2018-07-06 17:39:48 +00:00
Andrew Turner
1d802c646c Move the SMCCC SYSINIT later in the boot so the psci driver has attached.
Sponsored by:	DARPA, AFRL
2018-06-20 10:57:29 +00:00
Andrew Turner
95c4b3c735 Fix the SMCCC signatures, they are all 32-bit calls. This fixes SMCCC
version detection.

Sponsored by:	DARPA, AFRL
2018-06-20 10:02:50 +00:00
Andrew Turner
09d1a08ddc Add the SMCCC return codes from ARM DEN 0070A.
While here add a comment with the document the function IDs come from.

Sponsored by:	DARPA, AFRL
2018-06-13 15:41:22 +00:00
Andrew Turner
f651b52527 Add support for the ARM SMC Calling Convention (SMCCC). This is a method
to call into the firmware in a similar way to the existing PSCI, and used
PSCI to detect when SMCCC is enabled.

There is a function ID space we can use. Currently we only support 3
functions in the ARM Architecture Calls region, however it is expected we
will expend these in the future.

Sponsored by:	DARPA, AFRL
2018-06-13 15:32:00 +00:00
Andrew Turner
9e8cb3d226 Move psci_call to a header file so we can use it in other files to
communicate with the firmware.

Sponsored by:	DARPA, AFRL
2018-06-13 15:24:07 +00:00
Andrew Turner
5add83935a Add a handler for the PSCI_FEATURES function. This needs PSCI 1.0, so
check for this, returning an error if the version is too old.

Sponsored by:	DARPA, AFRL
2018-06-13 12:33:47 +00:00
Andrew Turner
4493861b9a Find and cache the PSCI version on driver attach.
Sponsored by:	DARPA, AFRL
2018-06-13 12:32:04 +00:00
Andrew Turner
811880f2a4 Add the PSCI_FEATURES function ID. This is found in PSCI 1.0 and is used
to query if a given function is implemented and its features.

Sponsored by:	DARPA, AFRL
2018-06-13 12:26:37 +00:00
Andrew Turner
0c38b2d37c Rework PSCI so it only searches for the call function once.
This is in preperation for supporting newer smccc functions that also use
the same call method.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D15745
2018-06-12 14:54:17 +00:00
Andrew Turner
8ab09f8a4e Add a function to find the PSCI version the firmware implements from
outside the PSCI driver.

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2018-01-09 15:57:09 +00:00
Ed Maste
a5c9ec376b psci: change bootverbose string to 'PSCI 0.2 compatible'
Prior to r324754 we treated PSCI 0.2 and 1.0 as identical, and r324754
extended that to include all PSCI 1.x revisions. Change the string
emitted under bootverbose to reference '0.2 compatible' to avoid
confusion when the system includes a later PSCI rev.

Discussed with:	andrew
Sponsored by:	The FreeBSD Foundation
2017-10-19 16:40:17 +00:00
Andrew Turner
833a983e5e Allow later PSCI revisions to also work. The latest ARM Trusted Firmware
reports version 1.1 so the check was failing. As thjis is a minor change
from 1.0, and future 1.x revisions are also expected to be backwards
compatible just ignore the minor revision in the init handler.

Sponsored by:	DARPA, AFRL
2017-10-19 13:22:52 +00:00
Andrew Turner
845ed71645 Also handle psci 1.0. This can be seen as a bug fix update for the 0.2
specification we already support, with the only changes in functions we
don't currently use.

Sponsored by:	DARPA, AFRL
2017-10-06 15:46:11 +00:00
Ed Maste
fa8d7c4417 arm: add .arch_extension sec for smc instruction
Clang 4.0 accepts the smc instruction with or without specifying
.arch_extension sec, but Clang 5.0 produces an error without it.

MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
2017-06-18 00:08:38 +00:00
Andrew Turner
574a7c6c47 Call the PSCI reset from cpu_reset on arm64. When rebooting from DDB the
kernel calls this directly so the event handler is not called, meaning
the computer fails to reboot.

Tested by:	cognet
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-04-24 11:06:10 +00:00
Andrew Turner
2b5014f6fe Add ACPI support to the PSCI driver. This checks the Fixed ACPI Description
Table to find if the hardware supports PSCI, and if so what method the
kernel should use to interact with it.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-12-07 14:24:53 +00:00
Andrew Turner
c2dd354bf4 Create a new PSCI error code and use it to signal that starting the CPU is
impossible as the PSCI firmware is missing.

Sponsored by:	ABT Systmes Ltd
2016-10-25 14:18:27 +00:00
Andrew Turner
6e3244f594 Start to support PSCI 1.0. For all the functions we currently support this
can be seen as the same as 0.2. There are changes with the data passed to
CPU_SUSPEND, however we don't yet use this call.

Sponsored by:	ABT Systems Ltd
2015-08-11 13:42:58 +00:00
Andrew Turner
7ad1ac7d6a Rework the PSCI cpu on code to allow it to work before device drivers have
started. This allows this functions to be used with the regular ARM SMP
initialisation sequence.
2015-05-24 11:08:06 +00:00
Andrew Turner
7d9cff3d23 Add psci for arm64. This is currently used when rebooting and powering off
in qemu.

Sponsored by:	The FreeBSD Foundation
2015-04-13 16:41:33 +00:00
Andrew Turner
46b1fe9224 Add a driver for the ARM Power State Coordination Interface (PSCI). This
handles versions 0.1 and 0.2 of the standard on 32-bit ARM.

With this driver we can shutdown in QEMU. Further work is needed to
turn secondary cores on on boot and to support later revisions of the
specification.

Submitted by:	Robin Randhawa <Robin.Randhawa at ARM.com>
Sponsored by:	The FreeBSD Foundation
2015-04-12 13:00:58 +00:00