From patchwork Fri Jan 6 11:22:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1722373 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=umtN2jJy; 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=CCqffFIV; 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 4NpLXr3JkWz23fq for ; Fri, 6 Jan 2023 22:22:36 +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=kOIbzQ85h5uy9A33OFB0pwz0Xm3UKNZrTV+3HZ1PRMY=; b=umtN2jJytGaG87 Ch7z89PqhUtZGlYCCBMpver9+nvaTkunU6akIZkqi+NBJFPAc6wIYUa9BqIlQWsJfov1FBaiF3SjF 4zhmjR1Xe+6SmdVGK6vvzOabI2OEo5bt+c+GEaSlw+VhLgE14sw/NGl6pp7KJFQA81vCLrckqc34/ 5EgKTHNbPNUI2TZ6rWnPV/vAHCh3pPlTwYA0QHoK9rdtJa1oxZ0LR3XsNjIwVEnr/WWBqITc68oLS 2/fxBD73gRX6DqtkJNRv0zykvJQWgyRahKCIScZozAdebWXFIiPgqIQFWTIY2PYLumrZlJJC99sql nMamCSxb4gXtw1fBZ4Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDknl-007i6K-4x; Fri, 06 Jan 2023 11:22:21 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDknh-007i3B-QB for opensbi@lists.infradead.org; Fri, 06 Jan 2023 11:22:19 +0000 Received: by mail-wr1-x42a.google.com with SMTP id s9so973447wru.13 for ; Fri, 06 Jan 2023 03:22:16 -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=6zIWMy8OVGBLIFyH/EZ3AqXENiyhsmS66/S6uwBRvH8=; b=CCqffFIVw6pMGhGhPf4CtBNRpGT+yR7/Mkk8F+NEI9iN2n/yWygsW1X05jLABwhxbv BhtROihR33s8fp9nKFnwGQwfP3nKUgA4518+ZSHkypEANHEUiyXDfhGJf7ctV1ZGrYud +m7rtAcnMrrXeuF8iX+uAGXSpJHW073J/cN/1+4/ynwukCvr9seWY/vpN7Z65o4oFy7M 0Vxnkbtg71FJVWF7trDbewbiQZ2W4onpYHxMgZG/vN7UeoR5vUmJGt66l0nglP9Z31jM WTivp45dPdCeQDf3xVSQST7lFDmCrV+dq9tMWTuseaS/QlNbKRoCMzF028Nzn3GIvBE5 h2xA== 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=6zIWMy8OVGBLIFyH/EZ3AqXENiyhsmS66/S6uwBRvH8=; b=phxDbp3wshY+K1jQ/9Dj2SzixmH0WatnRTruEO9IgKfIsQhAxrkZO76d1NO24rSTam 9ZPwQCV7qlrf8j7y8hL7dn9+Jt2TEI3px4XjkeJuWnYc4bTCozURp1mHyIb2yi5iBZi8 7jh7LDW19eJhJy9Se/WF+iStE32XRjQc9WUdg1XlWdd/BMLyyDHBMO53R01te5V148yP x454kRecGpKzpiFAU6OgP9jiWvfPqd18mFYiMSDt928fSo+B3ql3Dr98gBvSTUz5bSWh dT1K3u6ETkwnjT5hBGjKIWX2oCo1m2myWuQML+F4oCdrLP9+lnZ7NKMauinVtFnXW/1p VryA== X-Gm-Message-State: AFqh2krYsVdWlOK8NJQ9ZIkmgcSdO3fx8WvM1NSp6ZQ/NwFlF360zimk BXvGF1lWEwFczq4UiADR5cfDIcu97yMKparI X-Google-Smtp-Source: AMrXdXtmNQjp/yl327zzY+jfRrVvhZ/xsC7mYLfzWoJtsp/3vIN+IENtjA06+fTWj4xqlSQgOBbFXg== X-Received: by 2002:a05:6000:170f:b0:24a:9a21:c9e with SMTP id n15-20020a056000170f00b0024a9a210c9emr32917498wrc.59.1673004135174; Fri, 06 Jan 2023 03:22:15 -0800 (PST) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id j11-20020adfd20b000000b0024207478de3sm874362wrh.93.2023.01.06.03.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 03:22:14 -0800 (PST) From: Andrew Jones To: opensbi@lists.infradead.org Cc: 'Sia Jee Heng ' , 'Anup Patel ' , 'Ley Foon Tan ' , 'Atish Patra ' Subject: [RFC PATCH 03/11] lib: sbi_hsm: Ensure errors are consistent with spec Date: Fri, 6 Jan 2023 12:22:01 +0100 Message-Id: <20230106112209.441825-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106112209.441825-1-ajones@ventanamicro.com> References: <20230106112209.441825-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_032217_882133_5E857D77 X-CRM114-Status: GOOD ( 12.10 ) 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:42a 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 6ef6c5bdd4a7..3635f968e020 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;