Xen-Devel Archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Xenia Ragiadakou" <xenia.ragiadakou@amd.com>,
	"Sergiy Kibrik" <Sergiy_Kibrik@epam.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Andrei Semenov" <andrei.semenov@vates.fr>,
	"Vaishali Thakkar" <vaishali.thakkar@vates.tech>
Subject: [PATCH 3/5] x86/spec-ctrl: Remove open-coded check of SVM_FEATURE_SPEC_CTRL
Date: Mon, 29 Apr 2024 16:16:23 +0100	[thread overview]
Message-ID: <20240429151625.977884-4-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20240429151625.977884-1-andrew.cooper3@citrix.com>

Now that the SVM feature leaf has been included in normal feature handling, it
is available early enough for init_speculation_mitigations() to use.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Xenia Ragiadakou <xenia.ragiadakou@amd.com>
CC: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
CC: George Dunlap <george.dunlap@citrix.com>
CC: Andrei Semenov <andrei.semenov@vates.fr>
CC: Vaishali Thakkar <vaishali.thakkar@vates.tech>
---
 xen/arch/x86/include/asm/cpufeature.h | 3 +++
 xen/arch/x86/spec_ctrl.c              | 7 +------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 9bc553681f4a..77cfd900cb56 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -217,6 +217,9 @@ static inline bool boot_cpu_has(unsigned int feat)
 #define cpu_has_rfds_no         boot_cpu_has(X86_FEATURE_RFDS_NO)
 #define cpu_has_rfds_clear      boot_cpu_has(X86_FEATURE_RFDS_CLEAR)
 
+/* CPUID level 0x8000000a.edx */
+#define cpu_has_v_spec_ctrl     boot_cpu_has(X86_FEATURE_V_SPEC_CTRL)
+
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
 #define cpu_has_cpuid_faulting  boot_cpu_has(X86_FEATURE_CPUID_FAULTING)
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 40f6ae017010..0bda9d01def5 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -11,7 +11,6 @@
 #include <xen/warning.h>
 
 #include <asm/amd.h>
-#include <asm/hvm/svm/svm.h>
 #include <asm/intel-family.h>
 #include <asm/microcode.h>
 #include <asm/msr.h>
@@ -1896,12 +1895,8 @@ void __init init_speculation_mitigations(void)
          *
          * No need for SCF_ist_sc_msr because Xen's value is restored
          * atomically WRT NMIs in the VMExit path.
-         *
-         * TODO: Adjust cpu_has_svm_spec_ctrl to be usable earlier on boot.
          */
-        if ( opt_msr_sc_hvm &&
-             (boot_cpu_data.extended_cpuid_level >= 0x8000000aU) &&
-             (cpuid_edx(0x8000000aU) & (1u << SVM_FEATURE_SPEC_CTRL)) )
+        if ( opt_msr_sc_hvm && cpu_has_v_spec_ctrl )
             setup_force_cpu_cap(X86_FEATURE_SC_MSR_HVM);
     }
 
-- 
2.30.2



  parent reply	other threads:[~2024-04-29 15:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 15:16 [PATCH 0/5] x86: AMD CPUID handling improvements Andrew Cooper
2024-04-29 15:16 ` [PATCH 1/5] x86/cpu-policy: Infrastructure for the AMD SVM and SEV leaves Andrew Cooper
2024-04-30 12:45   ` Jan Beulich
2024-04-30 13:25     ` Andrew Cooper
2024-04-30 13:33       ` Jan Beulich
2024-05-01  9:16       ` George Dunlap
2024-04-29 15:16 ` [PATCH 2/5] x86/cpu-policy: Add SVM features already used by Xen Andrew Cooper
2024-04-29 15:24   ` Andrew Cooper
2024-04-30 13:02   ` Jan Beulich
2024-05-01 10:00   ` George Dunlap
2024-05-01 10:39     ` Andrew Cooper
2024-05-01 10:51       ` George Dunlap
2024-04-29 15:16 ` Andrew Cooper [this message]
2024-04-30 13:13   ` [PATCH 3/5] x86/spec-ctrl: Remove open-coded check of SVM_FEATURE_SPEC_CTRL Jan Beulich
2024-04-29 15:16 ` [PATCH 4/5] x86/svm: Switch SVM features over normal cpu_has_* Andrew Cooper
2024-04-30  5:51   ` Vaishali Thakkar
2024-04-30 13:25   ` Jan Beulich
2024-04-29 15:16 ` [PATCH 5/5] x86/cpu-policy: Introduce some SEV features Andrew Cooper
2024-04-30  6:15   ` Vaishali Thakkar
2024-04-30 13:54   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240429151625.977884-4-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Sergiy_Kibrik@epam.com \
    --cc=andrei.semenov@vates.fr \
    --cc=george.dunlap@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=vaishali.thakkar@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenia.ragiadakou@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).