Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1136903imm; Wed, 10 Oct 2018 09:38:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61rTcqtnZwRsgAgi5JA4xLROZ1zIp0G6djd7kpaPzFzmM6AX9pQrN/biydd+ew1d8PHPHZB X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr33094523pll.299.1539189503755; Wed, 10 Oct 2018 09:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539189503; cv=none; d=google.com; s=arc-20160816; b=g/m2oQS0CBFmOaifheOjmHsVcnJRT/gbrm3Lw8afN1IHrBka5oMgpSRC+WKGhT34BJ 4NgQda0a/day5fSnN4+o/s0slaOVlCIYlI+kR/9oZtld6JFnrSnga5dkwfsG41Of+p6h d3ZVMPRTfb+Kw5kflN3Zngv0f3G3/f/G7JLX/MKOB/dQxw5hcrTDf4QcNER+mmtFSKYV Au1e1sgFUdULkEIS0JZ+/gaIRatbeVZ7pLuAy6RL1pFhEvSqMypBIT9w2vavBd6h6OJl /uF6MHIx4ECgADtNGzmQyoTbGz0Dv2Dnqt89vPAwIUaPfE13ObUijLuijHT9IJ0cCBm2 hZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QRA3WgWOj/CUyWYuG9yhNehhknydh+HS3rKiLe3Uw24=; b=GlOyGRCw2jMA9LX70cYroJ3k/fsnBKbHMCvoi6an5AydowWe7H6h4lqx94+KMMUBfP hn0Ev9acYoU63xpWqOCh6O8GjgE0ieqqfR83HxpUt7SCIcaf5tE76Q4VbVNm/xKoWVt8 u9M8RtiPXDhyh8we8FCp6bT+MG/br9qMVPWy7HiyXsdsYppOY7TTMTu1yIp/HjqGLcA9 xZVtKTgwagnXEtX9rQ3KWYQua7PFTLbDf0fPhmSNkswWGeaDbrYkk9QsE1Qw4n2A8DZa URv3oc7FJDBI1jV/QZ6hf0qvlJW7+jGPWAEh5y+7BUPkV7lsNFFJgakJP+IlL4jUGNsQ FaKQ== 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 a59-v6si25979414pla.60.2018.10.10.09.38.08; Wed, 10 Oct 2018 09:38:23 -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 S1726862AbeJKAAf (ORCPT + 99 others); Wed, 10 Oct 2018 20:00:35 -0400 Received: from mail.skyhub.de ([5.9.137.197]:50876 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbeJKAAe (ORCPT ); Wed, 10 Oct 2018 20:00:34 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IvppudFY23jU; Wed, 10 Oct 2018 18:37:37 +0200 (CEST) Received: from zn.tnic (p200300EC2BCA7500329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2bca:7500:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 06EB81EC0104; Wed, 10 Oct 2018 18:37:36 +0200 (CEST) Date: Wed, 10 Oct 2018 18:37:30 +0200 From: Borislav Petkov To: Andi Kleen Cc: peterz@infradead.org, x86@kernel.org, eranian@google.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH v2 1/2] x86/cpufeature: Add facility to match microcode revisions Message-ID: <20181010163730.GA6125@zn.tnic> References: <20181010162608.23899-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181010162608.23899-1-andi@firstfloor.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lemme paste some of tglx's review comments from last time. On Wed, Oct 10, 2018 at 09:26:07AM -0700, Andi Kleen wrote: > 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 s/versions/revisions/ > 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, s/difference/different/ > 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 "What means microcodes or steppings? If you mean microcode revisions then please spell it out and use it all over the place. steppings is confusing at best as its associated to the CPU stepping." > + * > + * 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; "Why u16? The corresponding members in cpuinfo_x86 are 8bit wide so why wasting memory for these tables?" > + 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) s/ucode/microcode/ > +{ > + 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 > -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.