From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: probes: Don't stop the machine if we're in the debugger
Date: Mon, 24 Aug 2015 17:19:26 -0700 [thread overview]
Message-ID: <55DBB48E.7040508@codeaurora.org> (raw)
In-Reply-To: <1440460739-19522-1-git-send-email-dianders@chromium.org>
On 08/24/2015 04:58 PM, Douglas Anderson wrote:
> If we're in kgdb then the machine is already stopped. Trying to stop
> it again will cause us to try to sleep, which is not allowed while in
> kgdb. To avoid this problem, only stop the machine when we're not in
> kgdb.
>
> Reported-by: Aapo Vienamo <avienamo@nvidia.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
Can you add the backtrace?
> arch/arm/kernel/patch.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
> index 69bda1a..abf30ec 100644
> --- a/arch/arm/kernel/patch.c
> +++ b/arch/arm/kernel/patch.c
> @@ -1,5 +1,6 @@
> #include <linux/kernel.h>
> #include <linux/spinlock.h>
> +#include <linux/kgdb.h>
> #include <linux/kprobes.h>
> #include <linux/mm.h>
> #include <linux/stop_machine.h>
> @@ -124,6 +125,9 @@ void __kprobes patch_text(void *addr, unsigned int insn)
> .insn = insn,
> };
>
> - stop_machine(patch_text_stop_machine, &patch, NULL);
> + /* Stop machine before patching; but not if in the debugger */
> + if (unlikely(in_dbg_master()))
> + patch_text_stop_machine(&patch);
> + else
> + stop_machine(patch_text_stop_machine, &patch, NULL);
> }
Perhaps it would be better to add a different function for the kgdb call
site? Then it's explicit what's going on without us having to figure out
when in_dbg_master() is true.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <sboyd@codeaurora.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: Kees Cook <keescook@chromium.org>,
Nicolas Pitre <nico@linaro.org>,
tixy@linaro.org, wangnan0@huawei.com, linux@arm.linux.org.uk,
linux-kernel@vger.kernel.org, Aapo Vienamo <avienamo@nvidia.com>,
rabin@rab.in, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ARM: probes: Don't stop the machine if we're in the debugger
Date: Mon, 24 Aug 2015 17:19:26 -0700 [thread overview]
Message-ID: <55DBB48E.7040508@codeaurora.org> (raw)
In-Reply-To: <1440460739-19522-1-git-send-email-dianders@chromium.org>
On 08/24/2015 04:58 PM, Douglas Anderson wrote:
> If we're in kgdb then the machine is already stopped. Trying to stop
> it again will cause us to try to sleep, which is not allowed while in
> kgdb. To avoid this problem, only stop the machine when we're not in
> kgdb.
>
> Reported-by: Aapo Vienamo <avienamo@nvidia.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
Can you add the backtrace?
> arch/arm/kernel/patch.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
> index 69bda1a..abf30ec 100644
> --- a/arch/arm/kernel/patch.c
> +++ b/arch/arm/kernel/patch.c
> @@ -1,5 +1,6 @@
> #include <linux/kernel.h>
> #include <linux/spinlock.h>
> +#include <linux/kgdb.h>
> #include <linux/kprobes.h>
> #include <linux/mm.h>
> #include <linux/stop_machine.h>
> @@ -124,6 +125,9 @@ void __kprobes patch_text(void *addr, unsigned int insn)
> .insn = insn,
> };
>
> - stop_machine(patch_text_stop_machine, &patch, NULL);
> + /* Stop machine before patching; but not if in the debugger */
> + if (unlikely(in_dbg_master()))
> + patch_text_stop_machine(&patch);
> + else
> + stop_machine(patch_text_stop_machine, &patch, NULL);
> }
Perhaps it would be better to add a different function for the kgdb call
site? Then it's explicit what's going on without us having to figure out
when in_dbg_master() is true.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-08-25 0:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 23:58 [PATCH] ARM: probes: Don't stop the machine if we're in the debugger Douglas Anderson
2015-08-24 23:58 ` Douglas Anderson
2015-08-25 0:19 ` Stephen Boyd [this message]
2015-08-25 0:19 ` Stephen Boyd
2015-08-25 16:50 ` Kees Cook
2015-08-25 16:50 ` Kees Cook
2015-08-25 19:40 ` Doug Anderson
2015-08-25 19:40 ` Doug Anderson
2015-08-25 22:08 ` Doug Anderson
2015-08-25 22:08 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55DBB48E.7040508@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.