From nobody Wed Sep 20 16:07:22 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RrNhp5Hn9z4trMb; Wed, 20 Sep 2023 16:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RrNhp4k1Sz4PNj; Wed, 20 Sep 2023 16:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695226042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aVlwDaC7zJqJStVUG0qwG1NhDQCKwgRtYWyGZTzyYx4=; b=NtA00TRDXJG+DvK48XIHdtQGKTZMEx0elhIqpyp3ql2DGpgqATXNXKjMAzKvbwC/fHuS/H 0ImUIdAlhHG8+3i9E7IfT2mkBGSIETP58YGDbbMTEIaI2X2CFlc2OHI4jbC66JouyZdzbO 7PvhMjEAZnQeCiu8eMJsW0ylDPrWfZgrJUoKxBxYSp4F4H8a2cnyZG8issTp80g9iZHv9M A9eGIRgkvXJ487msEiQNMwuHrSik6dGwUqVUcv8IAdRVpXChx3CIfIE4nmyChc81ESwnJ4 Sc67ciGu+/ZcW39ZTu5Q+sGzUtozvq4Ek0aujXdmjSAw0le/8lVsq3WYFOadfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695226042; a=rsa-sha256; cv=none; b=v9gi1A2BZI7SZR5+R0wcjjhWu0rseDK4xymfSTKurcHIdhEWO0Palf5LWToFefkvlfmQtg gEn0clg+75J7u+hYrxtU2SyvW9prGkDuqkBLTQ5/i3MoXN25nmR9sAbS+fLoXOxEd4DvXa NbBABLtGX7wx8Baa5v0P0UzGToyaq+CLpk4HpXGAe/oY0XZx3gwDCFmDbrWOtjh51KqYov 6uN1Hjl0TPwovjua+OXm80oA8xMDV+/tsc9P5leqUpmbbJ0NtqOQ5LNlQIm073mkAd6IAt yeOgw26Jfly461x9iSjPnFGqXiqMjIOECZRq3z1Gf4BAiF+18MXPznO3m4IW8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695226042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aVlwDaC7zJqJStVUG0qwG1NhDQCKwgRtYWyGZTzyYx4=; b=yepKjxaxTTtkewp0QL9VVSiS+3TI6ncoL2aoMLBCvnTJouAvhuoNTQw854kwRGkf+v+845 zFz6i44muTTYdXl1F6TfcPrT/rRfX5bUcLqPyVNhs0xyC7pQcXNVBnVBlWZSpf2wXDsUla BcS36fzhVluVSbCmUc4T1PmPQ2FRPTkEjutupirztAgBcIDf4SUXnt7c2YoLUGdLi93w/C Kt4JgLH68ELF3wByWZjnthG+TTcydFaNJTQRD2jsg6rFP5RBHOOK6U+8cjSdgCCBGgL/9F AY0tfdIpf3FtR6N/YL9iNx835HhADtq3Fe90x1uMhfG1bMCb5BrsiPPPLGAdMA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RrNhp3qg0z129c; Wed, 20 Sep 2023 16:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38KG7MrY052812; Wed, 20 Sep 2023 16:07:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38KG7MGs052809; Wed, 20 Sep 2023 16:07:22 GMT (envelope-from git) Date: Wed, 20 Sep 2023 16:07:22 GMT Message-Id: <202309201607.38KG7MGs052809@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 8a723e2bd868 - main - Check SMCCC is ready before using List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a723e2bd8683b0e046ed9d03178082f84c8cf26 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=8a723e2bd8683b0e046ed9d03178082f84c8cf26 commit 8a723e2bd8683b0e046ed9d03178082f84c8cf26 Author: Andrew Turner AuthorDate: 2023-09-19 09:11:48 +0000 Commit: Andrew Turner 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));