From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B243BC021A0 for ; Wed, 12 Feb 2025 12:29:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDCA16B008C; Wed, 12 Feb 2025 07:29:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8C4E6B0092; Wed, 12 Feb 2025 07:29:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5D826B0093; Wed, 12 Feb 2025 07:29:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B16D76B008C for ; Wed, 12 Feb 2025 07:29:07 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 708BF121992 for ; Wed, 12 Feb 2025 12:29:06 +0000 (UTC) X-FDA: 83111222292.07.50D7FE8 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by imf05.hostedemail.com (Postfix) with ESMTP id 43D03100002 for ; Wed, 12 Feb 2025 12:29:04 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=RPqGCMmK; spf=pass (imf05.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=pass (policy=quarantine) header.from=weissschuh.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739363345; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TvPbFPdhs4rsZAIf9ArjWz0MAEl7abAALU3gmrYlJXw=; b=ic+GYbQkZKas6/PzhkVRu6/fEbEA2nzlaPSXiPsYNs+Fnv5rV/VpkJEaDayfsRrzvbYtq/ BN5NRiODYSE56QYop+2psiMGa4nY2rQ3wPdRfLW+/P7hVUd/JJKl9NZoJrc0f0o85wGeVf VxGG+TFBUQYiCbUYf1pUY4Wzfkm+n+U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=RPqGCMmK; spf=pass (imf05.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=pass (policy=quarantine) header.from=weissschuh.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739363345; a=rsa-sha256; cv=none; b=VOQoWC5Oy31RpznueHRG7WFGwFfDP7ZhsX6/P9iak3KpLz9tFHlbnbqUniNK4iiqmAyNCw g7ocC7psjp/w5KoQneMMZXUpvpxTon9f2eEtKHiYArpUG8ty7DG6KJsm/yjdC1I790izsf YcHTMrcLOhWetRfx/aD50WJb16eVE6A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1739363341; bh=CQ3SUXjx0/f8m1n41c4a7SuLTF0PmDTDTSkoGsVR/Bc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RPqGCMmKw9maDfoACsq5XCW1kNFM6USyJeTgaD0ZKnBDjJTzkCAXYBi0J0p/zs+gW CqjmKFSFDdJ1G1DqeLIdoAIUzFk59nzTIK1L5fU/sV+967mEPcUqwhoHA45Q4Y6o++ DEc57IMn3o42I47CfAucVGa1HdoUC+cRjFDTaZ2E= Date: Wed, 12 Feb 2025 13:29:00 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Alexander Graf , Andrew Morton , Andy Lutomirski , Anthony Yznaga , Arnd Bergmann , Ashish Kalra , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Dave Hansen , David Woodhouse , Eric Biederman , Ingo Molnar , James Gowans , Jonathan Corbet , Krzysztof Kozlowski , Mark Rutland , Paolo Bonzini , Pasha Tatashin , "H. Peter Anvin" , Peter Zijlstra , Pratyush Yadav , Rob Herring , Rob Herring , Saravana Kannan , Stanislav Kinsburskii , Steven Rostedt , Thomas Gleixner , Tom Lendacky , Usama Arif , Will Deacon , devicetree@vger.kernel.org, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH v4 05/14] kexec: Add Kexec HandOver (KHO) generation helpers Message-ID: References: <20250206132754.2596694-1-rppt@kernel.org> <20250206132754.2596694-6-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250206132754.2596694-6-rppt@kernel.org> X-Rspam-User: X-Stat-Signature: nsekomire7iyqq9tuikb6ja9cme5zccg X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 43D03100002 X-HE-Tag: 1739363344-991839 X-HE-Meta: U2FsdGVkX18/Kuu56eD+stEwkmTy+wMrQiBIy+12ndnmzHfaEgA7If+5HrrfuhEMZSGi+XxThzQ5bPWALCLFgBgamHzC8p5+f4qZLFgNs34II0g62UZoiowPAvqhBuo6d4mW0MlrkqDiSLJNGFoltoFmGTOWz+1McUnWbcdgtspiS3VlOWedAKBaN3r3RiBMtLQKHDYSKqr9oCR869xL16PcdEraTpxuss1KaOzsADlLn0PhXbklrqicb//e1RXI2i3q8pkVkFIyASMH/RwtFGUd9FYI4xbicyq2rEVaE8NQGfI2felDXqtlqsvERhq42rXYubnrz3czntIvQIphDufs4pHDEIoeZo3p0b1olFp18BSig98iZLwdalcsST4rh4QBj4gk+Z9DpuJcldaYoJzKsyYhjerGsKFJIfcI3oaEHvmTbseqCpJQ8jHk+GyVDh4F7M21BRtbnc/eOSQP3g2khfZTYWs7eZxRcwqH8AR8vv14beeGmaTcPESI1i4YB9XfISva6tO3jP/N6PoBrFVDYOn1+jWLw/maiJaEmUr8rRdH7+xUKiCQUdEkIpyKVVlsPjvJqcKLcuYIXikI6iwlSy9iZG1k8dt5d7OdSVyt5hqL6cjFvqbrjAfson+OCcCkPtkVbYA93d5t/Fo3MB1N1oBdxs3OJExqIEiu7irY+KtwBGhWOCprGqCeA8dR5vt4iPNY+8CykDYAFzW9y6/tw+8xETHKsTic5cO8Gg0/E71fEFiyT8HyoWqAoGFw4geUob0l1dfW3RlyhX2EsNr/zDr8nxK5yAK6Xzs7pf81hulX5jaF8rbI3RHQLovq2BDjYdJM6VWAiD0j1A7Ih4OcNhkmcy9vPmLE7z7x1Ovd5tSH1umT9F6VHSfQKbythEV5Q45UT02xNS4x73WqPITbDEUu9CYZm+VYDAZdxEizbtYCQ5rTtg2dOUF0glLVNBdbYuZ7lAdvpkwzdeK zgHMt7ON cLXOXCbtSnbVqcgnCOk0+ELoj0nZdWZyI7sOnwvUxlAVb25Su6zu7VCZPeJFU9s5np+Jfd05rb7/64R6BiN0GplIDYPhqhA2/WQ1Ae+TkudRBEoa/WrxROFNzlB/Ux39IygzH+yAJRD4Iq9PAHcs7IjCXEduHXRHLe736T5/iVUcy6cidTZELvFHecpBfgJqbTtiCzQzYRKcPzzHkq/SFU/cXtb1IzkSl/Vk7VzsHS8Uc4SUchu5Ni8DZHG4r5l/90P4PsC+4ZPrzK2SG/Ruv6rqcQA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025-02-06 15:27:45+0200, Mike Rapoport wrote: > From: Alexander Graf > > This patch adds the core infrastructure to generate Kexec HandOver > metadata. Kexec HandOver is a mechanism that allows Linux to preserve > state - arbitrary properties as well as memory locations - across kexec. > > It does so using 2 concepts: > > 1) Device Tree - Every KHO kexec carries a KHO specific flattened > device tree blob that describes the state of the system. Device > drivers can register to KHO to serialize their state before kexec. > > 2) Scratch Regions - CMA regions that we allocate in the first kernel. > CMA gives us the guarantee that no handover pages land in those > regions, because handover pages must be at a static physical memory > location. We use these regions as the place to load future kexec > images so that they won't collide with any handover data. > > Signed-off-by: Alexander Graf > Co-developed-by: Mike Rapoport (Microsoft) > Signed-off-by: Mike Rapoport (Microsoft) > --- > Documentation/ABI/testing/sysfs-kernel-kho | 53 +++ > .../admin-guide/kernel-parameters.txt | 24 + > MAINTAINERS | 1 + > include/linux/cma.h | 2 + > include/linux/kexec.h | 18 + > include/linux/kexec_handover.h | 10 + > kernel/Makefile | 1 + > kernel/kexec_handover.c | 450 ++++++++++++++++++ > mm/internal.h | 3 - > mm/mm_init.c | 8 + > 10 files changed, 567 insertions(+), 3 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-kernel-kho > create mode 100644 include/linux/kexec_handover.h > create mode 100644 kernel/kexec_handover.c > --- /dev/null > +++ b/include/linux/kexec_handover.h > @@ -0,0 +1,10 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef LINUX_KEXEC_HANDOVER_H > +#define LINUX_KEXEC_HANDOVER_H #include > + > +struct kho_mem { > + phys_addr_t addr; > + phys_addr_t size; > +}; > + > +#endif /* LINUX_KEXEC_HANDOVER_H */ > +static ssize_t dt_read(struct file *file, struct kobject *kobj, > + struct bin_attribute *attr, char *buf, Please make the bin_attribute argument const. Currently both work, but the non-const variant will go away. This way I can test my stuff on linux-next. > + loff_t pos, size_t count) > +{ > + mutex_lock(&kho_out.lock); > + memcpy(buf, attr->private + pos, count); > + mutex_unlock(&kho_out.lock); > + > + return count; > +} > + > +struct bin_attribute bin_attr_dt_kern = __BIN_ATTR(dt, 0400, dt_read, NULL, 0); The new __BIN_ATTR_ADMIN_RO() could make this slightly shorter.