Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2150859lqt; Mon, 22 Apr 2024 03:01:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8uhSPKmFFF61VU4eWxqtJdGllBDR00URk8HWpM+8OKrPPyx38UA+8xENmj2FNdyfdGUL7BZFswsEsIxtFndFfVP4L2acefXXLlKUaEQ== X-Google-Smtp-Source: AGHT+IGv9gR80Dp9k+KJuVME0ND0h1Ckqt/SCPLGovI0ZTPNaXaF5FdfCvstMFaA58yG9zLHoeyv X-Received: by 2002:a05:6102:30b0:b0:47b:b8a7:7ddc with SMTP id y16-20020a05610230b000b0047bb8a77ddcmr10368034vsd.30.1713780081684; Mon, 22 Apr 2024 03:01:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713780081; cv=pass; d=google.com; s=arc-20160816; b=UMBuutt8B2EsIlLyQ9Obr4KFm4VTqMa8U1EKUGO0Bs9wgmcvRf5AlgyoX6gcuKh8WJ 7TGKPFFP+0gMlvIFp2yDwfjHqfNXe4vAh1E2RnIG3h5s/KkzFbWax+vRf1biEWoRqkLi 9jpCaj8dzDjo4jqtE3HgiGSgTWgt0kpYHapCLTqv3c+AFCvcTNkpJC9pCoMTk8AtNz6Q oTiZd3XvgzMO1g/tzWuqZTn8J3h6oZMzBt0e0r/wPbPI3+4rDCH9Wji7Br3xADuKI50c +/Dz+dzWpsM7knH1VrQf4+eBT8VrEZ39r56Gz+RzmV7DG3+kJNcr751rplCrD9cf7eKE ObsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=a9hI7A6km8WqPAn1moauJLIkkzsRvNZx2A1wWvsp/r4=; fh=nc0fknZ7Ugza3bm9KD5ejx8UDmqPehkw9JKfTDY6F6I=; b=ihXedaF02OiRrMx8wiojyZpFXodebdnCedIeMTAU1SHdJow4UG3yO1knIfOwXk/1my ImVSEO24Yftb4LJ/bf2DF053rQJzC2a751Unu8cCI5TVCSdcZ241f6tdKQuztPHBDLTt bM997Bj60Br48pJo/ubt2oKrqv1mScKRdhWjPtKwhfaMdE142Z91AtBlDnMpeFDYQTWk +8q5pnFkBNG5exB+dmLi+6P8kZeWjgr7arFZ+1Gm9ySUpHhoiMhQO/XjtEfnNEUnpyUG CzVfLdwI1tYiRekD7+Kha5IDrSsW/Tl/WkcEXIcGrXUOOlzvOGv9KJQ4pVnJOxQgUVfy /FEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ef2wO9+A; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-153143-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153143-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t2-20020a05610210c200b0047bf78a7474si1852vsr.417.2024.04.22.03.01.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 03:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153143-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ef2wO9+A; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-153143-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153143-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E7971C20FEE for ; Mon, 22 Apr 2024 10:01:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3469C13D50F; Mon, 22 Apr 2024 10:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ef2wO9+A"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zGnIVHzm" 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 89EAF6518F; Mon, 22 Apr 2024 10:01:12 +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=1713780074; cv=none; b=hpahLlMxtnXTU7YwiqnwQFKOxfPfGCUtYvhKW3CDP4DPNfxuyl/CzwafK0a1YbZELLmiEXbn4SumdFTYnBEVot5H+jL9mu08WITOKU57FwEfHIWWHn5oHoFWutcPmdZZH/mUJH/PBUzQaPsndste9ieFnvdrtpYF1ks3HdXOInc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780074; c=relaxed/simple; bh=BmYENEXDN0xAfqgj5FhEWxPMBxEHPT9mLHNE4e9Se00=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=aLVY3HzFc6OMLNc4kEJlLSSQQSAMh5bMJsJSNbekYFDB3ZmlAFUCQt1sGs5yKIKs7tr4v5Jtuzf0bX9TXXA3xKe9S9ZvPOWCAEUXMmg35ZnPqU8dYsk9eJEOOrZ6RKHcz8UhMONyf+3SOqhrJQhQRyUGMp/9Epd9bcoWDUFd31E= 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=Ef2wO9+A; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zGnIVHzm; 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 Date: Mon, 22 Apr 2024 10:01:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713780069; h=from:from:sender:sender:reply-to: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=a9hI7A6km8WqPAn1moauJLIkkzsRvNZx2A1wWvsp/r4=; b=Ef2wO9+AgSPtZLyVi1yxNTWAz5a0JzPhW7J6Lv49WRwQGLnnEECKnAln91w3B8380UCDR3 akLP15d5dWL0n9zfzstClSTztiDbKaPb6Ldcvdwe4jBZ1Fb0zFPFOqr0FIyY6xp520Zdii e4Wb8PEvXVyhMFQShbo9ZJaxnWcC7PMT40w0f/JDX8u5x+vJpTMdKWRtjomqZUh3Yhw81G vLsG2EhoqWYqaUvxR6HmB9u8zN5YSmLj/W8zNtuHiBbpyZDEfa8YdrU97lNNQYQuXJKJmI PMqaRWqSJDNU1l1zc0fACDG7nTARQRkWbkz/mfl9pdkr1arA6LI0CnmPqUnLEQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713780069; h=from:from:sender:sender:reply-to: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=a9hI7A6km8WqPAn1moauJLIkkzsRvNZx2A1wWvsp/r4=; b=zGnIVHzmSaZgZSqY2Vx67xU/1wF9MQ7GH0idF7dc9AJVr3VzeE7WIzu81CMTa98HLZGSd5 LLDNiGhiPGgHO5Aw== From: "tip-bot2 for Tony Luck" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cpu] x86/cpu/vfm: Add new macros to work with (vendor/family/model) values Cc: Tony Luck , "Borislav Petkov (AMD)" , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240416211941.9369-3-tony.luck@intel.com> References: <20240416211941.9369-3-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171378006732.10875.16181122194584504255.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/cpu branch of tip: Commit-ID: e6dfdc2e89a0adedf455814c91b977d6a584cc88 Gitweb: https://git.kernel.org/tip/e6dfdc2e89a0adedf455814c91b977d6a584cc88 Author: Tony Luck AuthorDate: Tue, 16 Apr 2024 14:19:04 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 22 Apr 2024 11:43:55 +02:00 x86/cpu/vfm: Add new macros to work with (vendor/family/model) values To avoid adding a slew of new macros for each new Intel CPU family switch over from providing CPU model number #defines to a new scheme that encodes vendor, family, and model in a single number. [ bp: s/casted/cast/g ] Signed-off-by: Tony Luck Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Thomas Gleixner Link: https://lore.kernel.org/r/20240416211941.9369-3-tony.luck@intel.com --- arch/x86/include/asm/cpu_device_id.h | 93 +++++++++++++++++++++++++++- 1 file changed, 93 insertions(+) diff --git a/arch/x86/include/asm/cpu_device_id.h b/arch/x86/include/asm/cpu_device_id.h index bf4e065..970a232 100644 --- a/arch/x86/include/asm/cpu_device_id.h +++ b/arch/x86/include/asm/cpu_device_id.h @@ -3,6 +3,39 @@ #define _ASM_X86_CPU_DEVICE_ID /* + * Can't use because it generates expressions that + * cannot be used in structure initializers. Bitfield construction + * here must match the union in struct cpuinfo_86: + * union { + * struct { + * __u8 x86_model; + * __u8 x86; + * __u8 x86_vendor; + * __u8 x86_reserved; + * }; + * __u32 x86_vfm; + * }; + */ +#define VFM_MODEL_BIT 0 +#define VFM_FAMILY_BIT 8 +#define VFM_VENDOR_BIT 16 +#define VFM_RSVD_BIT 24 + +#define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT) +#define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT) +#define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT) + +#define VFM_MODEL(vfm) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT) +#define VFM_FAMILY(vfm) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT) +#define VFM_VENDOR(vfm) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT) + +#define VFM_MAKE(_vendor, _family, _model) ( \ + ((_model) << VFM_MODEL_BIT) | \ + ((_family) << VFM_FAMILY_BIT) | \ + ((_vendor) << VFM_VENDOR_BIT) \ +) + +/* * Declare drivers belonging to specific x86 CPUs * Similar in spirit to pci_device_id and related PCI functions * @@ -49,6 +82,16 @@ .driver_data = (unsigned long) _data \ } +#define X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \ + _steppings, _feature, _data) { \ + .vendor = _vendor, \ + .family = _family, \ + .model = _model, \ + .steppings = _steppings, \ + .feature = _feature, \ + .driver_data = (unsigned long) _data \ +} + /** * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY @@ -164,6 +207,56 @@ X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \ steppings, X86_FEATURE_ANY, data) +/** + * X86_MATCH_VFM - Match encoded vendor/family/model + * @vfm: Encoded 8-bits each for vendor, family, model + * @data: Driver specific data or NULL. The internal storage + * format is unsigned long. The supplied value, pointer + * etc. is cast to unsigned long internally. + * + * Stepping and feature are set to wildcards + */ +#define X86_MATCH_VFM(vfm, data) \ + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ + VFM_VENDOR(vfm), \ + VFM_FAMILY(vfm), \ + VFM_MODEL(vfm), \ + X86_STEPPING_ANY, X86_FEATURE_ANY, data) + +/** + * X86_MATCH_VFM_STEPPINGS - Match encoded vendor/family/model/stepping + * @vfm: Encoded 8-bits each for vendor, family, model + * @steppings: Bitmask of steppings to match + * @data: Driver specific data or NULL. The internal storage + * format is unsigned long. The supplied value, pointer + * etc. is cast to unsigned long internally. + * + * feature is set to wildcard + */ +#define X86_MATCH_VFM_STEPPINGS(vfm, steppings, data) \ + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ + VFM_VENDOR(vfm), \ + VFM_FAMILY(vfm), \ + VFM_MODEL(vfm), \ + steppings, X86_FEATURE_ANY, data) + +/** + * X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature + * @vfm: Encoded 8-bits each for vendor, family, model + * @feature: A X86_FEATURE bit + * @data: Driver specific data or NULL. The internal storage + * format is unsigned long. The supplied value, pointer + * etc. is cast to unsigned long internally. + * + * Steppings is set to wildcard + */ +#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \ + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ + VFM_VENDOR(vfm), \ + VFM_FAMILY(vfm), \ + VFM_MODEL(vfm), \ + X86_STEPPING_ANY, feature, data) + /* * Match specific microcode revisions. *