git: 8a723e2bd868 - main - Check SMCCC is ready before using
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 20 Sep 2023 16:07:22 UTC
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=8a723e2bd8683b0e046ed9d03178082f84c8cf26 commit 8a723e2bd8683b0e046ed9d03178082f84c8cf26 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2023-09-19 09:11:48 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2023-09-20 16:01:37 +0000 Check SMCCC is ready before using 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/dev/psci/smccc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/psci/smccc.c b/sys/dev/psci/smccc.c index 5c5e140abab1..9008eb2fbd39 100644 --- a/sys/dev/psci/smccc.c +++ b/sys/dev/psci/smccc.c @@ -43,7 +43,7 @@ #define SMCCC_VERSION_1_0 0x10000 /* Assume 1.0 until we detect a later version */ -static uint32_t smccc_version = SMCCC_VERSION_1_0; +static uint32_t smccc_version; void smccc_init(void) @@ -51,6 +51,7 @@ smccc_init(void) int32_t features; uint32_t ret; + smccc_version = SMCCC_VERSION_1_0; features = psci_features(SMCCC_VERSION); if (features != PSCI_RETVAL_NOT_SUPPORTED) { ret = psci_call(SMCCC_VERSION, 0, 0, 0); @@ -69,6 +70,7 @@ smccc_init(void) uint32_t smccc_get_version(void) { + MPASS(smccc_version != 0); return (smccc_version); } @@ -76,6 +78,7 @@ int32_t smccc_arch_features(uint32_t smccc_func_id) { + MPASS(smccc_version != 0); if (smccc_version == SMCCC_VERSION_1_0) return (PSCI_RETVAL_NOT_SUPPORTED); @@ -90,6 +93,7 @@ int smccc_arch_workaround_1(void) { + MPASS(smccc_version != 0); KASSERT(smccc_version != SMCCC_VERSION_1_0, ("SMCCC arch workaround 1 called with an invalid SMCCC interface")); return (psci_call(SMCCC_ARCH_WORKAROUND_1, 0, 0, 0)); @@ -99,6 +103,7 @@ int smccc_arch_workaround_2(int enable) { + MPASS(smccc_version != 0); KASSERT(smccc_version != SMCCC_VERSION_1_0, ("SMCCC arch workaround 2 called with an invalid SMCCC interface")); return (psci_call(SMCCC_ARCH_WORKAROUND_2, enable, 0, 0));