linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v9 0/8] x86/cpu, kvm: Support AMD Automatic IBRS
@ 2023-01-24 16:33 Kim Phillips
  2023-01-24 16:33 ` [PATCH v9 1/8] x86/cpu, kvm: Add support for CPUID_80000021_EAX Kim Phillips
                   ` (8 more replies)
  0 siblings, 9 replies; 47+ messages in thread
From: Kim Phillips @ 2023-01-24 16:33 UTC (permalink / raw)
  To: x86
  Cc: Kim Phillips, Borislav Petkov, Boris Ostrovsky, Dave Hansen,
	H. Peter Anvin, Ingo Molnar, Joao Martins, Jonathan Corbet,
	Konrad Rzeszutek Wilk, Paolo Bonzini, Sean Christopherson,
	Thomas Gleixner, David Woodhouse, Greg Kroah-Hartman,
	Juergen Gross, Peter Zijlstra, Tony Luck, Tom Lendacky,
	Alexey Kardashevskiy, kvm, linux-doc, linux-kernel

The AMD Zen4 core supports a new feature called Automatic IBRS
(Indirect Branch Restricted Speculation).

Enable Automatic IBRS by default if the CPU feature is present.
It typically provides greater performance over the incumbent
generic retpolines mitigation.

Patch 1 [unchanged from v7] Adds support for the leaf that
contains the AutoIBRS feature bit.

Patch 2 moves the leaf's open-coded code from __do_cpuid_func()
to kvm_set_cpu_caps() in preparation for adding the features in
their native leaf.

Patches 3-6 introduce the new leaf's supported bits one by one.

Patch 7 [unchanged from v7] Adds support for AutoIBRS by turning
its EFER enablement bit on at startup if the feature is available.

Patch 8 [unchanged from v7] Adds support for propagating AutoIBRS
to the guest.

v9: Address comments from Sean Christopherson:
    - Patch 1: "KVM guests", not "VM guests"
    - Patches 2 & 8:
      - Subject prefix change to "KVM: x86: "
    - Patch 2:
      - Added Sean's blurb about the synthetic features to the commit message
      - Added BIT(2) /* LFENCE always serializing */ to
        kvm_cpu_cap_mask() in kvm_set_cpu_caps() to mirror true code movement
    - Patch 4: Removed the kvm_cpu_cap_set for LFENCE_RDTSC since the
      previous set_cpu_cap()s and kvm_cpu_cap_mask() presence will effectively
      synthesize the feature now that the feature bit is in its proper place.

v8: https://lore.kernel.org/lkml/20230123225700.2224063-1-kim.phillips@amd.com/
    Address comments from Sean Christopherson, Boris:
    - Move open-coded cpuid leaf 0x80000021 EAX bit propagation code
      in a single step/patch to avoid CPUID bits getting cleared
      by the open-coded ANDs coming after cpuid_entry_override().
    - Includes changes Boris made when committing v7 to tip/x86-cpu, i.e.:
      - Removing "AMD" prefix from feature comment text in cpufeatures.h
      - Convert test in check_null_seg_clears_base() too.
      - commit message changes

v7: https://lore.kernel.org/lkml/20230116230159.1511393-1-kim.phillips@amd.com/
    - Add Dave Hansen's Acked-by to unchanged patch 6/7
    - Change patch 3/7 to not bother to set MSR DE_CFG[1]
      if X86_FEATURE_LFENCE_RDTSC is already set [Boris]
    - v6 went out with two 1/1's, try to not do that again

v6: https://lore.kernel.org/lkml/20230110224643.452273-1-kim.phillips@amd.com/
    Address v5 comment from Boris:
    - Move CPUID leaf 0x8000021 EAX feature bits from scattered
      to the new whole leaf since the majority of the features
      will be used in the kernel and thus a separate leaf is
       appropriate.

v5: https://lore.kernel.org/lkml/20221205233235.622491-1-kim.phillips@amd.com/
    Address v4 comments from Dave Hansen, Pawan Gupta, and Boris:
    - Don't add new user-visible 'autoibrs' command line
      options that have to be documented: reuse 'eibrs'
    - Update Documentation/admin-guide/hw-vuln/spectre.rst
    - Add NO_EIBRS_PBRSB to Hygon as well
    - Re-word commit texts to not use words like 'us'

