Received: by 10.223.176.46 with SMTP id f43csp470605wra; Wed, 24 Jan 2018 00:49:03 -0800 (PST) X-Google-Smtp-Source: AH8x226+arz0dEIdEzA6wAdfCibYpdJ80pw3XkSVgaRwezWomXFrQ2BBwYYR62Y4NIKX3QNtVqv9 X-Received: by 10.98.30.1 with SMTP id e1mr12417113pfe.37.1516783743166; Wed, 24 Jan 2018 00:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516783743; cv=none; d=google.com; s=arc-20160816; b=jCmHM8I95ScWPbT9499uOiM8xKo0oEBgl7fGTsPkviBCE7EzXLbSey9Ouzsk4cuTVJ Z4JOlgKlhyECRoRpxePvEmLKTsTwRIg7AKolKXM++tcPMLq0D0QoWFJ5tKuexcRQ9HdX BzjLATK0V5Fao2iDg3TS95QbAcZXbGhScf2SSuL3P3eqBLsPyBQCyeh8SwjCjM3Dr2qo 26agPpiwkomon4q8ejQMqrwQsB0ng6nyiY+GF+2TRVomKcl2XhhClFNoiFPylFrbTb46 Ltrc8jKn9qI/zNfxAuA6NOYRTnFUcz6KVHzca+tkW74QGzP2tc0bRqaPGEG6iXToIIC4 6nXQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=vRHsRA6lC+1EvX6mg3HJ9XSsPNaxsSTzeijX3+qfvHg=; b=alFei4kQbjYs6MwiAZNAtff/XXqj5fK5qtvER99jgGoqBloU+Wsula0bLTA/aP0ldW qEmm2D5M+CmT2kMStCjDetFf930G5S+2GtyL3crfWIRNvR6r4NWaJMaVU7ziVPxMjZt9 GsiUi3Zh5w0Cj3p6DDu73iWjpiIHtJfuRoSbMSq9lT/AjwecvFah03ByxaKGpUh+ue1N c/02emOqlO1PkQErsH7ZcVFtgwdRAvuWC523ux8e+jksEULUcH0iIdnWWdnQRdKpYpJM T2pY7T/I028GjwoWP3xR7NWovIUJczKrYurVYqDSMFJxPCKlFqBl02Mq1QwacHdD7MIq REVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lddo10Gw; 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 g2si16005122pgu.30.2018.01.24.00.48.49; Wed, 24 Jan 2018 00:49:03 -0800 (PST) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lddo10Gw; 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 S932640AbeAXIrz (ORCPT + 99 others); Wed, 24 Jan 2018 03:47:55 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:39081 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932553AbeAXIrv (ORCPT ); Wed, 24 Jan 2018 03:47:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vRHsRA6lC+1EvX6mg3HJ9XSsPNaxsSTzeijX3+qfvHg=; b=lddo10GwP1GN2kDF13wYNfE8We FAqmQICWAD4nbC6XHk5w4rrQYvUNKCpiPjlWQLI8k1yuh2tfPvr7LDdyVuoyXT+BeguhTzO/T2AZR BA9D45YkUpM9JqMpdDZ6pceVaiszlej9wz/DbsWP7K8hoH+9Nomd6d9a6e2freb5re4xSepQu3gVm 1wlFyaPMC6mEQe49jIHFIwHQASc17q2CTWOkL57iHCtBfS/cLTHdsGAjWW8nlGKcXx3KZknuydCi7 xEbGDOFpkEpWB5iYHwhGrrlb2dxmSovw5K4+l4sd33LExB2L2Xy8moFq9nmbAvK56gCBMDcSFxsNA SBkOND6w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eeGiY-0007um-6m; Wed, 24 Jan 2018 08:47:38 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2C255201395E2; Wed, 24 Jan 2018 09:47:35 +0100 (CET) Date: Wed, 24 Jan 2018 09:47:35 +0100 From: Peter Zijlstra To: David Woodhouse Cc: Thomas Gleixner , KarimAllah Ahmed , linux-kernel@vger.kernel.org, Andi Kleen , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Tim Chen , Tom Lendacky , kvm@vger.kernel.org, x86@kernel.org Subject: Re: [RFC 05/10] x86/speculation: Add basic IBRS support infrastructure Message-ID: <20180124084735.GM2228@hirez.programming.kicks-ass.net> References: <1516476182-5153-1-git-send-email-karahmed@amazon.de> <1516476182-5153-6-git-send-email-karahmed@amazon.de> <1516741116.13558.11.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516741116.13558.11.camel@infradead.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 08:58:36PM +0000, David Woodhouse wrote: > +static const struct sku_microcode spectre_bad_microcodes[] = { > + { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0B, 0x80 }, > + { INTEL_FAM6_KABYLAKE_MOBILE, 0x0A, 0x80 }, > + { INTEL_FAM6_KABYLAKE_MOBILE, 0x0A, 0x80 }, > + { INTEL_FAM6_KABYLAKE_MOBILE, 0x09, 0x80 }, > + { INTEL_FAM6_KABYLAKE_DESKTOP, 0x09, 0x80 }, > + { INTEL_FAM6_SKYLAKE_X, 0x04, 0x0200003C }, > + { INTEL_FAM6_SKYLAKE_MOBILE, 0x03, 0x000000C2 }, > + { INTEL_FAM6_SKYLAKE_DESKTOP, 0x03, 0x000000C2 }, > + { INTEL_FAM6_BROADWELL_CORE, 0x04, 0x28 }, > + { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x0000001B }, > + { INTEL_FAM6_HASWELL_ULT, 0x01, 0x21 }, > + { INTEL_FAM6_HASWELL_GT3E, 0x01, 0x18 }, > + { INTEL_FAM6_HASWELL_CORE, 0x03, 0x23 }, > + { INTEL_FAM6_IVYBRIDGE_X, 0x04, 0x42a }, > + { INTEL_FAM6_HASWELL_X, 0x02, 0x3b }, > + { INTEL_FAM6_HASWELL_X, 0x04, 0x10 }, > + { INTEL_FAM6_HASWELL_CORE, 0x03, 0x23 }, > + { INTEL_FAM6_BROADWELL_XEON_D, 0x02, 0x14 }, > + { INTEL_FAM6_BROADWELL_XEON_D, 0x03, 0x7000011 }, > + { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x0000001B }, > + /* For 406F1 Intel says "0x25, 0x23" while VMware says 0x0B000025 > + ?* and a real CPU has a firmware in the 0x0B0000xx range. So: */ > + { INTEL_FAM6_BROADWELL_X, 0x01, 0x0b000025 }, > + { INTEL_FAM6_KABYLAKE_DESKTOP, 0x09, 0x80 }, > + { INTEL_FAM6_SKYLAKE_X, 0x03, 0x100013e }, > + { INTEL_FAM6_SKYLAKE_X, 0x04, 0x200003c }, > +}; Typically tglx likes to use x86_match_cpu() for these things; see also commit: bd9240a18edfb ("x86/apic: Add TSC_DEADLINE quirk due to errata"). > + > +static int bad_spectre_microcode(struct cpuinfo_x86 *c) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(spectre_bad_microcodes); i++) { > + if (c->x86_model == spectre_bad_microcodes[i].model && > + ????c->x86_mask == spectre_bad_microcodes[i].stepping) > + return (c->microcode <= spectre_bad_microcodes[i].microcode); > + } > + return 0; > +} The above is Intel only, you should check vendor too I think. > ?static void early_init_intel(struct cpuinfo_x86 *c) > ?{ > ? u64 misc_enable; > @@ -122,6 +173,18 @@ static void early_init_intel(struct cpuinfo_x86 *c) > ? if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) > ? c->microcode = intel_get_microcode_revision(); > ? > + if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) || > + ?????cpu_has(c, X86_FEATURE_AMD_SPEC_CTRL) || > + ?????cpu_has(c, X86_FEATURE_AMD_PRED_CMD) || > + ?????cpu_has(c, X86_FEATURE_AMD_STIBP)) && bad_spectre_microcode(c)) { > + pr_warn("Intel Spectre v2 broken microcode detected; disabling SPEC_CTRL\n"); > + clear_cpu_cap(c, X86_FEATURE_SPEC_CTRL); > + clear_cpu_cap(c, X86_FEATURE_STIBP); > + clear_cpu_cap(c, X86_FEATURE_AMD_SPEC_CTRL); > + clear_cpu_cap(c, X86_FEATURE_AMD_PRED_CMD); > + clear_cpu_cap(c, X86_FEATURE_AMD_STIBP); > + } And since its Intel only, what are those AMD features doing there?