[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] xen/riscv: don't decrement total_pages on failed paging_alloc_page()



commit 13d4a6776b931481984e0c1caf5a228ace3ec701
Author:     Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
AuthorDate: Thu Nov 26 09:45:17 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 26 09:45:17 2026 +0100

    xen/riscv: don't decrement total_pages on failed paging_alloc_page()
    
    paging_alloc_page() unconditionally decrements d->arch.paging.total_pages,
    even when the freelist is empty and page_list_remove_head() returns NULL.
    In that case the counter underflows, so arch_get_paging_mempool_size()
    reports a bogus pool size and subsequent paging_freelist_adjust() calls
    operate on a wrong page count.
    
    Only decrement the counter when a page was actually taken from the
    freelist.
    
    Fixes: af87a609c79d ("xen/riscv: implement p2m_next_level()")
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/riscv/paging.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/riscv/paging.c b/xen/arch/riscv/paging.c
index 35f572689a..6464c7ce68 100644
--- a/xen/arch/riscv/paging.c
+++ b/xen/arch/riscv/paging.c
@@ -120,7 +120,8 @@ struct page_info *paging_alloc_page(struct domain *d)
 
     spin_lock(&d->arch.paging.lock);
     pg = page_list_remove_head(&d->arch.paging.freelist);
-    d->arch.paging.total_pages--;
+    if ( pg )
+        d->arch.paging.total_pages--;
     spin_unlock(&d->arch.paging.lock);
 
     return pg;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.