From patchwork Tue Oct 23 23:57:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Higgins X-Patchwork-Id: 10653965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F15A13A4 for ; Tue, 23 Oct 2018 23:59:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D2C2A0CF for ; Tue, 23 Oct 2018 23:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D3DA2A3B1; Tue, 23 Oct 2018 23:59:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BCDD2A0CF for ; Tue, 23 Oct 2018 23:59:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 138F22117D75A; Tue, 23 Oct 2018 16:59:59 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::649; helo=mail-pl1-x649.google.com; envelope-from=3_bxpww4kdiwr7u3tq3xywwy38w44w1u.s421y3ad-3bty221y898.gh.47w@flex--brendanhiggins.bounces.google.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F11EA2117D757 for ; Tue, 23 Oct 2018 16:59:57 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id s24-v6so1525373plp.12 for ; Tue, 23 Oct 2018 16:59:57 -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=oGdXbFIhNj3NCoFDamNMWsHnXa4sRdxkoyMpZQpUXaPRhSwUkcs76zz/vVyJVybE47 dnHQp8JMsooVa+22+gQhxRQC3OxWgSXGhoyTC/MOjI4BO6XdNx4dl7rgecrbvZOno0aV KWuuR89gd3aJleCnVK/MDZRuaiIpmK/hCRviJW9FtgoF1xT0GhKNkcbl6s5u00H/EX00 ZG6bnznw56jzaBGnqbyKpWfLnzUFgYvm+NxDCuxk6Xd9xtpfgNBpvASHm60V+IUa5l7j UWt7dUneg94NdWof69RUa50SDacn2twhed5EJwOU7Kovl/tKmDWVNYo8lShgUZmwOVev 67qg== X-Gm-Message-State: AGRZ1gJnAMzqWWzeEHfuAChoRAnmJvpA1lErqRb436szLgO+TO5uLy4o YvudjrtsDc0ZHXhbaForieUL9XgqDxsP9vcD7UovZA== X-Google-Smtp-Source: AJdET5eqXAp+/iws1KPP7vDDWFDc90iv2ui+fE+0/W/M6tvyz4dYd5p4tqPvTkGZUaE8z6wekIB4P0Fo77lczqOisUKd/Q== 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 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: brakmo@fb.com, robh@kernel.org, richard@nod.at, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, mpe@ellerman.id.au, Tim.Bird@sony.com, linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, kieran.bingham@ideasonboard.com, julia.lawall@lip6.fr, joel@jms.id.au, linux-kselftest@vger.kernel.org, khilman@baylibre.com, joe@perches.com, daniel@ffwll.ch, jdike@addtoit.com, Brendan Higgins , kunit-dev@googlegroups.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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");