From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765954AbcIOBBV (ORCPT ); Wed, 14 Sep 2016 21:01:21 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:33108 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754934AbcIOBBU (ORCPT ); Wed, 14 Sep 2016 21:01:20 -0400 MIME-Version: 1.0 In-Reply-To: References: <1473887291-18384-1-git-send-email-khuey@kylehuey.com> <1473887291-18384-2-git-send-email-khuey@kylehuey.com> From: Kyle Huey Date: Wed, 14 Sep 2016 18:01:18 -0700 Message-ID: Subject: Re: [RESEND][PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. To: Dmitry Safonov <0x7f454c46@gmail.com> Cc: "Robert O'Callahan" , open list , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Al Viro , Milosz Tanski , "Dmitry V. Levin" , David Howells , Zach Brown , Eric B Munson , Peter Zijlstra , Jiri Slaby , "Michael S. Tsirkin" , Andrey Ryabinin , Paul Gortmaker , Borislav Petkov , Dmitry Vyukov , Dmitry Safonov , Mateusz Guzik , Dave Hansen Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 14, 2016 at 3:29 PM, Dmitry Safonov <0x7f454c46@gmail.com> wrote: > 2016-09-15 1:08 GMT+03:00 Kyle Huey : >> On Wed, Sep 14, 2016 at 2:59 PM, Dmitry Safonov <0x7f454c46@gmail.com> wrote: >>> 2016-09-15 0:08 GMT+03:00 Kyle Huey : >>>> Signed-off-by: Kyle Huey >>>> --- >>>> arch/x86/entry/syscalls/syscall_32.tbl | 1 + >>>> arch/x86/kernel/process.c | 80 ++++++++++++++++++++++++++++++++++ >>>> arch/x86/kernel/process_64.c | 66 ---------------------------- >>>> 3 files changed, 81 insertions(+), 66 deletions(-) >>>> >>>> diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl >>>> index f848572..3b6965b 100644 >>>> --- a/arch/x86/entry/syscalls/syscall_32.tbl >>>> +++ b/arch/x86/entry/syscalls/syscall_32.tbl >>>> @@ -386,3 +386,4 @@ >>>> 377 i386 copy_file_range sys_copy_file_range >>>> 378 i386 preadv2 sys_preadv2 compat_sys_preadv2 >>>> 379 i386 pwritev2 sys_pwritev2 compat_sys_pwritev2 >>>> +380 i386 arch_prctl sys_arch_prctl >>> >>> Why not define it as other 32-bit syscalls with compat_sys_ prefix >>> with the help of COMPAT_SYSCALL_DEFINE() macro? >>> Then you could omit code moving, drop is_32 helper. >>> I miss something obvious? >> >> The code will have to move regardless, because right now do_arch_prctl >> is in process-64.c which is only compiled on a 64 bit kernel. > > Why? This code will not work anyway for 32-bit in your patches > by obscuring it with is_32. > >> As I told Dave Hansen in the non-RESEND thread (not sure why >> git-send-email didn't put him in this one ...) I considered doing a >> compat_sys_arch_prctl that would reject the relevant arch_prctls that >> don't apply on 32 bit but I didn't see any prior art for it (in my >> admittedly non-exhaustive search). > > Well, you could just add to 64-bit do_arch_prctl() new cases for your > prctls - that would be just a two-lines for each new prctl. > Also add compat_sys_ and define *only* what's needed there for you, > do not add there ARCH_{SET,GET}_{FS,GS}. > Does this make sense? Yeah, I should have spoken more clearly. We'll need some implementation of the syscall outside of process_64.c. But we could leave the 64 bit specific stuff behind in it. Dave Hansen suggested something similar (though without the compat_sys_bit) >FWIW, I don't think it would be horrible to leave the existing > do_arch_prctl() code in process_64.h and call it > do_64_bit_only_something_arch_prctl(), and only call in to it from the > generic do_arch_prctl(). You really have one reason for all the "if > (is_32)"'s and it would be nice to document why in one single place. - Kyle