Received: by 10.223.176.46 with SMTP id f43csp1229716wra; Sat, 20 Jan 2018 13:55:40 -0800 (PST) X-Google-Smtp-Source: AH8x224exwmHMiem7HhEHGYpMU2cvW2rqHXP2rBHCtASUvnBz62+TEEMv1SZkHQHcvQQAbQoFAPL X-Received: by 10.99.160.26 with SMTP id r26mr2973102pge.230.1516485340212; Sat, 20 Jan 2018 13:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516485340; cv=none; d=google.com; s=arc-20160816; b=nNZm3At1AUUuyxIEXIHr01+jkRuY6oUkePrLWyl+9YiXdlj0KwWPzz9/cCS3oyiAtv g8XPAqSKchkpaU8pNuxpBs7MOvP6kmq3BBQMM0oXr+traArYuJ1ttzi8pP6rfZxTEV9x RUwHz9USR2EVFsv7spVjAYNzpZza/mKcC3/VbX0rfDHf1Jr3wYh9tyQIGVBElDgllSQJ 7yvxU7uG2S83qQFE1NMWfzAKkcozpNEgj+KJYGA4RudfK/C+84issVpS0pu1ZZ6x26Ur AR9xzz3GzZsCIKC8KN5+fdTFU/8Y5d0l/tGrrlVnD8rvEgms9jnIY/BBgXH5AbeJW7xg krbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=fPkXwxhkDZpDctfrjgb5TcHx5iNyhsv/8qwiIP9svCk=; b=qJTeq+ltqPku3oMJ/S+Of1U4Pq9RNNmlyythGABswlA4JBGB9pvTZjEX6lfqNCiMjF 8xqcWR4/PALYKKf+Te0mlJpXyMStlc87rWJueTd69MXWONt7vbzSSk+B7ABPuTkef/Kd d9oyFAc94tXMX5OjJJLyq9/xkE9VANuGR3DgBDREu8rIzhseiczse2ZY7cGdBLfY4WC1 Y4McNjnk72SV3/lzLrr7KkLK1WlEXPaHqoFKBA80gsEC6J7mz9fvx6PUB/apqzCU7esd JXuaHrX772JRyD7WHT22GiyvcttBb2+H5LP+FCPyr3mlRshiKxyPgEz84pd9Ne6PQXe+ Xrgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@uplinklabs.net header.s=google1 header.b=hW+clFvQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=uplinklabs.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a61-v6si760404pla.689.2018.01.20.13.55.26; Sat, 20 Jan 2018 13:55:40 -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=pass header.i=@uplinklabs.net header.s=google1 header.b=hW+clFvQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=uplinklabs.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756771AbeATVvW (ORCPT + 99 others); Sat, 20 Jan 2018 16:51:22 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:42423 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756695AbeATVvQ (ORCPT ); Sat, 20 Jan 2018 16:51:16 -0500 Received: by mail-wm0-f65.google.com with SMTP id b141so9694689wme.1 for ; Sat, 20 Jan 2018 13:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uplinklabs.net; s=google1; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fPkXwxhkDZpDctfrjgb5TcHx5iNyhsv/8qwiIP9svCk=; b=hW+clFvQ7IzQcnmHs+tySt0mVXgIRKJ5yk1YMduaUwDGwWCBbhvmX38/x96nDjAA/w BDtnzgAsnIsC0AcV+M5IWQrl5NZZwTTnRiOkL/1i57LGmNHDDd5VX749a4byA1ZVKhiv mOLAb6oPpB32XdoIwkZGdChhmujoKQfH1BvjuNx6RGV9vqGFRU5BTxj4+cCKaCrmcz2d pyy+9I1uxlZwIg7plYqgzdbkCiy6MLkWVU2IwjYwv8Itfrbj9/9CHw4MWclO8JF930vm 1FJFEYHB+WjT+ZyaYdHhavUew5EJNIzxgtzg9UUsaB26Mp+ihfGLGRN+XCjhMI8e+NwD 9lFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fPkXwxhkDZpDctfrjgb5TcHx5iNyhsv/8qwiIP9svCk=; b=QXPR1t9DYHFVe/9iB++vJG5e6Imtf6oTwqfxMA/dhIa+CXzkBy3gwaNKNqSmTzXubj sIYpjP7Ax/YfanrfiMYDnE4dVI9n5CDFjO/5k1fbvXfJzK7tP58DVdmR7mSaTNTwCh/q 7kJDU2IRGGaGmYWyUupccAd4cj0jmPA7EaL1aa98fQZ04kZ+AkhpAUClq/d9iv9hMMPn 9AG0e5BFhRV3mAnNDoar998d5ld22cjXV6rM9fQpkJVXeMp8xThqUCiRsXL1k7aklxS3 igZ3C154YF90Dsedjz06knVj7PadyMP/vUHHTXEzF1Q/1qyIFc21m9T8ocJrXE9aiRkk vQ6A== X-Gm-Message-State: AKwxytdbYRluIW7PrIQtpoEltc5qDDtO0gl0/CymZmhFP+t7+0e+WPOJ l09sh+T95dVtIqgTmyYjK1OqQN/N1Vmt2JJWfONRtg== X-Received: by 10.28.68.4 with SMTP id r4mr1861423wma.94.1516485074832; Sat, 20 Jan 2018 13:51:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.136.107 with HTTP; Sat, 20 Jan 2018 13:51:14 -0800 (PST) In-Reply-To: <1516449813-7654-2-git-send-email-dwmw@amazon.co.uk> References: <1516449813-7654-1-git-send-email-dwmw@amazon.co.uk> <1516449813-7654-2-git-send-email-dwmw@amazon.co.uk> From: Steven Noonan Date: Sat, 20 Jan 2018 13:51:14 -0800 Message-ID: Subject: Re: [PATCH 1/4] x86/cpufeatures: Add Intel feature bits for Speculation Control To: David Woodhouse Cc: Arjan van de Ven , Thomas Gleixner , karahmed@amazon.de, Linux-X86 , Linux Kernel mailing List , tim.c.chen@linux.intel.com, Borislav Petkov , Peter Zijlstra , Paolo Bonzini , ak@linux.intel.com, Linus Torvalds , gregkh@linux-foundation.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 20, 2018 at 4:03 AM, David Woodhouse wrote: > Add three feature bits exposed by new microcode on Intel CPUs for > speculation control. We would now be up to five bits in CPUID(7).RDX > so take them out of the 'scattered' features and make a proper word > for them instead. > > Signed-off-by: David Woodhouse > --- > arch/x86/include/asm/cpufeature.h | 7 +++++-- > arch/x86/include/asm/cpufeatures.h | 12 +++++++++--- > arch/x86/include/asm/disabled-features.h | 3 ++- > arch/x86/include/asm/required-features.h | 3 ++- > arch/x86/kernel/cpu/common.c | 1 + > arch/x86/kernel/cpu/scattered.c | 2 -- > 6 files changed, 19 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h > index ea9a7dd..70eddb3 100644 > --- a/arch/x86/include/asm/cpufeature.h > +++ b/arch/x86/include/asm/cpufeature.h > @@ -29,6 +29,7 @@ enum cpuid_leafs > CPUID_8000_000A_EDX, > CPUID_7_ECX, > CPUID_8000_0007_EBX, > + CPUID_7_EDX, > }; > > #ifdef CONFIG_X86_FEATURE_NAMES > @@ -79,8 +80,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; > CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 15, feature_bit) || \ > CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ > CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ > + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ > REQUIRED_MASK_CHECK || \ > - BUILD_BUG_ON_ZERO(NCAPINTS != 18)) > + BUILD_BUG_ON_ZERO(NCAPINTS != 19)) > > #define DISABLED_MASK_BIT_SET(feature_bit) \ > ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \ > @@ -101,8 +103,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; > CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 15, feature_bit) || \ > CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ > CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ > + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ > DISABLED_MASK_CHECK || \ > - BUILD_BUG_ON_ZERO(NCAPINTS != 18)) > + BUILD_BUG_ON_ZERO(NCAPINTS != 19)) > > #define cpu_has(c, bit) \ > (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h > index 25b9375..adebdaa 100644 > --- a/arch/x86/include/asm/cpufeatures.h > +++ b/arch/x86/include/asm/cpufeatures.h > @@ -13,7 +13,7 @@ > /* > * Defines x86 CPU feature bits > */ > -#define NCAPINTS 18 /* N 32-bit words worth of info */ > +#define NCAPINTS 19 /* N 32-bit words worth of info */ > #define NBUGINTS 1 /* N 32-bit bug flags */ > > /* > @@ -206,8 +206,6 @@ > #define X86_FEATURE_RETPOLINE ( 7*32+12) /* Generic Retpoline mitigation for Spectre variant 2 */ > #define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* AMD Retpoline mitigation for Spectre variant 2 */ > #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ > -#define X86_FEATURE_AVX512_4VNNIW ( 7*32+16) /* AVX-512 Neural Network Instructions */ > -#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */ > > #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ > #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* Fill RSB on context switches */ > @@ -319,6 +317,14 @@ > #define X86_FEATURE_SUCCOR (17*32+ 1) /* Uncorrectable error containment and recovery */ > #define X86_FEATURE_SMCA (17*32+ 3) /* Scalable MCA */ > > +/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ > +#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ > +#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ > +#define X86_FEATURE_SPEC_CTRL (18*32+26) /* Speculation Control (IBRS + IBPB) */ > +#define X86_FEATURE_STIPB (18*32+27) /* Speculation Control with STIPB (Intel) */ Is this correct? I thought the acronym was "STIBP", i.e. "Single-Thread Indrect Branch Prediction"? If so, then you've got the B and P swapped. > +#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */ > + > + > /* > * BUG word(s) > */ > diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h > index e428e16..c6a3af1 100644 > --- a/arch/x86/include/asm/disabled-features.h > +++ b/arch/x86/include/asm/disabled-features.h > @@ -71,6 +71,7 @@ > #define DISABLED_MASK15 0 > #define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57) > #define DISABLED_MASK17 0 > -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18) > +#define DISABLED_MASK18 0 > +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) > > #endif /* _ASM_X86_DISABLED_FEATURES_H */ > diff --git a/arch/x86/include/asm/required-features.h b/arch/x86/include/asm/required-features.h > index d91ba04..fb3a6de 100644 > --- a/arch/x86/include/asm/required-features.h > +++ b/arch/x86/include/asm/required-features.h > @@ -106,6 +106,7 @@ > #define REQUIRED_MASK15 0 > #define REQUIRED_MASK16 (NEED_LA57) > #define REQUIRED_MASK17 0 > -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18) > +#define REQUIRED_MASK18 0 > +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) > > #endif /* _ASM_X86_REQUIRED_FEATURES_H */ > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index 372ba3f..e5d66e9 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -745,6 +745,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c) > cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx); > c->x86_capability[CPUID_7_0_EBX] = ebx; > c->x86_capability[CPUID_7_ECX] = ecx; > + c->x86_capability[CPUID_7_EDX] = edx; > } > > /* Extended state features: level 0x0000000d */ > diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c > index d0e6976..df11f5d 100644 > --- a/arch/x86/kernel/cpu/scattered.c > +++ b/arch/x86/kernel/cpu/scattered.c > @@ -21,8 +21,6 @@ struct cpuid_bit { > static const struct cpuid_bit cpuid_bits[] = { > { X86_FEATURE_APERFMPERF, CPUID_ECX, 0, 0x00000006, 0 }, > { X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 }, > - { X86_FEATURE_AVX512_4VNNIW, CPUID_EDX, 2, 0x00000007, 0 }, > - { X86_FEATURE_AVX512_4FMAPS, CPUID_EDX, 3, 0x00000007, 0 }, > { X86_FEATURE_CAT_L3, CPUID_EBX, 1, 0x00000010, 0 }, > { X86_FEATURE_CAT_L2, CPUID_EBX, 2, 0x00000010, 0 }, > { X86_FEATURE_CDP_L3, CPUID_ECX, 2, 0x00000010, 1 }, > -- > 2.7.4 >