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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F75BCFB449 for ; Mon, 7 Oct 2024 15:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TXLByxgQO38tEiqRKfkJDtPyksE44EY2/93lJNbxUPM=; b=ngc4K0qm16s5HfJvmHhN9mhgkl 3aLNoMu0/TpvQCBn7T8m7xu7MT6aT1ZOCbWXvTnWw22pJoPQ2dkC2GlpIYzbJx/9EWUvRvTrVCcEI hlkb9xcWc8pUplwHZB0n2045Thp0wiB0nyschXkkRNbKq2a/877g9pjalrY084OYhQsgHFmgH78NH Ps5LtWsEijwjuK+cWLHLRQWxcLl5FRQiPeRk80eYVLTuyLyHmtLUqWnyLvbZqLPehwi36KFIX3I/s NfP3N0s+teG23yPYa6A1mFWelCEdec2LS5TunvR3W/dfsmRU3W3W6ehfM53U+wlk9cL+wmFvZw+Uj jvLfi6dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxpjA-00000002xhf-28FP; Mon, 07 Oct 2024 15:32:52 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxpgm-00000002x26-1cgQ; Mon, 07 Oct 2024 15:30:25 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2fabfc06c26so39897491fa.2; Mon, 07 Oct 2024 08:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728315022; x=1728919822; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TXLByxgQO38tEiqRKfkJDtPyksE44EY2/93lJNbxUPM=; b=PnbR9tovCsb6c83u+EXG7lZqxtInqvkDNSIJrfsshiFOoHlmOeS5tzvGDFRWC5RjAY zVbdo4npxyMz/AO9NIev+LwqBG5tu37vcISdPk/TmDfqQlxI9i5DmCdzlohJyY8n+9u+ 3ZP+aMjEogsn/NJZzjuloZm6Vd855rDd/Ezp16bIgIEwJ8KbKGvuFvn4utzDE8g8uY2y cs+FG7B5dKy19WRdcLui0ssT+N0UUcg5Q5mN7NnDr2XdPFPBawDrhDRtLU6o6OLMhBMZ L1Vki0jqDYZ5QEms7tzGHfXwL4nXot953Btryx3BkwRmUzIiIeuIL8NtouEMo8RuUxv1 MQPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728315022; x=1728919822; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TXLByxgQO38tEiqRKfkJDtPyksE44EY2/93lJNbxUPM=; b=jC0lu8u7yDf5NBSV9qId5hfPTVeHeCC6JvqroWlReQS/aoS6AC8iC66wDqn0+4EiJS 9LKHVme93/A+juM+ssfDyXXF13g1vq0Ztrk9cGPZ00KRFaBgLqh7WrSrnablIq6VGTYA VDv0KLB6cz6mVkmkRnMAZRJGvG6XT8O00TtVoeaoZyGuU5YOHr71CMNUe1JG3QMN1N5B 4/SUE0Iey6qx8/A7Tayw2mwhdxzDTS+eFWL7SG2m5to3onuE9UZVZNO2A3Eq/7ah/3+3 VV2VPXFvMHjlSswtSgnob7LxjDuJtSflt5Gf7cpCinpOjMILMQj2T+PG5HUZkMM6kqY5 O2NQ== X-Forwarded-Encrypted: i=1; AJvYcCVN1gY34lrRfKuhIFAFxWIIWP8I3s+1BlntOZjPjiGn2+TKNwTa8CLgOtJBBUSkbnWFnRRMbUxVIsELLc91UH/ZuQ==@lists.infradead.org, AJvYcCXIv+Ge0tVLZ7j6gehyXKTalpZwq5haBOmGGAO57KoHjoIQjVonYz7spjhZSN2sPeeACYqt2w==@lists.infradead.org X-Gm-Message-State: AOJu0YwYMvRr9N63+c3VjjioL/Y4U5cXsN1vYTD66WcV/ltAjmnoYFvU TRqNQXG/4O6S2j9U2DG7VfRWuGRnBYAgA9MGDVAwtDyNkNGLZZho2VBntQ== X-Google-Smtp-Source: AGHT+IFzFcHLeJlu8dAi5eLHYzBkuPCqoVEGXKOk00hKW7JHJg1u6N9K9qAJKE3PQff6BeCe5jf0bg== X-Received: by 2002:a05:6402:13cd:b0:5c4:a6f:9be7 with SMTP id 4fb4d7f45d1cf-5c8d2e397c1mr12425589a12.8.1728315009552; Mon, 07 Oct 2024 08:30:09 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1126:4:eb:d0d0:c7fd:c82c? ([2620:10d:c092:500::4:3232]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05eb5ebsm3426058a12.65.2024.10.07.08.30.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2024 08:30:09 -0700 (PDT) Message-ID: <4b9456a3-47ea-4a00-92fe-131ccd80e550@gmail.com> Date: Mon, 7 Oct 2024 16:30:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] of/kexec: save pa of initial_boot_params for arm64 and use it at kexec To: Rob Herring Cc: mark.rutland@arm.com, will@kernel.org, leitao@debian.org, catalin.marinas@arm.com, saravanak@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kexec@lists.infradead.org References: <20241003113840.2972416-1-usamaarif642@gmail.com> <20241004000316.GA1910499-robh@kernel.org> Content-Language: en-US From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241007_083024_450285_90740659 X-CRM114-Status: GOOD ( 25.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 07/10/2024 15:39, Rob Herring wrote: > On Mon, Oct 7, 2024 at 9:06 AM Usama Arif wrote: >> >> >> >> On 04/10/2024 01:03, Rob Herring wrote: >>> On Thu, Oct 03, 2024 at 12:38:40PM +0100, Usama Arif wrote: >>>> __pa() is only intended to be used for linear map addresses and using >>>> it for initial_boot_params which is in fixmap for arm64 will give an >>>> incorrect value. Hence stash the physical address when it is known at >>>> boot time and use it at kexec time instead of converting the virtual >>>> address using __pa(). >>>> >>>> Reported-by: Breno Leitao >>>> Suggested-by: Mark Rutland >>>> Signed-off-by: Usama Arif >>>> Fixes: ac10be5cdbfa ("arm64: Use common of_kexec_alloc_and_setup_fdt()") >>>> --- >>>> arch/arm64/kernel/setup.c | 8 ++++++++ >>>> drivers/of/fdt.c | 6 ++++++ >>>> drivers/of/kexec.c | 8 ++++++-- >>>> include/linux/of_fdt.h | 2 ++ >>>> 4 files changed, 22 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c >>>> index b22d28ec8028..a4d96f5e2e05 100644 >>>> --- a/arch/arm64/kernel/setup.c >>>> +++ b/arch/arm64/kernel/setup.c >>>> @@ -194,6 +194,14 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys) >>>> /* Early fixups are done, map the FDT as read-only now */ >>>> fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); >>>> >>>> + /* >>>> + * Save dt_phys address so that it can be used later for kexec. This >>>> + * is done as __pa() is only intended to be used for linear map addresses >>>> + * and using it for initial_boot_params which is in fixmap will give an >>>> + * incorrect value. >>>> + */ >>>> + set_initial_boot_params_pa(dt_phys); >>> >>> No new arch->dt functions please. If we need to save off the PA, then do >>> that when we set initial_boot_params. >>> >>> Rob >> >> >> initial_boot_params is set in early_init_dt_verify, called by early_init_dt_scan. >> This is done in setup_machine_fdt in arm64 where the PA is available, >> but in other functions in other architectures, where the PA is not available. > > Doesn't __pa() work for all the other architectures? That's what your > patch indicates. > Yes, __pa() works for all other architectures. But we would need to add initial_boot_params_pa of type phys_addr_t as an argument for early_init_dt_scan, which is called by all other archs, and we technically cant use 0 as an invalid value. We could convert initial_boot_params_pa to void *, and pass NULL for all other archs. But again, I don't really think we should be changing the early_init_dt_scan(dt_virt) call in all other archs to early_init_dt_scan(dt_virt, NULL) just to save initial_boot_params_pa in arm64? >> So it makes it quite messy to set it in the same place as initial_boot_params. >> Its only needed for arm64 and making a change in all archs probably isnt a good idea? >> >> Any reason to not add a new function to make arch -> of/fdt call? > > Yes. It is the opposite direction I have reworked the interfaces to. > We don't want each arch calling various early DT functions at random > times and order. That's fragile when the DT functions make assumptions > about when they are called or what's been initialized already. > > Another option is to make arm64 copy the DT as some arches do. > > Rob Ah maybe I didn't understand this properly, but isnt early_init_dt_scan an arch -> of/fdt interfaces. set_initial_boot_params_pa is a similar interface to early_init_dt_scan?