From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbbCVOPc (ORCPT ); Sun, 22 Mar 2015 10:15:32 -0400 Received: from mail-qg0-f49.google.com ([209.85.192.49]:35327 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbbCVOP3 (ORCPT ); Sun, 22 Mar 2015 10:15:29 -0400 MIME-Version: 1.0 In-Reply-To: References: <1423778052-21038-2-git-send-email-dvlasenk@redhat.com> From: Denys Vlasenko Date: Sun, 22 Mar 2015 15:15:08 +0100 Message-ID: Subject: Re: [tip:x86/asm] x86/asm/entry/64: Always allocate a complete " struct pt_regs" on the kernel stack To: Brian Gerst Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Will Drewry , Andy Lutomirski , Alexei Starovoitov , Oleg Nesterov , "H. Peter Anvin" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Denys Vlasenko , Kees Cook , Linus Torvalds , Linux Kernel Mailing List , linux-tip-commits@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> @@ -492,7 +496,6 @@ GLOBAL(stub32_clone) >> >> ALIGN >> ia32_ptregs_common: >> - popq %r11 >> CFI_ENDPROC >> CFI_STARTPROC32 simple >> CFI_SIGNAL_FRAME >> @@ -507,9 +510,9 @@ ia32_ptregs_common: >> /* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/ >> CFI_REL_OFFSET rsp,RSP-ARGOFFSET >> /* CFI_REL_OFFSET ss,SS-ARGOFFSET*/ >> - SAVE_REST >> + SAVE_EXTRA_REGS 8 >> call *%rax >> - RESTORE_REST >> - jmp ia32_sysret /* misbalances the return cache */ >> + RESTORE_EXTRA_REGS 8 >> + ret >> CFI_ENDPROC >> END(ia32_ptregs_common) > > This change is causing Wine to fail when it's built to support both > 32-bit and 64-bit code: > > [ 523.657406] wineserver[1605]: segfault at 453a7c90 ip > 00000000453a7c90 sp 00000000b3c6ad10 error 14 in > ld-2.21.so[7fad453a7000+21000] > > It tries to exec the 64-bit wineserver from 32-bit code and faults > because %rip is truncated. This is because simply returning to the > caller will exit via sysretl which doesn't change %cs to 64-bit mode. > We need to set a thread flag to enter the slow path and return via > iret instead. > > Patch coming to fix it. Something like adding orl $_TIF_NOTIFY_RESUME,TI_flags+THREAD_INFO(%rsp,RIP) in stub32_execve[at] will probably do it Please add a comment why it is needed.