v4: https://lore.kernel.org/lkml/20221201015003.295769-8-kim.phillips@amd.com/
    Moved some kvm bits that had crept into patch 6/7 back into 7/7,
    and addressed v3 comments:
    - Don't put ", kvm" in titles of patches that don't touch kvm.  [SeanC]
    - () after function names, i.e. kvm_set_cpu_caps().  [SeanC]
    - follow the established kvm_cpu_cap_init_scattered() style [SeanC]
    - Add using cpu_feature_enabled() instead of static_cpu_has() to
      commit text [SeanC]
    - Pawan Gupta mentioned that the ordering of enabling the Intel
      feature bit past Intel EIBRS bug detection could be avoided
      by setting NO_EIBRS_PBRSB to cpu_vuln_whitelist, so did that
      which allowed regrouping all EIBRS related code to one place
      in cpu_set_bug_bits().

v3: https://lore.kernel.org/lkml/20221129235816.188737-1-kim.phillips@amd.com/
    - Remove Co-developed-bys.  They require signed-off-bys,
      so co-developers need to add them themselves.
    - update check_null_seg_clears_base() [Boris]
    - Made the feature bit additions separate patches
      because v2 patch was clearly doing too many things at once.

v2: https://lore.kernel.org/lkml/20221124000449.79014-1-kim.phillips@amd.com/
    https://lkml.org/lkml/2022/11/23/1690
    - Use synthetic/scattered bits instead of introducing new leaf [Boris]
    - Combine the rest of the leaf's bits being used [Paolo]
      Note: Bits not used by the host can be moved to kvm/cpuid.c if
      maintainers do not want them in cpufeatures.h.
    - Hoist bitsetting code to kvm_set_cpu_caps(), and use
      cpuid_entry_override() in __do_cpuid_func() [Paolo]
    - Reuse SPECTRE_V2_EIBRS spectre_v2_mitigation enum [Boris, PeterZ, D.Hansen]
      - Change from Boris' diff:
        Moved setting X86_FEATURE_IBRS_ENHANCED to after BUG_EIBRS_PBRSB
        so PBRSB mitigations wouldn't be enabled.
    - Allow for users to specify "autoibrs,lfence/retpoline" instead
      of actively preventing the extra protections.  AutoIBRS doesn't
      require the extra protection, but allow it anyway.

v1: https://lore.kernel.org/lkml/20221104213651.141057-1-kim.phillips@amd.com/

Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Alexey Kardashevskiy <aik@amd.com>
Cc: kvm@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org

Kim Phillips (8):
  x86/cpu, kvm: Add support for CPUID_80000021_EAX
  x86/cpu, kvm: Move open-coded cpuid leaf 0x80000021 EAX bit
    propagation code
  x86/cpu, kvm: Add the NO_NESTED_DATA_BP feature
  x86/cpu, kvm: Move X86_FEATURE_LFENCE_RDTSC to its native leaf
  x86/cpu, kvm: Add the Null Selector Clears Base feature
  x86/cpu, kvm: Add the SMM_CTL MSR not present feature
  x86/cpu: Support AMD Automatic IBRS
  x86/cpu, kvm: Propagate the AMD Automatic IBRS feature to the guest

 Documentation/admin-guide/hw-vuln/spectre.rst |  6 ++--
 .../admin-guide/kernel-parameters.txt         |  6 ++--
 arch/x86/include/asm/cpufeature.h             |  7 +++--
 arch/x86/include/asm/cpufeatures.h            | 11 +++++--
 arch/x86/include/asm/disabled-features.h      |  3 +-
 arch/x86/include/asm/msr-index.h              |  2 ++
 arch/x86/include/asm/required-features.h      |  3 +-
 arch/x86/kernel/cpu/amd.c                     |  2 +-
 arch/x86/kernel/cpu/bugs.c                    | 20 ++++++++-----
 arch/x86/kernel/cpu/common.c                  | 26 +++++++++-------
 arch/x86/kvm/cpuid.c                          | 30 +++++++------------
 arch/x86/kvm/reverse_cpuid.h                  |  1 +
 arch/x86/kvm/svm/svm.c                        |  3 ++
 arch/x86/kvm/x86.c                            |  3 ++
 14 files changed, 72 insertions(+), 51 deletions(-)

--
2.34.1

