mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Borislav Petkov <bp@alien8.de>, Xin Li <xin3.li@intel.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de,
	mingo@redhat.com, dave.hansen@linux.intel.com,
	peterz@infradead.org, brgerst@gmail.com,
	chang.seok.bae@intel.com, jgross@suse.com
Subject: Re: [PATCH v6 5/5] x86/gsseg: use the LKGS instruction if available for load_gs_index()
Date: Sun, 30 Jun 2024 19:34:42 -0700	[thread overview]
Message-ID: <3A846C73-305E-4C55-B846-AC00657BA95B@zytor.com> (raw)
In-Reply-To: <20240630160448.GAZoGCIHXRuBY8sLqW@fat_crate.local>

On June 30, 2024 9:04:48 AM PDT, Borislav Petkov <bp@alien8.de> wrote:
>On Wed, Jan 11, 2023 at 11:20:32PM -0800, Xin Li wrote:
>> From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
>> 
>> The LKGS instruction atomically loads a segment descriptor into the
>> %gs descriptor registers, *except* that %gs.base is unchanged, and the
>> base is instead loaded into MSR_IA32_KERNEL_GS_BASE, which is exactly
>> what we want this function to do.
>> 
>> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
>> Signed-off-by: Xin Li <xin3.li@intel.com>
>> ---
>> 
>> Changes since v5:
>> * Remove reviewers' SOBs (Borislav Petkov).
>> 
>> Changes since v4:
>> * Clear the LKGS feature from Xen PV guests (Juergen Gross).
>> 
>> Changes since v3:
>> * We want less ASM not more, thus keep local_irq_{save,restore}() inside
>>   native_load_gs_index() (Thomas Gleixner).
>> * For paravirt enabled kernels, initialize pv_ops.cpu.load_gs_index to
>>   native_lkgs (Thomas Gleixner).
>> 
>> Changes since v2:
>> * Mark DI as input and output (+D) as in v1, since the exception handler
>>   modifies it (Brian Gerst).
>> 
>> Changes since v1:
>> * Use EX_TYPE_ZERO_REG instead of fixup code in the obsolete .fixup code
>>   section (Peter Zijlstra).
>> * Add a comment that states the LKGS_DI macro will be replaced with "lkgs %di"
>>   once the binutils support the LKGS instruction (Peter Zijlstra).
>> ---
>>  arch/x86/include/asm/gsseg.h | 33 +++++++++++++++++++++++++++++----
>>  arch/x86/kernel/cpu/common.c |  1 +
>>  arch/x86/xen/enlighten_pv.c  |  1 +
>>  3 files changed, 31 insertions(+), 4 deletions(-)
>> 
>> diff --git a/arch/x86/include/asm/gsseg.h b/arch/x86/include/asm/gsseg.h
>> index d15577c39e8d..ab6a595cea70 100644
>> --- a/arch/x86/include/asm/gsseg.h
>> +++ b/arch/x86/include/asm/gsseg.h
>> @@ -14,17 +14,42 @@
>>  
>>  extern asmlinkage void asm_load_gs_index(u16 selector);
>>  
>> +/* Replace with "lkgs %di" once binutils support LKGS instruction */
>> +#define LKGS_DI _ASM_BYTES(0xf2,0x0f,0x00,0xf7)
>
>Right, so this is %di only and not %edi.
>
>FRED spec says:
>
>"LKGS takes a single 16-bit operand (in a register or memory) and uses it to
>load a descriptor from the GDT or an LDT."
>
>However, latest objdump (GNU objdump (GNU Binutils) 2.42.50.20240630) says
>
>ffffffff81026dfb:       f2 0f 00 f7             lkgs   %edi
>
>objdump needs fixing, I'd say...
>

It is much like "movl %edi,%ds"...

  reply	other threads:[~2024-07-01  2:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  7:20 [PATCH v6 0/5] x86: Enable LKGS instruction Xin Li
2023-01-12  7:20 ` [PATCH v6 1/5] x86/cpufeature: add the cpu feature bit for LKGS Xin Li
2023-01-12 12:16   ` [tip: x86/cpu] x86/cpufeature: Add the CPU " tip-bot2 for H. Peter Anvin (Intel)
2023-01-12  7:20 ` [PATCH v6 2/5] x86/opcode: add the LKGS instruction to x86-opcode-map Xin Li
2023-01-12 12:16   ` [tip: x86/cpu] x86/opcode: Add " tip-bot2 for H. Peter Anvin (Intel)
2023-01-12  7:20 ` [PATCH v6 3/5] x86/gsseg: make asm_load_gs_index() take an u16 Xin Li
2023-01-12 12:16   ` [tip: x86/cpu] x86/gsseg: Make " tip-bot2 for H. Peter Anvin (Intel)
2023-01-12  7:20 ` [PATCH v6 4/5] x86/gsseg: move load_gs_index() to its own new header file Xin Li
2023-01-12 12:16   ` [tip: x86/cpu] x86/gsseg: Move " tip-bot2 for H. Peter Anvin (Intel)
2023-01-12  7:20 ` [PATCH v6 5/5] x86/gsseg: use the LKGS instruction if available for load_gs_index() Xin Li
2023-01-13  9:36   ` [tip: x86/cpu] x86/gsseg: Use " tip-bot2 for H. Peter Anvin (Intel)
2024-06-30 16:04   ` [PATCH v6 5/5] x86/gsseg: use " Borislav Petkov
2024-07-01  2:34     ` H. Peter Anvin [this message]
2024-07-01  6:08       ` Borislav Petkov
2024-07-01  6:31         ` H. Peter Anvin
2024-07-01  6:40           ` Borislav Petkov
2024-07-01  8:01             ` H. Peter Anvin
2024-07-01  9:47               ` Borislav Petkov
2023-01-12 12:13 ` [PATCH v6 0/5] x86: Enable LKGS instruction Ingo Molnar
2023-01-12 14:57   ` Peter Zijlstra
2023-01-13 13:29     ` Ingo Molnar
2023-01-13 18:26       ` Li, Xin3

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=3A846C73-305E-4C55-B846-AC00657BA95B@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin3.li@intel.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

all inboxes | Powered by JetHome®