Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2878831lqz; Wed, 3 Apr 2024 11:04:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn700LAaFZMeG3asopbW/mW2mBngPGowEjd94Jg/psnXn2wEKxXqbQAOJc0uNg5hIMEWfddV1thQ95PfDoZmEOnVx144hhJjBTr552Xg== X-Google-Smtp-Source: AGHT+IH+k4N3vpf1c1oRf7somX8fonsrRyBXFPRc6NJbyral+FpFGZmunir4gHxZkzPDR4e3s58B X-Received: by 2002:a05:6a20:9f8a:b0:1a3:4c97:23a2 with SMTP id mm10-20020a056a209f8a00b001a34c9723a2mr373444pzb.20.1712167482830; Wed, 03 Apr 2024 11:04:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712167482; cv=pass; d=google.com; s=arc-20160816; b=jLzlmHz2wvvVXWlX9porMlM70MVfHESMaKLArZZRYF+8Ppkhz2RHMTEsGv6A/1xWd0 sBvYRmEt3Dhlz2Fe5wvNoKpg8FMO8k87xL5ilDGUIHWN1ZfInqFBFbiUfOEtNEpXJRoF uB0tHaFzkkt1bLSmEHFF34Z/kw4pFJHEm0wqhnOkjIRA9FjZ2ixQnk7nVo6BKfNXpHcK KPu4bIPBdqEMYBXQvRpeQ7zZP455P4bvXR72uN/qVOefFh7EdUCxY7KIdVhFQzP74uPk WrGKKxEW0Flb+fsfuUJWyBLXn1JUJvrOgJlTbOJzEHOp/zWf2VqMBOiw3sUMe/1foWFo 7lvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LxTDVH/2vo4vcGrOHHlZhI/B5ozl7ouQkArxm5bwHHM=; fh=w1LA0WCF7QwJXx+RIdLHRigEBMAi6AmV4Vyp9mvxbgw=; b=kulzM4funOLY9JBbAMHAB9NLzywGEXz+C1h6HjvqmtMyzyHGBAiZYa5L4mGlY4lN7X pPzDwYmkMvoaBA45NSykBx8W3siHs8S54vt0QpArbPPSODIE1MSe6RtnulDUmUmB/nk0 wuAxhUlVB/T6nrKKIZf5VxzRwcVOv4yD/SHMbMyzjyj6PVLVZCKNRoRwBcmXrmYTPV6q 6chYbcSODlt3xwRP+pQ6BjcD6S1T5XskocApZ1V2lglOQWhGUesk3UXx45iEC3fEm8b3 /Iphit3+Hh9t0lnZKw66KJMvrJEUZs14iDYfxzYpPiSNATo20dsyUGR1wnwAlz4h/MRo 8hUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ybs71K4C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g65-20020a636b44000000b005d9b49b7ad6si12877463pgc.775.2024.04.03.11.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 11:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ybs71K4C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6AF9B284CF9 for ; Wed, 3 Apr 2024 17:59:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E6AD15573C; Wed, 3 Apr 2024 17:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ybs71K4C" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 424221DFD6; Wed, 3 Apr 2024 17:57:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712167046; cv=none; b=UE24PMMsTN6kWzCDeoiSl2SB4eJE+pgjlOSTQehEUwdY9yNOZAsLLMfhq2bIkL811whDWtdDpfjpq+rSInMb2hiwBUJoQhK8yA8z3qMumbE8oCRjUrxNDjBArBTbWWqvHyu3GPNWMObuvBQZIZBGqsr92/9xcJK2FjH/AnjBv+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712167046; c=relaxed/simple; bh=d+ZUMUm1KAc8rkyq6ddYBLNSuuaZzHkrsJHewdp8CGc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YClaAySQJpoP1jcxva1w3EXgG/Lnfr/oIZxo3nC/FfRpbad9fDTsgN1Jyynd210RCh9TlUEhj5NPa7AZbVYf/2WDHMcUHLI/hONw1+pedrd3bnqaz8vlS/dDGfoh6EqwjoL4ceiUdEEvniCbdRhY7Ts5xbxsA3Y8X/3HByZ9Knw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ybs71K4C; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EF24C433F1; Wed, 3 Apr 2024 17:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712167045; bh=d+ZUMUm1KAc8rkyq6ddYBLNSuuaZzHkrsJHewdp8CGc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ybs71K4CaHKCzezTzi0rrbC9vZx7neRUWRqt0aX2rOcjTwvDoefIzHsDVku6laGq7 uMP5K+CXvfXbI5o1I/ywjXvdPXxOWxkisQwEODDMRC1ggUb76Nf5ZnlZ5dYrNaNwAr H8rBZRb9iAdZGfr1wTRJ8Kw39dNDmcDLFW2juM1zHafyo4Nx3KuQ3ldxH4piv0Cd8w VU5iHl0yU8wHyQJg2aR4g/w2IKiOwhTK+EDAwgvUt6gjsAPEvZ3YjYVtqp65oAbz9Y Irsm/lDhIrVYlVVk8QBeI65oL0h5mgEYc7s4WrdLVZN1q12s/YPasYkhGEinwr/fCq fwxyPPYmRu75w== Date: Wed, 3 Apr 2024 10:57:23 -0700 From: Nathan Chancellor To: Uros Bizjak Cc: Thomas Gleixner , Linus Torvalds , kernel test robot , oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Arjan van de Ven , x86@kernel.org, Luc Van Oostenryck , Sparse Mailing-list , "Paul E. McKenney" , llvm@lists.linux.dev Subject: Re: arch/x86/include/asm/processor.h:698:16: sparse: sparse: incorrect type in initializer (different address spaces) Message-ID: <20240403175723.GA2667607@dev-arch.thelio-3990X> References: <87edcruvja.ffs@tglx> <87bk7vuldh.ffs@tglx> <87bk7ux4e9.ffs@tglx> <878r2ywk3k.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Apr 02, 2024 at 01:43:00PM +0200, Uros Bizjak wrote: > On Mon, Mar 4, 2024 at 8:07 AM Thomas Gleixner wrote: > > > > On Mon, Mar 04 2024 at 06:42, Uros Bizjak wrote: > > > > > On Mon, Mar 4, 2024 at 12:49 AM Thomas Gleixner wrote: > > >> > > >> On Sun, Mar 03 2024 at 21:24, Uros Bizjak wrote: > > >> > On Sun, Mar 3, 2024 at 9:21 PM Uros Bizjak wrote: > > >> >> On Sun, Mar 3, 2024 at 9:10 PM Thomas Gleixner wrote: > > >> >> > That's so sad because it would provide us compiler based __percpu > > >> >> > validation. > > >> >> > > >> >> Unfortunately, the c compiler can't strip qualifiers, so typeof() is > > >> >> of limited use also when const and volatile qualifiers are used. > > >> >> Perhaps some extension could be introduced to c standard to provide an > > >> >> unqualified type, e.g. typeof_unqual(). > > >> > > > >> > Oh, there is one in C23 [1]. > > >> > > >> Yes. I found it right after ranting. > > >> > > >> gcc >= 14 and clang >= 16 have support for it of course only when adding > > >> -std=c2x to the command line. > > >> > > >> Sigh. The name space qualifiers are non standard and then the thing > > >> which makes them more useful is hidden behind a standard. > > > > > > With GCC, you can use __typeof_unqual__ (please note underscores) > > > without -std=c2x [1]: > > > > > > "... Alternate spelling __typeof_unqual__ is available in all C modes > > > and provides non-atomic unqualified version of what __typeof__ > > > operator returns..." > > > > > > Please also see the example in my last post. It can be compiled without -std=... > > > > With gcc >= 14. Not so with clang... > > Please note that clang-17.0.6 currently fails to compile kernel with > named address spaces [1]. So perhaps kernel can use __typeof_unqual__ > (available without -std=c2x) in the hope that clang implements > __typeof_unqual__ in one of its next releases, following the examples > of GCC [2] and MSVC[3]. This is now supported in clang 19.0.0 (main): https://github.com/llvm/llvm-project/commit/cc308f60d41744b5920ec2e2e5b25e1273c8704b I have inquired about applying this to the 18.x series, such that it would either make 18.1.3 or 18.1.4, but that is still open for discussion. I think the error that I mentioned at [1] is resolved with using __typeof_unqual__, I tested this diff, which is likely incorrect but allows me to continue testing without that warning/error due to -Werror: diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 20696df5d567..fc77c99d2e80 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,7 +95,7 @@ #endif /* CONFIG_SMP */ -#define __my_cpu_type(var) typeof(var) __percpu_seg_override +#define __my_cpu_type(var) __typeof_unqual__(var) __percpu_seg_override #define __my_cpu_ptr(ptr) (__my_cpu_type(*ptr)*)(__force uintptr_t)(ptr) #define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) #define __percpu_arg(x) __percpu_prefix "%" #x However, I get a crash in LLVM's backend with that diff applied on top of commit 034dd140a6d8 ("Merge branch into tip/master: 'x86/shstk'"), which appears to be another tangential issue. I've filed https://github.com/ClangBuiltLinux/linux/issues/2013 so that we don't lose track of this. Cheers, Nathan