From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 EE16FF44847 for ; Fri, 10 Apr 2026 12:22:43 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fsbWN3S2Hz2yhP; Fri, 10 Apr 2026 22:21:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775823680; cv=none; b=dl9PWs8ARTes3+mlJQfRtZvWXGVUfnC9MviCL6SoDX6dWzMZMMo1Q3ujHODM8UTlffZVMYNM/xUhQXrig7+iuRUNuUZmlj+Uh/c1VwhQh7hZntK87hArAU9WF5qNlw3ctpWY8mI+Fa1F+0+CgMU+8LsrrNjbvPFUelfJttMUk7tiIA3DRM6005u8/BfQi1kjSzrf/n/SWfHJXFaMjxbewi+riYNEHTp+Bc2LB6rqZI5OInaYr+j1M5NOJYg0KwWMPu7mBCjzXzshGkDYtSKgWoLLj5CzEQl4wj7en+UJdeP18GtyzpJNuVdsId2c0h5ltVGYsamWi64xXkKPj48JCQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775823680; c=relaxed/relaxed; bh=U8y46tGevNTaaJuQgRNS3grY9omWgCX/AAW8OBbapGE=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JfShPrB2n5qlVjU0T7HJoocdmHAdYcq8fMA898xUAnGoO0KpoPWsRA6tYCRaKd6pLgcz4P3PPkpMlF7k8FCq6spgXa6hb8W25KjjeQPqcklHZlrrTXsQPg44wZ2/sLS3kNipi3CkIskPbJ5qfdMwjsp9YERsaQLc1U9/VPdRUzModhWlqlfqF19lLLKRYixH+Dte1KSbZUF/ZVcksw7AGkVKchcAien52s4GQwr+TKIiOdNCELpiLtbdP6jdoOVM76IFpZfLPczoIHP99UQItDvEoZkXmWfyM/99vmH09dTVsLjRj27ijLp9X4aLhc0Kv7nhiwlUt8GUi+lpUXwymw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=OA4RjUak; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=tglx@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=OA4RjUak; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=tglx@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fsbWM4kfVz2ytV for ; Fri, 10 Apr 2026 22:21:19 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id A5F7D6111B; Fri, 10 Apr 2026 12:21:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57879C2BCB3; Fri, 10 Apr 2026 12:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823677; bh=8aVhqN+bsjtC+8iOVhItTcCo4nE5t4ex+cjOCvHOROg=; h=Date:From:To:Cc:Subject:References:From; b=OA4RjUakSKbHP7uZl9Rn6aI/7Qts08y1gdCxG4212yNJdVKaYLulTRlHhQ1giBOu6 tARhrIBIltPo7n2ZqupgbCjM222ynMbD+JMBXCcsIED9ns8vEth54JFbieyU26o9rm KoQTgfYyoH0jSRf5j3OQodGQDBBjhAykp4Hy5bQdfGP0P88P76fnb883frBXWWU03q P/YOEYqjXf/L4ccO74xjFbM3qOQBRFdrvTUVXM6TfNVPJX1ACluXAp6rS0x+D02XQB ZfqSCQC8dN3KdQ34VmPvfFKRcfafCQ6soBJ+KtAS56vLrMJXpWDVh/K6XVrYMUGmaP YaxQP6ppalRew== Date: Fri, 10 Apr 2026 14:21:14 +0200 Message-ID: <20260410120319.853669871@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Paul Walmsley , linux-riscv@lists.infradead.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 34/38] riscv: Select ARCH_HAS_RANDOM_ENTROPY References: <20260410120044.031381086@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 The only remaining non-architecture usage of get_cycles() is to provide random_get_entropy(). Switch riscv over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Add 'asm/timex.h' includes to the relevant files, so the global include can be removed once all architectures are converted over. Signed-off-by: Thomas Gleixner Cc: Paul Walmsley Cc: linux-riscv@lists.infradead.org --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/random.h | 25 +++++++++++++++++++++++++ arch/riscv/include/asm/timex.h | 13 ------------- arch/riscv/kernel/unaligned_access_speed.c | 1 + arch/riscv/kvm/vcpu_timer.c | 1 + arch/riscv/lib/delay.c | 1 + 6 files changed, 29 insertions(+), 13 deletions(-) --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -47,6 +47,7 @@ config RISCV select ARCH_HAS_PREPARE_SYNC_CORE_CMD select ARCH_HAS_PTDUMP if MMU select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_RANDOM_ENTROPY select ARCH_HAS_SET_DIRECT_MAP if MMU select ARCH_HAS_SET_MEMORY if MMU select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL --- /dev/null +++ b/arch/riscv/include/asm/random.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_RISCV_RANDOM_H +#define _ASM_RISCV_RANDOM_H + +#include + +#ifdef CONFIG_RISCV_M_MODE +/* + * Much like MIPS, we may not have a viable counter to use at an early point + * in the boot process. Unfortunately we don't have a fallback, so instead + * invoke the fallback function. + */ +static inline unsigned long random_get_entropy(void) +{ + if (unlikely(clint_time_val == NULL)) + return random_get_entropy_fallback(); + return get_cycles(); +} +#else /* !CONFIG_RISCV_M_MODE */ +static inline unsigned long random_get_entropy(void) +{ + return get_cycles(); +} +#endif /* CONFIG_RISCV_M_MODE */ +#endif /* _ASM_RISCV_RANDOM_H */ --- a/arch/riscv/include/asm/timex.h +++ b/arch/riscv/include/asm/timex.h @@ -31,19 +31,6 @@ static inline u32 get_cycles_hi(void) #define get_cycles_hi get_cycles_hi #endif /* CONFIG_64BIT */ -/* - * Much like MIPS, we may not have a viable counter to use at an early point - * in the boot process. Unfortunately we don't have a fallback, so instead - * we just return 0. - */ -static inline unsigned long random_get_entropy(void) -{ - if (unlikely(clint_time_val == NULL)) - return random_get_entropy_fallback(); - return get_cycles(); -} -#define random_get_entropy() random_get_entropy() - #else /* CONFIG_RISCV_M_MODE */ static inline cycles_t get_cycles(void) --- a/arch/riscv/kernel/unaligned_access_speed.c +++ b/arch/riscv/kernel/unaligned_access_speed.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "copy-unaligned.h" --- a/arch/riscv/kvm/vcpu_timer.c +++ b/arch/riscv/kvm/vcpu_timer.c @@ -14,6 +14,7 @@ #include #include #include +#include static u64 kvm_riscv_current_cycles(struct kvm_guest_timer *gt) { --- a/arch/riscv/lib/delay.c +++ b/arch/riscv/lib/delay.c @@ -10,6 +10,7 @@ #include #include +#include /* * This is copies from arch/arm/include/asm/delay.h