Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1124526imm; Wed, 10 Oct 2018 09:27:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV63vh1mcAM8EhXvVrTWr762DXhifOvFC7EJTbaNI5PilHk/AaBxA7eSC0gdLrY8KdUewwN1m X-Received: by 2002:a62:7788:: with SMTP id s130-v6mr35404751pfc.189.1539188857561; Wed, 10 Oct 2018 09:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539188857; cv=none; d=google.com; s=arc-20160816; b=gmFa2zh6KtGVSs4N5O7lx0rdSW05cYooABaSUvOt2DVYWSUz4fFf0yRSQ/ndMOmCyU WOGN35RosiT/5K46moCwRp/kfiBbWsjdSkUZjcStk5mCd21COExJUljvbwrLXwoYh7kv 2YmlxummRmNqffCOWzPDdU+Q2LLWKkYQL1lzjWmoLnDoC1HWxF4XJB7h3rLENp5YvSW0 xkSXI5CvlvKv8Ksu54yHo2k70KK/7k3ue7uA9rQyRi8sw90H9lxp+qgEjShatlIISYeO KdvhxuyL0BRdYDZHjhpIi/gl9uUs4wme26AI0We1Eohu5qasN4JXu90z7cTCQO9qQlGs OuLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=9/9s9ElInAOaI29zteZKLelef9oCe5JFO7w4ZBTcVfo=; b=mQafjvzoEb0ttFiD6BAEKSL2SA/SChC4YQVOe+nM+dQTum1r9O17vZHOLO/EwOTjAq d/F1I9hGAEPQws9RZ9X/qk7nV3M57blJUlnqpJbybrT18RxybSt+GLgPIenODQS2kvUr trS8k5EkFZ4+g6LChLCF7dLevfqkTpUtrUYVxf+RyidrvF+dTeYQy7Fac6YrpwN5o3mk oYRkB3lwaleB00exGPOBxFUJlb9u84wcJqR+g+MlicDZKmvnH2oMiQ8zGymDu+cGng8n 2C4CLYYrQ7fKkxn3WGY/z2g6wayFmrYcmn3ijFlVsQPoSo7w7tyZT/P6fi3+klFTN3dQ RMTA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q137-v6si30764062pfq.178.2018.10.10.09.27.22; Wed, 10 Oct 2018 09:27:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbeJJXtM (ORCPT + 99 others); Wed, 10 Oct 2018 19:49:12 -0400 Received: from mga17.intel.com ([192.55.52.151]:40793 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbeJJXtM (ORCPT ); Wed, 10 Oct 2018 19:49:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 09:26:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,364,1534834800"; d="scan'208";a="87300183" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.126]) by FMSMGA003.fm.intel.com with ESMTP; 10 Oct 2018 09:26:18 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 408A9300B47; Wed, 10 Oct 2018 09:26:18 -0700 (PDT) From: Andi Kleen To: peterz@infradead.org Cc: x86@kernel.org, eranian@google.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH v2 1/2] x86/cpufeature: Add facility to match microcode revisions Date: Wed, 10 Oct 2018 09:26:07 -0700 Message-Id: <20181010162608.23899-1-andi@firstfloor.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen For bug workarounds or checks it is useful to check for specific microcode versions. Add a new table format to check for steppings with min microcode revisions. This does not change the existing x86_cpu_id because it's an ABI shared with modutils, and also has quite difference requirements, as in no wildcards, but everything has to be matched exactly. Signed-off-by: Andi Kleen --- v2: Remove all CPU match, only check boot cpu Move INTEL_MIN_UCODE macro to header. Minor cleanups. Remove max ucode and driver data --- arch/x86/include/asm/cpu_device_id.h | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/match.c | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/arch/x86/include/asm/cpu_device_id.h b/arch/x86/include/asm/cpu_device_id.h index baeba0567126..1b90bd1d0b95 100644 --- a/arch/x86/include/asm/cpu_device_id.h +++ b/arch/x86/include/asm/cpu_device_id.h @@ -11,4 +11,30 @@ extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match); +/* + * Match specific microcodes + * + * vendor/family/model/stepping must be all set. + * min_ucode is optional and can be 0. + */ + +struct x86_ucode_id { + u8 vendor; + u8 family; + u16 model; + u16 stepping; + u32 min_ucode; +}; + +#define INTEL_MIN_UCODE(mod, step, rev) { \ + .vendor = X86_VENDOR_INTEL, \ + .family = 6, \ + .model = mod, \ + .stepping = step, \ + .min_ucode = rev, \ +} + +extern const struct x86_ucode_id * +x86_match_ucode(const struct x86_ucode_id *match); + #endif diff --git a/arch/x86/kernel/cpu/match.c b/arch/x86/kernel/cpu/match.c index 3fed38812eea..ec8ee31699cd 100644 --- a/arch/x86/kernel/cpu/match.c +++ b/arch/x86/kernel/cpu/match.c @@ -48,3 +48,24 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match) return NULL; } EXPORT_SYMBOL(x86_match_cpu); + +const struct x86_ucode_id *x86_match_ucode(const struct x86_ucode_id *match) +{ + struct cpuinfo_x86 *c = &boot_cpu_data; + const struct x86_ucode_id *m; + + for (m = match; m->vendor | m->family | m->model; m++) { + if (c->x86_vendor != m->vendor) + continue; + if (c->x86 != m->family) + continue; + if (c->x86_model != m->model) + continue; + if (c->x86_stepping != m->stepping) + continue; + if (c->microcode < m->min_ucode) + continue; + return m; + } + return NULL; +} -- 2.17.1