xen: fix broken tainted value in mark_page_free
PATCH 1/1 xen: fix broken tainted value in mark_page_free
Commit 540a637c3410780b519fc055f432afe271f642f8 defines a new helper mark_page_free to extract common codes, but it broke the local variable "tainted", revealed by Coverity ID 1491872.
This patch let mark_page_free() return boolean value of variable "tainted" and rename local variable "tainted" to "pg_tainted" to tell the difference from the global variable of the same name.
--- xen/common/page_alloc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
xen/common/page_alloc.c +10 -5
@@ -1380,8 +1380,10 @@ bool scrub_free_pages(void)return node_to_scrub (false) !=NUMA_NO_NODE ; } -static void mark_page_free (struct page_info *pg,mfn_t mfn) +static bool mark_page_free (struct page_info *pg,mfn_t mfn) { +unsigned int pg_tainted =0 ; +ASSERT (mfn_x (mfn) ==mfn_x (page_to_mfn (pg)));/*
@@ -1405,7 +1407,7 @@ static void mark_page_free(struct page_info *pg, mfn_t mfn)case PGC_state_offlining: pg->count_info = (pg->count_info & PGC_broken) | PGC_state_offlined; - tainted =1 ; + pg_tainted =1 ;break ;default :
@@ -1425,6 +1427,8 @@ static void mark_page_free(struct page_info *pg, mfn_t mfn)/* This page is not a guest frame any more. */ page_set_owner (pg,NULL );/* set_gpfn_from_mfn snoops pg owner */ set_gpfn_from_mfn (mfn_x (mfn),INVALID_M2P_ENTRY ); + +return pg_tainted; }/* Free 2^@order set of pages. */
@@ -1433,7 +1437,7 @@ static void free_heap_pages( {unsigned long mask;mfn_t mfn =page_to_mfn (pg); -unsigned int i, node =phys_to_nid (mfn_to_maddr (mfn)), tainted =0 ; +unsigned int i, node =phys_to_nid (mfn_to_maddr (mfn)), pg_tainted =0 ;unsigned int zone =page_to_zone (pg);ASSERT (order <=MAX_ORDER );
@@ -1443,7 +1447,8 @@ static void free_heap_pages(for ( i =0 ; i < (1 << order); i++ ) { -mark_page_free (&pg[i],mfn_add (mfn, i)); +if (mark_page_free (&pg[i],mfn_add (mfn, i)) ) + pg_tainted =1 ;if ( need_scrub ) {
@@ -1517,7 +1522,7 @@ static void free_heap_pages(page_list_add_scrub (pg, node, zone, order, pg->u.free.first_dirty); -if ( tainted ) +if ( pg_tainted )reserve_offlined_page (pg);spin_unlock (&heap_lock);
Signature · 1 line
2.25.1
Quoted 3 lines · Penny Zheng
Commit
540a637c3410780b519fc055f432afe271f642f8defines a new helpermark_page_freeto extract common codes, but it broke the local variable "tainted", revealed by Coverity ID 1491872.
Instead of mentioning the ID here, please ...
Quoted 3 lines
This patch let
mark_page_free()return boolean value of variable "tainted" and rename local variable "tainted" to "pg_tainted" to tell the difference from the global variable of the same name.
add a tag-like instance here, as we do elsewhere:
Coverity ID: 1491872
Quoted 10 lines
Signed-off-by Penny Zheng <[email protected]>--- xen/common/page_alloc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)xen/common/page_alloc.c +0
-0
xen/common/page_alloc.c bool scrub_free_pages(void) · line 1385
Quoted 7 lines
xen/common/page_alloc.c +2
-1@@ -1380,8 +1380,10 @@ bool scrub_free_pages(void)return node_to_scrub (false) !=NUMA_NO_NODE ; } -static void mark_page_free (struct page_info *pg,mfn_t mfn) +static bool mark_page_free (struct page_info *pg,mfn_t mfn) { +unsigned int pg_tainted =0 ;
bool please, considering ...
Quoted 10 lines
xen/common/page_alloc.c +1
-1@@ -1405,7 +1407,7 @@ static void mark_page_free(struct page_info *pg, mfn_t mfn)case PGC_state_offlining: pg->count_info = (pg->count_info & PGC_broken) | PGC_state_offlined; - tainted =1 ; + pg_tainted =1 ;break ;default :
xen/common/page_alloc.c static void mark_page_free(struct page_info *pg, mfn_t mfn) · line 1432
Quoted 6 lines
xen/common/page_alloc.c +2
-0@@ -1425,6 +1427,8 @@ static void mark_page_free(struct page_info *pg, mfn_t mfn)/* This page is not a guest frame any more. */ page_set_owner (pg,NULL );/* set_gpfn_from_mfn snoops pg owner */ set_gpfn_from_mfn (mfn_x (mfn),INVALID_M2P_ENTRY ); + +return pg_tainted; }
... this. Also both here and ...
xen/common/page_alloc.c static void free_heap_pages( · line 1440
Quoted 6 lines
xen/common/page_alloc.c +1
-1@@ -1433,7 +1437,7 @@ static void free_heap_pages( {unsigned long mask;mfn_t mfn =page_to_mfn (pg); -unsigned int i, node =phys_to_nid (mfn_to_maddr (mfn)), tainted =0 ; +unsigned int i, node =phys_to_nid (mfn_to_maddr (mfn)), pg_tainted =0 ;
... here I don't see why you stick to using "tainted" in the name when the goal is to ...
xen/common/page_alloc.c static void free_heap_pages( · line 1526
Quoted 7 lines
xen/common/page_alloc.c +1
-1@@ -1517,7 +1522,7 @@ static void free_heap_pages(page_list_add_scrub (pg, node, zone, order, pg->u.free.first_dirty); -if ( tainted ) +if ( pg_tainted )reserve_offlined_page (pg);
... control the call to this function: "offline" or "offlined" would seem quite a bit more to the point, getting us further away from the global meaning of "tainted".
Also please follow patch submission rules: To the list, with (all) maintainers Cc-ed.
Jan