From patchwork Wed Nov 28 19:36:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Higgins X-Patchwork-Id: 10703229 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 8C1EF15A8 for ; Wed, 28 Nov 2018 19:38:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F5002B0FF for ; Wed, 28 Nov 2018 19:38:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C702DC76; Wed, 28 Nov 2018 19:38:05 +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 21CC32B0FF for ; Wed, 28 Nov 2018 19:38:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1A8C721196227; Wed, 28 Nov 2018 11:38:05 -0800 (PST) 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::149; helo=mail-it1-x149.google.com; envelope-from=3m-7-ww4kdfo3j6f52f9a88afk8gg8d6.4gedafmp-fn5aeedaklk.st.gj8@flex--brendanhiggins.bounces.google.com; receiver=linux-nvdimm@lists.01.org Received: from mail-it1-x149.google.com (mail-it1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) (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 5D3042117FD5E for ; Wed, 28 Nov 2018 11:38:04 -0800 (PST) Received: by mail-it1-x149.google.com with SMTP id j202so3601322itj.1 for ; Wed, 28 Nov 2018 11:38:04 -0800 (PST) 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=9D74vhDKZ9zweNX8bjF2N0Y9OEVlGStLvbWGF8he3rU=; b=DUCrY0+bV3RwL0ek8kOGRSVO5v/D47qxtVHPVDyn/P0PBKfO7J+dAaLFJrHg6KA1H4 scBxeWPlXg29nrqLVQjBexctKZKf4sJRPuMm2gWIyWNVYbIwQ8repGuBGke3MQgytZ0U 0nWC9xlfOhMq9UV4wdHPOgiwRjjDbXnX672v/DOPwZrEL9SOKJro1mHudBWDcjR9XkAh xupw6E5Ty3A8oacOVm8zPZtMgBf2sTDwvSq0NPCwnsMtj+6r/YHj3x4778++02hbv/HY OApKXZoGIN/lngkLyyBTy92qH6Q1D1NtX26NvOt9gLsQtKYf2qXcWdbomlD1Lp1DPHVR leyw== 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=9D74vhDKZ9zweNX8bjF2N0Y9OEVlGStLvbWGF8he3rU=; b=H4dkn/ctGni5AwZnkQYDM09EwqqSEU3ak1GizoedpVo8ptaU4U08ipxcccxrCTEZUZ U1JTKgq72iembBsNGInmMny6meolJHvyE8rMcuT35QCaYQbSx5uoxHHnhAhzCMW7+xVs 4W660zYFnalllF/9pc9ASQVY52Gi28WrUWJ7YC3gZExeUbKtz1uiBaZ1G3IHv1dPDB6p B8TXD6/4tJKhBhHycXer+U8ffGCYHZayXtYktLSDWLjA/nBpV3C1MFeb3v8+d+MB08Mj ynloy8l+UFlfKxXBVqMN7/rj+6SogANzkegkMeX1rF7pWQ6cwXW4EwxBVBSgCXcEVZg3 mrjw== X-Gm-Message-State: AA+aEWY+T9P25rCBkVWr3eidyBSmosDOddigAZL+O9YB4h13YF4yYlmU 7oBj7Fp1C1GW9Xa4/A3sgwaCx250Ktp02ZJpZJiqAg== X-Google-Smtp-Source: AFSGD/UMhQyCRg6KQGlfagnXK2iwxLqCIGZ8HodTaJ7DpYmtIhCG98itNlSoTEwnNmng08QDMUsUiZnMCHqxdM/0JGaFXw== X-Received: by 2002:a24:74b:: with SMTP id f72-v6mr3353404itf.35.1543433883605; Wed, 28 Nov 2018 11:38:03 -0800 (PST) Date: Wed, 28 Nov 2018 11:36:25 -0800 In-Reply-To: <20181128193636.254378-1-brendanhiggins@google.com> Message-Id: <20181128193636.254378-9-brendanhiggins@google.com> Mime-Version: 1.0 References: <20181128193636.254378-1-brendanhiggins@google.com> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog Subject: [RFC v3 08/19] 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, jdike@addtoit.com, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org, frowand.list@gmail.com, robh@kernel.org, linux-nvdimm@lists.01.org, richard@nod.at, knut.omang@oracle.com, kieran.bingham@ideasonboard.com, joel@jms.id.au, khilman@baylibre.com, Brendan Higgins , Tim.Bird@sony.com, linux-um@lists.infradead.org, rostedt@goodmis.org, julia.lawall@lip6.fr, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, daniel@ffwll.ch, mpe@ellerman.id.au, joe@perches.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");