From nobody Tue Feb 10 05:10:05 2026 Received: from mail-yx1-f47.google.com (mail-yx1-f47.google.com [74.125.224.47]) (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 CE9742DF12B for ; Fri, 14 Nov 2025 19:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146822; cv=none; b=GeqmEVgPpaRHOk+evR00Nn1Gs63ycBSYqWexoDqteqokN/qSKr1r0XbGn1rfJkCgSJ8Di0yNJoG/xQuCfv5qYgzfpcd7iX4jmO0xF5AS+Ve5hQKZ7bUjwM6qPVwAZTBXE8V4UkzDmAAp/1qBLJWQVc0jf8WQhGAKCqiY7H4z+Fc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146822; c=relaxed/simple; bh=Uqq2r+qcIbSWV/pQBdQ0mG+2V9Cin/ndNvuaMmJlpQM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f/XN9T8crllsYaq04P+he3SEcTlWY+19tDWNr6u4x96+d/rzuLf82vlAPBcngVo8LlF1e8+9g6f0E0u2BiTbGOqXbL1VtniaTwk1RGRpE47LjYtwn/SA+lB9SIqY27EnmiE8JvElPx8rhVbPJ/UNdgI1E26ySUJkexz0sWf4210= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=Ta42OBpx; arc=none smtp.client-ip=74.125.224.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="Ta42OBpx" Received: by mail-yx1-f47.google.com with SMTP id 956f58d0204a3-640f88b873bso2108048d50.3 for ; Fri, 14 Nov 2025 11:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1763146816; x=1763751616; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vhwkZEBEr5WhXa61Cp+OEzgGPmuzFUzbgIvGt1K8dx0=; b=Ta42OBpxVamrlGAtLEy3btkKkV13u9DjSV8I70L/LaWXxICw0RkQlhiPas9UKeY4aW 3vR0b6Bbaz66CcBFnxDqUNQalvw8qWhwa9G0T9Vkcara7ZIPf6swp+T890oI1/8I6MyD cf+ox+CniXg9gmRGdU8dcRb0ZhFrWq5lHsA5+Dtwc+Ec7GLTASJn06OlQSDlO4iipwhX zorTO1xPBA6eX+MTEC8SeIMN4jS4uEbeqkmSz5hpGHOJ7R2PlcZxF1g1PvpaP1PmrVHV zy5Lv0AhN2B7AGebpah7krnYwuJyT72ynzyqCDwer4NvrwMBLtRuBqOtQOXcbnmWIx05 +XHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763146816; x=1763751616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=vhwkZEBEr5WhXa61Cp+OEzgGPmuzFUzbgIvGt1K8dx0=; b=iHWylUTAaRGeoRtsTw2YlHJobRU7+6qEr+Ojch+to2NHBAtCd/0PxjAl6uXk/zp7qw hNT263fTvgNVW90JlSWFWpfsfNyB1shs00WLOizZiBkR6cYGiG/SL2z2dZK/Cd604+cb 6NZhQmuEeTgHAYGFtybqvzqc9E9ggN1tWlaaBlVWQIH76u8OPXLxfXb96ZgzLa8O0SwW 0v3wdvgMCJvKX0vBMKx0XNiSZVvzinCjPawQIb4+6acCF5dzUkn61HUujgArwEtPp9PF JAB0B41LxXhodwMznm0Pj3yKhFVRNZuSd56NWwPbhXgkfpY1U/U3RQY5E7yrCtab+gZv 5ziA== X-Forwarded-Encrypted: i=1; AJvYcCVT3oL/7zQaw1C2sAGPoPcD9Y4IPjha2Nn1eIJ3loNrwD7RhM0KHTiCs8rt7bJnALSf1ftSEh1NJJthZjc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy77zKVa8Twpy8JZaVUrAIySLkWFoFgohOvcaVnXTxh4y65KxQt E3AG/uZQmuqz21Heyei0Nnan291GjnVhsYgubh2HpT99Bo+dpGvJkcwvlIKJKz9sPqA741HLOTI 0YN+2 X-Gm-Gg: ASbGncvftDi9WF0HPgTOawXolW7WOWrTPuPD4vAXqnN/oSSMMQPHQg99cMPsHqyBk9j GBeb5zhepX8YLFInY5BD91xClTsD/M7A4hXKsNIMR01oDyicXakAS2FotY0/JfGxTxmYwk3pR/I jr8AhivZtLqtcy0SbV3UdQYjH3BvtA0EyyBuT+yytpgisYeOjvv7vA2/w6wOw+WvY6mk8tC7oWk r5+ci06JbYLhuChiAE5JSM1VNyT0Q+PF0TiRgZnBsnnEEZfkHhFJapAplgulg8Ss7sr84rMKpvc egbThMwhSDAiX3rUyX8VNZJBq+hARJnct7S8ER9ltzOs+fPleiDjKGJ3fDIwF4R29PXBS8Qc/Ot 9GEl46aakQv5yzkUeoGoo4DqUIrq3/QJS6DHebs1QLHj/7nSvOC2WsNTW4x3KGgdcdVEzeBc36y xoVeVZcdOnmjascnPR/fYw2Wy06NaDxj8XDG3yZ3bLvwXjoQu8iHWFBAWB6UwQAYQiNS/mg2oZZ fKhWCg= X-Google-Smtp-Source: AGHT+IHftz04artgctWkQtgZIqMhYzNUfbd5DWlI95J4Cany7ZO/gJCBBXAhqFr39ej1tMVzPCYDjg== X-Received: by 2002:a53:acc3:0:10b0:63f:ba88:e905 with SMTP id 956f58d0204a3-641e757cfa3mr2955979d50.30.1763146815780; Fri, 14 Nov 2025 11:00:15 -0800 (PST) Received: from soleen.c.googlers.com.com (182.221.85.34.bc.googleusercontent.com. [34.85.221.182]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6410e8f4f2esm2014058d50.0.2025.11.14.11.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 11:00:15 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, bhe@redhat.com, pasha.tatashin@soleen.com, rppt@kernel.org, jasonmiu@google.com, arnd@arndb.de, coxu@redhat.com, dave@vasilevsky.ca, ebiggers@google.com, graf@amazon.com, kees@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org Subject: [PATCH v2 08/13] kho: Remove global preserved_mem_map and store state in FDT Date: Fri, 14 Nov 2025 13:59:57 -0500 Message-ID: <20251114190002.3311679-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog In-Reply-To: <20251114190002.3311679-1-pasha.tatashin@soleen.com> References: <20251114190002.3311679-1-pasha.tatashin@soleen.com> 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" Currently, the serialized memory map is tracked via kho_out.preserved_mem_map and copied to the FDT during finalization. This double tracking is redundant. Remove preserved_mem_map from kho_out. Instead, maintain the physical address of the head chunk directly in the preserved-memory-map FDT property. Introduce kho_update_memory_map() to manage this property. This function handles: 1. Retrieving and freeing any existing serialized map (handling the abort/retry case). 2. Updating the FDT property with the new chunk address. This establishes the FDT as the single source of truth for the handover state. Signed-off-by: Pasha Tatashin Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Pratyush Yadav --- kernel/liveupdate/kexec_handover.c | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 297136054f75..63800f63551f 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -119,9 +119,6 @@ struct kho_out { struct mutex fdts_lock; =20 struct kho_mem_track track; - /* First chunk of serialized preserved memory map */ - struct khoser_mem_chunk *preserved_mem_map; - struct kho_debugfs dbg; }; =20 @@ -382,6 +379,27 @@ static void kho_mem_ser_free(struct khoser_mem_chunk *= first_chunk) } } =20 +/* + * Update memory map property, if old one is found discard it via + * kho_mem_ser_free(). + */ +static void kho_update_memory_map(struct khoser_mem_chunk *first_chunk) +{ + void *ptr; + u64 phys; + + ptr =3D fdt_getprop_w(kho_out.fdt, 0, PROP_PRESERVED_MEMORY_MAP, NULL); + + /* Check and discard previous memory map */ + phys =3D get_unaligned((u64 *)ptr); + if (phys) + kho_mem_ser_free((struct khoser_mem_chunk *)phys_to_virt(phys)); + + /* Update with the new value */ + phys =3D first_chunk ? (u64)virt_to_phys(first_chunk) : 0; + put_unaligned(phys, (u64 *)ptr); +} + static int kho_mem_serialize(struct kho_out *kho_out) { struct khoser_mem_chunk *first_chunk =3D NULL; @@ -422,7 +440,7 @@ static int kho_mem_serialize(struct kho_out *kho_out) } } =20 - kho_out->preserved_mem_map =3D first_chunk; + kho_update_memory_map(first_chunk); =20 return 0; =20 @@ -1223,8 +1241,7 @@ int kho_abort(void) if (!kho_out.finalized) return -ENOENT; =20 - kho_mem_ser_free(kho_out.preserved_mem_map); - kho_out.preserved_mem_map =3D NULL; + kho_update_memory_map(NULL); kho_out.finalized =3D false; =20 return 0; @@ -1234,21 +1251,15 @@ static int __kho_finalize(void) { void *root =3D kho_out.fdt; struct kho_sub_fdt *fdt; - u64 *preserved_mem_map; + u64 empty_mem_map =3D 0; int err; =20 err =3D fdt_create(root, PAGE_SIZE); err |=3D fdt_finish_reservemap(root); err |=3D fdt_begin_node(root, ""); err |=3D fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE); - /** - * Reserve the preserved-memory-map property in the root FDT, so - * that all property definitions will precede subnodes created by - * KHO callers. - */ - err |=3D fdt_property_placeholder(root, PROP_PRESERVED_MEMORY_MAP, - sizeof(*preserved_mem_map), - (void **)&preserved_mem_map); + err |=3D fdt_property(root, PROP_PRESERVED_MEMORY_MAP, &empty_mem_map, + sizeof(empty_mem_map)); if (err) goto err_exit; =20 @@ -1271,8 +1282,6 @@ static int __kho_finalize(void) if (err) goto err_exit; =20 - *preserved_mem_map =3D (u64)virt_to_phys(kho_out.preserved_mem_map); - return 0; =20 err_exit: --=20 2.52.0.rc1.455.g30608eb744-goog