Message ID | AANLkTin8RuJaSbvDNC2dNJVdwVYk8JqSCJTTY=jDh0y4@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Thu, Jan 27, 2011 at 01:01:01PM +0200, Alex Rozenman wrote: > Hi, > > I found a bug in phys_page_find_alloc function causing initial region_offset > field to be set to incorrect initial value. > Usually, the pages are re-assigned afterwards, so the bug has very small > effect on regular QEMU users. > We use "memory unassigned" callback and this bug causes invalid addresses > there. > > A small patch is attached. I have ssh membership on savannah. Please approve > and/or push. > This is my first time when I am suggesting patches to QEMU; I also would > like to add some fixes for > ppc440/ppc440x6 cores. > > -- > Best regards, > Alex Rozenman (rozenman@gmail.com). > From 8935358ddf9bf5b80c8b8ac7014b650a519a3ebf Mon Sep 17 00:00:00 2001 > From: Alex Rozenman <rozenman@gmail.com> > Date: Thu, 27 Jan 2011 12:47:57 +0200 > Subject: [PATCH] phys_page_find_alloc: use correct initial region_offset > > --- > exec.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/exec.c b/exec.c > index db9ff55..00667d7 100644 > --- a/exec.c > +++ b/exec.c > @@ -416,6 +416,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) > pd = *lp; > if (pd == NULL) { > int i; > + int first_index = index & ~(L2_SIZE - 1); > > if (!alloc) { > return NULL; > @@ -425,7 +426,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) > > for (i = 0; i < L2_SIZE; i++) { > pd[i].phys_offset = IO_MEM_UNASSIGNED; > - pd[i].region_offset = (index + i) << TARGET_PAGE_BITS; > + pd[i].region_offset = (first_index + i) << TARGET_PAGE_BITS; > } > } The patch looks correct, but it is missing a Signed-off-by: entry. Also please provide a description in the patch itself.
From 8935358ddf9bf5b80c8b8ac7014b650a519a3ebf Mon Sep 17 00:00:00 2001 From: Alex Rozenman <rozenman@gmail.com> Date: Thu, 27 Jan 2011 12:47:57 +0200 Subject: [PATCH] phys_page_find_alloc: use correct initial region_offset --- exec.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/exec.c b/exec.c index db9ff55..00667d7 100644 --- a/exec.c +++ b/exec.c @@ -416,6 +416,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) pd = *lp; if (pd == NULL) { int i; + int first_index = index & ~(L2_SIZE - 1); if (!alloc) { return NULL; @@ -425,7 +426,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) for (i = 0; i < L2_SIZE; i++) { pd[i].phys_offset = IO_MEM_UNASSIGNED; - pd[i].region_offset = (index + i) << TARGET_PAGE_BITS; + pd[i].region_offset = (first_index + i) << TARGET_PAGE_BITS; } } -- 1.7.0.4