Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752537AbdC2PFm (ORCPT ); Wed, 29 Mar 2017 11:05:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52690 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbdC2PFl (ORCPT ); Wed, 29 Mar 2017 11:05:41 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4CBB980F9B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=oleg@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4CBB980F9B Date: Wed, 29 Mar 2017 17:05:35 +0200 From: Oleg Nesterov To: Andy Lutomirski Cc: Andrew Morton , Linus Torvalds , Denys Vlasenko , "H. Peter Anvin" , Ingo Molnar , Jan Kratochvil , Pedro Alves , Thomas Gleixner , X86 ML , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/1] get_nr_restart_syscall() should return __NR_ia32_restart_syscall if __USER32_CS Message-ID: <20170329150535.GA22925@redhat.com> References: <20170328145413.GA3164@redhat.com> <20170328145432.GA3163@redhat.com> <20170328162736.GA3983@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170328162736.GA3983@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 29 Mar 2017 15:05:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2153 Lines: 67 On 03/28, Oleg Nesterov wrote: > > On 03/28, Andy Lutomirski wrote: > > > > How about we store the syscall arch to be restored in task_struct > > along with restart_block? > > Yes, perhaps we will have to finally do this. Not really nice too. OK, how about the hack below? I do not want to a new member into task_struct/restart_block, so the patch below adds a sticky TS_COMPAT bit which logically is a member of "struct restart_block". TS_I386_REGS_POKED must die, I think. But this needs another discussion. Oleg. diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index b83c61c..a94bb5e 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -249,6 +249,17 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs) local_irq_enable(); /* + * Do this before debugger can change the regs. + */ + if (IS_ENABLED(CONFIG_IA32_EMULATION) && + unlikely(regs->ax == -ERESTART_RESTARTBLOCK)) { + if (current->thread.status & TS_COMPAT) + current->thread.status |= TS_COMPAT_XXX; + else + current->thread.status &= ~TS_COMPAT_XXX; + } + + /* * First do one-time work. If these work items are enabled, we * want to run them exactly once per syscall exit with IRQs on. */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 1be64da..87179ab 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -477,6 +477,7 @@ struct thread_struct { * have to worry about atomic accesses. */ #define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/ +#define TS_COMPAT_XXX 0x0008 /* * Set IOPL bits in EFLAGS from given mask diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 763af1d..b3b98ff 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -785,7 +785,7 @@ static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs) * than the tracee. */ #ifdef CONFIG_IA32_EMULATION - if (current->thread.status & (TS_COMPAT|TS_I386_REGS_POKED)) + if (current->thread.status & TS_COMPAT_XXX) return __NR_ia32_restart_syscall; #endif #ifdef CONFIG_X86_X32_ABI