Received: by 10.223.164.202 with SMTP id h10csp5950576wrb; Tue, 21 Nov 2017 19:15:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMZJMneMqGRwVNj0sFfYGAjNJzvODjy+XalcxXq4cnaUn5BCq6f3ndJBH/hIZQUqvnHfYozf X-Received: by 10.98.89.220 with SMTP id k89mr17687071pfj.36.1511320505452; Tue, 21 Nov 2017 19:15:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511320505; cv=none; d=google.com; s=arc-20160816; b=zR8zlp53gkFpBMTyiuwCRlxhM4IXBhFc20oAwE+m5g9YOwB9xjUJqHnWAA3NyNdYmI gNRrp1ydyIYBc+p9dczqchrcht/WBz8156nc3kV8KZZ0ng/iQN8K61XQ4n+ZD9xU+vBn Ez+PEzuAWQQagO2o/1kIpyXzJySuA1QSG6/G9CuD6SY5gXH2dGo73nSIoeYoF1bHPuMp c/XMDM+/CId6VenSECCknWiyy3vQx8QE28QveVoyAo5SwvxKP6bfTV6h4PSkHHebL09U NbAUBm+kU4eUhPjcgskNDBSwY8SsSYeHvyIHwNtfMYDXjcehjmTtDlIZlcoSX0uygFr4 aM3Q== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=7LnIjoNCNLRpiJmsXU/DZLl9sjpe1TvxJZloBu2uKXQ=; b=l/jMbcWUhFGVN20lUbt06rTg8k0le3lTfUCWyaPIRif1qneLQesO1f6E+fpGpW5MlE ywOOQ1lBsYMqAycAnbsNXLGflqYuXPBh5l45hh4L5OBUrcU87ksI8nr7F7TCS4psrG4/ DZmY+iIZcgHoUX0o+NRN+gEkPs/OOg+ANMURuyFLOfnf5lRx3BTVZEurSjKj1bWSLs3c QkpueNxYIsmEN8Q5EJZXEJXkQGGXSo9z7Nf+l7XHqxW2vTsr5LhVq95royr9J8C3Pqlq 8PHBPoPgc6TBsREZRW7hTu6mQEyiw4NmHiHBC1488HkyfHj+IFBVco2ZSKT+x819YM3V 84YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E+ak0u1C; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si3728309pgo.542.2017.11.21.19.14.54; Tue, 21 Nov 2017 19:15:05 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E+ak0u1C; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdKVDNv (ORCPT + 76 others); Tue, 21 Nov 2017 22:13:51 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:34829 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbdKVDNt (ORCPT ); Tue, 21 Nov 2017 22:13:49 -0500 Received: by mail-it0-f65.google.com with SMTP id u132so4629968ita.0; Tue, 21 Nov 2017 19:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7LnIjoNCNLRpiJmsXU/DZLl9sjpe1TvxJZloBu2uKXQ=; b=E+ak0u1ClOwYSwim3C+r8gvsbRTbYA64GvZdf0//mtf9yoPd5Mni49agAYHjJTzFP3 ikfZl0Von1uvB71dS2Bc5Dkvekj/25+GYkG5akzR7sKOOORvmq42IdoK02pfAJusIPuY 5iINvZcIX3ipEnzL1BP9sBkFy9F84yv0txBbWhoOjDCLwgwgAC+2cLqVRb76JAGn0ji1 bFGszp5OfZszmOL6alvVKuzS+P9oeKPc2JmaKo1XE1a5L8jvJxVLaJ0ZEnwVI/anBsIk F1k+YnMdrJXUt7NGclau8CJFB91rgRPaiZ1RfUlKt+fSjIGO0JBzuU7q3ptns9aCDe9l FBSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7LnIjoNCNLRpiJmsXU/DZLl9sjpe1TvxJZloBu2uKXQ=; b=FmwHaeVuEQGKEIs+DrDlciMb7tbeN9abiY2oqyZoMUb3Fl8hwOtiMd3baO4pB/C1QQ zFZzrW5byd3Xzue1H3QMsYYuHaHGs+8LKrRr/Y3K6IUDot2dMkmZVJDFx1NGyJeHCnW9 ymyeayOVthrkNoRl7Vt8vcd0jd5v0j97KsLfQpb+drK2m4T6fzAHp5Yy1Ah6ddWHUF3Q tvzJ1/2IB1P2d04ZfYVrfANTHwSupWQ3O4Ea0FQFQ6v7ufWAPHChaaEabKCgfN/Eexu1 Ns5FCub1kJR1NjOFQXdEefoOjmVkMvdB4DpeooPnFN9fD4Pt6zRUtwBm9+eLwXjfx/Yn kg7g== X-Gm-Message-State: AJaThX6couPrW4bkeKKmFzpe8lGzBz6aNHsD6Q+pf6GSrcjZ4gCkt7tf hJMu2zVcj/ZeNJSCcyuIV7OdLwOb45Y4+qBeUeU= X-Received: by 10.36.40.207 with SMTP id h198mr5229805ith.95.1511320428226; Tue, 21 Nov 2017 19:13:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.7.91 with HTTP; Tue, 21 Nov 2017 19:13:47 -0800 (PST) In-Reply-To: References: <61b5cd5e7f2cf2f485a990cdf238788b817a1d53.1510118606.git.green.hu@gmail.com> From: Vincent Chen Date: Wed, 22 Nov 2017 11:13:47 +0800 Message-ID: Subject: Re: FW: [PATCH 15/31] nds32: System calls handling To: Arnd Bergmann Cc: Greentime , Linux Kernel Mailing List , linux-arch , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Networking , Vincent Chen 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 2017-11-13 19:42 GMT+08:00 Arnd Bergmann : > On Mon, Nov 13, 2017 at 3:51 AM, Vincent Chen wrote: >>>>On Wed, Nov 8, 2017 at 6:55 AM, Greentime Hu wrote: >>>> From: Greentime Hu > >> >>>> +#define __ARCH_WANT_SYS_CLONE >>> >>>This seems ok, though it would be nice to have the reverse logic and have architectures opt-out of the generic version when they need to provide their own, rather than having most architectures set it. >>> >> >> Thanks >> I will provide nds32 SYSCALL_DEFINE_5(clone) in the next version patch. > > That's not what I meant, my suggestion is to create a new patch to remove the > __ARCH_WANT_SYS_CLONE symbol from all architectures, and instead use > something like __ARCH_HAVE_SYS_CLONE on architectures that do *not* > want the generic implementation. > > nds32 clearly wants the generic implementation here, it just shouldn't have to > select that symbol to get it. > >>>> +/* >>>> + * Special system call wrappers >>>> + * >>>> + * $r0 = syscall number >>>> + * $r8 = syscall table >>>> + */ >>>> + .type sys_syscall, #function >>>> +ENTRY(sys_syscall) >>>> + addi $p1, $r0, #-__NR_syscalls >>>> + bgtz $p1, 3f >>>> + move $p1, $r0 >>>> + move $r0, $r1 >>>> + move $r1, $r2 >>>> + move $r2, $r3 >>>> + move $r3, $r4 >>>> + move $r4, $r5 >>>> +! add for syscall 6 args >>>> + lwi $r5, [$sp + #SP_OFFSET ] >>>> + lwi $r5, [$r5] >>>> +! ~add for syscall 6 args >>>> + >>>> + lw $p1, [tbl+$p1<<2] >>>> .+ jr $p1 >>>> +3: b sys_ni_syscall >>>> +ENDPROC(sys_syscall) >>> >>>Can you explain what this is used for? >>> >> >> This is used to handle syscall(int number, ....). >> Unlike other architectures, the system number shall be determined in >> compile time when issuing system call in nds32. >> Therefore, we only can parse the content of syscall(int number, ....) >> and distribute it to destination handler in kernel space >> (Other architecture can handle it in user space by glibc's syscall wrapper) > > Hmm, I think other architectures that run into this problem use self-modifying > code for syscall(), but that is also ugly as it requires having a page that > is both writable and executable. > > I think your approach can be tricky for things like seccomp(). It's possible > that you get all of it right, but if you can come up with a different solution, > that might be better. > > How much would it cost to simply always pass the syscall number > in a register, and not use the immediate argument at all? > After re-evaluating the performance, we decide to use a particular register to transfer syscall number instead of immediate argument. So, above sys_syscall will be removed in the next version patch Thanks >>>> --- /dev/null >>>> +++ b/arch/nds32/kernel/sys_nds32.c >>>> + >>>> +long sys_mmap2(unsigned long addr, unsigned long len, >>>> + unsigned long prot, unsigned long flags, >>>> + unsigned long fd, unsigned long pgoff) { >>>> + if (pgoff & (~PAGE_MASK >> 12)) >>>> + return -EINVAL; >>>> + >>>> + return sys_mmap_pgoff(addr, len, prot, flags, fd, >>>> + pgoff >> (PAGE_SHIFT - 12)); } >>>> + >>>> +asmlinkage long sys_fadvise64_64_wrapper(int fd, int advice, loff_t offset, >>>> + loff_t len) { >>>> + return sys_fadvise64_64(fd, offset, len, advice); } >>> >>>You should always use SYSCALL_DEFINE*() macros to define entry points for your own syscalls in C code for consistency. I also wonder if we should just move those two into common code, a lot of architectures need the first one in particular. >>> >> >> The sys_fadvise64_64_wrapper is used to reorder the input parameter. >> >> In order to solve register alignment problem, we adjust the input >> parameter order of fadvise64_64 while issuing this syscall. >> Therefore, we need this wrapper to reorder the input parameter to fit >> sys_fadvise64_64's API in kernel. > > I understand what it's used for, it's just that I would recommend writing it > differently, as > > SYSCALL_DEFINE4(fadvise64_64_wrapper, int, fd, int, advice, loff_t, > offset, loff_t, len) > { > return sys_fadvise64_64(fd, offset, len, advice); > } > > Arnd From 1583951033555679020@xxx Mon Nov 13 11:43:39 +0000 2017 X-GM-THRID: 1583483337964688427 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread