From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Petr Mladek <pmladek@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Jiri Kosina <jkosina@suse.cz>,
linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH v3 1/8] x86: allow to handle errors in text_poke function family
Date: Thu, 14 Nov 2013 20:10:01 +0900 [thread overview]
Message-ID: <5284AF89.20505@hitachi.com> (raw)
In-Reply-To: <1384425686-21018-2-git-send-email-pmladek@suse.cz>
(2013/11/14 19:41), Petr Mladek wrote:
> The text_poke functions called BUG() in case of error. This was too strict.
> There are situations when the system is still usable even when the patching
> has failed, for example when enabling the dynamic ftrace.
>
> This commit modifies text_poke, text_poke_early, and text_poke_bp functions
> to return an error code instead calling BUG(). The code is returned instead
> of the patched address. The address was just copied from the first parameter,
> so it was no extra information. It has not been used anywhere yet.
>
> The commit also modifies the few locations where text_poke functions were used
> and the error code has to be handled now. It just passes the error code if
> there already is an existing error handling, for example in
> kgdb_arch_set_breakpoint. It calls BUG() in the other locations.
>
> Note that BUG() still need to be called in text_poke_bp when the code already is
> partially modified but the operation can not be finished.
Mostly this looks good for me, see below.
> @@ -566,7 +576,8 @@ void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
> WARN_ON(!PageReserved(pages[0]));
> pages[1] = virt_to_page(addr + PAGE_SIZE);
> }
> - BUG_ON(!pages[0]);
> + if (unlikely(!pages[0]))
> + return -EFAULT;
> local_irq_save(flags);
> set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
> if (pages[1])
> @@ -580,10 +591,11 @@ void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
> sync_core();
> /* Could also do a CLFLUSH here to speed up CPU recovery; but
> that causes hangs on some VIA CPUs. */
> - for (i = 0; i < len; i++)
> - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
> local_irq_restore(flags);
> - return addr;
> + for (i = 0; i < len; i++)
> + if (((char *)addr)[i] != ((char *)opcode)[i])
> + return -EPERM;
> + return 0;
Hmm, IMHO, it would be better to keep the old one, because it actually failed to modify
as expected for some reason (not only permission error). And we are not sure the
code is same as old one. (only compared with what we expected)
Thank you,
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2013-11-14 11:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 10:41 [PATCH v3 0/8] x86: use new text_poke_bp in ftrace Petr Mladek
2013-11-14 10:41 ` [PATCH v3 1/8] x86: allow to handle errors in text_poke function family Petr Mladek
2013-11-14 11:10 ` Masami Hiramatsu [this message]
2013-11-14 10:41 ` [PATCH v3 2/8] x86: allow to call text_poke_bp during boot Petr Mladek
2013-11-14 11:12 ` Masami Hiramatsu
2013-11-14 10:41 ` [PATCH v3 3/8] x86: add generic function to modify more calls using int3 framework Petr Mladek
2013-11-14 10:41 ` [PATCH v3 4/8] x86: speed up int3-based patching using direct write Petr Mladek
2013-11-14 11:36 ` Masami Hiramatsu
2013-11-14 12:46 ` Petr Mladek
2013-11-14 13:07 ` Masami Hiramatsu
2013-11-14 10:41 ` [PATCH v3 5/8] x86: do not trace __probe_kernel_read Petr Mladek
2013-11-14 10:41 ` [PATCH v3 6/8] x86: modify ftrace function using the new int3-based framework Petr Mladek
2013-11-14 10:41 ` [PATCH v3 7/8] x86: patch all traced function calls using the " Petr Mladek
2013-11-14 10:41 ` [PATCH v3 8/8] x86: enable/disable ftrace graph call using new " Petr Mladek
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=5284AF89.20505@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=fweisbec@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pmladek@suse.cz \
--cc=rostedt@goodmis.org \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox