ia64/xen-unstable

changeset 6773:36e74b5dfa95

Fix a bug in shadow_remove_all_access_in_page.

Fixes a fairly obvious bug, in which an if statement was reversed. The
bug has been present for a while, so apparently this code isn't well
tested.

Signed-off-by: Michael Vrable <mvrable@cs.ucsd.edu>
author kaf24@firebug.cl.cam.ac.uk
date Tue Sep 13 09:09:59 2005 +0000 (2005-09-13)
parents 1cb7adaa3355
children f804b28871ba
files xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c
line diff
     1.1 --- a/xen/arch/x86/shadow32.c	Tue Sep 13 08:35:41 2005 +0000
     1.2 +++ b/xen/arch/x86/shadow32.c	Tue Sep 13 09:09:59 2005 +0000
     1.3 @@ -2214,7 +2214,7 @@ static u32 remove_all_access_in_page(
     1.4      struct domain *d, unsigned long l1mfn, unsigned long forbidden_gmfn)
     1.5  {
     1.6      l1_pgentry_t *pl1e = map_domain_page(l1mfn);
     1.7 -    l1_pgentry_t match;
     1.8 +    l1_pgentry_t match, ol2e;
     1.9      unsigned long flags  = _PAGE_PRESENT;
    1.10      int i;
    1.11      u32 count = 0;
    1.12 @@ -2226,17 +2226,17 @@ static u32 remove_all_access_in_page(
    1.13      
    1.14      for (i = 0; i < L1_PAGETABLE_ENTRIES; i++)
    1.15      {
    1.16 -        if ( unlikely(!l1e_has_changed(pl1e[i], match, flags) == 0) )
    1.17 -        {
    1.18 -            l1_pgentry_t ol2e = pl1e[i];
    1.19 -            pl1e[i] = l1e_empty();
    1.20 -            count++;
    1.21 -
    1.22 -            if ( is_l1_shadow )
    1.23 -                shadow_put_page_from_l1e(ol2e, d);
    1.24 -            else /* must be an hl2 page */
    1.25 -                put_page(&frame_table[forbidden_gmfn]);
    1.26 -        }
    1.27 +        if ( l1e_has_changed(pl1e[i], match, flags) )
    1.28 +            continue;
    1.29 +
    1.30 +        ol2e = pl1e[i];
    1.31 +        pl1e[i] = l1e_empty();
    1.32 +        count++;
    1.33 +
    1.34 +        if ( is_l1_shadow )
    1.35 +            shadow_put_page_from_l1e(ol2e, d);
    1.36 +        else /* must be an hl2 page */
    1.37 +            put_page(&frame_table[forbidden_gmfn]);
    1.38      }
    1.39  
    1.40      unmap_domain_page(pl1e);
     2.1 --- a/xen/arch/x86/shadow_public.c	Tue Sep 13 08:35:41 2005 +0000
     2.2 +++ b/xen/arch/x86/shadow_public.c	Tue Sep 13 09:09:59 2005 +0000
     2.3 @@ -1622,7 +1622,7 @@ static u32 remove_all_access_in_page(
     2.4      struct domain *d, unsigned long l1mfn, unsigned long forbidden_gmfn)
     2.5  {
     2.6      l1_pgentry_t *pl1e = map_domain_page(l1mfn);
     2.7 -    l1_pgentry_t match;
     2.8 +    l1_pgentry_t match, ol2e;
     2.9      unsigned long flags  = _PAGE_PRESENT;
    2.10      int i;
    2.11      u32 count = 0;
    2.12 @@ -1634,17 +1634,17 @@ static u32 remove_all_access_in_page(
    2.13  
    2.14      for (i = 0; i < L1_PAGETABLE_ENTRIES; i++)
    2.15      {
    2.16 -        if ( unlikely(!l1e_has_changed(pl1e[i], match, flags) == 0) )
    2.17 -        {
    2.18 -            l1_pgentry_t ol2e = pl1e[i];
    2.19 -            pl1e[i] = l1e_empty();
    2.20 -            count++;
    2.21 +        if ( l1e_has_changed(pl1e[i], match, flags) )
    2.22 +            continue;
    2.23  
    2.24 -            if ( is_l1_shadow )
    2.25 -                shadow_put_page_from_l1e(ol2e, d);
    2.26 -            else /* must be an hl2 page */
    2.27 -                put_page(&frame_table[forbidden_gmfn]);
    2.28 -        }
    2.29 +        ol2e = pl1e[i];
    2.30 +        pl1e[i] = l1e_empty();
    2.31 +        count++;
    2.32 +
    2.33 +        if ( is_l1_shadow )
    2.34 +            shadow_put_page_from_l1e(ol2e, d);
    2.35 +        else /* must be an hl2 page */
    2.36 +            put_page(&frame_table[forbidden_gmfn]);
    2.37      }
    2.38  
    2.39      unmap_domain_page(pl1e);