Kim Phillips (8):
  x86/cpu, kvm: Add support for CPUID_80000021_EAX
  KVM: x86: Move open-coded cpuid leaf 0x80000021 EAX bit propagation
    code
  x86/cpu, kvm: Add the NO_NESTED_DATA_BP feature
  x86/cpu, kvm: Move X86_FEATURE_LFENCE_RDTSC to its native leaf
  x86/cpu, kvm: Add the Null Selector Clears Base feature
  x86/cpu, kvm: Add the SMM_CTL MSR not present feature
  x86/cpu: Support AMD Automatic IBRS
  KVM: x86: Propagate the AMD Automatic IBRS feature to the guest

 Documentation/admin-guide/hw-vuln/spectre.rst |  6 ++--
 .../admin-guide/kernel-parameters.txt         |  6 ++--
 arch/x86/include/asm/cpufeature.h             |  7 +++--
 arch/x86/include/asm/cpufeatures.h            | 11 ++++++--
 arch/x86/include/asm/disabled-features.h      |  3 +-
 arch/x86/include/asm/msr-index.h              |  2 ++
 arch/x86/include/asm/required-features.h      |  3 +-
 arch/x86/kernel/cpu/amd.c                     |  2 +-
 arch/x86/kernel/cpu/bugs.c                    | 20 +++++++------
 arch/x86/kernel/cpu/common.c                  | 26 +++++++++--------
 arch/x86/kvm/cpuid.c                          | 28 ++++++-------------
 arch/x86/kvm/reverse_cpuid.h                  |  1 +
 arch/x86/kvm/svm/svm.c                        |  3 ++
 arch/x86/kvm/x86.c                            |  3 ++
 14 files changed, 70 insertions(+), 51 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2023-03-16 11:04 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 16:33 [PATCH v9 0/8] x86/cpu, kvm: Support AMD Automatic IBRS Kim Phillips
2023-01-24 16:33 ` [PATCH v9 1/8] x86/cpu, kvm: Add support for CPUID_80000021_EAX Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 2/8] KVM: x86: Move open-coded cpuid leaf 0x80000021 EAX bit propagation code Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] KVM: x86: Move open-coded CPUID " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 3/8] x86/cpu, kvm: Add the NO_NESTED_DATA_BP feature Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 4/8] x86/cpu, kvm: Move X86_FEATURE_LFENCE_RDTSC to its native leaf Kim Phillips
2023-01-24 21:32   ` Sean Christopherson
2023-01-25 12:09     ` Borislav Petkov
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 5/8] x86/cpu, kvm: Add the Null Selector Clears Base feature Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 6/8] x86/cpu, kvm: Add the SMM_CTL MSR not present feature Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 16:33 ` [PATCH v9 7/8] x86/cpu: Support AMD Automatic IBRS Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-02-24 18:52   ` [PATCH v9 7/8] " Josh Poimboeuf
2023-02-24 21:08     ` Borislav Petkov
2023-02-24 21:35       ` Josh Poimboeuf
2023-02-24 21:59         ` Borislav Petkov
2023-02-24 22:03           ` Luck, Tony
2023-02-24 22:12             ` Borislav Petkov
2023-02-24 23:30               ` pawan.kumar.gupta
2023-03-10 10:23         ` [tip: x86/misc] MAINTAINERS: Add x86 hardware vulnerabilities section tip-bot2 for Josh Poimboeuf
2023-02-24 22:51       ` [PATCH v9 7/8] x86/cpu: Support AMD Automatic IBRS Borislav Petkov
2023-02-24 23:23         ` Borislav Petkov
2023-02-25  0:09         ` Josh Poimboeuf
2023-02-25  0:20           ` [PATCH] x86/CPU/AMD: Make sure EFER[AIBRSE] is set Borislav Petkov
2023-02-25  0:52             ` Pawan Gupta
2023-02-25  1:32               ` Josh Poimboeuf
2023-02-25 12:21                 ` Borislav Petkov
2023-02-25 17:28                   ` Josh Poimboeuf
2023-02-25 22:56                     ` Borislav Petkov
2023-02-25 23:43                       ` Josh Poimboeuf
2023-02-26 11:18                         ` Borislav Petkov
2023-02-26 17:27                           ` Josh Poimboeuf
2023-02-26 18:44                             ` Borislav Petkov
2023-02-27 15:25                   ` Dave Hansen
2023-02-27 15:40                     ` Borislav Petkov
2023-02-27 16:39                       ` Dave Hansen
2023-03-10 16:22                         ` [PATCH -v2] " Borislav Petkov
2023-03-13 15:42                           ` Dave Hansen
2023-03-16 11:04     ` [tip: x86/cpu] " tip-bot2 for Borislav Petkov (AMD)
2023-01-24 16:33 ` [PATCH v9 8/8] KVM: x86: Propagate the AMD Automatic IBRS feature to the guest Kim Phillips
2023-01-26 10:12   ` [tip: x86/cpu] " tip-bot2 for Kim Phillips
2023-01-24 21:37 ` [PATCH v9 0/8] x86/cpu, kvm: Support AMD Automatic IBRS Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).