From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wei.liu2@citrix.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 2/6] x86/msr: Cleanup of misc constants
Date: Tue, 26 Jun 2018 14:18:14 +0100 [thread overview]
Message-ID: <1530019098-7058-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1530019098-7058-1-git-send-email-andrew.cooper3@citrix.com>
Begin the process of cleaning up msr-index.h. Order the MSRs at the
head of the file by index, use spaces for indentation, _AC() for bit
positions, and add a comment describing the expected style. Abbreviate
the ARCH_CAPS_* constants to reduce code volume.
Leave a trailing comment to logically split the file in two, between the
now-consistent head, and legacy tail which will be improved moving
forwards.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
xen/arch/x86/spec_ctrl.c | 8 +++---
xen/include/asm-x86/msr-index.h | 59 ++++++++++++++++++++++++++---------------
2 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 08e6784..4db2ae0 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -215,8 +215,8 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
(_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "",
(_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "",
(e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "",
- (caps & ARCH_CAPABILITIES_IBRS_ALL) ? " IBRS_ALL" : "",
- (caps & ARCH_CAPABILITIES_RDCL_NO) ? " RDCL_NO" : "",
+ (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "",
+ (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
(caps & ARCH_CAPS_RSBA) ? " RSBA" : "",
(caps & ARCH_CAPS_SSB_NO) ? " SSB_NO" : "");
@@ -429,11 +429,11 @@ static __init void xpti_init_default(bool force)
return;
if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD )
- caps = ARCH_CAPABILITIES_RDCL_NO;
+ caps = ARCH_CAPS_RDCL_NO;
else if ( boot_cpu_has(X86_FEATURE_ARCH_CAPS) )
rdmsrl(MSR_ARCH_CAPABILITIES, caps);
- if ( caps & ARCH_CAPABILITIES_RDCL_NO )
+ if ( caps & ARCH_CAPS_RDCL_NO )
opt_xpti = 0;
else
opt_xpti = OPT_XPTI_DOM0 | OPT_XPTI_DOMU;
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index 1b10f3e..2c9b75f 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -1,32 +1,34 @@
#ifndef __ASM_MSR_INDEX_H
#define __ASM_MSR_INDEX_H
-/* CPU model specific register (MSR) numbers */
-
-/* x86-64 specific MSRs */
-#define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */
-#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */
-#define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */
-#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */
-#define MSR_FS_BASE 0xc0000100 /* 64bit FS base */
-#define MSR_GS_BASE 0xc0000101 /* 64bit GS base */
-#define MSR_SHADOW_GS_BASE 0xc0000102 /* SwapGS GS shadow */
-#define MSR_TSC_AUX 0xc0000103 /* Auxiliary TSC */
+/*
+ * CPU model specific register (MSR) numbers
+ *
+ * Definitions for an MSR should follow this style:
+ *
+ * #define MSR_$NAME 0x$INDEX
+ * #define $NAME_$BIT1 (_AC(1, ULL) << $POS1)
+ * #define $NAME_$BIT2 (_AC(1, ULL) << $POS2)
+ *
+ * Blocks of related constants should be sorted by MSR index. The constant
+ * names should be as concise as possible, and the bit names may have an
+ * abbreviated name.
+ */
/* Speculation Controls. */
-#define MSR_SPEC_CTRL 0x00000048
-#define SPEC_CTRL_IBRS (_AC(1, ULL) << 0)
-#define SPEC_CTRL_STIBP (_AC(1, ULL) << 1)
-#define SPEC_CTRL_SSBD (_AC(1, ULL) << 2)
+#define MSR_SPEC_CTRL 0x00000048
+#define SPEC_CTRL_IBRS (_AC(1, ULL) << 0)
+#define SPEC_CTRL_STIBP (_AC(1, ULL) << 1)
+#define SPEC_CTRL_SSBD (_AC(1, ULL) << 2)
-#define MSR_PRED_CMD 0x00000049
-#define PRED_CMD_IBPB (_AC(1, ULL) << 0)
+#define MSR_PRED_CMD 0x00000049
+#define PRED_CMD_IBPB (_AC(1, ULL) << 0)
-#define MSR_ARCH_CAPABILITIES 0x0000010a
-#define ARCH_CAPABILITIES_RDCL_NO (_AC(1, ULL) << 0)
-#define ARCH_CAPABILITIES_IBRS_ALL (_AC(1, ULL) << 1)
-#define ARCH_CAPS_RSBA (_AC(1, ULL) << 2)
-#define ARCH_CAPS_SSB_NO (_AC(1, ULL) << 4)
+#define MSR_ARCH_CAPABILITIES 0x0000010a
+#define ARCH_CAPS_RDCL_NO (_AC(1, ULL) << 0)
+#define ARCH_CAPS_IBRS_ALL (_AC(1, ULL) << 1)
+#define ARCH_CAPS_RSBA (_AC(1, ULL) << 2)
+#define ARCH_CAPS_SSB_NO (_AC(1, ULL) << 4)
#define MSR_EFER 0xc0000080 /* Extended Feature Enable Register */
#define EFER_SCE (_AC(1, ULL) << 0) /* SYSCALL Enable */
@@ -40,6 +42,19 @@
#define EFER_KNOWN_MASK (EFER_SCE | EFER_LME | EFER_LMA | EFER_NXE | \
EFER_SVME | EFER_LMSLE | EFER_FFXSE)
+#define MSR_STAR 0xc0000081 /* Legacy mode SYSCALL target */
+#define MSR_LSTAR 0xc0000082 /* Long mode SYSCALL target */
+#define MSR_CSTAR 0xc0000083 /* Compat mode SYSCALL target */
+#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */
+#define MSR_FS_BASE 0xc0000100 /* 64bit FS base */
+#define MSR_GS_BASE 0xc0000101 /* 64bit GS base */
+#define MSR_SHADOW_GS_BASE 0xc0000102 /* SwapGS GS shadow */
+#define MSR_TSC_AUX 0xc0000103 /* Auxiliary TSC */
+
+/*
+ * Legacy MSR constants in need of cleanup. No new code below this comment.
+ */
+
/* Intel MSRs. Some also available on other CPUs */
#define MSR_IA32_PERFCTR0 0x000000c1
#define MSR_IA32_A_PERFCTR0 0x000004c1
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-06-26 13:18 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 13:18 [PATCH 0/6] x86/msr: Introductory MSR cleanup Andrew Cooper
2018-06-26 13:18 ` [PATCH 1/6] x86/msr: Clean up the MSR_EFER constants Andrew Cooper
2018-06-26 15:33 ` Wei Liu
2018-06-27 10:39 ` Roger Pau Monné
2018-06-27 10:44 ` Andrew Cooper
2018-06-28 13:00 ` Jan Beulich
2018-06-28 13:36 ` Andrew Cooper
2018-06-28 13:56 ` Jan Beulich
2018-09-07 14:47 ` Andrew Cooper
2018-09-07 15:09 ` Jan Beulich
2018-06-26 13:18 ` Andrew Cooper [this message]
2018-06-26 15:43 ` [PATCH 2/6] x86/msr: Cleanup of misc constants Wei Liu
2018-06-27 10:48 ` Roger Pau Monné
2018-06-26 13:18 ` [PATCH 3/6] x86/msr: Clean up the MSR_{PLATFORM_INFO, MISC_FEATURES_ENABLES} constants Andrew Cooper
2018-06-26 16:31 ` Wei Liu
2018-06-27 11:08 ` Roger Pau Monné
2018-06-28 13:04 ` Jan Beulich
2018-06-26 13:18 ` [PATCH 4/6] x86/msr: Clean up the MSR_FEATURE_CONTROL constants Andrew Cooper
2018-06-26 17:59 ` Andrew Cooper
2018-06-27 9:05 ` Jan Beulich
2018-06-27 11:08 ` Wei Liu
2018-06-27 11:21 ` Roger Pau Monné
2018-06-28 13:11 ` Jan Beulich
2018-07-02 5:56 ` Tian, Kevin
2018-06-26 13:18 ` [PATCH 5/6] x86/msr: Clean up the MSR_APIC_BASE constants Andrew Cooper
2018-06-27 13:26 ` Wei Liu
2018-06-27 13:32 ` Roger Pau Monné
2018-06-27 13:35 ` Andrew Cooper
2018-06-27 14:50 ` Andrew Cooper
2018-06-26 13:18 ` [PATCH 6/6] x86/msr: Clean up the x2APIC MSR constants Andrew Cooper
2018-06-27 13:26 ` Wei Liu
2018-06-27 13:50 ` Roger Pau Monné
2018-06-27 14:15 ` Andrew Cooper
2018-06-28 13:18 ` Jan Beulich
2018-06-26 18:22 ` [PATCH 7/6] x86/msr: Introduce msr_{set, clear}_bits() helpers Andrew Cooper
2018-06-27 13:35 ` Wei Liu
2018-06-27 14:17 ` Roger Pau Monné
2018-06-27 14:27 ` Andrew Cooper
2018-06-28 13:26 ` 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=1530019098-7058-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/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 NNTP newsgroup(s).