Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2616126ybt; Tue, 16 Jun 2020 10:23:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxffgce2Ft5ZrHecIWc08sxzQ5WMzjOk9cYUf3LvzhiiNjzypuW5VgFEKY9Hs3YAJr1BDjv X-Received: by 2002:aa7:c356:: with SMTP id j22mr3370867edr.59.1592328198343; Tue, 16 Jun 2020 10:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592328198; cv=none; d=google.com; s=arc-20160816; b=mpSVCfYjg3bWtlLttyXTYyAYJnSb5yc2b66pPVkWkH3NXFCHg7mIajLzgNfybaeM/K fpJAmgPdNjlJYT5HrDdgUHqQwqiviG6R80W7wKA5apJJxEMQ8HYh2TdbeM1ovgaq3cTZ K4vdVOgF+WkVLf4JC5F2vTjwgZTYDqF08qZ8XLk9AVvZSfQvsrGebyUN25b+2pgSNrir /tysnolidEqAsqScKY9oZBqR3x1K6RRj9Z760ckfDMyQxNB8c9i5IP5+YdWF2xfe/RSn er9JYqoL7EQM9liCw3rHCphxMxH5GRBk9IfuCi9Y6bOGSzbLM8FUiW0kYuG9uV2G25lk bFHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/vHq52omWlog0YiKhxrpQ9eFFCo1rr88pNsfYob/7tk=; b=xJQn1fMkSbPMpuePTDlWSuRRDm9ql3ovJtRfZ4zhUNMpFlwofw35nXrqIfUdR1brg1 7Bq+P9RB5H7CFj/tvoVI2TVyupHcSt+AO6cEfOi58wHhJolQjFw8WCbDfE8iWjImspZJ aRGAl5rmLxw9O70s0ATvm/x2KQzLUc4PK/Fa9ntUiTB8GY11lHLQYoSmhSDDYKIRETD9 c+KRyePJR3gI3+VgfWway3fNfn4VfcBKtMoMn6QileiSzQWy9TMvYcfN7U7ZmM0Xz5N/ nI5FN79q0TI7InvzXjlEmNqGyVL2ZKIjBQpTEJMIbjXbuxkR4kf1c3gQ5wdfEczbq4Qr 6Rdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kKp61PCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si11309521edx.175.2020.06.16.10.22.55; Tue, 16 Jun 2020 10:23:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kKp61PCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728549AbgFPRRn (ORCPT + 99 others); Tue, 16 Jun 2020 13:17:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727962AbgFPRRl (ORCPT ); Tue, 16 Jun 2020 13:17:41 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BC9C061573 for ; Tue, 16 Jun 2020 10:17:41 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id c8so22822287iob.6 for ; Tue, 16 Jun 2020 10:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/vHq52omWlog0YiKhxrpQ9eFFCo1rr88pNsfYob/7tk=; b=kKp61PCmH0YJN59e08g6UWRGA2qPc2SQu2edP+4uWaU5v7dgwA8n2GmMeiSkMb9ev9 m7KYESJwHaOcgOrlwbtrLKEP8297fuw8T29I7zFhfjVku208u21q7zo92p0esqHZ9WB/ Z9nyiM49patEAHIfL+EYVlJ3U/I7KCcPI/LTTN+xIK4zXU+8+tUMtCL9xRMehHuiavSN nwzKymid8grfAPP+tXu5wJSH55j5DSGeVvq7rH98XqaTl3TJ3yHO0wGGWObRWaEQRPbh aieg2VomUmwc1mBtmISvHA6uB8G9qcxiuitfXLNfqeLkZl7mDRvOUTrJ87Y0QhecJ6mV lKog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/vHq52omWlog0YiKhxrpQ9eFFCo1rr88pNsfYob/7tk=; b=QPbXAU8qyhYSuQnWvk1uvhOorKtosNPua+oPnGccx6HMawsHjSoRyQ9VHly3Azdi8s to6/BzmLMORvVlIcJoWpINzm+Nmxa4H6vV7/qRW1uYVEMT1W4UNx5gI9FXIUHjlMUbCV 2bEgJiDdJe/y9Wyh+wiTK5x+P2j3Y23QnSLUZK022MWsMncuWKNAF459kiRhksYnq1Lv irzrdM7K1ECgIytta/X73hdgRcdrlzZQe+ijVjysudKh4UUpxyVJirUWJNLl6CfB0BIy LI38LziG8tvJxK8w9JsbeUC8sKyuQHnXk3iyWAQWucWmimnAUCaDVH3WM35ffdYCcGEP +fhg== X-Gm-Message-State: AOAM531/0441pP9FXM2OH6mECynML5YausqxHbbEjLDMSXrI07DygKCk kDggQjCBgTGi6rWzzYr+gXvX5Pz/yu99ZF5qIXdQ+Wk= X-Received: by 2002:a02:896:: with SMTP id 144mr15829689jac.126.1592327860458; Tue, 16 Jun 2020 10:17:40 -0700 (PDT) MIME-Version: 1.0 References: <20200616142315.375918-1-brgerst@gmail.com> <20200616142315.375918-2-brgerst@gmail.com> In-Reply-To: From: Brian Gerst Date: Tue, 16 Jun 2020 13:17:29 -0400 Message-ID: Subject: Re: [PATCH 1/2] x86/x32: Use __x64 prefix for X32 compat syscalls To: Andy Lutomirski Cc: LKML , X86 ML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Christoph Hellwig , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 16, 2020 at 12:49 PM Andy Lutomirski wrote: > > On Tue, Jun 16, 2020 at 7:23 AM Brian Gerst wrote: > > > > The ABI prefix for syscalls specifies the argument register mapping, so > > there is no specific reason to continue using the __x32 prefix for the > > compat syscalls. This change will allow using native syscalls in the X32 > > specific portion of the syscall table. > > Okay, I realize that the x86 syscall machinery is held together by > duct tape and a lot of luck, but: > > > > > Signed-off-by: Brian Gerst > > --- > > arch/x86/entry/syscall_x32.c | 8 +++----- > > arch/x86/include/asm/syscall_wrapper.h | 10 +++++----- > > 2 files changed, 8 insertions(+), 10 deletions(-) > > > > diff --git a/arch/x86/entry/syscall_x32.c b/arch/x86/entry/syscall_x32.c > > index 3d8d70d3896c..f993e6254043 100644 > > --- a/arch/x86/entry/syscall_x32.c > > +++ b/arch/x86/entry/syscall_x32.c > > @@ -9,15 +9,13 @@ > > #include > > > > #define __SYSCALL_64(nr, sym) > > +#define __SYSCALL_COMMON(nr, sym) __SYSCALL_X32(nr, sym) > > > > -#define __SYSCALL_X32(nr, sym) extern long __x32_##sym(const struct pt_regs *); > > -#define __SYSCALL_COMMON(nr, sym) extern long __x64_##sym(const struct pt_regs *); > > +#define __SYSCALL_X32(nr, sym) extern long __x64_##sym(const struct pt_regs *); > > #include > > #undef __SYSCALL_X32 > > -#undef __SYSCALL_COMMON > > > > -#define __SYSCALL_X32(nr, sym) [nr] = __x32_##sym, > > -#define __SYSCALL_COMMON(nr, sym) [nr] = __x64_##sym, > > +#define __SYSCALL_X32(nr, sym) [nr] = __x64_##sym, > > > > asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_x32_syscall_max+1] = { > > /* > > diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h > > index a84333adeef2..267fae9904ff 100644 > > --- a/arch/x86/include/asm/syscall_wrapper.h > > +++ b/arch/x86/include/asm/syscall_wrapper.h > > @@ -17,7 +17,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs); > > * __x64_sys_*() - 64-bit native syscall > > * __ia32_sys_*() - 32-bit native syscall or common compat syscall > > * __ia32_compat_sys_*() - 32-bit compat syscall > > On a 64-bit kernel, an "ia32" compat syscall is __ia32_compat_sys_*, but... > > > - * __x32_compat_sys_*() - 64-bit X32 compat syscall > > + * __x64_compat_sys_*() - 64-bit X32 compat syscall > > Now an x32 compat syscall is __x64_compat? This seems nonsensical. Again, think of it as how the registers are mapped, not which syscall table it belongs to. X32 and X64 are identical in that regard. > I'm also a bit confused as to how this is even necessary for your > other patch. This came out of discussion on Cristoph's patch to combine compat execve*() into the native version: https://lore.kernel.org/lkml/20200615141239.GA12951@lst.de/ The bottom line is that marking a syscall as X32-only in the syscall table forces an __x32 prefix even if it's not a "compat" syscall. This causes a link failure. This is just another quirk caused by how X32 was designed. The solution is to make the prefix consistent for the whole table. The other alternative is to use __x32 for all the common syscalls. The second patch isn't really necessary, but it makes more sense to not have a compat syscall with no corresponding native version. -- Brian Gerst