From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/6] x86/msr: Clean up the MSR_EFER constants
Date: Wed, 27 Jun 2018 11:44:04 +0100 [thread overview]
Message-ID: <a7d9dea6-6b46-2ff5-209d-9a9e28ea920c@citrix.com> (raw)
In-Reply-To: <20180627103925.ely2brpjbfiobswr@mac.bytemobile.com>
On 27/06/18 11:39, Roger Pau Monné wrote:
> On Tue, Jun 26, 2018 at 02:18:13PM +0100, Andrew Cooper wrote:
>> The bit position constants are only used by the trampoline asm, but the
>> code is shorter and clearer when using the mask constants. This halves
>> the number of constants used.
>>
>> Consistently use _AC() for the bit constants, and start to use spaces
>> for indentation. Furthermore, EFER contains the NX-Enable bit, to
>> rename the constant to EFER_NXE to match both the AMD and Intel specs.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>
> Just a couple of comments.
>
>> ---
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: Roger Pau Monné <roger.pau@citrix.com>
>> ---
>> xen/arch/x86/boot/trampoline.S | 2 +-
>> xen/arch/x86/boot/wakeup.S | 7 +++----
>> xen/arch/x86/cpu/intel.c | 2 +-
>> xen/arch/x86/efi/efi-boot.h | 2 +-
>> xen/arch/x86/hvm/hvm.c | 4 ++--
>> xen/include/asm-x86/hvm/hvm.h | 2 +-
>> xen/include/asm-x86/msr-index.h | 33 ++++++++++++---------------------
>> 7 files changed, 21 insertions(+), 31 deletions(-)
>>
>> diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
>> index 5588c79..7e77e61e 100644
>> --- a/xen/arch/x86/boot/trampoline.S
>> +++ b/xen/arch/x86/boot/trampoline.S
>> @@ -138,7 +138,7 @@ trampoline_protmode_entry:
>> or $EFER_LME|EFER_SCE,%eax /* Long Mode + SYSCALL/SYSRET */
>> bt $cpufeat_bit(X86_FEATURE_NX),%edi /* No Execute? */
>> jnc 1f
>> - btsl $_EFER_NX,%eax /* No Execute */
>> + or $EFER_NXE, %eax /* No Execute */
>> 1: wrmsr
>>
>> mov $(X86_CR0_PG | X86_CR0_AM | X86_CR0_WP | X86_CR0_NE |\
>> diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
>> index f9632ee..a37680b 100644
>> --- a/xen/arch/x86/boot/wakeup.S
>> +++ b/xen/arch/x86/boot/wakeup.S
>> @@ -144,11 +144,10 @@ wakeup_32:
>> jz .Lskip_eferw
>> movl $MSR_EFER,%ecx
>> rdmsr
>> - btsl $_EFER_LME,%eax /* Long Mode */
>> - btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */
>> - btl $20,%edi /* No Execute? */
>> + or $EFER_LME | EFER_SCE, %eax /* Long Mode + SYSCALL/SYSRET */
> I usually do: '$(EFER_LME | EFER_SCE), ...' because I think is clearer.
Ok.
>
>> + bt $cpufeat_bit(X86_FEATURE_NX), %edi /* No Execute? */
>> jnc 1f
>> - btsl $_EFER_NX,%eax /* No Execute */
>> + or $EFER_NXE, %eax /* No Execute */
>> 1: wrmsr
>> .Lskip_eferw:
>> diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
>> index 8fbccc8..1b10f3e 100644
>> --- a/xen/include/asm-x86/msr-index.h
>> +++ b/xen/include/asm-x86/msr-index.h
>> @@ -4,7 +4,6 @@
>> /* CPU model specific register (MSR) numbers */
>>
>> /* x86-64 specific MSRs */
>> -#define MSR_EFER 0xc0000080 /* extended feature register */
>> #define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */
>> #define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */
>> #define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */
>> @@ -14,26 +13,6 @@
>> #define MSR_SHADOW_GS_BASE 0xc0000102 /* SwapGS GS shadow */
>> #define MSR_TSC_AUX 0xc0000103 /* Auxiliary TSC */
>>
>> -/* EFER bits: */
>> -#define _EFER_SCE 0 /* SYSCALL/SYSRET */
>> -#define _EFER_LME 8 /* Long mode enable */
>> -#define _EFER_LMA 10 /* Long mode active (read-only) */
>> -#define _EFER_NX 11 /* No execute enable */
>> -#define _EFER_SVME 12 /* AMD: SVM enable */
>> -#define _EFER_LMSLE 13 /* AMD: Long-mode segment limit enable */
>> -#define _EFER_FFXSE 14 /* AMD: Fast FXSAVE/FXRSTOR enable */
>> -
>> -#define EFER_SCE (1<<_EFER_SCE)
>> -#define EFER_LME (1<<_EFER_LME)
>> -#define EFER_LMA (1<<_EFER_LMA)
>> -#define EFER_NX (1<<_EFER_NX)
>> -#define EFER_SVME (1<<_EFER_SVME)
>> -#define EFER_LMSLE (1<<_EFER_LMSLE)
>> -#define EFER_FFXSE (1<<_EFER_FFXSE)
>> -
>> -#define EFER_KNOWN_MASK (EFER_SCE | EFER_LME | EFER_LMA | EFER_NX | \
>> - EFER_SVME | EFER_LMSLE | EFER_FFXSE)
>> -
>> /* Speculation Controls. */
>> #define MSR_SPEC_CTRL 0x00000048
>> #define SPEC_CTRL_IBRS (_AC(1, ULL) << 0)
>> @@ -49,6 +28,18 @@
>> #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 */
>> +#define EFER_LME (_AC(1, ULL) << 8) /* Long Mode Enable */
>> +#define EFER_LMA (_AC(1, ULL) << 10) /* Long Mode Active */
>> +#define EFER_NXE (_AC(1, ULL) << 11) /* No Execute Enable */
>> +#define EFER_SVME (_AC(1, ULL) << 12) /* Secure Virtual Machine Enable */
>> +#define EFER_LMSLE (_AC(1, ULL) << 13) /* Long Mode Segment Limit Enable */
>> +#define EFER_FFXSE (_AC(1, ULL) << 14) /* Fast FXSAVE/FXRSTOR */
> Isn't the align a little bit too much?
See later patches in this series. EFER is the exception, being so short.
>
> And for clarity I would also indent the bitmasks, so:
>
> #define MSR_EFER 0xc0000080 /* Extended Feature Enable Register */
> #define EFER_SCE (_AC(1, ULL) << 0) /* SYSCALL Enable */
I'm open to idea of indenting the bit constants, if everyone else
agrees. This mostly affects the next patch, which introduces a style
expectation.
~Andrew
_______________________________________________
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-27 10:44 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 [this message]
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 ` [PATCH 2/6] x86/msr: Cleanup of misc constants Andrew Cooper
2018-06-26 15:43 ` 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=a7d9dea6-6b46-2ff5-209d-9a9e28ea920c@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).