From patchwork Wed Jan 18 14:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1728271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=w9LZjmag; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=UlkrmBHy; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxpQt3NqKz23fT for ; Thu, 19 Jan 2023 01:43:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gG3exFnkQ3BNLU0FpvLYoDoDUDAcTEw6ZCQQ+QFIZeI=; b=w9LZjmagAuF//i ywL04ub529hVls7jC9v1kcUCQgtHJxFVReNoL+tjUeD6wwCpW4NYVdZN7laSBhyj7WTWnTfVrD0LK OGWXxiI6GhLz1FFsLxUGy6j6ap0IHCb6Bqahpj91p6wJCJpydIsUkwy6G3vUU1SUUcOghlp7uYlNw cHo0mSFgf7esDh8UDMzonAmRs85CVqPxihAvWcKNPO+i7pWq8hnOKikc6CuVAsx68DhXqFYy7c/ny v6Fsh2cq2wD39TgdPii9qgImEBss0NySMhzvuUDTRkKWSQYQW70mdy+xJ8TogbQJs51iIlBNpFtFK kFexj96EOljTGcivBQFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI9eV-001OLE-4t; Wed, 18 Jan 2023 14:42:59 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI9eC-001OB7-PI for opensbi@lists.infradead.org; Wed, 18 Jan 2023 14:42:43 +0000 Received: by mail-wm1-x32e.google.com with SMTP id g10so24841545wmo.1 for ; Wed, 18 Jan 2023 06:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y+QOrCVncQRH/0/znLIdOlJeILvyCL2T+Mvkca1eddM=; b=UlkrmBHysjLJXnJuLkZ7DHSPlwhbeclJez9V4EK6L7g0UH6Y0bUrXxaZfW7/M0y6nl LJsk9+mXsWcEM2Klz2VnAR9kufGOZiiXwpyaOAhoyRWtZ2zDkNbnfy6QmF9kNWfsx0tu +gS/2ZBUlZWRnUhwhxg8Gp8iwkMbXczPXnP6OOW79yN1YyRWnvZf3s8Iw//x9uqURPvf szFbOpApMLVmrDPEaBvJIpxlboMoEB58PCZqX92YvuXoBEx16k6sA57MRWrdky6bwGRX A4vkflgeZHctnkjlLTEZkK/hWe9uYcGGRkKMpTqiOynDwoIvenv1LTO4pgjzaOLDP8dN GqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y+QOrCVncQRH/0/znLIdOlJeILvyCL2T+Mvkca1eddM=; b=cC/hXmRWncricde92nIrbtSvoHLPRqJbKx2Leh0YGtAT/nsZbRgCAAVqgB+viaiNSv 7sF+avE/DmzTWNCpeVXRfzoeetdPCALaqDhaAvqRof2yA+VEJc51okFXTgt7AvQjO6iw 2WS6xES7z/JNr8tE1rgaFjpgAkYrJk1DmMvRrZxPtVd5ghXqVAJWTj7q3rmOnIP8rf5w xit8iaRdxlX1988PWHP8CtlJ/sL/wBQqM83nag17wtmH2d60rdRUlGg4k45iZdaNR9NQ BY+6FZm8C8Xu691NG9G0QN/DTmilD56Df+Kvk+tS8pWT/CVGvW47FcdcdluKm4gwhWO3 yMMg== X-Gm-Message-State: AFqh2koUhYhMFVhrByOzI/6PHlixhrokj21MexBNQ9M+fvbcjMbGwsnI 1Rb3T2MR6hMfXZH/gL5xcwb+4vmnLFCTP/fv X-Google-Smtp-Source: AMrXdXsyeZZyTOcrXybxfnAKoMANK4IJm1jTn2VYk9ootqDslZeb6YZDdS/pM1WN62vG6maGrEIWeQ== X-Received: by 2002:a05:600c:d3:b0:3da:23a4:627e with SMTP id u19-20020a05600c00d300b003da23a4627emr6784549wmm.6.1674052959292; Wed, 18 Jan 2023 06:42:39 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id ay22-20020a05600c1e1600b003dafbd859a6sm2164140wmb.43.2023.01.18.06.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:42:38 -0800 (PST) From: Andrew Jones To: opensbi@lists.infradead.org Cc: 'Atish Patra ' , 'Anup Patel ' , 'Ley Foon Tan ' , 'Sia Jee Heng ' , Anup Patel Subject: [PATCH 03/11] lib: sbi_hsm: Ensure errors are consistent with spec Date: Wed, 18 Jan 2023 15:42:26 +0100 Message-Id: <20230118144234.79263-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118144234.79263-1-ajones@ventanamicro.com> References: <20230118144234.79263-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230118_064240_907061_43C49C3A X-CRM114-Status: GOOD ( 11.49 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: HSM functions define when SBI_ERR_INVALID_PARAM should be returned. Ensure it's not used for reasons that don't meet the definitions by using the catch-all code, SBI_ERR_FAILED, for those reasons inst [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:32e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org HSM functions define when SBI_ERR_INVALID_PARAM should be returned. Ensure it's not used for reasons that don't meet the definitions by using the catch-all code, SBI_ERR_FAILED, for those reasons instead. Also, in one case sbi_hart_suspend() may have returned SBI_ERR_DENIED, which isn't defined for that function at all. Use SBI_ERR_FAILED for that case too. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_hsm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index c7454499b2ba..2fbb0d0afc7e 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -403,7 +403,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, /* Sanity check on domain assigned to current HART */ if (!dom) - return SBI_EINVAL; + return SBI_EFAIL; /* Sanity check on suspend type */ if (SBI_HSM_SUSPEND_RET_DEFAULT < suspend_type && @@ -416,7 +416,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, /* Additional sanity check for non-retentive suspend */ if (suspend_type & SBI_HSM_SUSP_NON_RET_BIT) { if (rmode != PRV_S && rmode != PRV_U) - return SBI_EINVAL; + return SBI_EFAIL; if (dom && !sbi_domain_check_addr(dom, raddr, rmode, SBI_DOMAIN_EXECUTE)) return SBI_EINVALID_ADDR; @@ -430,7 +430,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, /* Directly move from STARTED to SUSPENDED state */ if (!__sbi_hsm_hart_change_state(hdata, SBI_HSM_STATE_STARTED, SBI_HSM_STATE_SUSPENDED)) - return SBI_EDENIED; + return SBI_EFAIL; /* Save the suspend type */ hdata->suspend_type = suspend_type;