Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1703478rdb; Wed, 31 Jan 2024 06:49:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IH00Za0/G1jUYUbeiSD++ggOeKH6R0X2flcd+DiZPukOgSTefgBbVZvNLnEzJoKjngKGYx3 X-Received: by 2002:a17:906:5acf:b0:a35:fea3:c35a with SMTP id x15-20020a1709065acf00b00a35fea3c35amr1240233ejs.17.1706712591832; Wed, 31 Jan 2024 06:49:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706712591; cv=pass; d=google.com; s=arc-20160816; b=usI07eHOwnAX4+svwx6O4Dk8k5iPxYzn1zddvTirTC5eizy0N0JryYZ4vCHYz3jYwj KLkTRLqquif/R5ndRtLxKqtU6C3pgX/6iFeTj3Y5dFqose3kwFgeWP7cDicFUecpjMmG 4tVBBUh48xq3pwVMRd5z/TCjfMFHES9FjTAZbzK65ex3alrN5E1dzC10VAjXyPKOhRcf qRHKUJUajO7h65gUA43r9swSQ/KohhyWKZVjEMrQVHzMaOLx1UGCnOhWupVW10sJ/U8D nkJcT7ZQyk9VPPsH2X9nFtwhEZ+YXPQmV3OOkCPMgtEV7vxRHscmf2SRtXEahXpi0P7l fE5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dy6Gp2c7mTVA2cLhC90HPq3IvQEQGsGUSctQcwMmri0=; fh=k5fAuBnWxkBoIhNsb7x3/g0tQacGt1rKM7ylM/xrnJw=; b=Vc6SAMo2sdSIMVMmean5caiwOSG3tjr+vFg8VGZq0ZutUIlkyP7FE6wKFot8xQELyV aV5ZH1JRgq/X/1AR+Qh8HFeXHBny6iTUrnCO/eCeCuwnO/oCAW5kFq/NwbbG7k5AJugE 050Ndz8Ez2UIu6IeAZr5QpjbOZnp1hBkdA/bK7L3fNbvukAEVHhcctPkRSEMsYRxHONd 4OW+hQVznwyfCL4jYKD10JMAMCKgVBgmxyHVUKdG93PK3zD32IQCXspe8PYhe4In+iI4 lqHQycUAzQmBmyt+xElG1fm2tsFqiqpZts7AgxyIMumD1wF2ok3EaRVvr3+SfGfnC8Ri S0hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QW+u4gkx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46627-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46627-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUNZatbKUixR3dHX2rzaxTeh3Infs16Ul7evQ/X4zkthTxY3cjNKgD5ZWlILRA9LtEF5GrqD5usIUUzRW18tIqrBk78WUMLU6pHC1Kx/g== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cd21-20020a170906b35500b00a3571c3b695si4006965ejb.629.2024.01.31.06.49.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:49:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46627-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QW+u4gkx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46627-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46627-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8EE8D1F259E4 for ; Wed, 31 Jan 2024 14:49:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD43C84A3C; Wed, 31 Jan 2024 14:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QW+u4gkx" 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 BE81084A25; Wed, 31 Jan 2024 14:49:41 +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=1706712581; cv=none; b=IPjKnuUAKAyQvdmnJVsio/rmvjepDTKYEMXqBQtjYIld+X6cDOSjQgRRTcY+zMa65GEWX6c8C3xJyVzxRazKKpMkL/YHXoZD6m1nY0bqFb5Wk28rdljc6bZSUUoau4EmXsxIiKVPzhkAEE03ZAwtvTzobIV3LKJQItpqnHPxnWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706712581; c=relaxed/simple; bh=2yHAEIfWo9jtDG3p0AkHhbA/aM0nxnP2vXRtqVa7teY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=of1j+/5tEnySYCkBCNiEzjgVL3GOVNdhNCz8HOvDTpQDWSBkaMzdds5kkNG/wVDFNUgWmeGuDM2/aBkUnQFGOd+3vnnpkXze3VL7Lr9TWJnEFixNZY7S+khQZ0Ncv6TQjjonpNonJvf0Yl+81CCX7dueCYmQ9I24p488AbCNDzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QW+u4gkx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDC5CC433C7; Wed, 31 Jan 2024 14:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706712581; bh=2yHAEIfWo9jtDG3p0AkHhbA/aM0nxnP2vXRtqVa7teY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QW+u4gkxi4Y+A1kx9nhpvAQ1EP8rM+k3jqjMGovujJJB59p7806HWkXfBEj0gLi/3 dpE9ybCf48GATqlB1ESTepI2Vpc3Gz5mcuduAC0xO4CA3jImqCFl1onHVBM3vgNgve P7WRiiNDNwbi/bBxQFbHMPjLCcSFpaECoKh3R4IzGBz8kKHS0VLNM+83cFVzXFslcS ElzySdf458R0htk5byWFQGchyYXTxhGF1QstYas278sioSKd3GxQvzlRYyXl412lt1 JdArA3NOIlG6ngKW+zO3XK46/bMum/FZUw4ptS5PISyPW2hhEUfe+LEN6JUngCsW63 Vc+Yrx6EsRs4Q== Date: Wed, 31 Jan 2024 08:49:39 -0600 From: Rob Herring To: Alexander Graf Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kexec@lists.infradead.org, linux-doc@vger.kernel.org, x86@kernel.org, Eric Biederman , "H . Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Steven Rostedt , Andrew Morton , Mark Rutland , Tom Lendacky , Ashish Kalra , James Gowans , Stanislav Kinsburskii , arnd@arndb.de, pbonzini@redhat.com, madvenka@linux.microsoft.com, Anthony Yznaga , Usama Arif , David Woodhouse , Benjamin Herrenschmidt , Krzysztof Kozlowski Subject: Re: [PATCH v3 08/17] arm64: Add KHO support Message-ID: <20240131144939.GA1241147-robh@kernel.org> References: <20240117144704.602-1-graf@amazon.com> <20240117144704.602-9-graf@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240117144704.602-9-graf@amazon.com> On Wed, Jan 17, 2024 at 02:46:55PM +0000, Alexander Graf wrote: > We now have all bits in place to support KHO kexecs. This patch adds > awareness of KHO in the kexec file as well as boot path for arm64 and > adds the respective kconfig option to the architecture so that it can > use KHO successfully. > > Signed-off-by: Alexander Graf > > --- > > v1 -> v2: > > - test bot warning fix > - Change kconfig option to ARCH_SUPPORTS_KEXEC_KHO > - s/kho_reserve_mem/kho_reserve_previous_mem/g > - s/kho_reserve/kho_reserve_scratch/g > - Remove / reduce ifdefs for kho fdt code > --- > arch/arm64/Kconfig | 3 +++ > arch/arm64/kernel/setup.c | 2 ++ > arch/arm64/mm/init.c | 8 ++++++ > drivers/of/fdt.c | 39 ++++++++++++++++++++++++++++ > drivers/of/kexec.c | 54 +++++++++++++++++++++++++++++++++++++++ > 5 files changed, 106 insertions(+) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 8f6cf1221b6a..44d8923d9db4 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -1496,6 +1496,9 @@ config ARCH_SUPPORTS_KEXEC_IMAGE_VERIFY_SIG > config ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG > def_bool y > > +config ARCH_SUPPORTS_KEXEC_KHO > + def_bool y > + > config ARCH_SUPPORTS_CRASH_DUMP > def_bool y > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > index 417a8a86b2db..9aa05b84d202 100644 > --- a/arch/arm64/kernel/setup.c > +++ b/arch/arm64/kernel/setup.c > @@ -346,6 +346,8 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) > > paging_init(); > > + kho_reserve_previous_mem(); > + > acpi_table_upgrade(); > > /* Parse the ACPI tables for possible boot-time configuration */ > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 74c1db8ce271..1a8fc91509af 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -358,6 +358,8 @@ void __init bootmem_init(void) > */ > arch_reserve_crashkernel(); > > + kho_reserve_scratch(); > + > memblock_dump_all(); > } > > @@ -386,6 +388,12 @@ void __init mem_init(void) > /* this will put all unused low memory onto the freelists */ > memblock_free_all(); > > + /* > + * Now that all KHO pages are marked as reserved, let's flip them back > + * to normal pages with accurate refcount. > + */ > + kho_populate_refcount(); > + > /* > * Check boundaries twice: Some fundamental inconsistencies can be > * detected at build time already. > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > index bf502ba8da95..f9b9a36fb722 100644 > --- a/drivers/of/fdt.c > +++ b/drivers/of/fdt.c > @@ -1006,6 +1006,42 @@ void __init early_init_dt_check_for_usable_mem_range(void) > memblock_add(rgn[i].base, rgn[i].size); > } > > +/** > + * early_init_dt_check_kho - Decode info required for kexec handover from DT > + */ > +static void __init early_init_dt_check_kho(void) > +{ > + unsigned long node = chosen_node_offset; > + u64 kho_start, scratch_start, scratch_size, mem_start, mem_size; > + const __be32 *p; > + int l; > + > + if (!IS_ENABLED(CONFIG_KEXEC_KHO) || (long)node < 0) > + return; > + > + p = of_get_flat_dt_prop(node, "linux,kho-dt", &l); These need to be documented. chosen node schema lives in dtschema. > + if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32)) > + return; I would just make all these fixed 64-bit values rather than based on address and size cells. That's what we've done on more recent chosen properties describing regions. Rob