From nobody Thu Sep 24 14:26:24 2026 Received: from out-2uec-a106.jellyfish.systems (out-2uec-a106.jellyfish.systems [63.250.43.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E06638E106 for ; Wed, 23 Sep 2026 02:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.250.43.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131474; cv=none; b=d3ha8r1NHHqIHeePC9s8wkryOFYPRYaYHb758TA1WE719p3WfdmyxrRix5CkN2LVdmHMu8DPdUEVLKaqrWVzMN8L0d+CeeO5T76Qx5bLziOwCIBjqk1utOQrfpacnBSJskSS3h49ydM6Q8UFQxCR18hsBpl/k4h3p23jU3T1czE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131474; c=relaxed/simple; bh=1FNXjnkkShKduOmgw1ZZnqtP8QiB8yibQu0OlPMpM2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N6ypaeBCo3zCpgj5LDFybsp35wgomXAQ/OQJLwR742rtxG4cwu4jUDLJMapIUrKLV7fiVnVNV9DiA/yUfj5K88ySNy6sMkvTEdGaeTY+L24LHJBEPRxKQWWER+JA7nMDOGDRxtn8HnLN1tAuSuh0+WvPepG7rbqJLCp9SGe6RjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc; spf=pass smtp.mailfrom=tychen.cc; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b=IwvCtPGS; arc=none smtp.client-ip=63.250.43.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tychen.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b="IwvCtPGS" Received: from fedora (unknown [120.199.7.38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.spacemail.com (Postfix) with ESMTPSA id 4hqLZL28X8z8sYF; Wed, 23 Sep 2026 02:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tychen.cc; s=spacemail; t=1790130700; bh=4NmJHuTnYwRJLDD5IFTn5S7aIbzSeEjEGBUsClZv5Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IwvCtPGSL00D6EVhxp68pIUcsDF5v/TCpS02ROzmyWaN25dgQ/w7fM2ZrfdIOyv3Q XE/m0L+SQFLr43XtMEAPrOJxawXXeYRa2aNst48Hm4dtwVm6yk67eJqpC/obEFO/kz qP/PvcvOAgPx2H6lrvK0FaPVSiszRg40gqSyJjOLd20zDBjXPWdpUT+VG1vfeyyr2J TDG59e/VCES1uW4qtNUyumRAvdMOjjpK2e0L3qcRw2VpbugDhWsLIdU6RV02gRk4Xx AndLiO9jGTt945vGT7VWgW8i/nI6P6PqLdKNvqJ7MVH6C/7ILnrJN6W+tG+FQ+01ko pEoYBQNoMcQjA== From: Tianyi Chen To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] memblock tests: use physical addresses for region removal Date: Wed, 23 Sep 2026 11:31:23 +0900 Message-ID: <20260923023126.1910311-2-hi@tychen.cc> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923023126.1910311-1-hi@tychen.cc> References: <20260923023126.1910311-1-hi@tychen.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: hi@tychen.cc Content-Type: text/plain; charset="utf-8" With BUILD=3D32, phys_addr_t remains 64-bit while pointers are 32-bit. Casting the address near PHYS_ADDR_MAX to void * truncates it before memblock_free() converts it back with __pa(). The reserved region is therefore left unchanged and memblock_free_near_max_check() fails. Use memblock_phys_free() for all synthetic physical ranges in the basic API tests. This also removes the integer-to-pointer cast warnings from the other removal checks. Retain the checks that freeing past PHYS_ADDR_MAX clips the removed region. Fixes: 21a233f68afe ("memblock tests: add additional tests for basic api an= d memblock_alloc") Assisted-by: LLM Signed-off-by: Tianyi Chen --- tools/testing/memblock/tests/basic_api.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/membl= ock/tests/basic_api.c index 01e836fba488..47bcdcc115a5 100644 --- a/tools/testing/memblock/tests/basic_api.c +++ b/tools/testing/memblock/tests/basic_api.c @@ -1730,7 +1730,7 @@ static int memblock_free_simple_check(void) reset_memblock_regions(); memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - memblock_free((void *)r1.base, r1.size); + memblock_phys_free(r1.base, r1.size); =20 ASSERT_EQ(rgn->base, r2.base); ASSERT_EQ(rgn->size, r2.size); @@ -1778,7 +1778,7 @@ static int memblock_free_absent_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r2.base, r2.size); + memblock_phys_free(r2.base, r2.size); =20 ASSERT_EQ(rgn->base, r1.base); ASSERT_EQ(rgn->size, r1.size); @@ -1832,7 +1832,7 @@ static int memblock_free_overlap_top_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r2.base, r2.size); + memblock_phys_free(r2.base, r2.size); =20 ASSERT_EQ(rgn->base, r2.base + r2.size); ASSERT_EQ(rgn->size, total_size); @@ -1881,7 +1881,7 @@ static int memblock_free_overlap_bottom_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r2.base, r2.size); + memblock_phys_free(r2.base, r2.size); =20 ASSERT_EQ(rgn->base, r1.base); ASSERT_EQ(rgn->size, total_size); @@ -1938,7 +1938,7 @@ static int memblock_free_within_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r2.base, r2.size); + memblock_phys_free(r2.base, r2.size); =20 ASSERT_EQ(rgn1->base, r1.base); ASSERT_EQ(rgn1->size, r1_size); @@ -1976,7 +1976,7 @@ static int memblock_free_only_region_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r1.base, r1.size); + memblock_phys_free(r1.base, r1.size); =20 ASSERT_EQ(rgn->base, 0); ASSERT_EQ(rgn->size, 0); @@ -2003,7 +2003,7 @@ static int memblock_free_only_region_check(void) * Expect the total size of reserved memory to be updated and the counter = to * not be updated. */ -static int memblock_free_near_max_check(void) +static int memblock_phys_free_near_max_check(void) { struct memblock_region *rgn; phys_addr_t total_size; @@ -2026,7 +2026,7 @@ static int memblock_free_near_max_check(void) =20 reset_memblock_regions(); memblock_reserve(r1.base, r1.size); - memblock_free((void *)r2.base, r2.size); + memblock_phys_free(r2.base, r2.size); =20 ASSERT_EQ(rgn->base, r1.base); ASSERT_EQ(rgn->size, total_size); @@ -2086,7 +2086,7 @@ static int memblock_free_overlap_two_check(void) reset_memblock_regions(); memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - memblock_free((void *)r3.base, r3.size); + memblock_phys_free(r3.base, r3.size); =20 ASSERT_EQ(rgn1->base, r1.base); ASSERT_EQ(rgn1->size, new_r1_size); @@ -2114,7 +2114,7 @@ static int memblock_free_checks(void) memblock_free_overlap_bottom_check(); memblock_free_within_check(); memblock_free_only_region_check(); - memblock_free_near_max_check(); + memblock_phys_free_near_max_check(); memblock_free_overlap_two_check(); =20 prefix_pop(); --=20 2.55.0 From nobody Thu Sep 24 14:26:24 2026 Received: from out-93wp-a34.jellyfish.systems (out-93wp-a34.jellyfish.systems [104.207.68.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8005363083 for ; Wed, 23 Sep 2026 02:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.207.68.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130729; cv=none; b=s2t7SOjvd7UcwSVASUZfSK9urviAsi2SBDi5DGFAJqHkG4WlL0tmzi1riRL7mzZWvpqEdDbY1C1v41KyYA7wRVycpSpzBn5zL0mmUSRZu+aEFpZg49P9tzF8WT2UT9yhRpIbBsepe7xKejN8Eu+fKkueS5yR6jCioXXLGE6UZ80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130729; c=relaxed/simple; bh=+zpy3l3uQZbtn3EA5tBa12RRyLBX5X8jEzCv9ArKHCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qeEq06+Aa530M85nOb9IZEmxTV5sjhrEBTVfDrtHZ8doY22u+ep0xpN3kkehaXDhNkl3GB6vcuW4wuf+LfCCKASrGni1+OWr+2/MeUxB8HKCtXCcqKiiFi3En4IeurkYV3K0Gv91y3/uvWvc/tM63AKjM2LjiwI8HcLP7Maqbho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc; spf=pass smtp.mailfrom=tychen.cc; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b=G5wmWHGF; arc=none smtp.client-ip=104.207.68.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tychen.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b="G5wmWHGF" Received: from fedora (unknown [120.199.7.38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.spacemail.com (Postfix) with ESMTPSA id 4hqLZP2xcYz8sYH; Wed, 23 Sep 2026 02:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tychen.cc; s=spacemail; t=1790130703; bh=yOXnInNUODU5Lzwbj44QgpGQDJ5UdG0pb1N+gcZ3ygM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G5wmWHGF8x5Fjt8JXLIilAfxBLUl9aQ34u42tdylL7dNFnoM1NAqY0nWyDDx+J9yx fljLl8gdfcAKGAoO9WyBRPyJoNOCD5+BqPI+iyloAdpemuOe4MzU0THBcoz/JBisi4 TI8CsTXrHcTHpshU1yOCiiPwYTKWdYSbmza6yeOY5oiEZkb+eoiSajTeC2dkPnAVxo s/k5vnjcacO9S8zSilBs9zOwA7Ar2A+9aRXWn3aagBwiOmWna9bHrvEOEKQUIQ0B3r RlLNzSWPlBYcUGGMBFkZn6CpRIsCU9qQLPkk5IA8lPgRlj965ZI6YmktGqWBm73Fvs z89vhmX/xvmuQ== From: Tianyi Chen To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] memblock tests: zero-extend simulated memory addresses Date: Wed, 23 Sep 2026 11:31:24 +0900 Message-ID: <20260923023126.1910311-3-hi@tychen.cc> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923023126.1910311-1-hi@tychen.cc> References: <20260923023126.1910311-1-hi@tychen.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: hi@tychen.cc Content-Type: text/plain; charset="utf-8" Converting a 32-bit pointer directly to the 64-bit phys_addr_t can sign-extend it when BUILD=3D32 is used. A dummy allocation above 2 GiB then gets registered at an address different from its unsigned pointer value. The low-address tests compare that value against the registered range and fail once the earlier maximum-address free test is fixed. Convert through uintptr_t when registering and reporting dummy memory. This preserves the pointer bits and agrees with the simulator __pa() conversion and the allocation tests. Fixes: 284d950dd6b0 ("memblock tests: Add simulation of physical memory") Assisted-by: LLM Signed-off-by: Tianyi Chen --- tools/testing/memblock/tests/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock= /tests/common.c index ac032610a56e..2a248973eb4c 100644 --- a/tools/testing/memblock/tests/common.c +++ b/tools/testing/memblock/tests/common.c @@ -67,7 +67,7 @@ static inline void fill_memblock(void) void setup_memblock(void) { reset_memblock_regions(); - memblock_add((phys_addr_t)memory_block.base, MEM_SIZE); + memblock_add((phys_addr_t)(uintptr_t)memory_block.base, MEM_SIZE); fill_memblock(); } =20 @@ -88,7 +88,7 @@ void setup_numa_memblock(const unsigned int node_fracs[]) int flags; =20 reset_memblock_regions(); - base =3D (phys_addr_t)memory_block.base; + base =3D (phys_addr_t)(uintptr_t)memory_block.base; flags =3D (movable_node_is_enabled()) ? MEMBLOCK_NONE : MEMBLOCK_HOTPLUG; =20 for (int i =3D 0; i < NUMA_NODES; i++) { @@ -115,7 +115,7 @@ void dummy_physical_memory_cleanup(void) =20 phys_addr_t dummy_physical_memory_base(void) { - return (phys_addr_t)memory_block.base; + return (phys_addr_t)(uintptr_t)memory_block.base; } =20 phys_addr_t dummy_physical_memory_low_limit(void) --=20 2.55.0 From nobody Thu Sep 24 14:26:24 2026 Received: from out-2z4y-a131.jellyfish.systems (out-2z4y-a131.jellyfish.systems [198.54.127.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D92AB36B054 for ; Wed, 23 Sep 2026 02:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130728; cv=none; b=UV+vs1QlhW6oP+9z5BEZAPFx4LZt2QIXaoGg7RCtryMGu5T187ewF0RjBj/DNgIn1YSsLVJjNs6NkWr1xi1oV0oO+TLIO3lZtEnbW5y0LrSIhIuKMGMgSMDinNa8dfySxsMv9aRziYLPkw6lf7umintHyFd00b5TirtUhKFaZXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130728; c=relaxed/simple; bh=U62+tggc8nNFxAYbHZrx2WK8iGpKMeEFQdo5LOE9Urs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d1WhrEjIOTh77ShAklo40vXvMP4gBCGe8g6xjfLZN7zFanNGlJrHplzfk/vmHjq9tkSOzu9mWi1WFkOMSh95gr5QTyj+YrIW+HI45ScVjblduPj0QxM/rOvYww6oiyk5k2ccTSNlpWOzwlW4gANj/0b7jI0MkH66EGziH1550Qg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc; spf=pass smtp.mailfrom=tychen.cc; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b=pqPP1eUl; arc=none smtp.client-ip=198.54.127.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tychen.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b="pqPP1eUl" Received: from fedora (unknown [120.199.7.38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.spacemail.com (Postfix) with ESMTPSA id 4hqLZS3Tcqz8sYF; Wed, 23 Sep 2026 02:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tychen.cc; s=spacemail; t=1790130707; bh=eY2FwUhC+QO6BDI+/C9DuRURjCy94COvOGbyA9JIVXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pqPP1eUlaCDTUv5yCrMgjH2Wc/3DT6OkW+73aUgF1rN5slTP+4VSHmpSU3PFtP6Sf 9+2OlvqjVW+bGed9UI7fz9L5qPAvygnMpQQ5bfpVf3ZIsVzSnXY0YMRfSjiuzguuRn 4aTDwgxNHI1FpzJaGcVTyDkuNtWvoUOmyPEgaIuwh7/IFPjYd1eaDEbvw9EvQNNIYv qHyvBfuoCA5UTn+5tF8yB/W9W93XPPMqw7uu9ijIL3WOllCaQvdH3uKN8L7mtJGrTG BR9Fv6Vx0S9ky/PKpnL890E8FcFT4nIBpUR+gQCjcYFtme25oYZLLm4KYCxUwdRxWc hetsWI7wL3cGg== From: Tianyi Chen To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] tools: use __pa() in virt_to_phys() Date: Wed, 23 Sep 2026 11:31:25 +0900 Message-ID: <20260923023126.1910311-4-hi@tychen.cc> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923023126.1910311-1-hi@tychen.cc> References: <20260923023126.1910311-1-hi@tychen.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: hi@tychen.cc Content-Type: text/plain; charset="utf-8" With 32-bit pointers and a 64-bit phys_addr_t, GCC warns about the pointer-to-integer cast in virt_to_phys(). It can also sign-extend pointers whose top bit is set, turning 0x80000000 into 0xffffffff80000000. Use __pa() to convert through unsigned long before widening the result. This preserves the unsigned pointer value and matches the other address conversion helpers. Reported-by: Mike Rapoport Link: https://lore.kernel.org/r/179007180279.508753.4595268983388589280.b4-= review@b4 Assisted-by: LLM Signed-off-by: Tianyi Chen --- tools/include/linux/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/linux/mm.h b/tools/include/linux/mm.h index 84b5954f66c3..480526de8d65 100644 --- a/tools/include/linux/mm.h +++ b/tools/include/linux/mm.h @@ -30,7 +30,7 @@ static inline void *phys_to_virt(unsigned long address) #define virt_to_phys virt_to_phys static inline phys_addr_t virt_to_phys(volatile void *address) { - return (phys_addr_t)address; + return __pa(address); } =20 static inline void totalram_pages_inc(void) --=20 2.55.0 From nobody Thu Sep 24 14:26:24 2026 Received: from out-2z4y-a134.jellyfish.systems (out-2z4y-a134.jellyfish.systems [198.54.127.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC2BB372EF5 for ; Wed, 23 Sep 2026 02:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130728; cv=none; b=QBy1N2asOi9qZmhu+Ma605t8BJs8HpCbJHKum/prOXWgV7SlNHYQ2p+BV7hGtqJO3ZBYqSaeSDabciCyracQudJOUuUyH0lyy6eKqqHyuA7WD8a9s4nE1SfqIn0dNKwmsoITcRc5ALMzftYonC0sWJyx3nlR4xyTeZQHjt0UzkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790130728; c=relaxed/simple; bh=H8G1ZpSGU+XEPkSOWl5JwWrQCV5ATc+10WGucScsNZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R0Qvez2WJMocU4YoX9fUgg+HgRFLEguu5986sCjVvpi0Oqd5RQPjhjiPK/rz76zz+1SIkIfr9XFHlt91Jwyx2juIr9DJyHKtKE4Em/9J+qyXZfr8yk6285sjEMp8YudbhiqCoaQ53Pk8iKOx2QYU0TDSDSosVzABTWzNcLksvUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc; spf=pass smtp.mailfrom=tychen.cc; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b=JxeV8+Gt; arc=none smtp.client-ip=198.54.127.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tychen.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tychen.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tychen.cc header.i=@tychen.cc header.b="JxeV8+Gt" Received: from fedora (unknown [120.199.7.38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.spacemail.com (Postfix) with ESMTPSA id 4hqLZW45MGz8sYH; Wed, 23 Sep 2026 02:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tychen.cc; s=spacemail; t=1790130709; bh=r5BCBsILvYpkCei8NxC2nBexoyGfpFRtjZRXstiHS3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxeV8+Gta6mPvrkqBEcX7kwlYEAqpPcPO5yJBmlxp2MWLyMY9zeRQhNoPUx69Q5gj fgfZCk0mgSYgRKQDuKntGl16gTZQC+q7m7a4bN2goCXzbRjOz/ZQpj0OAC5lg5l+nF NxB8EjwKuB1EvIEkwzUrFZK2ZvudGhURT/E+53XQrJ4YFL9Jj/3JK2pN24rg7eMTGO 1UIw8wv0506cABI7dNCAoeidT4/nQTr6L8qJ7Ti85cSy7x4O96egJ4GEwjBQ9phkQk 3ykc0JQu5LrqD+r4T5v5Fd6Wp8VIrnICCLH0xOyh2lAv9S1VE5fjabpFUQ/nVsa25C abAFNQ8fO/4Ow== From: Tianyi Chen To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] memblock: initialize the region merge end index Date: Wed, 23 Sep 2026 11:31:26 +0900 Message-ID: <20260923023126.1910311-5-hi@tychen.cc> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923023126.1910311-1-hi@tychen.cc> References: <20260923023126.1910311-1-hi@tychen.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: hi@tychen.cc Content-Type: text/plain; charset="utf-8" GCC 13 reports that end_rgn may be used uninitialized when building the memblock simulator with BUILD=3D32 and its default sanitizer flags. Every insertion sets end_rgn, and the nr_new check prevents merging when there were no insertions, so this is not an uninitialized read. Initialize the index to zero to avoid the warning without disabling the diagnostic. Reported-by: Mike Rapoport Link: https://lore.kernel.org/r/179007180279.508753.4595268983388589280.b4-= review@b4 Assisted-by: LLM Signed-off-by: Tianyi Chen --- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memblock.c b/mm/memblock.c index 22d14a637f24..aee1fe36130b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -614,7 +614,7 @@ static int __init_memblock memblock_add_range(struct me= mblock_type *type, bool insert =3D false; phys_addr_t obase =3D base; phys_addr_t end =3D base + memblock_cap_size(base, &size); - int idx, nr_new, start_rgn =3D -1, end_rgn; + int idx, nr_new, start_rgn =3D -1, end_rgn =3D 0; struct memblock_region *rgn; =20 if (!size) --=20 2.55.0