From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE27F28A1CB; Thu, 17 Jul 2025 09:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752745161; cv=none; b=ZyDZk57poT8xoJkmkH4VL0j4mGGDFBggwOcz3p7szwhjvUMg5vVT0z+sOOENqCLzISCaF6zFZ65T2ApV8X3Wsoz3CW7S44BauXicQhqZ0AdMex9EfN+ZxJNXOvuitrVO8ScUwGdmHWMwGGwGuKg45NGGwawPhBFw70S9gd/EEc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752745161; c=relaxed/simple; bh=qcEDNnlUMtq2IkP0HriN612nVzOADpXFPILGbH21gWQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GV0e3NGiSC1PK+RKqk9cl6n3unahmNds9t3opqW5CYD1RHfS2IuHjcbeyEJrxX253gRZUiuBndE2pzRqJgQy/fC5IgMKAKxmN9DSg29q7/B+ib7KoPOkUUH7npwQ0iwXJdUUSxRUEuviCiZz5FVXVIBs5QLQ0sPAmbk4dDafQ5w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id A2122433F0; Thu, 17 Jul 2025 09:39:12 +0000 (UTC) Message-ID: <1abf91b9-a295-4b0c-b4c8-176f7c59b950@ghiti.fr> Date: Thu, 17 Jul 2025 11:39:11 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/7] riscv: Add tools support for xmipsexectl To: aleksa.paunovic@htecgroup.com, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jonathan Corbet Cc: Palmer Dabbelt , Conor Dooley , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20250625-p8700-pause-v4-0-6c7dd7f85756@htecgroup.com> <20250625-p8700-pause-v4-6-6c7dd7f85756@htecgroup.com> Content-Language: en-US From: Alexandre Ghiti In-Reply-To: <20250625-p8700-pause-v4-6-6c7dd7f85756@htecgroup.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeitddvgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeetlhgvgigrnhgurhgvucfihhhithhiuceorghlvgigsehghhhithhirdhfrheqnecuggftrfgrthhtvghrnheptdfhleefjeegheevgeeljeellefgvefhkeeiffekueejteefvdevhfelvdeggeeinecukfhppedukeehrddvudefrdduheegrdduhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudekhedrvddufedrudehgedrudehuddphhgvlhhopegluddtrddugedrtddrudefngdpmhgrihhlfhhrohhmpegrlhgvgiesghhhihhtihdrfhhrpdhnsggprhgtphhtthhopedugedprhgtphhtthhopegrlhgvkhhsrgdrphgruhhnohhvihgtsehhthgvtghgrhhouhhprdgtohhmpdhrtghpthhtoheprhhosghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkrhiikhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegtohhnohhrodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlrdifrghlmhhslhgvhiesshhifhhivhgvrdgtohhmpdhrtghpthhtohepphgrlhhmvghrsegurggssggvl hhtrdgtohhmpdhrtghpthhtoheprghouhesvggvtghsrdgsvghrkhgvlhgvhidrvgguuhdprhgtphhtthhopegtohhrsggvtheslhifnhdrnhgvth X-GND-Sasl: alex@ghiti.fr On 6/25/25 16:21, Aleksa Paunovic via B4 Relay wrote: > From: Aleksa Paunovic > > Use the hwprobe syscall to decide which PAUSE instruction to execute in > userspace code. > > Signed-off-by: Aleksa Paunovic > --- > tools/arch/riscv/include/asm/vdso/processor.h | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/tools/arch/riscv/include/asm/vdso/processor.h b/tools/arch/riscv/include/asm/vdso/processor.h > index 662aca03984817f9c69186658b19e9dad9e4771c..027219a486b7b93814888190f8224af29498707c 100644 > --- a/tools/arch/riscv/include/asm/vdso/processor.h > +++ b/tools/arch/riscv/include/asm/vdso/processor.h > @@ -4,26 +4,33 @@ > > #ifndef __ASSEMBLY__ > > +#include > +#include > +#include > #include > > static inline void cpu_relax(void) > { > + struct riscv_hwprobe pair; > + bool has_mipspause; > #ifdef __riscv_muldiv > int dummy; > /* In lieu of a halt instruction, induce a long-latency stall. */ > __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); > #endif > > -#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE > - /* > - * Reduce instruction retirement. > - * This assumes the PC changes. > - */ > - __asm__ __volatile__ ("pause"); > -#else > - /* Encoding of the pause instruction */ > - __asm__ __volatile__ (".4byte 0x100000F"); > -#endif > + pair.key = RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0; > + __riscv_hwprobe(&pair, 1, 0, NULL, 0); So this should not trigger a syscall, so even if it's weird, I guess that's ok. Another solution that was already suggested for CFI would be to implement VDSO alternatives, we could easily parse the VDSO elf and patch it at boot time, I'm pretty sure that will be useful at some point. > + has_mipspause = pair.value & RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL; > + > + if (has_mipspause) { > + /* Encoding of the mips pause instruction */ > + __asm__ __volatile__(".4byte 0x00501013"); Here you could have used the MIPS_PAUSE introduced earlier. > + } else { > + /* Encoding of the pause instruction */ > + __asm__ __volatile__(".4byte 0x100000F"); > + } > + > barrier(); > } > > Anyway, let's merge this for now: Reviewed-by: Alexandre Ghiti Thanks, Alex