Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6917584ybc; Thu, 28 Nov 2019 07:38:53 -0800 (PST) X-Google-Smtp-Source: APXvYqyKkmr2LR59m2pPfib5WZ/oFTouAaol/dcfxtJhTWpEsDmC/uITL7eRUom5FxUGtYOe6AV2 X-Received: by 2002:a17:906:5e52:: with SMTP id b18mr54772331eju.318.1574955533866; Thu, 28 Nov 2019 07:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574955533; cv=none; d=google.com; s=arc-20160816; b=OHO899p0t028bZc5ufI5dL7xxPUBJr7J+6iTeWzaERe7b8XJeSI2nKlmyIDYA6c0zH FHBb5mu1bPFG3O+u5rgtGfHyFO5CJ/leH3AHtQQv16lNgjCyoiTxqi9HkAdOD4S84MRB b43rflN4h6OvNgoeqSi8HH8Ot+aWhTBg4SWEtOgbK2fkJzDrEAAOE7LY1Bh2paL2ipzL xmur8CoMTus9H8tHqFgZm/UxRc8vHpSXFe4tZaHf6JajF9zFMycQrXT95a/LVmmnwRBE E1Hu6LeohpBMRlOtF1qRK60HUYt+cUzmmOfygmRaCwVp/ndURFDV8yR0nwNkvWtWxr1o r2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YC/yOmLYDa2qCJXbkoxWtK75q4ey4hZxhcY9IKRFnMU=; b=lz+zZmgWoI6e2UHX9KI2mdkxQZVXfAqkXbC38OPibh1tSNEFWhS5qBSmo5m+HP0FvU jsQjXPx9K1nQ6Gad56D31WZ/FsOGZ/1E3y0Y0K/wMZYGE4w5q1qjUywdH5mt6lsAPjqh 4/ACDjWCJEF+gtNrxSLdDxzP2X54v0YVySE9X93HFOPYLZKJbErO7k/VAG5Y+i2wfpb4 1WRVgmoJmBw5cQuqE20wt/FEBjyF6F1f/sZJr4R4woe1bJlbZEMakB+sFpAfcFqQjSDO XxMCc1phvqEX/5I5puMPW2w324FoQu2QysHaNThl9M8dFanR+j2DTpGt4+LshAEzGKuS LOYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wi0CNiKn; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si5484985edy.63.2019.11.28.07.38.29; Thu, 28 Nov 2019 07:38:53 -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=@redhat.com header.s=mimecast20190719 header.b=Wi0CNiKn; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbfK1Pg6 (ORCPT + 99 others); Thu, 28 Nov 2019 10:36:58 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37105 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726401AbfK1Pg5 (ORCPT ); Thu, 28 Nov 2019 10:36:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574955416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YC/yOmLYDa2qCJXbkoxWtK75q4ey4hZxhcY9IKRFnMU=; b=Wi0CNiKnMuFmyM9mi73ko4XZE6fiQ/icwaA27db4aTsIuytTmFjanGeqSKQWMJyCwzFzTt 0woLsYs15+i3oqt3g6zqTJdIQ/bMBACveGqMrP1kPybkJYqtFaRDGbaY475Zq1Hzqj7Gj1 yG9VipncOHNQKHI2gYERL39iNwaVmPs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-NMvYYFpDPHKfBuiGbcDclA-1; Thu, 28 Nov 2019 10:36:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37766100F76F; Thu, 28 Nov 2019 15:36:51 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.44]) by smtp.corp.redhat.com (Postfix) with SMTP id 5132B60161; Thu, 28 Nov 2019 15:36:45 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 28 Nov 2019 16:36:50 +0100 (CET) Date: Thu, 28 Nov 2019 16:36:44 +0100 From: Oleg Nesterov To: Linus Torvalds Cc: Andrew Morton , Andy Lutomirski , Borislav Petkov , Ingo Molnar , Jan Kratochvil , Pedro Alves , Peter Anvin , Thomas Gleixner , Linux Kernel Mailing List , the arch/x86 maintainers Subject: Re: [PATCH] ptrace/x86: introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall() Message-ID: <20191128153644.GA5508@redhat.com> References: <20191126110659.GA14042@redhat.com> <20191126110758.GA14051@redhat.com> <20191127170234.GA26180@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: NMvYYFpDPHKfBuiGbcDclA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/27, Linus Torvalds wrote: > > On Wed, Nov 27, 2019 at 9:02 AM Oleg Nesterov wrote: > > > > OK, lets add the new restart_block.nr_restart_syscall field, then we ne= ed > > > > void set_restart_block_fn(restart, fn) > > { > > restart->nr_restart_syscall =3D arch_get_nr_restart_sys= call() > > restart->fn =3D fn; > > } > > No, I'd suggest just adding an arch-specific "unsigned long" to the > restart data (and not force the naming to something like the system > call number - that's just an x86 detail), and then something like this > on x86: > > void arch_set_restart_data(restart) > { > restart->arch_data =3D x86_get_restart_syscall(); > } > #define arch_set_restart_data arch_set_restart_data > > and then we'd have in generic code something like > > #ifndef arch_set_restart_data > #define arch_set_restart_data(block) do { } while (0) > #endif OK, let it be arch_data/arch_set_restart_data, the same thing. You misunderstood my question, I do not see a good place for the code above. So I am going to uglify */signal.[ch] files. See the incomplete patch below, everything else is trivial. Please tell me if you think I should move this code somewhere else. Oleg. diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index 33d3c88..f536bcb 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -5,6 +5,10 @@ #ifndef __ASSEMBLY__ #include =20 +struct restart_block; +extern void arch_set_restart_data(struct restart_block *); +#define arch_set_restart_data=09arch_set_restart_data + /* Most things should be clean enough to redefine this at will, if care is taken to make libc match. */ =20 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 8eb7193..ede5443 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -768,6 +768,11 @@ handle_signal(struct ksignal *ksig, struct pt_regs *re= gs) =09signal_setup_done(failed, ksig, stepping); } =20 +void arch_set_restart_data(struct restart_block *restart) +{ +=09// TODO +} + static inline unsigned long get_nr_restart_syscall(const struct pt_regs *r= egs) { =09/* diff --git a/include/linux/restart_block.h b/include/linux/restart_block.h index bba2920..d39f836 100644 --- a/include/linux/restart_block.h +++ b/include/linux/restart_block.h @@ -55,6 +55,8 @@ struct restart_block { =09}; }; =20 +extern long set_restart_fn(struct restart_block *restart, +=09=09=09=09long (*fn)(struct restart_block *)); extern long do_no_restart_syscall(struct restart_block *parm); =20 #endif /* __LINUX_RESTART_BLOCK_H */ diff --git a/include/linux/signal.h b/include/linux/signal.h index 1a5f883..542499f 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -5,12 +5,17 @@ #include #include #include +#include =20 struct task_struct; =20 /* for sysctl */ extern int print_fatal_signals; =20 +#ifndef arch_set_restart_data +#define arch_set_restart_data(restart) do { } while (0) +#endif + static inline void copy_siginfo(kernel_siginfo_t *to, =09=09=09=09const kernel_siginfo_t *from) { diff --git a/kernel/signal.c b/kernel/signal.c index bcd46f5..d6402e6 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -4493,6 +4493,14 @@ SYSCALL_DEFINE3(sigsuspend, int, unused1, int, unuse= d2, old_sigset_t, mask) } #endif =20 +long set_restart_fn(struct restart_block *restart, +=09=09=09long (*fn)(struct restart_block *)) +{ +=09restart->fn =3D fn; +=09arch_set_restart_data(restart); +=09return -ERESTART_RESTARTBLOCK; +} + __weak const char *arch_vma_name(struct vm_area_struct *vma) { =09return NULL;