Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp115328ima; Tue, 23 Oct 2018 20:52:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5fS9t5KAr1xIFGNQ+vUh3KO3+KjTCeJPsdIIDABFYV1kLlFpo8wsY0pZVNzBuxJMZHR/1lr X-Received: by 2002:a62:9f11:: with SMTP id g17-v6mr1034227pfe.144.1540353137657; Tue, 23 Oct 2018 20:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540353137; cv=none; d=google.com; s=arc-20160816; b=SUqmAYheo3iVNymCbM+Y9Eb9L0Mfi8zIJnKUmOPH87LZ8gTh9h07+1CQMtNwe9Iqpi srEQXvZLRwDZEZF0QwY9pWKRiXtYZjYFwAd9Ba6R4Rvx+M+pSID8HourMYDQMSNDQQYL mxm72OVo2suILnQ0wBm5Iq8NIflfC5N4Er0YHOoXIjIoMA+qVShYnchmKi6T+ht7koTq PO+eYA8SNNiHkMsz9nzcauDXTPFxGFnky9X++Gz0q7FAxcyeFrcGFUWS6TlNJM8atXzw tHrauRo80e905c/A+9zeNkvhy+lnQgehYQUBntHnZa8Op9e7mn1I7Va1VHr47nVy3VP4 dk0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=AZXGizRDYB34OjNAQjmrfiUD+eNMXlsWMwWZ+590v6s=; b=IdOdbzz+rtjPr/f77XuwkWdFxekaegN3X4X1diVzJzi3PYZb3JSXG2szKLMEILCrDM ffAYIaxSLLVF3oDb7IY8Dii7+IpUxgiK2t+qdIfJHg8l32/OfbltTnZ5gTl6jTWf2JQs 6W5zzbREBlLOGeL/VQUZH8roq7sEIlElHjJ2NUSgNpMzT0VZQBZZPQBBJfe5DG2tc5Zt Bo2pQsUiNuN6a2DKIoRBLVqmGuPOi7AJTFYbC5UX6bvKohXds26+mUr73di4MujmRFDW myUbOeAHetv6Qm5gyeGCdy6nxO/CTJs3AXOHfhPUwh1s7GgOnuqAzdjI6Sr1E9tH3Fkw eNZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WPSOrUgg; 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 h15-v6si3385495pgb.547.2018.10.23.20.52.02; Tue, 23 Oct 2018 20:52:17 -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=@google.com header.s=20161025 header.b=WPSOrUgg; 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 S1726735AbeJXMRr (ORCPT + 99 others); Wed, 24 Oct 2018 08:17:47 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:37763 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbeJXMRr (ORCPT ); Wed, 24 Oct 2018 08:17:47 -0400 Received: by mail-pg1-f202.google.com with SMTP id u43-v6so1909208pgn.4 for ; Tue, 23 Oct 2018 20:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=AZXGizRDYB34OjNAQjmrfiUD+eNMXlsWMwWZ+590v6s=; b=WPSOrUggU3rnluD6CS22h/UnyXqz+yZgPhghBy1ulhS1ExIvkAlgrPhT2pxavu/1Yy /M40uBDuFS/4BLISVGD2wj64ZxwEpD2qeFrLkiswC9i0L9hxosRGOVWsaVfMHjE5FvGr g79xGMLyciKHemaRWT56krnP6UJujxt5kaMn8WSJaoJwxTiNjRukz0B1zjtDGsnlPF+j oGrxUJa7w0u2dw4cUSntMXlUdM2cO4WeX/hemjsNn3JuNvqsObmNw14i9i6V6bk2XlJ0 eAUrn1wx5scw40yF22chLWPdwFc02fYz0s/RtLtbYteaFDBgQeDwtBEuaCIWIFNYKcah FQeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AZXGizRDYB34OjNAQjmrfiUD+eNMXlsWMwWZ+590v6s=; b=mawlymbwIjXt5rgLgUzI6NyLz4OG3mV/1BBRpTKPIjnyhU0IRujPVbV7/1hM0agl2Z baSH+wt2Yv4XTGWWYkArjKdAg2NU2RlSGwDALR9wRwmm9SNh38B9UcoDdGumN0lJXY9J ZA5P013WbqcvVt7C+stp1Ec1CqMIX0OJC2NW0g80ZEux3HCo6Cr5Mo8zGTlVTxKEuMqA bF/fBz/t2Np/UipLW6oSt1lp/HRXsuNf/MyVGR5WaZhU+kp0IhacKuHwz3I85J/IZ+GS c6qtlOYgGn42d+b/G7vF76QHnpfExzX2BFlh10gN1KB3ag1Qy4MIiqcOUZefFRLaDYkE wNHQ== X-Gm-Message-State: AGRZ1gKFOxQLJJMJbHaRCu6aMT5+U3sNc2z6Th3BjCJRb0pOF3+2B/AL QPlKOesrVIfN6EAkQq7aIec37EdbDOuAa0B9FrJKiQ== X-Received: by 2002:a63:f1d:: with SMTP id e29-v6mr249762pgl.13.1540339197533; Tue, 23 Oct 2018 16:59:57 -0700 (PDT) Date: Tue, 23 Oct 2018 16:57:44 -0700 In-Reply-To: <20181023235750.103146-1-brendanhiggins@google.com> Message-Id: <20181023235750.103146-9-brendanhiggins@google.com> Mime-Version: 1.0 References: <20181023235750.103146-1-brendanhiggins@google.com> X-Mailer: git-send-email 2.19.1.568.g152ad8e336-goog Subject: [RFC v2 08/14] arch: um: add shim to trap to allow installing a fault catcher for tests From: Brendan Higgins To: gregkh@linuxfoundation.org, keescook@google.com, mcgrof@kernel.org, shuah@kernel.org Cc: joel@jms.id.au, mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, julia.lawall@lip6.fr, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, robh@kernel.org, dan.j.williams@intel.com, linux-nvdimm@lists.01.org, kieran.bingham@ideasonboard.com, Brendan Higgins 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 Add context to current thread that allows a test to specify that it wants to skip the normal checks to run an installed fault catcher. Signed-off-by: Brendan Higgins --- arch/um/include/asm/processor-generic.h | 4 +++- arch/um/kernel/trap.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h index b58b746d3f2ca..d566cd416ff02 100644 --- a/arch/um/include/asm/processor-generic.h +++ b/arch/um/include/asm/processor-generic.h @@ -27,6 +27,7 @@ struct thread_struct { struct task_struct *prev_sched; struct arch_thread arch; jmp_buf switch_buf; + bool is_running_test; struct { int op; union { @@ -51,7 +52,8 @@ struct thread_struct { .fault_addr = NULL, \ .prev_sched = NULL, \ .arch = INIT_ARCH_THREAD, \ - .request = { 0 } \ + .request = { 0 }, \ + .is_running_test = false, \ } static inline void release_thread(struct task_struct *task) 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; + 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; } @@ -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"); -- 2.19.1.568.g152ad8e336-goog