From patchwork Mon Jul 1 18:51:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Taube X-Patchwork-Id: 13718546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6A76C2BD09 for ; Mon, 1 Jul 2024 18:52:04 +0000 (UTC) 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=UgUEeQ1Uc4077ZxJbR5uHAQ52NnHDmEesNwXi/23SOk=; b=236KrojQul46PU PasJMNhW2PcLUH60F4PjaN8S6cyMxWckfny3WJShszbGUVTRVZYtm6ZpInY5zBYI1Gew5ziUJ5GsR WlH81TN8uOZe/J1DVpPwh874q/1fBomkhzeFeTunO5MEx5SWxJeP7UIzoIdyCWYjzjHh36+yGj0zJ 4YvOGL9DKcfOBlcqewfRswHVVlBQjPAWCk5VAR3fP4wqXP9//UcxvLKCosY/MkjO/RA6H+kT8eWke FYT5cwLcZ4UaNKnJ4IChC0Ew9Jp+Kb1HZeiBywslDWwXtKmsV/yJ4DroRsWkSUJBxHHxToMDZ9Y8A XTIHMCiqhpW/1bnSjG7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM89-00000004WVh-25VB; Mon, 01 Jul 2024 18:52:01 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM86-00000004WUX-3WoB for linux-riscv@lists.infradead.org; Mon, 01 Jul 2024 18:52:00 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1f4a5344ec7so23981585ad.1 for ; Mon, 01 Jul 2024 11:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719859918; x=1720464718; 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=anHX1DM3URGCkXrGn4JIrBeC+s/73VzKMiEIav89N4M=; b=0D73/lJSfSOH6c2pmJmx20z68jN5ysisuUzTrRh0oLQFT8bnvSrOTZ0149K25U0Dkm zxyqGuoCWqK4OZH5tVlxlFnkzSf78Cfc9dqW4zh8X7dVu/SU2uxhBhXptPBmR9kBDpPf VFFHr28S/Xes6zuU6qzz/etDS6rZP+hNIKaUOc3xRsuNkXzxkt/AIhAHTehI93TSSLbW p5d77SWlf4gRdRZoiYSCsJYVYVBB5P34RHqgrNvJdLbxYRLHK2aGxV17MWA5qoQZMUMr EWJNTSXvMkLaHooXz7l5i5M3OsMP824zS51tnoZWMCTRcxlxG+udhoedNdhSbCfmFs2A PPNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719859918; x=1720464718; 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=anHX1DM3URGCkXrGn4JIrBeC+s/73VzKMiEIav89N4M=; b=bp+FoufCsI6j/Q5pYdOtyFoAAv5FM1GZA9ZjUfAwY1SZDreZt8FPvlqbWx1k+FLQJs XbO3zYvpcScOS2kU6AnPUrVHopAAnDIIygntLG1TWN5nc1qhfHRjJ5jIOO0/ZlGRyHL1 LvsC57cJ443eSBC7kxKbI/n1iV5nUuDnlV0/Gs6zAiJWhbyy9v8TAdsCM0Zm3L9Bx/rl 8VlJXDGmND5XVyaR2NqGhN6BN3BOI2t5Q+xwVnRVqwQG99GO3ASXbbifFF0/V4VQCVYD ynqq5GARgkn0zEcXtkp9T3tQOf2jeu5u5D28v1ngPFTCsel07/85QQ5LZju78Dtxs2FW +Baw== X-Gm-Message-State: AOJu0Yxqz7AetU/LlA2scY2kcKaa2u9mq+fmiyxKCPWXyO+wpSMWcohi 2wW66eo4hye+MKON3OLQXJPsnnV3dZ62jqMVsaLgTI3ugT0x5YjGIH+flMCT+CydsktZV88JUvB Z X-Google-Smtp-Source: AGHT+IENBUzEg6ya4sq7aW1QaFBBcsao6oM/eWof/SzwO+QqO8+WPKu4MnxkOTanbSTh10xlJQnXDA== X-Received: by 2002:a17:902:d4cd:b0:1f7:1d71:25aa with SMTP id d9443c01a7336-1fadb42d78bmr110124205ad.6.1719859917674; Mon, 01 Jul 2024 11:51:57 -0700 (PDT) Received: from jesse-desktop.. (pool-108-26-179-17.bstnma.fios.verizon.net. [108.26.179.17]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10d1ccesm69883375ad.20.2024.07.01.11.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 11:51:57 -0700 (PDT) From: Jesse Taube To: linux-riscv@lists.infradead.org Cc: Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jesse Taube , Alexandre Ghiti , Conor Dooley , Masahiro Yamada , Wende Tan , Christophe JAILLET , Sami Tolvanen , Andrew Morton , Baoquan He , "Mike Rapoport (IBM)" , "Vishal Moola (Oracle)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v3 1/4] RISC-V: pi: Force hidden visibility for all symbol references Date: Mon, 1 Jul 2024 14:51:29 -0400 Message-ID: <20240701185132.319995-2-jesse@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701185132.319995-1-jesse@rivosinc.com> References: <20240701185132.319995-1-jesse@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_115158_907904_01E7A3BF X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Eliminate all GOT entries in the .pi section, by forcing hidden visibility for all symbol references, which informs the compiler that such references will be resolved at link time without the need for allocating GOT entries. Include linux/hidden.h in Makefile, like arm64, for the hidden visibility attribute. Signed-off-by: Jesse Taube Reviewed-by: Alexandre Ghiti --- V1 -> V2: - New patch V2 -> V3: - No changes --- arch/riscv/kernel/pi/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/pi/Makefile b/arch/riscv/kernel/pi/Makefile index 50bc5ef7dd2f..1ef7584be0c3 100644 --- a/arch/riscv/kernel/pi/Makefile +++ b/arch/riscv/kernel/pi/Makefile @@ -5,6 +5,7 @@ KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \ -Os -DDISABLE_BRANCH_PROFILING $(DISABLE_STACKLEAK_PLUGIN) \ $(call cc-option,-mbranch-protection=none) \ -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \ + -include $(srctree)/include/linux/hidden.h \ -D__DISABLE_EXPORTS -ffreestanding \ -fno-asynchronous-unwind-tables -fno-unwind-tables \ $(call cc-option,-fno-addrsig) From patchwork Mon Jul 1 18:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Taube X-Patchwork-Id: 13718547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F79AC3065A for ; Mon, 1 Jul 2024 18:52:17 +0000 (UTC) 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=v254OPyN1AOb1q3c3eekDsrj4GGvhDXYeG093oQRcRY=; b=rZ4DMpPw4HxhOs Lj8nghDCc7Cg5zKlOSgThLSpQq8vM+LPZ3y+XLuNonIpYhegdsUNbSwta0u8Q38x/vkszTwXFlOmc X7uQZqAwPatzJ+CMb4aDaZFSorBzwKR9a9xNTqUFGiyerJfc9pTTqGuwqRFTz6CgOdovcJbk2uXJS PQgBvaYAq5yY+2uEUwmQnQNBJuDb3nLiru55xxRXsepHWsj3HYaqxqGCohvmdq0SQLQqjW+WtO0Is eVgHA0nGVkB3Qs2hGH22hLb+jEpwaW886jDgfiznzCZMoKQOc0VfqwzcTx6Nn9CP6BrQgW26nfWlY PPJ5xSz9k3do04z8484A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM8M-00000004Wd3-0aqZ; Mon, 01 Jul 2024 18:52:14 +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 1sOM8H-00000004WaX-25wT for linux-riscv@lists.infradead.org; Mon, 01 Jul 2024 18:52:10 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70670fb3860so2034641b3a.1 for ; Mon, 01 Jul 2024 11:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719859928; x=1720464728; 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=wS9GYxuXw7/qz6F0Huo3Gpz70QhA7niN6kxlAksoOL8=; b=rTkphKOelVM74iMjCVq3qZnsmranTxPqDuDdnbQxzimlhW59S/rTWF5a8O9I02IoJC QZPpN+SSmiVhf075aQoU0SjaQJRf7D23z3rq+FXe71bn4fxB5lNQcy+AZlqbPpFJ/hzc 5jtqE80VtmlmMc7rD1F+C9FMe/Ir3wBK+9SXAr/5K7jVc3mSYF4N4MPVxlIni3VKNzc2 tyeygEQAn9x1cybZD8H1qjZlX4gwsnMdkQTStAIrXAfKBv3AJUJTYv3XVGrf56QzLei8 kVzDB5khoXzAG6oi/sQOdJrinQGwg9hS+In5KQNQJExO0ZgXIgDGJJka3tQtAANvSJdq aIeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719859928; x=1720464728; 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=wS9GYxuXw7/qz6F0Huo3Gpz70QhA7niN6kxlAksoOL8=; b=mvx4ka17f4tbx95XY2Al30060m+D9AK/Wyo7tplpx3KCpB4s3PQzxf3jrZxKd3yfMo oAoeLCR/yLxU4VYbBqoJ0IYHoeZ/REoKucImXJWhwuWsInw8VRGR98ck3OkRArsWiOVG 3/E6S579lgyaduhV24N6ZVIGxthykl4qmVtpW8P2AGYAgG7xzjducuDhR930zTh6/Qcf DTopv5NLFzOwstHMdDgEOv68Up5ssvsV5Wi+1FJLWPOXKo6ONftshVvR0p13bHPcfmHw Kz46aioDS+esiBKrlyXsAIBvTrYVFBaprWWhMajzu8Pz5GkQ1OzrpgVunw+jeHoz4scK h0Lw== X-Gm-Message-State: AOJu0YxccG2TkdX2kePvKiK8sVt6UMO9bAWr3Er/vSquCbPr0lxvSuTD eDulY6fVywdB2VJfeaAUxkADDYW57QNrW3Rt9dOQqu0OoNw3zVJ8SejIVy9iMGzhVdXTfdEqyw4 3 X-Google-Smtp-Source: AGHT+IG4RGDVsfQVAXbtDLxsNorbihdnFaeyKDYqlytZdtsd3sF4TSa+MDTMQVNkNGIHeIsWv6QxPQ== X-Received: by 2002:a05:6a21:7885:b0:1be:e4dd:17a1 with SMTP id adf61e73a8af0-1bef611ba18mr5678163637.5.1719859928442; Mon, 01 Jul 2024 11:52:08 -0700 (PDT) Received: from jesse-desktop.. (pool-108-26-179-17.bstnma.fios.verizon.net. [108.26.179.17]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10d1ccesm69883375ad.20.2024.07.01.11.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 11:52:08 -0700 (PDT) From: Jesse Taube To: linux-riscv@lists.infradead.org Cc: Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jesse Taube , Alexandre Ghiti , Conor Dooley , Masahiro Yamada , Wende Tan , Christophe JAILLET , Sami Tolvanen , Andrew Morton , Baoquan He , "Mike Rapoport (IBM)" , "Vishal Moola (Oracle)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Charlie Jenkins Subject: [PATCH v3 2/4] RISC-V: lib: Add pi aliases for string functions Date: Mon, 1 Jul 2024 14:51:30 -0400 Message-ID: <20240701185132.319995-3-jesse@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701185132.319995-1-jesse@rivosinc.com> References: <20240701185132.319995-1-jesse@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_115209_559446_B8BD5242 X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org memset, strcmp, and strncmp are all used in the the __pi_ section. add SYM_FUNC_ALIAS for them. When KASAN is enabled in __pi___memset is also needed. Suggested-by: Charlie Jenkins Signed-off-by: Jesse Taube Reviewed-by: Charlie Jenkins Reviewed-by: Alexandre Ghiti --- V2 -> V3: - New patch --- arch/riscv/lib/memset.S | 2 ++ arch/riscv/lib/strcmp.S | 1 + arch/riscv/lib/strncmp.S | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/riscv/lib/memset.S b/arch/riscv/lib/memset.S index 35f358e70bdb..da23b8347e2d 100644 --- a/arch/riscv/lib/memset.S +++ b/arch/riscv/lib/memset.S @@ -111,3 +111,5 @@ SYM_FUNC_START(__memset) ret SYM_FUNC_END(__memset) SYM_FUNC_ALIAS_WEAK(memset, __memset) +SYM_FUNC_ALIAS(__pi_memset, __memset) +SYM_FUNC_ALIAS(__pi___memset, __memset) diff --git a/arch/riscv/lib/strcmp.S b/arch/riscv/lib/strcmp.S index 687b2bea5c43..bc73325b2fd1 100644 --- a/arch/riscv/lib/strcmp.S +++ b/arch/riscv/lib/strcmp.S @@ -120,3 +120,4 @@ strcmp_zbb: .option pop #endif SYM_FUNC_END(strcmp) +SYM_FUNC_ALIAS(__pi_strcmp, strcmp) diff --git a/arch/riscv/lib/strncmp.S b/arch/riscv/lib/strncmp.S index aba5b3148621..b36325a57f6a 100644 --- a/arch/riscv/lib/strncmp.S +++ b/arch/riscv/lib/strncmp.S @@ -136,3 +136,4 @@ strncmp_zbb: .option pop #endif SYM_FUNC_END(strncmp) +SYM_FUNC_ALIAS(__pi_strncmp, strncmp) From patchwork Mon Jul 1 18:51:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Taube X-Patchwork-Id: 13718548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BDEBC2BD09 for ; Mon, 1 Jul 2024 18:52:27 +0000 (UTC) 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=GWve7wVeIwYfqeI5nHOyI3371Pgo1Rlz5maVkm47yCU=; b=gjd2gRAQUl4g1c Yx1oYtrrr3k0FV8swFeabHuOxUFFLQLYIfOUjTiLWdRSzM9kLJGFnQsJWmquS2KbrCaPvOWb9vq0w nME0Mzd76ETK/r+TauFUSl7MSN4GN1WsTnNc+SCB0cnHV6KFk/zBQd6GbmNDQaE+44eC1Kv4Lg7LE u/TA46bSNrdO7vqbwbtJVPkD7nr0znC42McdgsZIbIvEEQ5sKhBDQeeGROgO30iQOMUjUTnuDu0zM FhnSMPBllkdrhwmdrIzniqK8JAlvbe5pN8k81JJLznVTHapGCtEYscTnYFd6I1ZcQ+721YKHhVl/7 3LqoX+n4/u1WFktz9t0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM8W-00000004Wix-0PkZ; Mon, 01 Jul 2024 18:52:24 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM8S-00000004WhA-2jIn for linux-riscv@lists.infradead.org; Mon, 01 Jul 2024 18:52:22 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1f9cd92b146so21871135ad.3 for ; Mon, 01 Jul 2024 11:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719859939; x=1720464739; 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=itcRXPPZh8Q3BXWaLokMC5j6eLfJ7AJxltwXOVqlQWc=; b=uDCtjvGfBiYsn47kko6MbJNhyK/Gibnf4E2U/Vjdyov+wJXON/F41w308STK+ZsSd8 gug2NrAxE7YoH26vAjEtjzoG8subox77VMICBiqUNeHxnbH2V1K5xmo4lRkXE1FZb1a9 6XKD+77XSKHC+bTGn0FWRccNnu6U1u0bZvDibOjMFIOce1gmrX8/VjB55qvNnTd5neyk H1EG2lnMVgH6AOH/m1ZpxJlqLQYu76EGERRyi/Y/Lt+kSoZOZcMMs+oiZ177y2xMP37X ksqBDwHxNcy9+xQb/VWhOqSrR45j0OVFnP9JhgvThBOtdYPqs6LspzO9f/gKioZSZzBC XbHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719859939; x=1720464739; 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=itcRXPPZh8Q3BXWaLokMC5j6eLfJ7AJxltwXOVqlQWc=; b=AqRprI26qPrrTf5/xr+oZjVobRRKsj+QqPRv++5CTG/r4SeouAtL8us8soZaWMuQ0h fuIXpO8Dlk70SV1fTnr7X7Vz1MVTwxMOzjfmua65Y4lnDO4Gs3e0qBPXA/tU4U1R2U4x xAJIXxSIvDYhqJfvvNswdNqkGzSR1kFNmgLYqYNm+4vZZSts5uZr50/i/TdzN8rnHPqe DcvYgIACWarf2+QF/wLqinXtphfx4ReRPvu/hplBGwNKe2iUdgvHpdP13+UBiR+IWztg zqJHeNkHwCkORnbImBKZ593fDJwexSudcRuCUq7UnxF0TSsm1wQQo6IQgFXLI0fAX676 JtCA== X-Gm-Message-State: AOJu0YxmTnfwe+cP3ZIeCPGfSCnfVfhSSbCx+IEycaHNSGi+nWWbnF2Q RXKqpIreqjQZIt9eUH9oeZemhiIfwVj/HP4eZX368iudd7MgzuQ4QC7kWKL7ex0dNxjIK8fHxOa f X-Google-Smtp-Source: AGHT+IGIUJjGzCtP0TFRY0kOYr6wkwolnJ7bp8Bd4PCKOWhg54h7MqyOQeiMmVlGODF0WvjecY3/hQ== X-Received: by 2002:a17:903:32d2:b0:1f6:fe0d:ad47 with SMTP id d9443c01a7336-1fadbd08cbbmr59034325ad.62.1719859939141; Mon, 01 Jul 2024 11:52:19 -0700 (PDT) Received: from jesse-desktop.. (pool-108-26-179-17.bstnma.fios.verizon.net. [108.26.179.17]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10d1ccesm69883375ad.20.2024.07.01.11.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 11:52:18 -0700 (PDT) From: Jesse Taube To: linux-riscv@lists.infradead.org Cc: Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jesse Taube , Alexandre Ghiti , Conor Dooley , Masahiro Yamada , Wende Tan , Christophe JAILLET , Sami Tolvanen , Andrew Morton , Baoquan He , "Mike Rapoport (IBM)" , "Vishal Moola (Oracle)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Charlie Jenkins Subject: [PATCH v3 3/4] RISC-V: pi: Add kernel/pi/pi.h Date: Mon, 1 Jul 2024 14:51:31 -0400 Message-ID: <20240701185132.319995-4-jesse@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701185132.319995-1-jesse@rivosinc.com> References: <20240701185132.319995-1-jesse@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_115220_714893_A4E30027 X-CRM114-Status: GOOD ( 13.46 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add pi.h header for declarations of the kernel/pi prefixed functions and any other related declarations. Suggested-by: Charlie Jenkins Signed-off-by: Jesse Taube Reviewed-by: Alexandre Ghiti --- V1 -> V2: - New patch V2 -> V3: - Spelling --- arch/riscv/kernel/pi/cmdline_early.c | 10 ++-------- arch/riscv/kernel/pi/fdt_early.c | 7 +------ arch/riscv/kernel/pi/pi.h | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 arch/riscv/kernel/pi/pi.h diff --git a/arch/riscv/kernel/pi/cmdline_early.c b/arch/riscv/kernel/pi/cmdline_early.c index f6d4dedffb84..fbcdc9e4e143 100644 --- a/arch/riscv/kernel/pi/cmdline_early.c +++ b/arch/riscv/kernel/pi/cmdline_early.c @@ -6,15 +6,9 @@ #include #include -static char early_cmdline[COMMAND_LINE_SIZE]; +#include "pi.h" -/* - * Declare the functions that are exported (but prefixed) here so that LLVM - * does not complain it lacks the 'static' keyword (which, if added, makes - * LLVM complain because the function is actually unused in this file). - */ -u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa); -bool set_nokaslr_from_cmdline(uintptr_t dtb_pa); +static char early_cmdline[COMMAND_LINE_SIZE]; static char *get_early_cmdline(uintptr_t dtb_pa) { diff --git a/arch/riscv/kernel/pi/fdt_early.c b/arch/riscv/kernel/pi/fdt_early.c index 899610e042ab..40ee299702bf 100644 --- a/arch/riscv/kernel/pi/fdt_early.c +++ b/arch/riscv/kernel/pi/fdt_early.c @@ -3,12 +3,7 @@ #include #include -/* - * Declare the functions that are exported (but prefixed) here so that LLVM - * does not complain it lacks the 'static' keyword (which, if added, makes - * LLVM complain because the function is actually unused in this file). - */ -u64 get_kaslr_seed(uintptr_t dtb_pa); +#include "pi.h" u64 get_kaslr_seed(uintptr_t dtb_pa) { diff --git a/arch/riscv/kernel/pi/pi.h b/arch/riscv/kernel/pi/pi.h new file mode 100644 index 000000000000..493c8cb7c0e6 --- /dev/null +++ b/arch/riscv/kernel/pi/pi.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _RISCV_PI_H_ +#define _RISCV_PI_H_ + +#include + +/* + * The following functions are exported (but prefixed). Declare them here so + * that LLVM does not complain it lacks the 'static' keyword (which, if + * added, makes LLVM complain because the function is unused). + */ + +u64 get_kaslr_seed(uintptr_t dtb_pa); +bool set_nokaslr_from_cmdline(uintptr_t dtb_pa); +u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa); + +#endif /* _RISCV_PI_H_ */ From patchwork Mon Jul 1 18:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Taube X-Patchwork-Id: 13718549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96963C3065A for ; Mon, 1 Jul 2024 18:52:36 +0000 (UTC) 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=ohnKBafdwIh0juz/fY3DsPzUk219kvkCd6odZiu0aI4=; b=vnkys6QQtWkr+W biVN+27CUEr4etEEPDQndsHd2ZMUTH676tCf9JrygZ3caER5bQysvYQrTXdMH55tAbBnV1Ej9YC0X wyGbLO35PeQO5qu1ZsV4v9uQRkMF41c1m62HglcZAjUIcGmQc9Zco/79H1TBxP5enzfrFcFEiPH4Z CTUaYFeNyimwLO6VZZNaoASlWZiFdpwUfHpIbghIMs29ngMkWQXWL60N6iTO+ZbpXOKz6JYkNf9xE tCmNf6Ci4pi7mRW7OYkp2p3ZHWwCpcKIa/IzVxYZ2Y1lEcmkIdhQorLEvBhQJH6lMxXcoiRJ5vhR6 1v/6sQHHv1/cRzd6Pf3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM8f-00000004Wog-1riz; Mon, 01 Jul 2024 18:52:33 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOM8c-00000004WnK-3m3H for linux-riscv@lists.infradead.org; Mon, 01 Jul 2024 18:52:32 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-6e7b121be30so1789455a12.1 for ; Mon, 01 Jul 2024 11:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719859949; x=1720464749; 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=o7ga8f6sjus3/pF6/pQYF6Kn0B235BOis1noItMLTHA=; b=Iz16kMgHMPi/S/UT/RTe0nApaGM3np3xaLJRdIiI0Oxbz7aXwGVox78EkIZbl68S7R vUhjtz7c5zBupIrb/hhxfNNxm3vu7PEMYZIsHr8aNNhdAdeM0EhhF4CjXMNcMREhsoCf I2UdNmqEPADCoXKaAXfKlpL7/NUxoqawXLSsEw2ZQ+BrMEhsVi/0q2ECS2NMnri8N3bs HdRAKWQXMxRmr23fAVegUSwr9yBwwZwvVfA6npgR+I7hPOOJsyssbPWlscI1vK8vtqW8 yzBZV73PQWED9x0sXTLmn24xfUT5XvorSCr7Lyf1mSgP3Ilcyxy7d0CkvklQr3x3dgiH EgjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719859949; x=1720464749; 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=o7ga8f6sjus3/pF6/pQYF6Kn0B235BOis1noItMLTHA=; b=KyXVkwocG2rcDXawakrhMiby30k/6mD8KddZn5Hlyn4++TJ/WgzXIfzROg8lkf4ESJ QmTtz/WjHEHWbrFcQqVsUkMAfneNgtQtFPZIrksRG0CIsOuKgND+UCX82w3N4EUuQS6k x6gtDBDkJsTLpwnlCsNAdwDKsZ3jxHpXdSRZcMjzkb7WrMcmZ8RCOUvmy1Kkv1uulpH6 qyy7ZLCvbkIY35rMmUWW31jWohCOwqhcxLbwlLH0FBDxr8V1HLOH61tslvycu6siL1ej yGUKd8pvPeswVz8zkg+Es9oitV20TjV6LZTGjQHgR36jdR7/XEWf9OBQo+BZ0svI3FTQ uIsQ== X-Gm-Message-State: AOJu0Yzw+vPXio6WiT14S1tue5skdefK/e5j4MRDGgWLoE74OTyhz3Sr zmJD9FnCQ01l0W06DO8mHlJPdJlAcsKpwQqcaA403DT94chMcdXdEyao+rd8bYn6P4tmNlpZJLE 9 X-Google-Smtp-Source: AGHT+IGcH0CpqPMsLOuGz5KxlnxLc6xQ6aLgSzqAFRR2NDXP2KKVJ1RBIMMsbs8u5NIC7eMylnsUiw== X-Received: by 2002:a05:6a20:9145:b0:1be:6387:b766 with SMTP id adf61e73a8af0-1bef60fedacmr6262081637.16.1719859949443; Mon, 01 Jul 2024 11:52:29 -0700 (PDT) Received: from jesse-desktop.. (pool-108-26-179-17.bstnma.fios.verizon.net. [108.26.179.17]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10d1ccesm69883375ad.20.2024.07.01.11.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 11:52:29 -0700 (PDT) From: Jesse Taube To: linux-riscv@lists.infradead.org Cc: Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jesse Taube , Alexandre Ghiti , Conor Dooley , Masahiro Yamada , Wende Tan , Christophe JAILLET , Sami Tolvanen , Andrew Morton , Baoquan He , "Mike Rapoport (IBM)" , "Vishal Moola (Oracle)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v3 4/4] RISC-V: Use Zkr to seed KASLR base address Date: Mon, 1 Jul 2024 14:51:32 -0400 Message-ID: <20240701185132.319995-5-jesse@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701185132.319995-1-jesse@rivosinc.com> References: <20240701185132.319995-1-jesse@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_115230_970988_453C64A7 X-CRM114-Status: GOOD ( 30.67 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Parse the device tree for Zkr in the isa string. If Zkr is present, use it to seed the kernel base address. On an ACPI system, as of this commit, there is no easy way to check if Zkr is present. Blindly running the instruction isn't an option as; we have to be able to trust the firmware. Signed-off-by: Jesse Taube Reviewed-by: Charlie Jenkins Reviewed-by: Alexandre Ghiti Tested-by: Zong Li --- V1 -> V2: - Almost entire rewrite V2 -> V3: - Dont parse iscv,isa-base - Move fdt_early_match_extension_isa in pi.h under comment - Only check enabled cpus - Rename early_isa_str to fdt_early_match_extension_isa - Rename get_ext_named to early_cpu_isa_ext_available - Rewrite isa_string_contains - Update commit description - Use fdt_stringlist_contains for riscv,isa-extensions --- arch/riscv/kernel/pi/Makefile | 2 +- arch/riscv/kernel/pi/archrandom_early.c | 30 +++++ arch/riscv/kernel/pi/fdt_early.c | 160 ++++++++++++++++++++++++ arch/riscv/kernel/pi/pi.h | 3 + arch/riscv/mm/init.c | 5 +- 5 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 arch/riscv/kernel/pi/archrandom_early.c diff --git a/arch/riscv/kernel/pi/Makefile b/arch/riscv/kernel/pi/Makefile index 1ef7584be0c3..dba902f2a538 100644 --- a/arch/riscv/kernel/pi/Makefile +++ b/arch/riscv/kernel/pi/Makefile @@ -33,5 +33,5 @@ $(obj)/string.o: $(srctree)/lib/string.c FORCE $(obj)/ctype.o: $(srctree)/lib/ctype.c FORCE $(call if_changed_rule,cc_o_c) -obj-y := cmdline_early.pi.o fdt_early.pi.o string.pi.o ctype.pi.o lib-fdt.pi.o lib-fdt_ro.pi.o +obj-y := cmdline_early.pi.o fdt_early.pi.o string.pi.o ctype.pi.o lib-fdt.pi.o lib-fdt_ro.pi.o archrandom_early.pi.o extra-y := $(patsubst %.pi.o,%.o,$(obj-y)) diff --git a/arch/riscv/kernel/pi/archrandom_early.c b/arch/riscv/kernel/pi/archrandom_early.c new file mode 100644 index 000000000000..3f05d3cf3b7b --- /dev/null +++ b/arch/riscv/kernel/pi/archrandom_early.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +#include "pi.h" + +/* + * To avoid rewriting code include asm/archrandom.h and create macros + * for the functions that won't be included. + */ +#undef riscv_has_extension_unlikely +#define riscv_has_extension_likely(...) false +#undef pr_err_once +#define pr_err_once(...) + +#include + +u64 get_kaslr_seed_zkr(const uintptr_t dtb_pa) +{ + unsigned long seed = 0; + + if (!fdt_early_match_extension_isa((const void *)dtb_pa, "zkr")) + return 0; + + if (!csr_seed_long(&seed)) + return 0; + + return seed; +} diff --git a/arch/riscv/kernel/pi/fdt_early.c b/arch/riscv/kernel/pi/fdt_early.c index 40ee299702bf..49ff5360bf87 100644 --- a/arch/riscv/kernel/pi/fdt_early.c +++ b/arch/riscv/kernel/pi/fdt_early.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "pi.h" @@ -23,3 +24,162 @@ u64 get_kaslr_seed(uintptr_t dtb_pa) *prop = 0; return ret; } + +/** + * fdt_device_is_available - check if a device is available for use + * + * @fdt: pointer to the device tree blob + * @node: offset of the node whose property to find + * + * Returns true if the status property is absent or set to "okay" or "ok", + * false otherwise + */ +static bool fdt_device_is_available(const void *fdt, int node) +{ + const char *status; + int statlen; + + status = fdt_getprop(fdt, node, "status", &statlen); + if (!status) + return true; + + if (statlen > 0) { + if (!strcmp(status, "okay") || !strcmp(status, "ok")) + return true; + } + + return false; +} + +/* Copy of fdt_nodename_eq_ */ +static int fdt_node_name_eq(const void *fdt, int offset, + const char *s) +{ + int olen; + int len = strlen(s); + const char *p = fdt_get_name(fdt, offset, &olen); + + if (!p || olen < len) + /* short match */ + return 0; + + if (memcmp(p, s, len) != 0) + return 0; + + if (p[len] == '\0') + return 1; + else if (!memchr(s, '@', len) && (p[len] == '@')) + return 1; + else + return 0; +} + +/** + * isa_string_contains - check if isa string contains an extension + * + * @isa_str: isa string to search + * @ext_name: the extension to search for + * + * Returns true if the extension is in the given isa string, + * false otherwise + */ +static bool isa_string_contains(const char *isa_str, const char *ext_name) +{ + size_t i, single_end, len = strlen(ext_name); + char ext_end; + + /* Error must contain rv32/64 */ + if (strlen(isa_str) < 4) + return false; + + if (len == 1) { + single_end = strcspn(isa_str, "sSxXzZ"); + /* Search for single chars between rv32/64 and multi-letter extensions */ + for (i = 4; i < single_end; i++) { + if (tolower(isa_str[i]) == ext_name[0]) + return true; + } + return false; + } + + /* Skip to start of multi-letter extensions */ + isa_str = strpbrk(isa_str, "sSxXzZ"); + while (isa_str) { + if (strncasecmp(isa_str, ext_name, len) == 0) { + ext_end = isa_str[len]; + /* Check if matches the whole extension excluding version. */ + if (ext_end == '\0' || ext_end == '_' || isdigit(ext_end)) + return true; + } + /* Multi-letter extensions must be split from other multi-letter + * extensions with an "_", the end of a multi-letter extension will + * either be the null character or the "_" at the start of the next + * multi-letter extension. + */ + isa_str = strchr(isa_str, '_'); + if (isa_str) + isa_str++; + } + + return false; +} + +/** + * early_cpu_isa_ext_available - check if cpu node has an extension + * + * @fdt: pointer to the device tree blob + * @node: offset of the cpu node + * @ext_name: the extension to search for + * + * Returns true if the cpu node has the extension, + * false otherwise + */ +static bool early_cpu_isa_ext_available(const void *fdt, int node, const char *ext_name) +{ + const void *prop; + int len; + + prop = fdt_getprop(fdt, node, "riscv,isa-extensions", &len); + if (prop && fdt_stringlist_contains(prop, len, ext_name)) + return true; + + prop = fdt_getprop(fdt, node, "riscv,isa", &len); + if (prop && isa_string_contains(prop, ext_name)) + return true; + + return false; +} + +/** + * fdt_early_match_extension_isa - check if all cpu nodes have an extension + * + * @fdt: pointer to the device tree blob + * @ext_name: the extension to search for + * + * Returns true if the all available the cpu nodes have the extension, + * false otherwise + */ +bool fdt_early_match_extension_isa(const void *fdt, const char *ext_name) +{ + int node, parent; + bool ret = false; + + parent = fdt_path_offset(fdt, "/cpus"); + if (parent < 0) + return false; + + fdt_for_each_subnode(node, fdt, parent) { + if (!fdt_node_name_eq(fdt, node, "cpu")) + continue; + + if (!fdt_device_is_available(fdt, node)) + continue; + + if (!early_cpu_isa_ext_available(fdt, node, ext_name)) + return false; + + ret = true; + } + + return ret; +} diff --git a/arch/riscv/kernel/pi/pi.h b/arch/riscv/kernel/pi/pi.h index 493c8cb7c0e6..21141d84fea6 100644 --- a/arch/riscv/kernel/pi/pi.h +++ b/arch/riscv/kernel/pi/pi.h @@ -11,7 +11,10 @@ */ u64 get_kaslr_seed(uintptr_t dtb_pa); +u64 get_kaslr_seed_zkr(const uintptr_t dtb_pa); bool set_nokaslr_from_cmdline(uintptr_t dtb_pa); u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa); +bool fdt_early_match_extension_isa(const void *fdt, const char *ext_name); + #endif /* _RISCV_PI_H_ */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 9940171c79f0..bfb068dc4a64 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1025,6 +1025,7 @@ static void __init pt_ops_set_late(void) #ifdef CONFIG_RANDOMIZE_BASE extern bool __init __pi_set_nokaslr_from_cmdline(uintptr_t dtb_pa); extern u64 __init __pi_get_kaslr_seed(uintptr_t dtb_pa); +extern u64 __init __pi_get_kaslr_seed_zkr(const uintptr_t dtb_pa); static int __init print_nokaslr(char *p) { @@ -1045,10 +1046,12 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) #ifdef CONFIG_RANDOMIZE_BASE if (!__pi_set_nokaslr_from_cmdline(dtb_pa)) { - u64 kaslr_seed = __pi_get_kaslr_seed(dtb_pa); + u64 kaslr_seed = __pi_get_kaslr_seed_zkr(dtb_pa); u32 kernel_size = (uintptr_t)(&_end) - (uintptr_t)(&_start); u32 nr_pos; + if (kaslr_seed == 0) + kaslr_seed = __pi_get_kaslr_seed(dtb_pa); /* * Compute the number of positions available: we are limited * by the early page table that only has one PUD and we must