linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: X86 ML <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Elvira Khabirova <lineprinter0@gmail.com>
Subject: Re: [PATCH] x86/signal: fix restart_syscall number for x32 tasks
Date: Thu, 17 Dec 2015 12:27:16 -0800	[thread overview]
Message-ID: <CALCETrUDmn_FoQXnQopO4H2c+N4P=Tv60w2T6G92c4L5_=soQA@mail.gmail.com> (raw)
In-Reply-To: <20151213034437.GA2392@altlinux.org>

On Sat, Dec 12, 2015 at 7:44 PM, Dmitry V. Levin <ldv@altlinux.org> wrote:
> On Mon, Dec 07, 2015 at 03:22:06PM -0800, Andy Lutomirski wrote:
>> [not real reply because I'm using a bad internet connection right now
>> and I'm not set up with my usual Gmane reply hack right now]
>>
>> The new code is (whitespace-damaged):
>>
>> static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
>> {
>> #if defined(CONFIG_X86_32) || !defined(CONFIG_X86_64)
>>  return __NR_restart_syscall;
>> #else /* !CONFIG_X86_32 && CONFIG_X86_64 */
>>  return test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall :
>>  __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT);
>> #endif /* CONFIG_X86_32 || !CONFIG_X86_64 */
>> }
>>
>> This is IMO awful.  This use of TIF_IA32 is wrong, and this is
>> otherwise gross.  Can we do it for real:
>>
>> if (is_ia32_task())
>>   return __NR_ia32_restart_syscall;
>> else
>>   return __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT);
>> /* preserve x32 bit */
>>
>> I'd send the patch myself, but you apparently have a good test case
>> for this, and I don't.
>
> Unfortunately, this won't compile on CONFIG_X86_32 because
> __NR_ia32_restart_syscall is defined for CONFIG_X86_64 only.
>
> Something like this should work:
>
> static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
> {
> #ifdef CONFIG_X86_64
>         if (is_ia32_task())
>                 return __NR_ia32_restart_syscall;
> # ifdef CONFIG_X86_X32_ABI
>         if (regs->orig_ax & __X32_SYSCALL_BIT)
>                 return __NR_restart_syscall | __X32_SYSCALL_BIT;
> # endif
> #endif
>         return __NR_restart_syscall;
> }

Looks good to me.  Want to send a patch?

--Andy

  reply	other threads:[~2015-12-17 20:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 23:22 [PATCH] x86/signal: fix restart_syscall number for x32 tasks Andy Lutomirski
2015-12-13  3:44 ` Dmitry V. Levin
2015-12-17 20:27   ` Andy Lutomirski [this message]
2015-12-18 23:37     ` [PATCH] x86/signal: Cleanup get_nr_restart_syscall Dmitry V. Levin
2015-12-19  6:34       ` H. Peter Anvin
2015-12-19 14:43         ` [PATCH v2] " Dmitry V. Levin
2015-12-19 20:48           ` Andy Lutomirski
2016-01-11 14:55             ` [RESEND PATCH " Dmitry V. Levin
2016-01-19 13:39               ` [tip:x86/asm] x86/signal: Cleanup get_nr_restart_syscall() tip-bot for Dmitry V. Levin
  -- strict thread matches above, loose matches on Subject: below --
2015-11-30 21:54 [PATCH] x86/signal: fix restart_syscall number for x32 tasks Dmitry V. Levin

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='CALCETrUDmn_FoQXnQopO4H2c+N4P=Tv60w2T6G92c4L5_=soQA@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=ldv@altlinux.org \
    --cc=lineprinter0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).