Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbcDRGTp (ORCPT ); Mon, 18 Apr 2016 02:19:45 -0400 Received: from terminus.zytor.com ([198.137.202.10]:52652 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751543AbcDRGTo (ORCPT ); Mon, 18 Apr 2016 02:19:44 -0400 Subject: Re: [PATCH] x86/entry/x32: Check top 32 bits of syscall number on the fast path To: Andy Lutomirski References: <1460940317.9121.56.camel@decadent.org.uk> <20160418004731.GB3348@decadent.org.uk> <5714679B.3040806@zytor.com> <57146ECA.5000901@zytor.com> <57147474.1090901@zytor.com> <57147837.2030706@zytor.com> Cc: Ben Hutchings , Andy Lutomirski , X86 ML , LKML From: "H. Peter Anvin" Message-ID: <57147C76.3060005@zytor.com> Date: Sun, 17 Apr 2016 23:19:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1080 Lines: 26 On 04/17/16 23:14, Andy Lutomirski wrote: >> >> It's not "weird", it is the ABI as defined. We have to do this for all >> the system call arguments, too; you just don't notice it because the >> compiler does it for us. Some other architectures, e.g. s390, has the >> opposite convention where the caller is responsible for normalizing the >> result; in that case we have to do it *again* in the kernel, which is >> one of the major reasons for the SYSCALL_*() macros. > > What ABI? > The C ABI for int. I hadn't seen the below, because I think syscall(3) is just braindamaged, but the odds are that if we'd ever use the upper 32 bits for anything we'd be in a world of hurt, so that would be highly theoretical IMO. Bit 31 might be possible, but I wouldn't really want to brave it unless we really have no choice. > Also, the behavior in which fail the syscall if any high bits are set > is faster -- it's one fewer instruction. Admittedly, the CPU can > probably do that instruction for free, but still... Yes, it can; at least on any remotely modern hardware. -hpa