Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2720050rwb; Fri, 20 Jan 2023 06:38:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMjjxWI2yQ9MSzpaWdI8eFliORZUnmUzb9NmQlgn/1GGpIFzxGQgPrugU8Bg4pVAtMzDNU X-Received: by 2002:a62:52d0:0:b0:582:c408:3ed1 with SMTP id g199-20020a6252d0000000b00582c4083ed1mr36218415pfb.32.1674225482479; Fri, 20 Jan 2023 06:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674225482; cv=none; d=google.com; s=arc-20160816; b=K2myTb0b+HOsBw/36Bxi+dDG3x+P+tM3LKXzV/DuKefvOLJqRbDvlNLNzv6Ouf4Pm2 yEkV8Ud3Vfh+yvL3sy5QO99nx6RhoX3e6f7oQ7cpheZ+yVcwKL9H0PnesKTqsVOcvcUF BXT869CjnaRv/iDV8HLoD/VzZ/xhmZqWDaW14RvMn4tQYJW1Pyb7uf4aMco2oNZlwmHW 4tlqPuUm1BgWI6BpyHe/hw+jmcRsPr5H13qVa1m+kg4h2yo/aG9GhtfF7+ji5Kwyc3+x 7RHIW+xYHMd2kCI3koeZQn48Af5JxE9MI5qsiTzeyn0TVC4b+6MNinwYLsW0KDfTXA3R Dg8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=F9kOqvxWdJiZ6o7rLV7rek2JVGrJsZXSaK0nvleVzCA=; b=LXUBIw9od7/6neUTqGI4LGEWvSt/hnUNjbyDBfeBvTfCtQvtCISn1s6yTFA0G1hYaV TJ9nyNAefgNGO73ugjLSe5LdDH4XsE2DkN7iQFs0491dte/kXe8NWLQW0F0RI4ctaBO6 aq//WqrsOLGRrWav0GFl1viuign3AZ1IFWz7HApOeUCsmJ4FfroJsg/B/gf4dXZSzzsj nUOrH4c1Sy4hdN02XTZqNjxbOQy5pM+fO90WSKiCwlOrYBuGiVFwClmpkx118I1/70MI dI0waxtz7qXfW8DO4aeTPvRPK/08033QWPXNtWSTFOzkwwMUqC6WyOOjBX1xOpLIgdk3 Vg4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=NTHbstKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a056a00228d00b0058dd23f63afsi11381513pfe.355.2023.01.20.06.37.56; Fri, 20 Jan 2023 06:38:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=NTHbstKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjATOaU (ORCPT + 49 others); Fri, 20 Jan 2023 09:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjATOaS (ORCPT ); Fri, 20 Jan 2023 09:30:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772A979297; Fri, 20 Jan 2023 06:29:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A8C81B82853; Fri, 20 Jan 2023 14:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 237E9C4339B; Fri, 20 Jan 2023 14:29:33 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="NTHbstKf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1674224971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=F9kOqvxWdJiZ6o7rLV7rek2JVGrJsZXSaK0nvleVzCA=; b=NTHbstKfPp3u89snVVs+oFRiOmLj7/9+v4hS84e1+clIoPhsJ2kSbFe1y7Ve3fpUvfhDFY RBcamZ38ta96TPzy+pU4lTKfZ8wbvpW/izzz3c6W+tHXCN5ZL8y0SX+AqrocY7EgB2oo7F 1Nc0qLsaQSetYUtiIFFpE6YtUNUcr48= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c179fd18 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Jan 2023 14:29:31 +0000 (UTC) Date: Fri, 20 Jan 2023 15:29:14 +0100 From: "Jason A. Donenfeld" To: Yann Sionneau Cc: 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 , Jules Maselbas , 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: References: <20230120141002.2442-1-ysionneau@kalray.eu> <20230120141002.2442-13-ysionneau@kalray.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230120141002.2442-13-ysionneau@kalray.eu> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.) > +#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? Also, related, does this CPU happen to have a "RDRAND"-like instruction? (I don't know anything about kvx or even what it is.) Jason