From patchwork Sun Sep 27 21:15:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 313603 Delivered-To: patches@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp2819499ilg; Sun, 27 Sep 2020 14:16:18 -0700 (PDT) X-Received: by 2002:a1c:488:: with SMTP id 130mr8069701wme.164.1601241378209; Sun, 27 Sep 2020 14:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601241378; cv=none; d=google.com; s=arc-20160816; b=kf1BxFtLsq4SD4NXbOLKLzuG3s6YbgfjGoJ7JoNqBclhjFY8BRJsdkrYfgTsN5qnBC Kh9PQT3irkxdV18dWeazZjcs9U9KhouYYbdGTsfMRWi0G2KN3F1coG258YGshk5kFkU5 BbYeFQJ1dTpMrHQj3ZD5sq1JIbXktSQd3hH1qQSC1pv3mpdTeX0DMShCJPiIBEeZcobq qMw/y0SGYy4fMNgo5ZNOjLFmCYfMjJ7Kpg/CgdUApLsuEe8fGcBJdB/evHS7YeCedEK8 dW1tADppbpNEeyKIXud9ogUzqBW/GqHlTKZVr7R2ErdleA+quJmv9tk2T5GNkJcheG6K jtag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=a99k07/EyDDQHmuhibQRaLo4XWgbxK6z35bVqiMsuv8=; b=dPUStuX+Q33Jhg4ABdCrxOL6jpJYa0DsPrkFBHeni7+ti9bUtzN7SgEa+gEqbvBqv2 7SlzJE/hkAOPobwbyBr3lKydzlwSCxFK3uNekjqBtdU6sp732pMdv7ohNHMdaFHZV8HT dkd+eXQK/l9RVrEX++Dp8JDvB8smYs09EJHdnObPHQWniZFVULX4UKc1lHIRuMvRlhX1 DWnvTat6Xv21+77PJ+aat8cpUSYZQcumkjgQV0skAXKjDwiOSlTbqY7QTfr5rE1y0FMM oSsEPrqHGsOMnYB1XAsJZcPVhv6YaWQzvxIdZO0BN/M8h2kaD/C+mdbds0aPCIY8EqUk 7wRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CjFXYG9B; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a6sor4454136wrr.58.2020.09.27.14.16.18 for (Google Transport Security); Sun, 27 Sep 2020 14:16:18 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CjFXYG9B; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a99k07/EyDDQHmuhibQRaLo4XWgbxK6z35bVqiMsuv8=; b=CjFXYG9BR8dkXSbiyxLxrUYbFRhjiOb1vcwmYg4vsW7360k60NHd/8S43UvXZA5FT5 y5VyC5QYUXGmFaaGmwntXMTbUvqNhpSq3moC26ISTM5UAC+skTj4T6PO3hrzqrT6z15R hmAIvGK4AYwwCnEQeuzshHnQDATrFWpGn/iA1WzpjEShT3FvgfRikun4C5n3kerVeLUL 1ASUSioryEuYeddzAzUwSfgNb8cD3KjYmuWABM8tEtkal6+cf2e68Low/keUuApsOV6f /6j0xr2ThzRu2LrBh/JoIfZRwmi19wGblaXZqiOMVOmiIOcQs99OXexE8U3y7loHj9U+ 9Zdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a99k07/EyDDQHmuhibQRaLo4XWgbxK6z35bVqiMsuv8=; b=HbbP6yJbPPt15etrNwZDqvXu2Fo1ivtBf3HCcK8c8rL3u6rUC+rIZGEwY+NnDahIeI GNlDITN1l+SwaULi7tddTNQlNqHziCAq/BSD50vPHazEm5AszoLxmqkc+QdQKMZw+LVC Chha9Fkkyj8mhgR26UjpnfHw14W2HhZ9fx37d1S7pEJdUlzrjLF2pGxtsayrHnYOAJu6 e1+RmucLjyhV99sTxJmjd9MjUwmpnvZuj1LFwzQ40CwhvP1BY2qhO8C+JWW8Q2a3UlDF vxkS2yU3lD5xoSZ/w6RQTSyvHjicBSlRHiOE7Pwki4BKLYgBaKbdR34X8wn1DUL89tgA B1xg== X-Gm-Message-State: AOAM530CVQfHd4DCNOSqhldW/MRk4gGJq9Za0YQ8IBPpdzVXkdiI0GCd oXRSKU4Kf5PEUXk16GhVCzfA/tCP X-Google-Smtp-Source: ABdhPJxsis82EaVU2Ny17vWSbD6xDjUxPFjWZp3tZqcI8T/hln1YFSfFswHXGrJGbExBNQLQpInGKQ== X-Received: by 2002:a5d:51ca:: with SMTP id n10mr15438828wrv.222.1601241377872; Sun, 27 Sep 2020 14:16:17 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id s17sm11396676wrr.40.2020.09.27.14.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 14:16:17 -0700 (PDT) From: Daniel Thompson To: Jason Wessel , Douglas Anderson Cc: Daniel Thompson , Peter Zijlstra , sumit.garg@linaro.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, will@kernel.org, Masami Hiramatsu , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v3 3/3] kernel: debug: Centralize dbg_[de]activate_sw_breakpoints Date: Sun, 27 Sep 2020 22:15:31 +0100 Message-Id: <20200927211531.1380577-4-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200927211531.1380577-1-daniel.thompson@linaro.org> References: <20200927211531.1380577-1-daniel.thompson@linaro.org> MIME-Version: 1.0 During debug trap execution we expect dbg_deactivate_sw_breakpoints() to be paired with an dbg_activate_sw_breakpoint(). Currently although the calls are paired correctly they are needlessly smeared across three different functions. Worse this also results in code to drive polled I/O being called with breakpoints activated which, in turn, needlessly increases the set of functions that will recursively trap if breakpointed. Fix this by moving the activation of breakpoints into the debug core. Signed-off-by: Daniel Thompson Reviewed-by: Douglas Anderson --- kernel/debug/debug_core.c | 2 ++ kernel/debug/gdbstub.c | 1 - kernel/debug/kdb/kdb_debugger.c | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) -- 2.25.4 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index faa1f99ce65a..e4339fd82db0 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -768,6 +768,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, } } + dbg_activate_sw_breakpoints(); + /* Call the I/O driver's post_exception routine */ if (dbg_io_ops->post_exception) dbg_io_ops->post_exception(); diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index cc3c43dfec44..e9a9c3097089 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c @@ -1061,7 +1061,6 @@ int gdb_serial_stub(struct kgdb_state *ks) error_packet(remcom_out_buffer, -EINVAL); break; } - dbg_activate_sw_breakpoints(); fallthrough; /* to default processing */ default: default_handle: diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c index 53a0df6e4d92..0220afda3200 100644 --- a/kernel/debug/kdb/kdb_debugger.c +++ b/kernel/debug/kdb/kdb_debugger.c @@ -147,7 +147,6 @@ int kdb_stub(struct kgdb_state *ks) return DBG_PASS_EVENT; } kdb_bp_install(ks->linux_regs); - dbg_activate_sw_breakpoints(); /* Set the exit state to a single step or a continue */ if (KDB_STATE(DOING_SS)) gdbstub_state(ks, "s"); @@ -167,7 +166,6 @@ int kdb_stub(struct kgdb_state *ks) * differently vs the gdbstub */ kgdb_single_step = 0; - dbg_deactivate_sw_breakpoints(); return DBG_SWITCH_CPU_EVENT; } return kgdb_info[ks->cpu].ret_state;