Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1728339imm; Sat, 13 Oct 2018 02:36:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV60hARnUrbSTgVabIArlCnHlrhKl5Ncxm+GDRC85BZV4433CYu4d2t73uS1YKxvfgkKz2Q44 X-Received: by 2002:a17:902:8648:: with SMTP id y8-v6mr9388636plt.335.1539423392626; Sat, 13 Oct 2018 02:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539423392; cv=none; d=google.com; s=arc-20160816; b=noakP6bcS3fAU15XnZZAsjnOCs62ZrRFD3Uyi05b5q9EXJjpkqN1e0vWxYd41F8mJu PaPO4g9va2gOLE3bRvmIsT613PC4qOGECQfWh5eLQ7i4Rr6SnEy+ZNzTHlB7WGZP8IOc nWl3KNuQ2PCeC98E1yBuP5Nj6BXu10i8iUD2xEnAjXL7sQFIAYn1BxbNWD6QOhIYuJC7 6Yv7F7kPGNGnLHIqEhgiBgOqRoQhjSyO+TCjdFsMqFGfsOIrQDYwb/RQp1T6nPRbNVMs oJ1ZwZdJfPNe1a2MNPV27xpmT6fW5Tj4zvPkd6CHIanEODkbKtSQeGe3fomWlHI/ahpF Hwkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=j/zc6wQ36sO1u4fc3rrPyavOx6jBHqad62tggf0q+Ts=; b=LmoFkuDCiSDdHHWOjqq2bIf4ZD30XypM1uMLGTsEDbGkI9sURMSs9omIxXZnW0ZMi9 MmJI1TS7BC4ox4qYJfe4PkYIM8QcIjbuSJJOg8eo8UOWAHeUbrxNHaBYyBg0wMEx/ZcH vMonBi7JyelxsAns/q53eZvAYQ1ZlH8Oa/xAaJddjOJ0ZRC0s3OFocJeIxT2cWV5UsqV 91J0/e6WFPMs243BXY0WYRo3VYrlk3EC1b3hm8tKV1jUWp52ruvw808uEsnLHTBYwWcR +BpuNULsmZzv/CIh/cRe60or7NyVI19CZXRyIf8YM/LD2991zMeZj6zVdlGloheQ16zi KHHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1-v6si3911458plo.165.2018.10.13.02.36.17; Sat, 13 Oct 2018 02:36:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726904AbeJMRKs (ORCPT + 99 others); Sat, 13 Oct 2018 13:10:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:32966 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeJMRKr (ORCPT ); Sat, 13 Oct 2018 13:10:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8C2C9ED1; Sat, 13 Oct 2018 02:34:20 -0700 (PDT) Received: from mbp (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 80E513F5D3; Sat, 13 Oct 2018 02:34:14 -0700 (PDT) Date: Sat, 13 Oct 2018 10:34:11 +0100 From: Catalin Marinas To: Eugene Syromiatnikov Cc: linux-doc@vger.kernel.org, Szabolcs Nagy , Palmer Dabbelt , Heiko Carstens , Yury Norov , Pavel Machek , Philipp Tomsich , Joseph Myers , linux-arch@vger.kernel.org, Steve Ellcey , Prasun Kapoor , Andreas Schwab , Alexander Graf , Bamvor Zhangjian , Geert Uytterhoeven , Dave Martin , Adam Borowski , Manuel Montezelo , James Hogan , Chris Metcalf , Arnd Bergmann , Andrew Pinski , Lin Yongting , Alexey Klimov , Wookey , Mark Brown , linux-arm-kernel@lists.infradead.org, Maxim Kuvyrkov , Florian Weimer , linux-api@vger.kernel.org, Nathan_Lynch , linux-kernel@vger.kernel.org, James Morse , Ramana Radhakrishnan , Martin Schwidefsky , "David S . Miller" , Christoph Muellner Subject: Re: [PATCH v9 00/24] ILP32 for ARM64 Message-ID: <20181013093411.o3id6yzkspsxr5jt@mbp> References: <20180516081910.10067-1-ynorov@caviumnetworks.com> <20180724173957.GA22106@yury-thinkpad> <20181010141017.GA2881@asgard.redhat.com> <20181010153655.GA212880@arrakis.emea.arm.com> <20181013021416.GE21972@asgard.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181013021416.GE21972@asgard.redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 13, 2018 at 04:14:16AM +0200, Eugene Syromiatnikov wrote: > On Wed, Oct 10, 2018 at 04:36:56PM +0100, Catalin Marinas wrote: > > On Wed, Oct 10, 2018 at 04:10:21PM +0200, Eugene Syromiatnikov wrote: > > > I have some questions regarding AArch64 ILP32 implementation for which I > > > failed to find an answer myself: > > > * How ptrace() tracer is supposed to distinguish between ILP32 and LP64 > > > tracees? For MIPS N32 and x32 this is possible based on syscall > > > number, but for AArch64 ILP32 I do not see such a sign. There's also > > > ARM_ip is employed for signalling entering/exiting, I wonder whether > > > it's possible to employ it also for signalling tracee's personality. > > > > With the current implementation, I don't think you can distinguish. From > > the kernel perspective, the register set is the same. What is the > > use-case for this? > > Err, a ptrace()-based tracer trying to trace a process, for example? I first thought it wouldn't matter for ptrace-based tracers since the syscall numbers are (mostly) the same. But the arguments layout in register is indeed different, so I see your point now about having to distinguish. > > We could add a new regset to expose the ILP32 state (NT_ARM_..., I can't > > think of a name now but probably not PER* as this implies PER_LINUX_... > > which is independent from TIF_32BIT_*). > > So that would require an additional ptrace() call on each syscall stop, > is that correct? The ILP32 state does not change at run-time, so it could only do a ptrace() call once and save the information. No need to re-read it on each syscall stop. We could set a high bit in the syscall number reported to the ptrace caller (though not changing the syscall ABI) but I haven't thought of other consequences. For example, can the ptrace caller change the syscall number? > > > * What's the reasoning behind capping syscall arguments to 32 bit? x32 > > > and MIPS N32 do not have such a restriction (and do not need special > > > wrappers for syscalls that pass 64-bit values as a result, except > > > when they do, as it is the case for preadv2 on x32); moreover, that > > > would lead to insurmountable difficulties for AArch64 ILP32 tracers > > > that try to trace LP64 tracees, as it would be impossible to pass > > > 64-bit addresses to process_vm_{read,write} or ptrace PEEK/POKE. > > > > We've attempted in earlier versions to allow a mix of 32 and 64-bit > > register values from ILP32 but it got pretty complicated. The entry code > > would need to know which registers need zeroing of the top 32-bit > > If kernel specifies 64-bit wide registers for syscalls, then it's the > caller's (libc's) responsibility to properly sign-extend arguments when > needed, and glibc, for example, already has proper type definitions that > aimed to handle this. We tried, see my other reply. -- Catalin