mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	x86@kernel.org, Dave Hansen <dave.hansen@linux.intel.com>,
	Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	David Laight <david.laight.linux@gmail.com>
Subject: Re: [tip: x86/cleanups] x86/segment: Use MOVL when reading segment registers
Date: Thu, 12 Mar 2026 11:56:58 -0700	[thread overview]
Message-ID: <0fd93689-3038-467e-ac96-ff5ad6533147@zytor.com> (raw)
In-Reply-To: <CAFULd4bbEGUvz2jR7CmmAX1DVGvEuaMZfn+DANnRD8TVY8cBXw@mail.gmail.com>

On 2026-03-12 02:30, Uros Bizjak wrote:
> 
> so one can use this variant when the segment register is really saved
> to a memory. The above code improves to:
> 
>    32333:    8c a2 0c 0c 00 00        mov    %fs,0xc0c(%rdx)
>    32339:    8c aa 0e 0c 00 00        mov    %gs,0xc0e(%rdx)
> 
> Unfortunately, inline asm does not support alternative instructions
> that would depend on output argument type (reg vs mem), so the
> selection can not be automatic. But by having specialized macro, a
> developer can use the variant that results in the most optimal code.
> 
> A prototype patch is attached to the message.
> 

On a more general note, there is a *really* ugly way to distinguish operand
type on the gas side:


	.section ".rodata","a"

	.macro classify typevar:req argument:req
	\typevar = 0
	.irpc char,\argument
	.ifeq .L_type
	.ifc \char,%
	\typevar = 1		/* Register */
	.endif
	.ifc \char,(
	\typevar = 2		/* Memory */
	.endif
	.ifc \char,$
	\typevar = 3		/* Immediate */
	.endif
	.endif
	.endr
	.ifne .L_type
	\typevar = 2
	.endif
	.endm

	classify .L_type,%rax

	.ascii "Type = "
	.byte .L_type + 0x30
	.asciz "\n"


	-hpa



  parent reply	other threads:[~2026-03-12 18:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05  9:02 [PATCH RESEND v2 1/3] x86: " Uros Bizjak
2026-01-05  9:02 ` [PATCH RESEND v2 2/3] x86/hyperv: Use savesegment() instead of inline asm() to save " Uros Bizjak
2026-01-19 16:22   ` H. Peter Anvin
2026-01-05  9:02 ` [PATCH RESEND v2 3/3] x86/hyperv: Remove ASM_CALL_CONSTRAINT with VMMCALL insn Uros Bizjak
2026-01-19 16:23   ` H. Peter Anvin
2026-01-19 16:22 ` [PATCH RESEND v2 1/3] x86: Use MOVL when reading segment registers H. Peter Anvin
2026-01-20 12:08 ` [tip: x86/cleanups] x86/segment: " tip-bot2 for Uros Bizjak
2026-01-20 12:38   ` H. Peter Anvin
2026-01-20 13:47     ` Uros Bizjak
2026-01-20 14:02       ` Uros Bizjak
2026-01-21 11:49     ` Brian Gerst
2026-01-21 14:08       ` David Laight
2026-01-21 16:16         ` Uros Bizjak
2026-01-21 18:55           ` David Laight
2026-03-12  9:30     ` Uros Bizjak
2026-03-12 18:55       ` H. Peter Anvin
2026-03-12 19:38         ` Uros Bizjak
2026-03-12 18:56       ` H. Peter Anvin [this message]
2026-03-12 19:11       ` H. Peter Anvin
2026-03-12 19:50         ` Uros Bizjak
2026-03-12 22:01           ` Uros Bizjak

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=0fd93689-3038-467e-ac96-ff5ad6533147@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®