Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp741771imm; Thu, 31 May 2018 08:36:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLU2FFwq/6C2QiDLCDSA5hCQ+BfLGMzPIcDZKLqCtg+9vLEb/g+Xu2mSif63gzRqnEKZG13 X-Received: by 2002:a63:8ec8:: with SMTP id k191-v6mr5895476pge.435.1527781019039; Thu, 31 May 2018 08:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527781019; cv=none; d=google.com; s=arc-20160816; b=Cmql6HmJe+5Qr4Ny3uaDudCMGQIP38bSA4kRQQA7kk3nJQ4xs5talCtmdOOwVN5da9 VEQsnYH9OE1rqmKYa0oBPZi1FASCwzZjR584Xsoo4Q/A31fUHE1CoCcE/HzP42+USInM iEofCYoPW+3VMIqkp4moolqINIjkD0sB8sRVmWiAq+GolbPaLFGtRs48tklPSAt9mnLk YxqY9GbSFkU45DXAhzcx9jwTf6NX5bdDID+P8jsJLP8Lv9cFztd23rKdLELb+AEJY7XE e/Y+CiF7/Ixk4KW8A3Z0ss4GqisOcRxZ+dWjOz5N2FUkMI57VmQTCZxBom0XY2qqOX3Z XVhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=wDTSla6Y/x4Kx1RFoab232dxBle5yubiHroZUNSDjPY=; b=EUmHPbMhs1JmvgO2LV/vu4a3uQx4OxKx9qutrN5ckIrt7QnpbfJMCzMWnSYg+qUt9p YF8DFopO+PzRa9ByydfgHaGQTZzpx+z8uqOTikuhIUIONUIy6F0qL5KEoCfByrjEPW7H 6fAb3k5fCCiY8V5XWrieQ3J49pjQzkyzHvGzxeKUsyXvFJTwUQvM4iCFwgATmvaHEHmF GiRluy5c7pav0lpffSxU1fYClgogD+yMYlhTk6EC049ZJODBtolVxIzdDIVOolDlBA0e kLCI5k73+Ke7C3RT6NZJQDpm2rEjK1hDXaYfdoOZW56cuoYpoo+6cD9NgvO+YbGVk2aU Z1VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fPeYQJiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a19-v6si3783283pfi.353.2018.05.31.08.36.44; Thu, 31 May 2018 08:36:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fPeYQJiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755505AbeEaPf6 (ORCPT + 99 others); Thu, 31 May 2018 11:35:58 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:38849 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755369AbeEaPf4 (ORCPT ); Thu, 31 May 2018 11:35:56 -0400 Received: by mail-wm0-f65.google.com with SMTP id m129-v6so54621377wmb.3 for ; Thu, 31 May 2018 08:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wDTSla6Y/x4Kx1RFoab232dxBle5yubiHroZUNSDjPY=; b=fPeYQJiBvBDVLsG3+EWIaxPPch8eIETP0RCSfNybbhKWA/GB5Crh86nMtnJ+rp9OiO KHSh4YLRgaEqIb1gLVb4OXrp2ksDBIEUdp6wnBgrdpGCtz/i5D+0disQU2u8q8ChqdyZ 7AdSMpFRRvzT9aXJZWcVd8ZpXZATWOiviKZgyCktEizgccMVAIkW3WDcpDGWnmG7zsyN xfKS34qlq0lu9YTzbUO43yJBPGhUDEcX80N9rsY4oLkImeZXwXbK4jeHyfwxTlGyGyEp K/ybJjL26P0SH968wcIy1arOhfz89DlkZ0Ah88VVEEyE/nWC/uTm+jL47SKbQZEpMU4m rXuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wDTSla6Y/x4Kx1RFoab232dxBle5yubiHroZUNSDjPY=; b=aSTOcdnu6L8rnxT+GF1IICAmqqh9sYdO6NspbMuANOuxNHh5PWvr4kTiZ8twFH4POc vbYVShsZ4MdDyT5iM5cYhhe51A3faiAzyLRz5TDeZdLGIeHgEQT4B/10t8embo/q1XaG PRGl9Z2N5zWF1m8oZMJuc7mE84d3PgqAfGUFMAPnA0TXaBQiR+mJ9PP9nAeF/ElKH9OR 2dWuMvGBPfQbchEQzpTIw0S3auPexMWBz+mk4awMR8PDI3tKkQ2zzWzSJNGWiNaAiyzE z0i4nca+8JBMiV3XNpdJahndMknjLHxL8XtW+u1MRlLDCp/xHBf5w6csju7iD+eKtaOe 3LKg== X-Gm-Message-State: ALKqPwe3Q+pH0ehzD5xUnY+D4tuVby650PWBZcYIyu4uM5R01n/WuHIA O+CxAxZm52K4Hm5KQ9Udj8g= X-Received: by 2002:a50:b832:: with SMTP id j47-v6mr8462571ede.272.1527780955438; Thu, 31 May 2018 08:35:55 -0700 (PDT) Received: from ltop.local ([2a02:a03f:4023:8a00:e536:460:2667:1db8]) by smtp.gmail.com with ESMTPSA id z44-v6sm10179203edb.72.2018.05.31.08.35.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 08:35:54 -0700 (PDT) Date: Thu, 31 May 2018 17:35:54 +0200 From: Luc Van Oostenryck To: Palmer Dabbelt Cc: yamada.masahiro@socionext.com, Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, albert@sifive.com, michal.lkml@markovi.net Subject: Re: [PATCH] riscv: pass machine size to sparse Message-ID: <20180531153553.kex32gupopdq2nqh@ltop.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180512 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 05:09:21AM -0700, Palmer Dabbelt wrote: > On Mon, 28 May 2018 23:14:20 PDT (-0700), yamada.masahiro@socionext.com wrote: > > 2018-05-29 15:11 GMT+09:00 Christoph Hellwig : > > > On Mon, May 28, 2018 at 06:35:05PM +0200, Luc Van Oostenryck wrote: > > > > By default, sparse assumes a 64bit machine when compiled on x86-64 > > > > and 32bit when compiled on anything else. > > > > > > > > This can of course create all sort of problems when this doesn't > > > > correspond to the target's machine size, like issuing false > > > > warnings like: 'shift too big (32) for type unsigned long' or > > > > is 64bit while sparse was compiled on a 32bit machine, or worse, > > > > to not emit legitimate warnings. > > > > > > > > Fix this by passing the appropriate -m32/-m64 flag to sparse. > > > > > > Can we please move this to the common Kbuild code using the > > > CONFIG_64BIT syombol? This really should not need boiler plate in > > > every architecture. > > > > > > I agree. > > > > Luc did so for -mbig/little-endian: > > https://patchwork.kernel.org/patch/10433957/ > > > > We should do likewise for -m32/64. > > Sorry for being a bit slow here, but I like the idea of making the > 32/64-bit issue generic as it seems like it'll be necessary for > every port. Sure, Christophe asked it too. I've sent a new version doing it once and for all for all archs but I forgot to CC you: https://lkml.org/lkml/2018/5/30/948 > Looking through the patch for big/little-endian I did > notice: > > * RISC-V compilers set "__riscv_xlen" to the length of an X > (integer) register in bits. > * RISC-V compilers define "__riscv", and it doesn't appear we inform > sparse about that. > > These two might not be that interesting, but we do already have some > cases where we're checking for __riscv_xlen in Linux. I've yet to > successfully use sparse, but adding at least > > CHECKFLAGS += -D__riscv > > seems reasonable, Sure (but I don't see a dependency in the kernel (yet)). > and possibly also some sort of > > ifeq ($(CONFIG_ARCH_RV64I),y) > CHECKFLAGS += -D__riscv_xlen=64 > else > CHECKFLAGS += -D__riscv_xlen=32 > fi > > might be necessary. Yes, this one is really needed. I'll send a patch for this one and __riscv. > We strive to follow the generic rules for > ABI-related stuff like __LP64__ but I don't think there's any > generic mapping for XLEN. Similarly there's "__riscv_flen" and > "__riscv_float_abi_*", but those are less likely to be used by the > kernel so they're probably not worth worrying about for now. Yes, I agree. Note that sparse will define __LP64__ (and _LP64) when in -m64 mode. > There's also a bunch of other RISC-V macros, the only one of which > we're currently using is "__riscv_muldiv" (and that's in a manner > that's unlikely to trigger any sort of static analysis). Between a > lack of Kconfig options and a glibc port we're essentially mandating > IMA right now, so these probably don't matter. Yes, I just saw. I think also it's better to leave it so for now. And if it becomes more used, then better to infer it from the compiler than harcoding it. Regards, -- Luc