Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7641277imu; Mon, 3 Dec 2018 16:46:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/V+pPi3sJeoenpIE08yPa3mRTG+sD4q1GYC0txezDSI1XgI+/Bg1PwpRpglQEjcIn6DxEF2 X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr17217715plp.19.1543884360949; Mon, 03 Dec 2018 16:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543884360; cv=none; d=google.com; s=arc-20160816; b=xDjJHR80aVp3Y7MtfXLt+GBCfHtuDXQHswgrzQxUtou8q//7cXiiJ63g+XjfPUEiAF eL+KNhchnDPYcyFP2EtYj63KEJsiICn3OwG+1XaQed0McaZ9TEjIzlYNJqEY2DHc2oFD tD//i4xEWhPair5m1dHeTB1OjJno/sWgh5F7e4ii6m+fPXF8sDs3YH3AV1bO5/O3kPEH UEEIcG//QKMfpFb/VHR1AtZF+F/5PHgKyL3G6AdGUHEOKLqvFTslumn1uiZ8r+oZ3aHr spblhSNVUTfk0cYQFZsmSNFLlGjJdGxDLUgcU1oGKuB/3n68OPrjyG6ZGLXeNi1qnpju NwXw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=87OqF1uN7d9ACrdQgcSiuLKj9o8edBytZUSUFVSbdVQ=; b=ySJXBECmhMDsQX3bYFjTGUFu3ryoszClAEjHCh/YHYdn4WMMTtyXKDbYfPYimD9KHL atvZ9dKfXXvuHZg/UB2QirW49sjepbEebgAWoYPt7+niYULv2tuzZeRIbVFqfC9198Ii T2tHbFaH94M9Q68/r7Gq7L75KC1nNKu88t9UdQ/cawH5puvTGP5c5pfsJuvAevRC55rP cLP/1kQFJibDkgssX0s4cUeucz9Qnf4eUSpsA9+gWDFE3Li5cvUqIZXIvEmitIOgkGyX 8ubmxSHniWBJxPwHicUtjv5uVnWjv2s/e8T8SfXBWlWeC9fgzagWRtpf600098lGcY5N lGew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gx0r0HHK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si5231505plo.422.2018.12.03.16.45.46; Mon, 03 Dec 2018 16:46:00 -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=@google.com header.s=20161025 header.b=Gx0r0HHK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726018AbeLDApK (ORCPT + 99 others); Mon, 3 Dec 2018 19:45:10 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45262 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbeLDApK (ORCPT ); Mon, 3 Dec 2018 19:45:10 -0500 Received: by mail-ot1-f66.google.com with SMTP id 32so13518597ota.12 for ; Mon, 03 Dec 2018 16:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=87OqF1uN7d9ACrdQgcSiuLKj9o8edBytZUSUFVSbdVQ=; b=Gx0r0HHKhggQcs6zw3DjJ/vh1cZISrIVYZJUPPJ6VC59gGtDeeIs9JmqkIirdq0TF8 O0TFo/t5TDXd3666I61W8BTr5TEchOKVb87N75wWA4sK98X30ojBc/8gLbncKHlUQOH2 JCkoTmpyndohEUzELTDk+ae0pqdDBd2t8ovX7UOp7OgDD9TwDNSnSmVebbdQE7heGIPG MOjsWsIFJh9S/x3gnlFvx8fdowcoBfz6NiADBiGIxj0nho8MdOOc4DHXGqGAjFcmDOSE qSX3T8cD6aoTCgeZCkGpoFFwsHspBsfmZb4EeMNw2Rh4zPybO2MZePAk448/apws2NbE T+kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=87OqF1uN7d9ACrdQgcSiuLKj9o8edBytZUSUFVSbdVQ=; b=dgRHRHElsxTmDZ/MuKfc30+cy8uxT6fySfiN+Auinq9kxGbqES+S1g846CqSCZDF3Z oqnSZw92qjlMkdzE7/uw2U/4pmEtjp441KfQakwp/iGKUeJyWzbDMEiXh/tbP8YammEa 3JOMaoC0Nv91hN1yNhNFeOsEn12oAxo4NQb5qWxheEu4Dve7OnOChBYWLglaugFdbkXa Lca5qTAQmwO+Y9gB1gMcMF6q4N3Agsjb3ngd1PlmUFJjaa7OTQtr/PTyKIaCRIO9utsQ Zwb6j93ESuWSqXoe4/sBYJQcZ653beuc3IezuPTXalZlxIJtvDP0o0yJAsVRLnhGjgRp IEbQ== X-Gm-Message-State: AA+aEWY/eWSfpfINmynUMTFQGO5bSwPscY8zgC3VXSyUQZD487vlPylz heB61KgCL5Mgz2HXK7zjXsjSiC+Vqc9mzS2dMeKAdw== X-Received: by 2002:a9d:3ac:: with SMTP id f41mr11002653otf.98.1543884307981; Mon, 03 Dec 2018 16:45:07 -0800 (PST) MIME-Version: 1.0 References: <20181128193636.254378-1-brendanhiggins@google.com> <20181128193636.254378-9-brendanhiggins@google.com> <20181130033429.GK18410@garbanzo.do-not-panic.com> <20181203234628.GR28501@garbanzo.do-not-panic.com> In-Reply-To: <20181203234628.GR28501@garbanzo.do-not-panic.com> From: Brendan Higgins Date: Mon, 3 Dec 2018 16:44:56 -0800 Message-ID: Subject: Re: [RFC v3 08/19] arch: um: add shim to trap to allow installing a fault catcher for tests To: mcgrof@kernel.org Cc: Greg KH , Kees Cook , shuah@kernel.org, Joel Stanley , mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, Julia Lawall , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Linux Kernel Mailing List , jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, Daniel Vetter , dri-devel@lists.freedesktop.org, Rob Herring , dan.j.williams@intel.com, linux-nvdimm@lists.01.org, kieran.bingham@ideasonboard.com, Frank Rowand , Knut Omang 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 On Mon, Dec 3, 2018 at 3:46 PM Luis Chamberlain wrote: > > On Mon, Dec 03, 2018 at 03:34:57PM -0800, Brendan Higgins wrote: > > On Thu, Nov 29, 2018 at 7:34 PM Luis Chamberlain wrote: > > > > > > On Wed, Nov 28, 2018 at 11:36:25AM -0800, Brendan Higgins wrote: > > > > diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c > > > > index cced829460427..bf90e678b3d71 100644 > > > > --- a/arch/um/kernel/trap.c > > > > +++ b/arch/um/kernel/trap.c > > > > @@ -201,6 +201,12 @@ void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs) > > > > segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); > > > > } > > > > > > > > +static void segv_run_catcher(jmp_buf *catcher, void *fault_addr) > > > > +{ > > > > + current->thread.fault_addr = fault_addr; > > > > + UML_LONGJMP(catcher, 1); > > > > +} > > > > + > > > > /* > > > > * We give a *copy* of the faultinfo in the regs to segv. > > > > * This must be done, since nesting SEGVs could overwrite > > > > @@ -219,7 +225,10 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, > > > > if (!is_user && regs) > > > > current->thread.segv_regs = container_of(regs, struct pt_regs, regs); > > > > > > > > - if (!is_user && (address >= start_vm) && (address < end_vm)) { > > > > + catcher = current->thread.fault_catcher; > > > > > > This and.. > > > > > > > + if (catcher && current->thread.is_running_test) > > > > + segv_run_catcher(catcher, (void *) address); > > > > + else if (!is_user && (address >= start_vm) && (address < end_vm)) { > > > > flush_tlb_kernel_vm(); > > > > goto out; > > > > } > > > > > > *not this* > > > > I don't understand. Are you saying the previous block of code is good > > and this one is bad? > > No, I was saying that the above block of code is a functional change, > but I was also pointing out other areas which were not and could be > folded into a separate atomic patch where no functionality changes. > > > > > @@ -246,12 +255,10 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, > > > > address = 0; > > > > } > > > > > > > > - catcher = current->thread.fault_catcher; > > > > if (!err) > > > > goto out; > > > > else if (catcher != NULL) { > > > > - current->thread.fault_addr = (void *) address; > > > > - UML_LONGJMP(catcher, 1); > > > > + segv_run_catcher(catcher, (void *) address); > > > > } > > > > else if (current->thread.fault_addr != NULL) > > > > panic("fault_addr set but no fault catcher"); > > > > > > But with this seems one atomic change which should be submitted > > > separately, its just a helper. Think it would make the actual > > > change needed easier to review, ie, your needed changes would > > > be smaller and clearer for what you need. > > > > Are you suggesting that I pull out the bits needed to implement abort > > in the next patch and squash it into this one? > > No, I'm suggesting you can probably split this patch in 2, one which > wraps things with no functional changes, and another which adds your > changes. > That makes sense. Thanks for the clarification!