Received: by 10.192.165.148 with SMTP id m20csp1399524imm; Wed, 25 Apr 2018 18:26:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ZVbM5evI/gnvu7z0R8y1ayah2kYEgBF5lPci8u3E/+Rd5pQBbw65Rfl68kJmSuFmjUp/L X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr31643999pla.111.1524705975869; Wed, 25 Apr 2018 18:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524705975; cv=none; d=google.com; s=arc-20160816; b=uPRsdbGNGxmSsyDzdIawjh8U7xJ/7aCDyCEMRg3DwSdbILjV3ogwCspbp3Mi+wPUaj clzjLnwaSekofoy2XCLR5cwl8J9kPV7ptE1xhhdQHQvDDuek+3SB4MU00I1vJ7Ozz07d 7QUwp2k4gAOv6s2UWegAo7ysNm1E5ksF7jUqmsivtKbErz8rQUhjcqScJH3WQ5bVcIRF DvvzYOJGdSlGcuZQMTlYDanbAjvywlzCDQHfK8LPj3/cioo4D0aK0v4IGYXukKJ8pPWt 9W3M8opv9LedAozsQ+UDXqwuQZoNaiWNY6XZCWR1kjxGGO1XXOoJi2kq6SB2i+KLxKws N+oQ== 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=AShGoFqeZEMFBunHPDF6cGnzjXmmyt/NvN8qyy6luUk=; b=X3dNoWWNZ5GXxj7rEtSYt1je6/fUoCsSZ5vQvofiheIvKpS0RQdLqKv4+uDjiN0lI1 DLrzVFP7/KCEfQRyP+gW4zIPemO3W4upnRbFWaQaokr9Mtk27JL/DmkLRaY+VV6wkeeD 9aITReboegia3BgWUoilMbafoC1OAqvejo50X0P1L4s325i0D3bfB8uDvQkiSoCSMq7L U78kN3Qfodqh48YZkgLkSEkg6qAk1dBgEHcO+FNA6wqQWK1SGP4SBffZQLYlQEqv+8A5 cwnUF5qD4i7k+8jbtEX0TXaY0Nnmmc4V9TCU/M9ctHSEAz8kHMp4sEEy0R9seWIy1/+k gITA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pfRurLJZ; 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=QUARANTINE 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 j23si16443114pfn.63.2018.04.25.18.26.01; Wed, 25 Apr 2018 18:26:15 -0700 (PDT) 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=pfRurLJZ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbeDZBYy (ORCPT + 99 others); Wed, 25 Apr 2018 21:24:54 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:38749 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbeDZBYv (ORCPT ); Wed, 25 Apr 2018 21:24:51 -0400 Received: by mail-ua0-f194.google.com with SMTP id y8so2488604ual.5; Wed, 25 Apr 2018 18:24:50 -0700 (PDT) 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=AShGoFqeZEMFBunHPDF6cGnzjXmmyt/NvN8qyy6luUk=; b=pfRurLJZgXuiNpAk9QhdwGHBCRTYc6KcWflNRIc59TqsQ+3Cl1HWhbY14qQgHd0TbT TQ/5N04cPqW559n0cyYFRqlfq0ftcfa939JbYZkACsWT0U5pvZZkVQRlbuOaSZOnIt0S IsU53ZeWBAQzjs3rnubn7mTU/qJh7or5l66l1dkYzRnY5VRdwyEZIXT43LAXLFBRQGPC vJdK5sjOgMv91f+IopbxUs061HRubw2zKQTBrFgjusLLimpgm2jPthAYbfVPvewT4Tt3 76AzBvMTSahvUp5blBiHPcNw7TgqJ4J9yZrWkZCJlwmq3Fvx2qXwNsXg4si5UGwGAJ/3 Vq9Q== 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=AShGoFqeZEMFBunHPDF6cGnzjXmmyt/NvN8qyy6luUk=; b=jlTOcz7yshteEfmpXLM38OKWveX6yzy4gbtLTLVoNNEQRaTbHe4ZpvdvUNH9O+Ogk8 ddDJTnq8bMxBF+dl1KXpFL+EsunuN9kTmYB4OJRY7/WkTa2e4Ol1rhagtVVV1cX6pI9t 8fukaM90AvcEMlvWK23OvQTztQXLLKIBFXj/rCkg4mP6uFyiJvbEnoqNTVlV5d4CCnMs IEhLKdDZZmd/GV0nHl4AtXtP2lAaMlMu8jh6pUajKZUTikimW9tNgnqeK4DAS+jn6uO5 E3Fraud+Ra4t4y17vGW198fTk8YHE10DbMqh9mCJu5YOVl52sMGZhoO1RvzvHVcZnFq3 t+4A== X-Gm-Message-State: ALQs6tAX1ji27U21k6qCnKLutXue947nfkowQQpnWjIf71qV6pUzbpWA wlN+s+s6GxbmE7N6E8LF+MIBoMvmcCeDoP9mQ3o= X-Received: by 10.176.24.88 with SMTP id j24mr24093301uag.94.1524705890314; Wed, 25 Apr 2018 18:24:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.92.86 with HTTP; Wed, 25 Apr 2018 18:24:09 -0700 (PDT) In-Reply-To: <87wowvuvml.fsf@xmission.com> References: <87604mhrnb.fsf@xmission.com> <20180420143811.9994-9-ebiederm@xmission.com> <87wowvuvml.fsf@xmission.com> From: Greentime Hu Date: Thu, 26 Apr 2018 09:24:09 +0800 Message-ID: Subject: Re: [REVIEW][PATCH 09/22] signal/nds32: Use force_sig_fault where appropriate To: "Eric W. Biederman" Cc: Vincent Chen , linux-arch , Linux Kernel Mailing List 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 2018-04-25 23:57 GMT+08:00 Eric W. Biederman : > Vincent Chen writes: > >> 2018-04-20 22:37 GMT+08:00 Eric W. Biederman : >>> Filling in struct siginfo before calling force_sig_info a tedious and >>> error prone process, where once in a great while the wrong fields >>> are filled out, and siginfo has been inconsistently cleared. >>> >>> Simplify this process by using the helper force_sig_fault. Which >>> takes as a parameters all of the information it needs, ensures >>> all of the fiddly bits of filling in struct siginfo are done properly >>> and then calls force_sig_info. >>> >>> In short about a 5 line reduction in code for every time force_sig_info >>> is called, which makes the calling function clearer. >>> >>> Cc: Greentime Hu >>> Cc: Vincent Chen >>> Signed-off-by: "Eric W. Biederman" >>> --- >>> arch/nds32/kernel/traps.c | 20 ++++---------------- >>> arch/nds32/mm/fault.c | 19 +++++-------------- >>> 2 files changed, 9 insertions(+), 30 deletions(-) >>> >>> diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c >>> index 46911768f4b5..636d1c7aa895 100644 >>> --- a/arch/nds32/kernel/traps.c >>> +++ b/arch/nds32/kernel/traps.c >>> @@ -222,20 +222,13 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err) >>> >>> int bad_syscall(int n, struct pt_regs *regs) >>> { >>> - siginfo_t info; >>> - >>> if (current->personality != PER_LINUX) { >>> send_sig(SIGSEGV, current, 1); >>> return regs->uregs[0]; >>> } >>> >>> - clear_siginfo(&info); >>> - info.si_signo = SIGILL; >>> - info.si_errno = 0; >>> - info.si_code = ILL_ILLTRP; >>> - info.si_addr = (void __user *)instruction_pointer(regs) - 4; >>> - >>> - force_sig_info(SIGILL, &info, current); >>> + force_sig_fault(SIGILL, ILL_ILLTRP, >>> + (void __user *)instruction_pointer(regs) - 4, current); >>> die_if_kernel("Oops - bad syscall", regs, n); >>> return regs->uregs[0]; >>> } >>> @@ -288,16 +281,11 @@ void __init early_trap_init(void) >>> void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, >>> int error_code, int si_code) >>> { >>> - struct siginfo info; >>> - >>> tsk->thread.trap_no = ENTRY_DEBUG_RELATED; >>> tsk->thread.error_code = error_code; >>> >>> - clear_siginfo(&info); >>> - info.si_signo = SIGTRAP; >>> - info.si_code = si_code; >>> - info.si_addr = (void __user *)instruction_pointer(regs); >>> - force_sig_info(SIGTRAP, &info, tsk); >>> + force_sig_fault(SIGTRAP, si_code >>> + (void __user *)instruction_pointer(regs), tsk); >>> } >>> >> >> I found a comma is missing after argument si_code. > > Good catch. Fixed. > > Unfortunately the only compiler I have for nds32 is my eyeballs so > this slipped through. Grr. > > Sorry for that. Our nds32 toolchain upstreaming is on-going. You may try this one. It is able to build defconfig and allnoconfig https://lkml.org/lkml/2018/4/17/395 https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/6.4.0/x86_64-gcc-6.4.0-nolibc-nds32le-linux.tar.xz or this one with glibc support https://github.com/andestech/build_script.git https://github.com/greentime/prebuilt-nds32-toolchain/releases