From patchwork Fri Aug 30 15:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=llMGkj3n; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=gFk792Sy; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwPYr4hwtz1ygJ for ; Sat, 31 Aug 2024 03:01:20 +1000 (AEST) 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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KKsP6x0xZ60DxkQgMEtAYBo8ovZkY+esCYHETCBGBXU=; b=llMGkj3nMTOBv1 sDeKVuqM0BkljrTxfd6Ad02hh1bWKz/2wwif6Ynfeuhq4RfixZlmDEa8ccbqpcgOpA46m9DhcIJan 2oqF7U+BxG6loDPaQWbcFSc7xKT8JvYuZ6ak+RsvNnmvOWYeCavpFMI+2DlR8ll8cdvIjxcP/hJIg 0uF4LHu2/s5cenIGjmyKqgIAQj7H9YMfir/4rGb80aZyJRtXTmhYihH1XtkTsmpLugzGKmEpjsIDX H6dsfWF1UwegwdT7bpDGpsDqU1enFkTzyFEiShpTG6gBFXH5hB2UodFJ2x9/+Z7woeMA7X9I8DC36 7f9LnresZ3fxuvwyh54g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk4zn-0000000770Z-4752; Fri, 30 Aug 2024 17:01:11 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3sV-00000006sUn-19gk for opensbi@lists.infradead.org; Fri, 30 Aug 2024 15:49:36 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-715cc93694fso1836537b3a.2 for ; Fri, 30 Aug 2024 08:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725032974; x=1725637774; darn=lists.infradead.org; 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=TEKJkDlJZFM5chzeT/k6ohJZ53QE6K2W83Z9QoPRvUE=; b=gFk792SyqD4BwGidz36LExBt/VRHXCjG+vqpJ1vBEEiyaxuPV8i5F4UDNAktXAO1e9 9Urm/3/sfce+f5nXcMDEqBqbteNXq72xFqsmNRBV2lC+IHOv7o+9MLmG3lLr5QiQ2cTg rFhoKQhrNYPOVQrd35fAqBUXQBJK6R9ey5PXVgzylog+IPitkkH46wtBIGlCXKOKqBhK r+yXO6CDtT3pwkG1I7afoFUrhuF5/z1wQAcFHEEm2Upu8n157odzS1Vwuf5fW1Pr1n6t Gsw/Ngqswm1e7Kj439Qy7pbEjHc7hbZeGgxBfaI0KcBMpKpRrNYQrXNrx3WSDQMxjoiK Tz0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725032974; x=1725637774; 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=TEKJkDlJZFM5chzeT/k6ohJZ53QE6K2W83Z9QoPRvUE=; b=V5jdvCl3n479D6p0EoC2MIJxuV3mEdIgSJWQ56fCR4OJYqugr8l08nzieS270nuoQJ vsbflEmn9j2ft+78m9WaaJwcToFq06ikWiFj2CAXKUghz9u6+eJL4b/oUqakGYd7tEoj 46ep1RvZFT1yQtI2+2kIp482C4QvsP+m1TXYHDLySbHrYvKwnzVXUZk1vHSc1iNxIfOk 8kIkNe1dsKoZfRtRXzXfLUK+R0Mm4p6ZSaa3HezkyLCy2znCHmfAceYJ2TBYG4NbUnNz ehWlYE5jzjIUcMrza+2zNyjBnfJu4dnmhYFwJGRwrQHlhEtkvzBSXYkAvy+KN8fri0x5 JxMw== X-Gm-Message-State: AOJu0YxkgOTOZvoX0QejzfcK9I3JLmRgnZg6seAE024RwfeOaMOKLh64 DeCwhMRY4WzJbCSHfQ3YgP0s3Rz9YqWbmc+oQZJrW+oE1lLmvcbqNTf5YBip8Dn7+thTOPNudyu jrGrccPPF8v3D7q/Ff4gh/poN8LOiMWr/QcGOzeLJ99KMFxC/PwCbgjfHjexNkZKitSWME3JKsD eM1KDjhNOkgv4gzk1cImabr3k+eQ5hOkLMcPeWbZHPpjuZGeTngw4= X-Google-Smtp-Source: AGHT+IEv0zcoY3W3nsdULS/ChEGwgzAKQQsWr/6wlmDOsPckNxHbVWFFdL2trO6voWmaBeEAFriYaQ== X-Received: by 2002:a05:6a20:c89c:b0:1c0:ef24:4125 with SMTP id adf61e73a8af0-1cce101e0a0mr7718432637.26.1725032974220; Fri, 30 Aug 2024 08:49:34 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e569e793sm2920817b3a.131.2024.08.30.08.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 08:49:33 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 02/12] include: sbi: Store the hart index in struct sbi_scratch Date: Fri, 30 Aug 2024 08:49:06 -0700 Message-ID: <20240830154929.3971790-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240830154929.3971790-1-samuel.holland@sifive.com> References: <20240830154929.3971790-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_084935_338799_41768158 X-CRM114-Status: GOOD ( 12.14 ) X-Spam-Score: -2.1 (--) 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: This is a more efficient way to get the index of the current hart than calling a function to loop through the hartindex -> hartid lookup table. Signed-off-by: Samuel Holland --- Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:436 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 This is a more efficient way to get the index of the current hart than calling a function to loop through the hartindex -> hartid lookup table. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- firmware/fw_base.S | 2 ++ include/sbi/sbi_scratch.h | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index b950c0b8..30dc28f0 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -218,6 +218,8 @@ _scratch_init: #endif REG_S a0, SBI_SCRATCH_OPTIONS_OFFSET(tp) MOV_3R a0, s0, a1, s1, a2, s2 + /* Store hart index in scratch space */ + REG_S t1, SBI_SCRATCH_HARTINDEX_OFFSET(tp) /* Move to next scratch space */ add t1, t1, t2 blt t1, s7, _scratch_init diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index 12e6a983..9ae4f891 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -42,8 +42,10 @@ #define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__) /** Offset of options member in sbi_scratch */ #define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__) +/** Offset of hartindex member in sbi_scratch */ +#define SBI_SCRATCH_HARTINDEX_OFFSET (14 * __SIZEOF_POINTER__) /** Offset of extra space in sbi_scratch */ -#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (14 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (15 * __SIZEOF_POINTER__) /** Maximum size of sbi_scratch (4KB) */ #define SBI_SCRATCH_SIZE (0x1000) @@ -83,6 +85,8 @@ struct sbi_scratch { unsigned long tmp0; /** Options for OpenSBI library */ unsigned long options; + /** Index of the hart */ + unsigned long hartindex; }; /** @@ -202,6 +206,10 @@ do { \ = (__type)(__ptr); \ } while (0) +/** Get the hart index of the current hart */ +#define current_hartindex() \ + (sbi_scratch_thishart_ptr()->hartindex) + /** Last HART index having a sbi_scratch pointer */ extern u32 last_hartindex_having_scratch;