aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/psci
Commit message (Collapse)AuthorAgeFilesLines
* dev/psci: Use the correct SMCCC TRNG fieldAndrew Turner2025-06-241-1/+1
| | | | | | | | | | | | The TRNG service will return random data in x3. Use the correct field when filling the buffer in trng_read. This driver has not been in any release, so no security advisory is needed. Reviewed by: bz Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D50979
* dev/psci: Check for functions before callingAndrew Turner2025-06-242-3/+4
| | | | | | | | | | | In the SMCCC TRNG and Errata ABI drivers check if the version functions are implemented before calling them. Without this the firmware may complain about an unimplemented function being called. Reported by: bz Reviewed by: bz Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D50978
* dev/psci: Use an SMCCC return valueAndrew Turner2025-06-241-1/+1
| | | | | | | | | | Switch to the SMCCC not supported macro in smccc_arch_features. This shouldn't be a functional change as the value is identical to the PSCI value it replaces. Reviewed by: bz, emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D50977
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-212-2/+2
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* psci: Support the arm64 Errata ABIAndrew Turner2025-01-241-0/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for the Arm Errata Management Firmware Interface (Errata ABI) [1]. This provides an interface for the kernel to query the status of an erratum workaround. Some errata may be mitigated depending on the other hardware in a SoC, e.g. Cortex-A78 erratum 2712571 is not affected in systems that use an Arm interconnect. As there may not be a way for the kernel to know if this is the case then it would have to implement the workaround even when not needed. There are other cases where the needed workaround is implemented in firmware and if not implemented then the kernel may decide to not use a feature. In this case we can query the firmware before deciding if we should use a feature or now. There is a known issue with some firmware implementations of the Errata ABI that incorrectly returns a status indicating the erratum is fully mitigated by the firmware, however there is a kernel component needed, e.g. Neoverse-N1 erratum 1542419. To handle this case we tell the caller there is some workaround implemented in the firmware and it can decide how to handle it. If this is fixed in a way we can detect we can add a new erratum status value to indicate this. [1] https://developer.arm.com/documentation/den0100/latest/ Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D48055
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-062-2/+3
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* sys: Add an SMCCC Random Number Generator driverAndrew Turner2024-10-151-0/+143
| | | | | | | | | | The Arm True Random Number Generator Firmware Interface provides a way to query the SMCCC firmware for up to 192 bits of entropy. Use it to provide another source of randomness to the kernel. Reviewed by: cem, markm Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46989
* dev/psci: Add SMCCC_MAKE_VERSIONAndrew Turner2024-10-151-0/+1
| | | | | | | This will be used to create an integer with a given version. It can then be used to check if the SMCCC version is late enough for a driver. Sponsored by: Arm Ltd
* dev/psci: Make SMCCC into a real driverAndrew Turner2024-10-152-2/+54
| | | | | | | | This will be used by other drivers that manage SMCCC firmware services to use as an attachment point. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46988
* sys: Use the new arm_smccc_invoke macrosAndrew Turner2024-10-151-3/+3
| | | | | | | | Simplify the calls into the SMCCC firmware with the new arm_smccc_invoke* macros. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46987
* dev/psci: Create macros to simplify calling SMCCCAndrew Turner2024-10-151-0/+32
| | | | | | | | | | | | When calling into SMCCC functions we often only need a few arguments. As the current function needs all 8 possible arguments to be set the unused values will be zero. Create a macro to pass in the used values, followed by enough zeros, then the result pointer. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46986
* arm64: Support BTI checking in most of the kernelAndrew Turner2024-06-051-0/+5
| | | | | | | | | | | | | | | | | LLD has the -zbti-report=error argument to check if the BTI note is present when linking. To allow for this to be used when linking the kernel and modules: - Add the BTI note to the remaining assembly files - Mark ptrauth.c as protected by BTI - Disable -zbti-report for vmm hypervisor switching code as it's not used there. The linux64 module doesn't build with the flag as it includes vdso code that doesn't include the note. Reviewed by: imp, kib, emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45466
* dev/psci: Fix a function nameAndrew Turner2024-05-171-1/+1
| | | | | | dd a missing underscore to arm_smccc_1_2_* to fix the GCC build. Sponsored by: Arm Ltd
* dev/psci: Check all compat stringsAndrew Turner2024-05-101-5/+11
| | | | | | | | | When searching for the PSCI FDT node we only check a few compat strings. Use the existing compat_data array to check all strings the driver may attach to. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44913
* psci: split off psci_reboot from psci_shutdownAndriy Gapon2024-02-181-5/+20
| | | | | | | Priority of psci_reboot set so that it is run after shutdown_panic is executed. This is to provide uniform experience with other platforms. MFC after: 3 weeks
* psci: Add FDT node status checkStephen J. Kiernan2024-02-151-0/+3
| | | | | | | | Consider the PSCI missing if the FDT node status says it is not okay. Reviewed by: andrew Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43920
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Check SMCCC is ready before usingAndrew Turner2023-09-201-1/+6
| | | | | | | | | Add asserts to check SMCCC has been initialised before callers try to use it. Reviewed by: emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D41917
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-164-8/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-162-4/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* Add PSCI affinity info return valuesAndrew Turner2023-03-161-0/+4
| | | | | | | | These can be returned from the PSCI AFFINITY_INFO call. This is not marked as optional so bhyve will need to implement it & can use these macros. Sponsored by: Arm Ltd
* Add a psci macro to build a version valueAndrew Turner2023-03-161-0/+1
| | | | | | | Add PSCI_VER that takes a major and minor version and builds the value returned by the firmware. This will be used by bhyve. Sponsored by: Arm Ltd
* Allow psci.h to be used by userspaceAndrew Turner2023-03-161-0/+4
| | | | | | | | | | Wrap parts of psci.h that aren't usable by userspace in _KERNEL checks. This allows it to be used to implement PSCI and SMCCC by bhyve in userspace. Sponsored by: Arm Ltd Sponsored by: Innovate UK Sponsored by: The FreeBSD Foundation
* arm_smcc_1_2_*: Don't trash SP and X19 if no return value structure.John Baldwin2023-02-011-2/+2
| | | | | | | | | Jumping direct to ret was not restoring the saved value of x19 and was also not adjusting sp to discard the two saved registers. Reviewed by: andrew Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D37922
* Only call SMCCC init on arm64Andrew Turner2023-01-291-0/+2
| | | | We don't build the smccc code on arm so don't call into it there.
* Make SMCCC usable by device driversAndrew Turner2023-01-293-3/+12
| | | | | | | | | To allow device drivers to call into SMCCC we need to initialise it earlier. As it depends on PSCI, and that is detected via ACPI or FDT move the call to smccc_init to the PSCI driver. Add a function for drivers to read the smccc version, or 0 if smccc is not present.
* psci: set psci_present as early as possibleKyle Evans2022-10-271-1/+1
| | | | | | | | | | | | | | | | | psci_attach is way too late to provide the intended semantics for psci_present. psci calls can be made immediately after psci_init(), called way earlier at SI_SUB_CPU + SI_ORDER_FIRST, and we need it to be valid as early as we can possibly call a psci function. This fixes booting RPi3+4 with the in-review spintable patch; rpi3-psci-monitor patches the FDT to add a PSCI node, but it doesn't patch each cpus' enable-method. Because of this, we would stall the boot while enabling CPU 1 as we saw a valid looking enable-method and "no" functional PSCI and attempted to use the spintable rather than simply not starting secondary APs. Fixes: 2218070b2c3c32 ("psci: finish psci_present implementation") Reported by: karels
* arm64: Enabling new hypercalls using HvCallSetVpRegisters and ↵Wei Hu2022-09-262-0/+60
| | | | | | | | | | | | | | | | | | HvCallGetVpRegisters Enabling HvCallSetVpRegisters and HvCallGetVpRegisters for hypercalls to read and write to specific MSRs. This is required for implementing wrmsr and rdmsr, which is required for Hyper-V vmbus driver for ARM64. Also we need to use arm smccc hvc 1.2 version as we need to access registers beyond X0-X3 for HvCallGetVpRegisters. Currently scoping it only for Hyper-V. Reviewed by: lwhsu, andrew, whu Tested by: Souradeep Chakrabarti <schakrabarti@microsoft.com> Signed-off-by: Souradeep Chakrabarti <schakrabarti@microsoft.com> Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D36256
* Merge the common parts of the SMCCC handlersAndrew Turner2022-08-252-38/+16
| | | | | | | | To simplify adding new handlers merge the common parts of the functions used to call into the arm SMCCC firmware. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36297
* psci: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-091-7/+3
|
* psci: finish psci_present implementationKyle Evans2022-03-192-1/+3
| | | | | | | | | | This was already declared in psci.h, but it was never defined/set. Do this now, so we can use it to decide if enable-method in /cpus FDT nodes should be inspected later on. While we're here, convert it to a boolean. Reviewed by: andrew (slightly earlier version) Differential Revision: https://reviews.freebsd.org/D34553
* psci: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+0
| | | | Notes: svn path=/head/; revision=365173
* Add generic arm/arm64 secure-monitor SMCCC interface and switchRuslan Bukin2019-09-135-36/+98
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=352301
* PSCI: Don't take missing implementation of psci get_version() as fatal.Michal Meloun2019-03-192-17/+50
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=345299
* Fix a typo on the PSCI smc call wrapper.Luiz Otavio O Souza2018-08-142-2/+2
| | | | | | | | Looks good from: andrew Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=337752
* Use int for the pcpu_ssbd argument. This is included from userland and mayAndrew Turner2018-07-312-3/+3
| | | | | | | | | | | not include the needed headers to get the bool definition. Reported by: manu Pointy hat to: andrew Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=336971
* Implement the SSBD (CVE-2018-3639) workaround on arm64Andrew Turner2018-07-312-0/+12
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=336967
* psci: Add \n at the end of printfEmmanuel Vadot2018-07-061-1/+1
| | | | | | | | Add a \n at the end of the printf if no PSCI function was found otherwise it mess up the console log. Notes: svn path=/head/; revision=336037
* Move the SMCCC SYSINIT later in the boot so the psci driver has attached.Andrew Turner2018-06-201-1/+1
| | | | | | | Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335439
* Fix the SMCCC signatures, they are all 32-bit calls. This fixes SMCCCAndrew Turner2018-06-201-3/+3
| | | | | | | | | version detection. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335438
* Add the SMCCC return codes from ARM DEN 0070A.Andrew Turner2018-06-131-0/+9
| | | | | | | | | While here add a comment with the document the function IDs come from. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335063
* Add support for the ARM SMC Calling Convention (SMCCC). This is a methodAndrew Turner2018-06-132-0/+156
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=335062
* Move psci_call to a header file so we can use it in other files toAndrew Turner2018-06-132-8/+9
| | | | | | | | | communicate with the firmware. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335061
* Add a handler for the PSCI_FEATURES function. This needs PSCI 1.0, soAndrew Turner2018-06-132-2/+19
| | | | | | | | | check for this, returning an error if the version is too old. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335056
* Find and cache the PSCI version on driver attach.Andrew Turner2018-06-131-0/+3
| | | | | | | Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335055
* Add the PSCI_FEATURES function ID. This is found in PSCI 1.0 and is usedAndrew Turner2018-06-131-0/+2
| | | | | | | | | to query if a given function is implemented and its features. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=335054
* Rework PSCI so it only searches for the call function once.Andrew Turner2018-06-121-42/+64
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=334999
* Add a function to find the PSCI version the firmware implements fromAndrew Turner2018-01-092-2/+12
| | | | | | | | | | outside the PSCI driver. MFC after: 1 week Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=327728
* psci: change bootverbose string to 'PSCI 0.2 compatible'Ed Maste2017-10-191-1/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=324758
* Allow later PSCI revisions to also work. The latest ARM Trusted FirmwareAndrew Turner2017-10-191-1/+1
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=324754