From patchwork Tue Dec 4 21:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 152866 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8552923ljp; Tue, 4 Dec 2018 13:24:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/Un/1MtwiIewXMBtIb2UvwnYfsSgBdw21s6YSupTFN17g1EUXccTqiHPFtYLyQ6kITPBInC X-Received: by 2002:a17:902:24e7:: with SMTP id l36mr9924527plg.61.1543958651107; Tue, 04 Dec 2018 13:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543958651; cv=none; d=google.com; s=arc-20160816; b=iwuYy4Q6FqV1xqUWDv2UqqhCfRCRFoCmsLaW0rz4qIVuxAN45Vkzriwo9w6aBYNtOf IJztuoXNKcO9fDoj7EWCSQ0MxQSk+xxvtttrW6WZ8okypWcBfTw5rhadYjcTlJajD1vc mTtn5WYjdG+eiCOWcdJqAHrVTdWGGygm9btYRH3gnoGjP8+qUJrYfLz2tAZjPe9AD4S/ QB90njPFmo13MrH/TMJSepfznXhRfwCGVp2E3ybvnwCgcA4IztgtFxi292EU0A+leYE7 mu/HCbvh/gLZUrlXI0M//e1Z2yTFe5OG0LCU/Hvd2vDUiaaHV4hgQyT9aB6dktYOpEp2 bSlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=WOhN5cF6U6usCDuKa/4wxDKOjB68l69l0NYaZlGPvPU=; b=CMmrwQ5dLvx5uMy5B2DlG1KvnH0MyceR6Tl0FT6eJv2hbr0iUbK7zy0h6uIm1KqtFS o5npucdCLyzC4Ar2pHLuYMNXZdKA+bBNkLB48ppRTI5+gNSeRpEc/jzXDIJX3r/ktdPh Sv1f7lti28AU9YUOiNRJbl6wwI4UPoDyJJfF0U8erRpChdSiRHuhOf8KKLLU54eKDVF/ /t76E5adGqn8BIGWb2UNc0WrhcnpdOV9Io6ax8VJZ1zS7ly2PCtyTtBk4nRtWXROtiw/ OQCyi06S7FY+lUBHA5+c78+8vTiNdlqnYFi0xKVDy4sSYIFt+lzs7/SQjxovfxyrrYXO 6+2g== 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 u13si17829238plq.268.2018.12.04.13.24.10; Tue, 04 Dec 2018 13:24:11 -0800 (PST) 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 S1726657AbeLDVYI (ORCPT + 31 others); Tue, 4 Dec 2018 16:24:08 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:34459 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbeLDVYF (ORCPT ); Tue, 4 Dec 2018 16:24:05 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N1g3U-1hVr8c2Txw-011z3G; Tue, 04 Dec 2018 22:23:54 +0100 From: Arnd Bergmann To: firoz.khan@linaro.org Cc: y2038@lists.linaro.org, linux-arch@vger.kernel.org, deepa.kernel@gmail.com, Arnd Bergmann , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan , Christophe Leroy , Joel Stanley , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] powerpc: split compat syscall table out from native table Date: Tue, 4 Dec 2018 22:23:07 +0100 Message-Id: <20181204212340.3915309-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: X-Provags-ID: V03:K1:ZivU5sOtOGpvDROJTPzC3cFFUPED1oKW1AZPSkRrG/FCNsI6ycM jjrNujJjd2p+OwP+pG02TnUfEYAH601nUI6m9yt/MeolUQHcCflniE4TV7DsknVpDSHunLG vifhgRA6fUkcl4BnthmsZ3nU8dgUqUsYLviHorZkE5cVSmm897Jp9xzVNZyOHpWdji3Duim An7RuQOsAXMwxohY2CtBA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:hf4vrmoC6nc=:vypGEd1o8AY7d7KwJ2UbdX wa0dHginCoT8xL5IRtQpi+SqJhReosWynypauUPdJuRDdscnREEFyytOyX8R0w2UcqDGJJdnp +Xw8XSRu4VGLgzmhGLcm2BAF5R0uCBt7nCRhpLWqDBQ+E/jM1k4M5WTw/L3VCsL0SWi1Hb5C/ isnwtj3yUjuK1DUzwTLvWnjMZ7Nd1p+BEqDgGsCX4ZW6hoMPAHLlcQ8Y40kvLVAQ0khNYK0f9 1Gsy2MQpXL3ivhzix8eJMO7s/rFbxRFGjWntopUMiGtCpLN5sAgRV1Etjs7CKfQJZfyk84dBa 9qzsveamUVTOhuZXna8PuuCT+qnQ8Ry+c7dzj3hSdg0M8NPrH5m9B8NMMiRhuJcRynN4tAIRl rI8ICpZWvI4vlPMY5WfhKJqMbGq5xjou8S/5xogdX0YuftwZ0hkrtZKGdjUdGa5mRKN9AN3rb 7UhKDHpgoK5uc8gvLlBGp8lkiUMdIHBnvJ12Fpe5il5TrC1Y5LWAGWEm5zIBMZJwYNV4FVPHp zwmG7DEUpuQadnWA4rz9C4HzIjKAHJgp1BQCFvKQD5VVHzhjCwz1xIkf0DPd67Zgj8YVsHl1H qjlS3sA2q1ZTwzxR+CeUpyyhQHajUWfa21ym5n07HTiLWCO4aHMj90YLEXvQPEdvBXOiQreNb dJb3vjAz9X8VoVYB6I7lifNwnAX5zwyrDvN91jpWSZQO5BdJhLgpNG/G9elvY+Zs1sW6sKKpd 1L/wIno4Zz9oM+SbMq6eWuXpC9xLVgmsFjcmjw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PowerPC uses a syscall table with native and compat calls interleaved, which is a slightly simpler way to define two matching tables. As we move to having the tables generated, that advantage is no longer important, but the interleaved table gets in the way of using the same scripts as on the other architectures. Split out a new compat_sys_call_table symbol that contains all the compat calls, and leave the main table for the native calls, to more closely match the method we use everywhere else. Signed-off-by: Arnd Bergmann --- This is completely untested, it's just for illustration and to get comments about whether this is a good idea. Firoz, can you try to get this working? --- arch/powerpc/include/asm/syscall.h | 3 +-- arch/powerpc/kernel/entry_64.S | 7 ++++-- arch/powerpc/kernel/systbl.S | 37 ++++++++++++++++++++++++------ arch/powerpc/kernel/vdso.c | 7 ++++-- 4 files changed, 41 insertions(+), 13 deletions(-) -- 2.18.0 diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index ab9f3f0a8637..1a0e7a8b1c81 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -18,9 +18,8 @@ #include /* ftrace syscalls requires exporting the sys_call_table */ -#ifdef CONFIG_FTRACE_SYSCALLS extern const unsigned long sys_call_table[]; -#endif /* CONFIG_FTRACE_SYSCALLS */ +extern const unsigned long compat_sys_call_table[]; static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) { diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 7b1693adff2a..5574d92646f1 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -54,6 +54,9 @@ SYS_CALL_TABLE: .tc sys_call_table[TC],sys_call_table +COMPAT_SYS_CALL_TABLE: + .tc compat_sys_call_table[TC],compat_sys_call_table + /* This value is used to mark exception frames on the stack. */ exception_marker: .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER @@ -173,7 +176,7 @@ system_call: /* label this so stack traces look sane */ ld r11,SYS_CALL_TABLE@toc(2) andis. r10,r10,_TIF_32BIT@h beq 15f - addi r11,r11,8 /* use 32-bit syscall entries */ + ld r11,COMPAT_SYS_CALL_TABLE@toc(2) clrldi r3,r3,32 clrldi r4,r4,32 clrldi r5,r5,32 @@ -181,7 +184,7 @@ system_call: /* label this so stack traces look sane */ clrldi r7,r7,32 clrldi r8,r8,32 15: - slwi r0,r0,4 + slwi r0,r0,3 barrier_nospec_asm /* diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S index 919a32746ede..883b8e36964c 100644 --- a/arch/powerpc/kernel/systbl.S +++ b/arch/powerpc/kernel/systbl.S @@ -17,13 +17,13 @@ #include #ifdef CONFIG_PPC64 -#define SYSCALL(func) .8byte DOTSYM(sys_##func),DOTSYM(sys_##func) -#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func),DOTSYM(compat_sys_##func) -#define PPC_SYS(func) .8byte DOTSYM(ppc_##func),DOTSYM(ppc_##func) -#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall) -#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func) -#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall) -#define SYSX(f, f3264, f32) .8byte DOTSYM(f),DOTSYM(f3264) +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f) #else #define SYSCALL(func) .long sys_##func #define COMPAT_SYS(func) .long sys_##func @@ -48,3 +48,26 @@ sys_call_table: #include + +#undef SYSCALL +#undef COMPAT_SYS +#undef PPC_SYS +#undef OLDSYS +#undef SYS32ONLY +#undef PPC64ONLY +#undef SYSX + +#ifdef CONFIG_COMPAT +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(compat_sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(compat_sys_##func) +#define PPC64ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f3264) + +.globl compat_sys_call_table +compat_sys_call_table: + +#include +#endif diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index 65b3bdb99f0b..7725a9714736 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c @@ -671,15 +671,18 @@ static void __init vdso_setup_syscall_map(void) { unsigned int i; extern unsigned long *sys_call_table; +#ifdef CONFIG_PPC64 + extern unsigned long *compat_sys_call_table; +#endif extern unsigned long sys_ni_syscall; for (i = 0; i < NR_syscalls; i++) { #ifdef CONFIG_PPC64 - if (sys_call_table[i*2] != sys_ni_syscall) + if (sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_64[i >> 5] |= 0x80000000UL >> (i & 0x1f); - if (sys_call_table[i*2+1] != sys_ni_syscall) + if (compat_sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_32[i >> 5] |= 0x80000000UL >> (i & 0x1f); #else /* CONFIG_PPC64 */