From: Chris Wright <chrisw@sous-sol.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chris Wright <chrisw@sous-sol.org>, Andi Kleen <ak@suse.de>,
Jeremy Fitzhardinge <jeremy@goop.org>,
patches@x86-64.org, linux-kernel@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] [5/12] x86_64: Make patching more robust, fix paravirt issue
Date: Sat, 18 Aug 2007 14:31:41 -0700 [thread overview]
Message-ID: <20070818213141.GW3672@sequoia.sous-sol.org> (raw)
In-Reply-To: <alpine.LFD.0.999.0708181355280.30176@woody.linux-foundation.org>
* Linus Torvalds (torvalds@linux-foundation.org) wrote:
> On Sat, 18 Aug 2007, Chris Wright wrote:
> > >
> > > Check the latest git head. Does it still break?
> >
> > Yeah, this is the latest git. The broken commit is Rusty's patch which,
> > after Linus reverted the write-protected remap changes, is no longer
> > necessary. AFAICT patching is writing garbage into the insn stream.
> > I suspect it's copying an uninitialized temp buffer.
>
> Can you send me the revert patch that is verified to work?
Now that I understand the problem, I do have a very simple (slightly
overkill) fix for paravirt patching. This can be cleaned up to avoid
the copies when they aren't needed, but that will take a little more
auditing of the various patchers. If you still prefer a revert I've
got one handy, and we can re-visit this all post .23.
thanks,
-chris
--
Subject: [PATCH] x86: properly initialize temp insn buffer for paravirt patching
From: Chris Wright <chrisw@sous-sol.org>
With commit ab144f5ec64c42218a555ec1dbde6b60cf2982d6 the patching code
now collects the complete new instruction stream into a temp buffer
before finally patching in the new insns. In some cases the paravirt
patchers will choose to leave the patch site unpatched (length mismatch,
clobbers mismatch, etc). This causes the new patching code to copy an
uninitialized temp buffer, i.e. garbage, to the callsite. Simply make
sure to always initialize the buffer with the original instruction stream.
A better fix is to audit all the patchers and return proper length so that
apply_paravirt() can skip copies when we leave the patch site untouched.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
arch/i386/kernel/alternative.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index 1b66d5c..9f4ac8b 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -366,6 +366,8 @@ void apply_paravirt(struct paravirt_patch_site *start,
unsigned int used;
BUG_ON(p->len > MAX_PATCH_LEN);
+ /* prep the buffer with the original instructions */
+ memcpy(insnbuf, p->instr, p->len);
used = paravirt_ops.patch(p->instrtype, p->clobbers, insnbuf,
(unsigned long)p->instr, p->len);
next prev parent reply other threads:[~2007-08-18 21:32 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-09 12:41 [PATCH] [0/12] x86 Late merge bug fixes for 2.6.23 Andi Kleen
2007-08-09 12:41 ` [PATCH] [1/12] x86: Work around mmio config space quirk on AMD Fam10h Andi Kleen
2007-08-10 10:19 ` [patches] " Joachim Deguara
2007-08-12 9:25 ` Linus Torvalds
2007-08-12 10:03 ` Andi Kleen
2007-08-12 19:15 ` Linus Torvalds
2007-08-13 3:06 ` Dave Jones
2007-08-13 3:26 ` Linus Torvalds
2007-08-13 3:38 ` dean gaudet
2007-08-09 12:41 ` [PATCH] [2/12] x86_64: Calgary - Fix mis-handled PCI topology Andi Kleen
2007-08-09 12:41 ` [PATCH] [3/12] x86_64: Don't mark __exitcall as __cold Andi Kleen
2007-08-09 12:41 ` [PATCH] [4/12] x86_64: Disable CLFLUSH support again Andi Kleen
2007-08-09 12:54 ` [patches] " Jan Beulich
2007-08-09 13:11 ` Muli Ben-Yehuda
2007-08-09 13:12 ` Andi Kleen
2007-08-09 13:29 ` [patches] " Jan Beulich
2007-08-09 16:24 ` Muli Ben-Yehuda
2007-08-09 12:41 ` [PATCH] [5/12] x86_64: Make patching more robust, fix paravirt issue Andi Kleen
2007-08-18 0:05 ` Jeremy Fitzhardinge
2007-08-18 0:11 ` Chris Wright
2007-08-18 9:49 ` Andi Kleen
2007-08-18 20:32 ` Chris Wright
2007-08-18 20:55 ` Linus Torvalds
2007-08-18 21:31 ` Chris Wright [this message]
2007-08-18 22:28 ` [PATCH] x86: skip paravirt patching when appropriate Chris Wright
2007-08-19 3:08 ` Zachary Amsden
2007-08-19 5:55 ` Zachary Amsden
2007-08-18 21:58 ` [PATCH] [5/12] x86_64: Make patching more robust, fix paravirt issue Jeremy Fitzhardinge
2007-08-20 1:50 ` Rusty Russell
2007-08-20 2:07 ` Chris Wright
2007-08-20 6:15 ` Jeremy Fitzhardinge
2007-08-21 7:30 ` Glauber de Oliveira Costa
2007-08-21 11:23 ` Andi Kleen
2007-08-21 12:26 ` Glauber de Oliveira Costa
2007-08-09 12:41 ` [PATCH] [6/12] x86_64: Early segment setup for VT Andi Kleen
2007-10-11 21:30 ` H. Peter Anvin
2007-08-09 12:41 ` [PATCH] [7/12] x86_64: really stop MCEs during code patching Andi Kleen
2007-08-09 12:41 ` [PATCH] [8/12] x86_64: Use global flag to disable broken local apic timer on AMD CPUs Andi Kleen
2007-08-09 16:46 ` Cal Peake
2007-08-09 16:50 ` Andi Kleen
2007-08-09 12:41 ` [PATCH] [9/12] x86_64: Avoid NMI Watchdog and/or long wait in setup_APIC_timer Andi Kleen
2007-08-09 12:41 ` [PATCH] [10/12] x86_64: Add warning in Documentation that zero-page is not a stable ABI Andi Kleen
2007-08-09 12:41 ` [PATCH] [11/12] x86_64: vdso.lds in arch/x86_64/vdso/.gitignore Andi Kleen
2007-08-09 12:41 ` [PATCH] [12/12] x86_64: Fix start_kernel warning Andi Kleen
2007-08-09 13:06 ` [PATCH] [0/12] x86 Late merge bug fixes for 2.6.23 Muli Ben-Yehuda
2007-08-09 13:12 ` Andi Kleen
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=20070818213141.GW3672@sequoia.sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=ak@suse.de \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@x86-64.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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
Powered by JetHome