Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp514787rdb; Thu, 15 Feb 2024 07:07:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXTObHbVHprxfjCusnRMAQSFzfEQTJd/fbPDBAEbCBYj2fcTC8R6ulR+u9S0NCtr7inaF5EAICsRkBfNlpc04PCO83f/qsOf5rK43ngAQ== X-Google-Smtp-Source: AGHT+IEmnG60SJ8EcvNVdkbPsiF3REB2OaqPOzGXlMgUU4PjNCeWW5j/sr9613Zj4rjyJYsRea5k X-Received: by 2002:a17:90a:8c13:b0:298:b523:1c7f with SMTP id a19-20020a17090a8c1300b00298b5231c7fmr1806669pjo.40.1708009644755; Thu, 15 Feb 2024 07:07:24 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e22-20020a656796000000b005dc833ef4e6si1250706pgr.75.2024.02.15.07.07.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:07:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67137-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=neutral (body hash did not verify) header.i=@linutronix.de header.s=2020 header.b="EC/xk6Ve"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-67137-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.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 C3741282772 for ; Thu, 15 Feb 2024 15:07:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F227E132C14; Thu, 15 Feb 2024 15:07:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EC/xk6Ve"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Q3F+Rr+I" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8AC8412B162 for ; Thu, 15 Feb 2024 15:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708009629; cv=none; b=NKf/P8JJIbk2Bl1Al0J8QyU0Ew+1Z+ZD5hAAfJIvGG025LxhQj8R21rV6rQ+7yF0gFXIoG5NeVGxuWeR7ke05rN0FmqiupTbvpFeeBM8oEwa1cFhw+D5fGQLXHACqc2qZPhTDn7NHk6TMCDdsYjOxYyNhJWizaQCA4j3iwi72rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708009629; c=relaxed/simple; bh=2h7Nalua6B7zD6VVA6BFd2ENrLxcOo7tFBbNQHN80Zg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=j2n/H5X7yuF1LEqfEZQuNIRo8S5DMstCkXR38iUd4fwhRVRdk7Bg04wYpH2JTzEIyIy1U1Jt707/MjYBP/SXmKkwUXyK6gFgg924SfWFIx2ipp8SMDvWFfTXvHZ91gPE2sBSCbo3juFjA+GnXnCS3G7/HNBlvd/6Amr/kWHGB60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EC/xk6Ve; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Q3F+Rr+I; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708009625; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+kjFECKwp/gnEjyA2W0gSKVNPHcDB8rT+e0g8GRi/vA=; b=EC/xk6VeD1mldde92+gNANHelHktQHrxKuMk2WVBC2C77r0s9S4a4p+E8QY9B6UOpQsx93 z8n25jcnOL7RWbPWrrh53SLwgpNDQG6cwq2UFnfWqwAuoTQf9fNGYUhEo1s/ge782p1C5w y/2x/Jrz3pzoNCi6d7AKUgKFCtkGfgYIkQxm94W2v8XOCHMiO/rkTDEywTwUKb5N0KJAVb JhBg8HuDmEMzG2fZ1kENCP8G4maYzeCVSfY9boWNAVA0Lqu+AhHC/U55UJjoxxyiumUZh/ LqDvnwM6GlssjVVTTAiztX1HVyw8Bv2EAilUjjcNiTIZooGXTLCHg33SeHGddQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708009625; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+kjFECKwp/gnEjyA2W0gSKVNPHcDB8rT+e0g8GRi/vA=; b=Q3F+Rr+It5GbOBoiUEy2iO5W961PEpIcI8HWMvg9cVDk0PUYtCUwQT2sqTXVo3lEe9y1va O4KE7WXkIUtVksDg== To: Andy Shevchenko Cc: LKML , x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" , Wang Wendy Subject: Re: [patch V6a 01/19] x86/cpu: Provide cpuid_read() et al. In-Reply-To: References: <20240212153109.330805450@linutronix.de> <20240212153624.516965279@linutronix.de> <878r3mg570.ffs@tglx> Date: Thu, 15 Feb 2024 16:07:05 +0100 Message-ID: <87edddepgm.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-Transfer-Encoding: quoted-printable On Thu, Feb 15 2024 at 10:49, Andy Shevchenko wrote: > On Wed, Feb 14, 2024 at 10:29=E2=80=AFPM Thomas Gleixner wrote: >> >> Provide a few helper functions to read CPUID leafs or individual registe= rs >> into a data structure without requiring unions. > > ... > >> +#define cpuid_subleaf(leaf, subleaf, regs) { \ >> + BUILD_BUG_ON(sizeof(*(regs)) !=3D 16); \ >> + __cpuid_read(leaf, subleaf, (u32 *)(regs)); \ >> +} >> + >> +#define cpuid_leaf(leaf, regs) { \ >> + BUILD_BUG_ON(sizeof(*(regs)) !=3D 16); \ >> + __cpuid_read(leaf, 0, (u32 *)(regs)); \ >> +} > > ... > >> +#define cpuid_subleaf_reg(leaf, subleaf, regidx, reg) { \ >> + BUILD_BUG_ON(sizeof(*(reg)) !=3D 4); \ >> + __cpuid_read_reg(leaf, subleaf, regidx, (u32 *)(reg)); \ >> +} >> + >> +#define cpuid_leaf_reg(leaf, regidx, reg) { \ >> + BUILD_BUG_ON(sizeof(*(reg)) !=3D 4); \ >> + __cpuid_read_reg(leaf, 0, regidx, (u32 *)(reg)); \ >> +} > > I'm wondering if we can use static_assert() instead of BUILD_BUG_ON() > in the above macros. Probably.