direct-io.hg

changeset 11505:88fb77ac4f09

[XEN][POWERPC] Fix allocation error for xencomm "mini" descriptors.

Previous code worked correctly only if the allocated structure fit in the same
page as the base address. If the structure did not fit, the computation for the
allocation was incorrect. Noticed by Kiyokuni KAWACHIYA <KAWATIYA@jp.ibm.com>.

Signed-off-by: Maria Butrico <butrico@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Fri Sep 08 10:23:56 2006 -0500 (2006-09-08)
parents fcc0efacc17a
children 3bd92176890c
files xen/arch/powerpc/of_handler/xencomm.c
line diff
     1.1 --- a/xen/arch/powerpc/of_handler/xencomm.c	Fri Sep 08 10:22:45 2006 -0500
     1.2 +++ b/xen/arch/powerpc/of_handler/xencomm.c	Fri Sep 08 10:23:56 2006 -0500
     1.3 @@ -50,18 +50,18 @@ static int __xencomm_init(struct xencomm
     1.4  static void *__xencomm_alloc_mini(void *area, int arealen)
     1.5  {
     1.6      unsigned long base = (unsigned long)area;
     1.7 -    unsigned int pageoffset;
     1.8 +    unsigned int left_in_page;
     1.9  
    1.10 -    pageoffset = base % PAGE_SIZE;
    1.11 +    left_in_page = PAGE_SIZE - base % PAGE_SIZE;
    1.12  
    1.13      /* we probably fit right at the front of area */
    1.14 -    if ((PAGE_SIZE - pageoffset) >= sizeof(struct xencomm_mini)) {
    1.15 +    if (left_in_page >= sizeof(struct xencomm_mini)) {
    1.16          return area;
    1.17      }
    1.18  
    1.19      /* if not, see if area is big enough to advance to the next page */
    1.20 -    if ((arealen - pageoffset) >= sizeof(struct xencomm_mini))
    1.21 -        return (void *)(base + pageoffset);
    1.22 +    if ((arealen - left_in_page) >= sizeof(struct xencomm_mini))
    1.23 +        return (void *)(base + left_in_page);
    1.24  
    1.25      /* area was too small */
    1.26      return NULL;