mm/memblock: correct totalram_pages accounting with KMSAN

When KMSAN is enabled, `kmsan_memblock_free_pages()` can hold back pages
for metadata instead of returning them to the early allocator.  The
callers, however, would unconditionally increment `totalram_pages`,
assuming the pages were always freed.  This resulted in an incorrect
calculation of the total available RAM, causing the kernel to believe it
had more memory than it actually did.

This patch refactors `memblock_free_pages()` to return the number of pages
it successfully frees.  If KMSAN stashes the pages, the function now
returns 0; otherwise, it returns the number of pages in the block.

The callers in `memblock.c` have been updated to use this return value,
ensuring that `totalram_pages` is incremented only by the number of pages
actually returned to the allocator.  This corrects the total RAM
accounting when KMSAN is active.

Link: https://lkml.kernel.org/r/20250924100301.1558645-1-glider@google.com
Fixes: 3c2065098260 ("init: kmsan: call KMSAN initialization routines")
Signed-off-by: Alexander Potapenko <glider@google.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Aleksandr Nogikh <nogikh@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Markus Elfring <Markus.Elfring@web.de>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
3 files changed