[PATCH] xen: fix scrub_page()

Ingo Molnar
2008-11-17T18:14:58Z

* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

>> Secondly, we actually have a function called "clear_highpage()"
>> that does this, except it uses kmap_atomic(page, KM_USER0). Which
>> is _probably better anyway, but I didn't check if there is some
>> magical reason why it wouldn't work.
>
> OK.

applied it with the changelog below to tip/x86/urgent, thanks guys!

AFAICS CONFIG_XEN_SCRUB_PAGES=y could not possibly have worked before
(kunmapping the wrong address is a crasher), so there's little
practical risk from using an atomic kmap here.

Ingo

-------------->
>From 26a3e99160cfb06a0a33e25b9fb0d516e2cc680d Mon Sep 17 00:00:00 2001
From: Jeremy Fitzhardinge <jeremy@goop.org>
Date: Mon, 17 Nov 2008 09:35:00 -0800
Subject: [PATCH] xen: fix scrub_page()

Impact: fix guest kernel crash with CONFIG_XEN_SCRUB_PAGES=y

Jens noticed that scrub_page() has a buggy unmap of the wrong
thing. (virtual address instead of page)

Linus pointed out that the whole scrub_page() code is an unnecessary
reimplementation of clear_highpage() to begin with.

Just use clear_highpage() rather than reimplementing it poorly.

Reported-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
drivers/xen/balloon.c | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a0fb5ea..526c191 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -122,14 +122,7 @@ static struct timer_list balloon_timer;
static void scrub_page(struct page *page)
{
#ifdef CONFIG_XEN_SCRUB_PAGES
- if (PageHighMem(page)) {
- void *v = kmap(page);
- clear_page(v);
- kunmap(v);
- } else {
- void *v = page_address(page);
- clear_page(v);
- }
+ clear_highpage(page);
#endif
}