From patchwork Mon Sep 14 13:01:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 249762 Delivered-To: patches@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp1614511ilg; Mon, 14 Sep 2020 06:02:05 -0700 (PDT) X-Received: by 2002:adf:c64e:: with SMTP id u14mr15374736wrg.373.1600088525612; Mon, 14 Sep 2020 06:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600088525; cv=none; d=google.com; s=arc-20160816; b=t5iESxuHApVV4FxxAPwERzPbZMdYEgEFyYyQzLO2I5YE7LHCyBOWczU1nZNz8JbjZn bVVhCe4SZZymm/T1ZB1hjrbRYWxJO//5Udu0UH6Clesp0KSSwLYlVUZECrIjbd3hm4VS zWQMa9AuG1GT87YC42x9oaG8Y/lY8j3e4/M7mTp5yIdTVvrzI5Wwm1YHhwTqSFFFPXH4 AFASzU7VXoDEVxqpNLh87d0K8NW4qE4WlKotl5W4rSCFGwJEVPZTU59y+cx0WgVdsq6o cTX8RfNCRrikzxz8fVuh8v8aTXqC8w90zKgyGGgYJ6q1ZpayaNA40jc1DSphlnn8VqlY 8vgQ== 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=tOLZ70bedyzf8xgXzV0MTRrdMCvy/3UOdRHKK+GhNMo=; b=d/2n44xrqwLhpAwYMlCuxTGDkrdYdgXwB6glEbt5MJve55hIoQBNHqkQ21UfjpVtGm 5D5Q4JrgYREMzgu5lHFlE3XtYFVtaQUFw1cvVCGOFtLyzOjNP3XEo56wo+wKJ44fozSw GUfZMi+v3imgkr7BCzrvIWSSL+aTsrNUDvbcbVQhl/WoFRGsurCiGlx0qJNiHEn6XfBq xNbZ7+gS3smkPTk4VqrviTGVEgHbphdERlqouam0xL7prvTuJQHkzFM2jX89e1QqbroE /+hghPhfkePb7WDe8GmaC+cw+FfZdIu6K72FVLR89lyRnmJhxKpVyabVaNspglV5h5At DDig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=POu12cEa; 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 e13sor4933832wrr.40.2020.09.14.06.02.05 for (Google Transport Security); Mon, 14 Sep 2020 06:02:05 -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=POu12cEa; 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=tOLZ70bedyzf8xgXzV0MTRrdMCvy/3UOdRHKK+GhNMo=; b=POu12cEaJFApnX2+rMx/2kxThtVNQIhVlX9u3uZHeXLJOzGppLaqXQdv+tPvj5R+xE tX780vtge+r4reu3udS1EdIs+vCSCvs8D/OznPjbRs9vgy+n5aPGJSYIbTB6XBJCv5nN Eo26ybzSJ1+gIxNxBFYRTZ8MiiuFtHMtM5t4awBHb5W7QJUXZGMexDV6XkZH+/ZibUR/ c57u3FcVLQ9yVf6Pe0gAy47AMCdKNxJpebRjlWTpU6ea9Nj/lqnkyRtHq5C2oaTmtJUN vB+yien4dbtStTvDkZj+6qjtUCyixOMzrjEZpwkgJj94aR/1IDbIEu6Lo/fqksseLJT1 Csmg== 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=tOLZ70bedyzf8xgXzV0MTRrdMCvy/3UOdRHKK+GhNMo=; b=lMLvcEkh+UNhJEFCerNmVeXvMeAnfaRWsJFrLnW7ry3eeL9o8QALoxW+CvqQfbtvwD H4+qrcQ3fXTe2+sNqZtN3MQsyZGX4l9BWnfl0jRh2p6rdeDYsHvFxQs+pgO1i8YOYI9C qRNy6IO02mha+jegWZxtoyjulaX++UUJiImnU0E/1aDh5VYR0kF/M4BsS6wrk6zAxMR9 WKOa7qRodbLT7Ru/gqTbxe5Q58hR4VSHmNlbXrVn3SVBVDhgbmUE2a2bvGR8v8Pd/RT2 lirgkq0Y55hBEiPY7dC9qaq4oCTH0McU9nHRV2uBf+0gZvER3Ob/7dDyXmg0EHELD1Wj Sd6Q== X-Gm-Message-State: AOAM531MGylijPQEDiTaLIm+sdoTtTOwfmbVcRHKqcawnweEMwSzhF65 528ctU+Tw+0i/K2zZkGwFLoA2KFX X-Google-Smtp-Source: ABdhPJxdxolEdcYMjP3ctpO3wrxCQQtg4g3aiPudfFv1rQGBGhcDTJuT8gbgF3Z/w5SfmtM8lkj34w== X-Received: by 2002:adf:f70d:: with SMTP id r13mr16395380wrp.317.1600088525276; Mon, 14 Sep 2020 06:02:05 -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 t6sm23420983wre.30.2020.09.14.06.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 06:02:04 -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: Mon, 14 Sep 2020 14:01:43 +0100 Message-Id: <20200914130143.1322802-4-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200914130143.1322802-1-daniel.thompson@linaro.org> References: <20200914130143.1322802-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 --- 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 Reviewed-by: Douglas Anderson diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 9618c1e2faf6..74d42d3f3180 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -763,6 +763,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;