All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86/ptrace: Use savesegment() in get_segment_reg() instead of inline asm
Date: Thu, 2 Apr 2026 14:48:02 +0200	[thread overview]
Message-ID: <ac5lggWkx-8t-a43@redhat.com> (raw)
In-Reply-To: <20260402062248.459921-1-ubizjak@gmail.com>

On 04/02, Uros Bizjak wrote:
>
> @@ -251,32 +251,31 @@ static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
>  	/*
>  	 * Returning the value truncates it to 16 bits.
>  	 */
> -	unsigned int seg;
> +	unsigned int retval;

LGTM, but perhaps it would be better to use "u16 retval" ? and remove the
comment.

Oleg.

>  
>  	switch (offset) {
>  	case offsetof(struct user_regs_struct, fs):
>  		if (task == current) {
> -			/* Older gas can't assemble movq %?s,%r?? */
> -			asm("movl %%fs,%0" : "=r" (seg));
> -			return seg;
> +			savesegment(fs, retval);
> +			return retval;
>  		}
>  		return task->thread.fsindex;
>  	case offsetof(struct user_regs_struct, gs):
>  		if (task == current) {
> -			asm("movl %%gs,%0" : "=r" (seg));
> -			return seg;
> +			savesegment(gs, retval);
> +			return retval;
>  		}
>  		return task->thread.gsindex;
>  	case offsetof(struct user_regs_struct, ds):
>  		if (task == current) {
> -			asm("movl %%ds,%0" : "=r" (seg));
> -			return seg;
> +			savesegment(ds, retval);
> +			return retval;
>  		}
>  		return task->thread.ds;
>  	case offsetof(struct user_regs_struct, es):
>  		if (task == current) {
> -			asm("movl %%es,%0" : "=r" (seg));
> -			return seg;
> +			savesegment(es, retval);
> +			return retval;
>  		}
>  		return task->thread.es;
>  
> -- 
> 2.53.0
> 


  reply	other threads:[~2026-04-02 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  6:22 [PATCH] x86/ptrace: Use savesegment() in get_segment_reg() instead of inline asm Uros Bizjak
2026-04-02 12:48 ` Oleg Nesterov [this message]
2026-04-02 13:09   ` Uros Bizjak
2026-04-02 13:40     ` Uros Bizjak
2026-04-02 14:03       ` Oleg Nesterov

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=ac5lggWkx-8t-a43@redhat.com \
    --to=oleg@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.