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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B4EC27C76 for ; Wed, 25 Jan 2023 21:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjAYV46 (ORCPT ); Wed, 25 Jan 2023 16:56:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236123AbjAYVz0 (ORCPT ); Wed, 25 Jan 2023 16:55:26 -0500 Received: from fx403.security-mail.net (smtpout140.security-mail.net [85.31.212.143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5727E86A8 for ; Wed, 25 Jan 2023 13:55:24 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by fx403.security-mail.net (Postfix) with ESMTP id 7CE77579880 for ; Wed, 25 Jan 2023 22:55:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1674683722; bh=WtoB9JtlKwd4Y8mogATd1m73eAkNffWMtzkgdcOdrFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jpK3fSfJCzy3ZANEGkjKa68WlzWKHAnxNIOUyHjrFerEyLWvdC7JV4+9BbvbaYOVc zG/WmhbgVQcAC7cuLJSoEk6kP3iplqZGTody8prkX2fh/DSCpiNkfhrN11Nmfvh2q9 5rHYkMRf2BwOr/BqbGtWV8yBWOizstOkO2UnIhWc= Received: from fx403 (localhost [127.0.0.1]) by fx403.security-mail.net (Postfix) with ESMTP id 0F1A55794C5; Wed, 25 Jan 2023 22:55:22 +0100 (CET) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx403.security-mail.net (Postfix) with ESMTPS id 194FF578B2C; Wed, 25 Jan 2023 22:55:21 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id D2EB627E0493; Wed, 25 Jan 2023 22:55:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id AEC3727E0491; Wed, 25 Jan 2023 22:55:20 +0100 (CET) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id si6Lv1AzzjtE; Wed, 25 Jan 2023 22:55:20 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 4AA5127E0461; Wed, 25 Jan 2023 22:55:20 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <13e79.63d1a549.170d1.0> DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu AEC3727E0491 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1674683720; bh=OP2H0clmfjMlntXGEQUOupSQETmz7iibW86xdOXdO/c=; h=Date:From:To:Message-ID:MIME-Version; b=FiSVH+wqDIs88qUIullcsu5BFjd2D7z2E5u8DrTYSpKgGNXgRV/wZx6pLf0jEnjj1 nq174SqV22wtEYt+DC4eOS10NI0yUL2JmwTj2bfQCvZEO4mxAawGM/7zjbG/MQC8HR kpFf4zpnPjbRuo+I0TP0j3cj6aN2Vd984BCzoL6c= Date: Wed, 25 Jan 2023 22:55:19 +0100 From: Jules Maselbas To: "Jason A. Donenfeld" Cc: Yann Sionneau , Arnd Bergmann , Jonathan Corbet , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Eric Biederman , Kees Cook , Oleg Nesterov , Ingo Molnar , Waiman Long , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Paul Moore , Eric Paris , Christian Brauner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guillaume Thouvenin , Clement Leger , Vincent Chardon , Marc =?utf-8?b?UG91bGhpw6hz?= , Julian Vetter , Samuel Jones , Ashley Lesdalons , Thomas Costis , Marius Gligor , Jonathan Borne , Julien Villette , Luc Michel , Louis Morhet , Julien Hascoet , Jean-Christophe Pince , Guillaume Missonnier , Alex Michon , Huacai Chen , WANG Xuerui , Shaokun Zhang , John Garry , Guangbin Huang , Bharat Bhushan , Bibo Mao , Atish Patra , Qi Liu , Jiaxun Yang , Catalin Marinas , Mark Brown , Janosch Frank , Alexey Dobriyan , Benjamin Mugnier , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-audit@redhat.com, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Subject: Re: [RFC PATCH v2 12/31] kvx: Add other common headers Message-ID: <20230125215519.GE5952@tellis.lin.mbt.kalray.eu> References: <20230120141002.2442-1-ysionneau@kalray.eu> <20230120141002.2442-13-ysionneau@kalray.eu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ALTERMIMEV2_out: done Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On Fri, Jan 20, 2023 at 03:29:14PM +0100, Jason A. Donenfeld wrote: > Hi Yann, > > On Fri, Jan 20, 2023 at 03:09:43PM +0100, Yann Sionneau wrote: > > +#include > > +#include > > + > > +extern unsigned long __stack_chk_guard; > > + > > +/* > > + * Initialize the stackprotector canary value. > > + * > > + * NOTE: this must only be called from functions that never return, > > + * and it must always be inlined. > > + */ > > +static __always_inline void boot_init_stack_canary(void) > > +{ > > + unsigned long canary; > > + > > + /* Try to get a semi random initial value. */ > > + get_random_bytes(&canary, sizeof(canary)); > > + canary ^= LINUX_VERSION_CODE; > > + canary &= CANARY_MASK; > > + > > + current->stack_canary = canary; > > + __stack_chk_guard = current->stack_canary; > > +} > > > You should rewrite this as: > > current->stack_canary = get_random_canary(); > __stack_chk_guard = current->stack_canary; > > which is what the other archs all now do. (They didn't used to, and this > looks like it's simply based on older code.) Thanks for the suggestion, this will be into v3 > > +#define get_cycles get_cycles > > + > > +#include > > +#include > > + > > +static inline cycles_t get_cycles(void) > > +{ > > + return kvx_sfr_get(PM0); > > +} > > Glad to see this CPU has a cycle counter. Out of curiosity, what is > its resolution? This cpu has 4 performance monitor (PM), the first one is reserved to count cycles, and it is cycle accurate. > Also, related, does this CPU happen to have a "RDRAND"-like instruction? I didn't knew about the RDRAND insruction, but no this CPU do not have an instruction like that. > (I don't know anything about kvx or even what it is.) It's a VLIW core, a bit like Itanium, there are currently not publicly available documentation. We have started a discussion internally at Kalray to share more information regarding this CPU and its ABI. A very crude instruction listing can be found in our fork of gdb-binutils: https://raw.githubusercontent.com/kalray/binutils/binutils-2_35_2/coolidge/opcodes/kv3-opc.c Best regards, -- Jules