Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp460640lqp; Sun, 9 Jun 2024 04:23:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/eIYmnhebuRmg7Y2eu3YcHCeFjUNuPs0KS4LMDsrToWG2yiHBP70LHkF9qzhGYeASHYI+8RD5rXyFrCsvQKEpSJ9HQEo5sbOjYE6EKg== X-Google-Smtp-Source: AGHT+IEuIDa8RKjmcDkpn2+xrCv2ZAUt6YveLxYxNc11YRnev9WHXI9y36DVcloi7XgS3ZONoOvm X-Received: by 2002:a05:6a20:3ca8:b0:1b6:c527:7e42 with SMTP id adf61e73a8af0-1b6c527811amr909682637.3.1717932191142; Sun, 09 Jun 2024 04:23:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717932191; cv=pass; d=google.com; s=arc-20160816; b=gzdFD++nc4DCyfWsYPiBT6Umrp8zdnEQHo574D+rPB5LxtD8bJi00oPnUOhrRdbNdH PJRm3wLqGN6YsCFqD27n3j+/QhlVOmn0Lf2XjS2YwP4NAMDOplECAyi8fvJH1iPbZCLC XinTAqbQzCHopl9xMrhGEEcYMql8tXf3k7QZvsYnahprNAoYFTp1ZRPlwY43peHoiKE+ xcqsh84uZjZnlLoetThVuiTqArqY6HqCHTRx7h7KZrunh/ut5tsAhuKubjeFNrcTVXJK dWhyZ93wQTfhig0XMqt1/nuGDqkTJpxsfvtSFm5AML+XiA9rEf6m/ReJF4a4RapnxaU7 5s3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Wvqqzt8mRbBVpIrsNZaWXP6FfYaMmAg35B1wSRhrLn0=; fh=ij3XRWP8/VrUIvmNELLx3T3EIRGrq4uvR9Zr+C6e09E=; b=jg6bZriW2noqXjS1DPcK7VDOb2fVbL87HjOHUfe5T0BuaXpp4YySAfDZ7ha95/kbBd seIappYpmp0HCqYl/3sO9iK4ezrDoHYbtgYl841IvxqBCjad+dfjc8VlvBEfX5VNHY1/ C9vOO3s42nfdJ4oRy3EiO7NNvRzK5cABB5BHb3J0JIOLYvhxwY6Fxr6buMIvcPOwsYAJ A2LfVmTmzx7Webn5uOcurKKzVGkjU+laEvqZXdxd9pktxUPptqtbQXcWV7r/nvX0kQ2I KnAvNb8roFEQqMrKo1upJ4FeClq5ItmCC+yncnkSzsDLI94hLh8XAqXhk47WtfdNUkbs L/oQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=YRHmiY2l; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-207345-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2d1179062si2879009a91.165.2024.06.09.04.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 04:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207345-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=YRHmiY2l; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-207345-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de 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 BD89F2810F8 for ; Sun, 9 Jun 2024 11:23:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB0EB2E84A; Sun, 9 Jun 2024 11:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="YRHmiY2l" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 8DA581865C; Sun, 9 Jun 2024 11:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717932184; cv=none; b=HSrGIcJSlZzuSnv4kMCvHKRBtXKBRQivk2zRumtRpjbTmZ7imC9DLZBOKTX86tO9jkiIG9IVg7l+7g+5+qsgjQkZhvwdx9whr3gC/fI4xjcCEmS+4/jN40dJ8qBw2VuVOmm55vzmjfWuBkPL6LoaS5dylUnKG598DjBLraUVnXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717932184; c=relaxed/simple; bh=VE6QwhzHXGGsL6EN23G7rodAUHJBH/uKxOmJM1ROGLs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qGT3DAkq5FAZR++GDED/hd0qrQ7A093itAFGhM91NIMnZTffiTHjQtBv+7v2Ejbz8t/G2waS0pphlSO0xXuUELu100IdDKzJtnle4h3WHkDtUuvaUYTYF4Sy2NOsYAxbd6tWp0MbDvXXCOIq8lyD6P8uXiyxNc/hTui0Xe6hHIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=YRHmiY2l; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 192A340E016E; Sun, 9 Jun 2024 11:22:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1fvZKEsG9R5s; Sun, 9 Jun 2024 11:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1717932175; bh=Wvqqzt8mRbBVpIrsNZaWXP6FfYaMmAg35B1wSRhrLn0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YRHmiY2lq5i9UbRqPmzL5EHzi+yjVKQEqYQ6+jkT/MPUKhEJ37/IkH26uRyV+zotS vCnF2wJKPy8bDiGMwMTWntUn8504NQkZkhXzUB1VZtO+OIKxu99LHXbqO6r4RhyJ2j N01Lg8tsVCtnh4QK8eQsK1dSii6HwWR0Ep2XJRD1gp+dy+UJolT6PrkwU68jpUA76C e40CPRJz5RpwQynC+YSJBgAFcEI6ahIBCcxUsUmNywbX14g8j5B9MzwEhuPPqG5WtO VEutse9TFvEUOaYI3b/wXvSU15acCtPM+2u+1rZr0Jz+ihzK4YhCz9zDaVwMSDhgYw uXHMOBmeQDtQ+N8sJT5ZnL1kRS7pbE2nl9XxH6olFh91yPMwlykGlQkhCEj/iSshcI PeXp4m29nF/FqAD+L1MtAfMes3EITQKxRRro+R6h/IxbOuryhsxa5NCd11nY/G/QDJ l6XsHBTXt65NNSpu2BG44Z8O6encs1VxNP0GS5Y6LHVjcOiTCbIE4SORJmIu1qnu/Z rvD6IOrwZSJFsF5zKfu09DhVyGtjs/lPmT3QtKIvvmIoFqMy1WcKKP7OCZKWgIt5yL e8EGRMjF2/X0FdQyoL97AacrUSpWTzEPgsHX9bruxu71nxlxqgLuYmuY0B2BiMVA7S +5KcQGE6/YiUW4HXgnFRC3oc= Received: from zn.tnic (p5de8ee85.dip0.t-ipconnect.de [93.232.238.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id DD72F40E016A; Sun, 9 Jun 2024 11:22:45 +0000 (UTC) Date: Sun, 9 Jun 2024 13:22:40 +0200 From: Borislav Petkov To: Linus Torvalds Cc: Peter Anvin , Ingo Molnar , Thomas Gleixner , Rasmus Villemoes , Josh Poimboeuf , Linux Kernel Mailing List , the arch/x86 maintainers , linux-arch Subject: Re: [PATCH] x86: add 'runtime constant' infrastructure Message-ID: <20240609112240.GBZmWQgNQXguD_8Nc8@fat_crate.local> References: <20240608193504.429644-2-torvalds@linux-foundation.org> 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 In-Reply-To: <20240608193504.429644-2-torvalds@linux-foundation.org> On Sat, Jun 08, 2024 at 12:35:05PM -0700, Linus Torvalds wrote: > Ingo / Peter / Borislav - I enabled this for 32-bit x86 too, because it > was literally trivial (had to remove a "q" from "movq"). I did a > test-build and it looks find, but I didn't actually try to boot it. Will do once you have your final version. I still have an Atom, 32-bit only laptop lying around here. > +#define runtime_const_ptr(sym) ({ \ > + typeof(sym) __ret; \ > + asm("mov %1,%0\n1:\n" \ > + ".pushsection runtime_ptr_" #sym ",\"a\"\n\t" \ > + ".long 1b - %c2 - .\n\t" \ > + ".popsection" \ > + :"=r" (__ret) \ > + :"i" ((unsigned long)0x0123456789abcdefull), \ > + "i" (sizeof(long))); \ > + __ret; }) You might wanna use asm symbolic names for the operands so that it is more readable: #define runtime_const_ptr(sym) ({ \ typeof(sym) __ret; \ asm("mov %[constant] ,%[__ret]\n1:\n" \ ".pushsection runtime_ptr_" #sym ",\"a\"\n\t" \ ".long 1b - %c[sizeoflong] - .\n\t" \ ".popsection" \ : [__ret] "=r" (__ret) \ : [constant] "i" ((unsigned long)0x0123456789abcdefull), \ [sizeoflong] "i" (sizeof(long))); \ __ret; }) For example. > +// The 'typeof' will create at _least_ a 32-bit type, but > +// will happily also take a bigger type and the 'shrl' will > +// clear the upper bits Can we pls use the multiline comments, like you do below in the same file. Otherwise, it looks ok to me and it boots in a guest. I'll take the final version for a spin on real hw in a couple of days, once the review dust settles. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette