public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>, Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Sasha Levin <sashal@kernel.org>,
	rdunlap@infradead.org, linux@dominikbrodowski.net,
	openrisc@lists.librecores.org
Subject: [PATCH AUTOSEL 4.9 18/24] openrisc: start CPU timer early in boot
Date: Mon, 30 May 2022 09:52:05 -0400	[thread overview]
Message-ID: <20220530135211.1937674-18-sashal@kernel.org> (raw)
In-Reply-To: <20220530135211.1937674-1-sashal@kernel.org>

From: "Jason A. Donenfeld" <Jason@zx2c4.com>

[ Upstream commit 516dd4aacd67a0f27da94f3fe63fe0f4dbab6e2b ]

In order to measure the boot process, the timer should be switched on as
early in boot as possible. As well, the commit defines the get_cycles
macro, like the previous patches in this series, so that generic code is
aware that it's implemented by the platform, as is done on other archs.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Acked-by: Stafford Horne <shorne@gmail.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/openrisc/include/asm/timex.h | 1 +
 arch/openrisc/kernel/head.S       | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/arch/openrisc/include/asm/timex.h b/arch/openrisc/include/asm/timex.h
index 9935cad1b9b9..34d015bf0462 100644
--- a/arch/openrisc/include/asm/timex.h
+++ b/arch/openrisc/include/asm/timex.h
@@ -27,6 +27,7 @@ static inline cycles_t get_cycles(void)
 {
 	return mfspr(SPR_TTCR);
 }
+#define get_cycles get_cycles
 
 /* This isn't really used any more */
 #define CLOCK_TICK_RATE 1000
diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
index 98dd6860bc0b..0b6be5b3522b 100644
--- a/arch/openrisc/kernel/head.S
+++ b/arch/openrisc/kernel/head.S
@@ -452,6 +452,15 @@ _start:
 	l.ori	r3,r0,0x1
 	l.mtspr	r0,r3,SPR_SR
 
+	/*
+	 * Start the TTCR as early as possible, so that the RNG can make use of
+	 * measurements of boot time from the earliest opportunity. Especially
+	 * important is that the TTCR does not return zero by the time we reach
+	 * rand_initialize().
+	 */
+	l.movhi r3,hi(SPR_TTMR_CR)
+	l.mtspr r0,r3,SPR_TTMR
+
 	CLEAR_GPR(r1)
 	CLEAR_GPR(r2)
 	CLEAR_GPR(r3)
-- 
2.35.1


  parent reply	other threads:[~2022-05-30 14:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30 13:51 [PATCH AUTOSEL 4.9 01/24] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 02/24] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 03/24] b43legacy: Fix assigning negative value to unsigned variable Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 04/24] b43: " Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 05/24] ipw2x00: Fix potential NULL dereference in libipw_xmit() Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 06/24] ACPICA: Avoid cache flush inside virtual machines Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 07/24] ALSA: jack: Access input_dev under mutex Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 08/24] drm/amd/pm: fix double free in si_parse_power_table() Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 09/24] ath9k: fix QCA9561 PA bias level Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 10/24] media: cx25821: Fix the warning when removing the module Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 11/24] scsi: megaraid: Fix error check return value of register_chrdev() Sasha Levin
2022-05-30 13:51 ` [PATCH AUTOSEL 4.9 12/24] drm/amd/pm: fix the compile warning Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 13/24] ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 14/24] ASoC: dapm: Don't fold register value changes into notifications Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 15/24] net: remove two BUG() from skb_checksum_help() Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 16/24] dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 17/24] ipmi:ssif: Check for NULL msg when handling events and messages Sasha Levin
2022-05-30 13:52 ` Sasha Levin [this message]
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 19/24] nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 20/24] ASoC: rt5645: Fix errorenous cleanup order Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 21/24] media: exynos4-is: Fix compile warning Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 22/24] ARM: 9201/1: spectre-bhb: rely on linker to emit cross-section literal loads Sasha Levin
2022-05-30 13:53   ` Ard Biesheuvel
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 23/24] rxrpc: Return an error to sendmsg if call failed Sasha Levin
2022-05-30 13:52 ` [PATCH AUTOSEL 4.9 24/24] eth: tg3: silence the GCC 12 array-bounds warning Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220530135211.1937674-18-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=arnd@arndb.de \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=linux@roeck-us.net \
    --cc=openrisc@lists.librecores.org \
    --cc=rdunlap@infradead.org \
    --cc=shorne@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=stefan.kristiansson@saunalahti.fi \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox