From nobody Thu Oct 2 07:45:20 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F175B1DFF7 for ; Sun, 21 Sep 2025 05:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758433521; cv=none; b=U3Fih/hC1mMmUZRA12txwRdduebXKXKrFF4QaNxIklOF8pX49oYY/3dlJ6Nn5W3YY7umJvvbnf9p+H1szuhE3uT78MbTyc++NkKKzQIAnoSQ6OoqRjCVBpE/D9suE+63bk7kqKvXhRJkaRZIdxvLwDk2f3ZhabXLkS79JKoIhxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758433521; c=relaxed/simple; bh=2ElMcd0eKP7FDlwP4eCezro2fZ4qxvCn6nBIpUc/YyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sDp4/sq6qaIo23RIZDVYuQaEEWRL1Di800PPBQAARLL3iWxd2T5dbPjzu1bLW5ns23POkkbgxMnUE8iy7WEPfP3Md3ddbZ8EioNphqMpAcwg1KgvTEsciwrP3wvmruxMeCvOjgfqGHM740zZlGGy/gDM8E9Sgk9rfpAGK247AEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TBGP/GUI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TBGP/GUI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72C06C4CEE7; Sun, 21 Sep 2025 05:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758433520; bh=2ElMcd0eKP7FDlwP4eCezro2fZ4qxvCn6nBIpUc/YyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBGP/GUIZ8NU7qzknyJtB8/KV50lutfqTQbg/GHLvAnVGJryTEWSAxOwN6KBjQzDo f5LFFpjrv4nkCXfT69YMg2u4ApYlL7rGv9RqSQXV2WRD2ypg60rEZhX09gkPygeD6Z piCT477rBl6tQFGZfMN4JENiCws06vVYPkyl875WnraoS+MkIk02db6x45XTqjUQKH 1pgCyaIhWi2/IiaEy1SmeLBnHmE5OpxG2Crf31xBmojIFUsaiBUp7O9hN2owtoYtfU fUNuz1p9ANpLZZNElM4+JLksRU9h+SJdkgRFtJLajgXNWnC9+EtrKUskOlfR4J8x0U cvpdx+8AIAZoQ== From: Mike Rapoport To: Andrew Morton Cc: Alexander Graf , Baoquan He , Changyuan Lyu , Chris Li , Jason Gunthorpe , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/4] lib/test_kho: use kho_preserve_vmalloc instead of storing addresses in fdt Date: Sun, 21 Sep 2025 08:44:58 +0300 Message-ID: <20250921054458.4043761-5-rppt@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250921054458.4043761-1-rppt@kernel.org> References: <20250921054458.4043761-1-rppt@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: "Mike Rapoport (Microsoft)" KHO test stores physical addresses of the preserved folios directly in fdt. Use kho_preserve_vmalloc() instead of it and kho_restore_vmalloc() to retrieve the addresses after kexec. This makes the test more scalable from one side and adds tests coverage for kho_preserve_vmalloc() from the other. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Pratyush Yadav --- lib/test_kho.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/test_kho.c b/lib/test_kho.c index fe8504e3407b..60cd899ea745 100644 --- a/lib/test_kho.c +++ b/lib/test_kho.c @@ -32,6 +32,7 @@ module_param(max_mem, long, 0644); struct kho_test_state { unsigned int nr_folios; struct folio **folios; + phys_addr_t *folios_info; struct folio *fdt; __wsum csum; }; @@ -67,18 +68,15 @@ static struct notifier_block kho_test_nb =3D { =20 static int kho_test_save_data(struct kho_test_state *state, void *fdt) { - phys_addr_t *folios_info; + phys_addr_t *folios_info __free(kvfree) =3D NULL; + struct kho_vmalloc folios_info_phys; int err =3D 0; =20 - err |=3D fdt_begin_node(fdt, "data"); - err |=3D fdt_property(fdt, "nr_folios", &state->nr_folios, - sizeof(state->nr_folios)); - err |=3D fdt_property_placeholder(fdt, "folios_info", - state->nr_folios * sizeof(*folios_info), - (void **)&folios_info); - err |=3D fdt_property(fdt, "csum", &state->csum, sizeof(state->csum)); - err |=3D fdt_end_node(fdt); + folios_info =3D vmalloc_array(state->nr_folios, sizeof(*folios_info)); + if (!folios_info) + return -ENOMEM; =20 + err =3D kho_preserve_vmalloc(folios_info, &folios_info_phys); if (err) return err; =20 @@ -93,6 +91,17 @@ static int kho_test_save_data(struct kho_test_state *sta= te, void *fdt) break; } =20 + err |=3D fdt_begin_node(fdt, "data"); + err |=3D fdt_property(fdt, "nr_folios", &state->nr_folios, + sizeof(state->nr_folios)); + err |=3D fdt_property(fdt, "folios_info", &folios_info_phys, + sizeof(folios_info_phys)); + err |=3D fdt_property(fdt, "csum", &state->csum, sizeof(state->csum)); + err |=3D fdt_end_node(fdt); + + if (!err) + state->folios_info =3D no_free_ptr(folios_info); + return err; } =20 @@ -209,8 +218,9 @@ static int kho_test_save(void) =20 static int kho_test_restore_data(const void *fdt, int node) { + const struct kho_vmalloc *folios_info_phys; const unsigned int *nr_folios; - const phys_addr_t *folios_info; + phys_addr_t *folios_info; const __wsum *old_csum; __wsum csum =3D 0; int len; @@ -225,8 +235,12 @@ static int kho_test_restore_data(const void *fdt, int = node) if (!old_csum || len !=3D sizeof(*old_csum)) return -EINVAL; =20 - folios_info =3D fdt_getprop(fdt, node, "folios_info", &len); - if (!folios_info || len !=3D sizeof(*folios_info) * *nr_folios) + folios_info_phys =3D fdt_getprop(fdt, node, "folios_info", &len); + if (!folios_info_phys || len !=3D sizeof(*folios_info_phys)) + return -EINVAL; + + folios_info =3D kho_restore_vmalloc(folios_info_phys); + if (!folios_info) return -EINVAL; =20 for (int i =3D 0; i < *nr_folios; i++) { @@ -246,6 +260,8 @@ static int kho_test_restore_data(const void *fdt, int n= ode) folio_put(folio); } =20 + vfree(folios_info); + if (csum !=3D *old_csum) return -EINVAL; =20 @@ -304,6 +320,7 @@ static void kho_test_cleanup(void) folio_put(kho_test_state.folios[i]); =20 kvfree(kho_test_state.folios); + vfree(kho_test_state.folios_info); folio_put(kho_test_state.fdt); } =20 --=20 2.50.1