From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934187AbcIAQFJ (ORCPT ); Thu, 1 Sep 2016 12:05:09 -0400 Received: from sender153-mail.zoho.com ([74.201.84.153]:21608 "EHLO sender153-mail.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933937AbcIAQFE (ORCPT ); Thu, 1 Sep 2016 12:05:04 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=subject:to:references:cc:from:message-id:date:user-agent:mime-version:in-reply-to:content-type; b=eBcZ9mmyhOKBNdj0WITTqnAd6td1dI5EsFbXi6yZ/4/b6IsUiBvjs4tMH+9aObiDy2bjwJs9FRX7 XcSFGcFt80C27eGSYSqLmDkoNMVnjdrmG3j8WIeegeRd4uBWdYv6 Subject: Re: [PATCH 2/2] arm64: regard FDT_SW_MAGIC as good fdt magic To: Mark Rutland References: <20160901112113.GA4220@leverpostej> Cc: zijun_hu@htc.com, catalin.marinas@arm.com, will.deacon@arm.com, robh+dt@kernel.org, frowand.list@gmail.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: zijun_hu Message-ID: <57C8516E.7000105@zoho.com> Date: Fri, 2 Sep 2016 00:03:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160901112113.GA4220@leverpostej> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/01/2016 07:21 PM, Mark Rutland wrote: > On Thu, Sep 01, 2016 at 06:58:29PM +0800, zijun_hu wrote: >> From: zijun_hu >> >> regard FDT_SW_MAGIC as good fdt magic during mapping fdt area >> see fdt_check_header() for details > > It looks like we should only see FDT_SW_MAGIC for a FDT that was in the > process of being created, but was not finished. So I'm somewhat confused > as to why fdt_check_header() would allow this. > > Neither ePAPR nor the new devicetree spec define FDT_SW_MAGIC. They both > only define 0xd00dfeed as a valid magic value. In libfdt, FDT_SW_MAGIC > is an internal constant, and it looks like fdt_check_header() simply > accepts this for convenience within libfdt. > > Given all of that, it looks like the kernel should *not* accept > FDT_SW_MAGIC in any case. > > Why do you think this is necessary? Have you seen a problem in practice? > i don't understand function modules involved with FDT_SW_MAGIC very well i just think it isn't a bad thing to keep consistent with fdt_check_header() no, i have no problem about fdt magic in practice BTW it seems FDT_SW_MAGIC is involved in fdt_create_empty_tree()@fdt_sw.c which operate fdt in runtime in kernel, this function is used in drivers/firmware/efi/libstub/fdt.c in u-boot, in arch/sandbox/cpu/cpu.c an arch/sandbox/cpu/state.c the sources mentioned above maybe help you for further decision >> --- a/scripts/dtc/libfdt/fdt.h >> +++ b/scripts/dtc/libfdt/fdt.h >> @@ -92,7 +92,8 @@ struct fdt_property { >> >> #endif /* !__ASSEMBLY */ >> >> -#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ >> +/* 4: version, 4: total size */ >> +#define FDT_MAGIC ((fdt32_t)0xd00dfeed) >> #define FDT_TAGSIZE sizeof(fdt32_t) >> >> #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ >> diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h >> index 59ca33976e56..6998f9249183 100644 >> --- a/scripts/dtc/libfdt/libfdt.h >> +++ b/scripts/dtc/libfdt/libfdt.h >> @@ -54,6 +54,8 @@ >> #include "libfdt_env.h" >> #include "fdt.h" >> >> +#define FDT_SW_MAGIC (~FDT_MAGIC) >> + >> #define FDT_FIRST_SUPPORTED_VERSION 0x10 >> #define FDT_LAST_SUPPORTED_VERSION 0x11 >> >> diff --git a/scripts/dtc/libfdt/libfdt_internal.h b/scripts/dtc/libfdt/libfdt_internal.h >> index 02cfa6fb612d..f4efde0119f2 100644 >> --- a/scripts/dtc/libfdt/libfdt_internal.h >> +++ b/scripts/dtc/libfdt/libfdt_internal.h >> @@ -90,6 +90,4 @@ static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n) >> return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n); >> } >> >> -#define FDT_SW_MAGIC (~FDT_MAGIC) >> - >> #endif /* _LIBFDT_INTERNAL_H */ > > Regardless of the above, changes to libfdt must happen in the upstream > libfdt codebase first. okay, make sense FDT team maybe help decide whether to expose FDT_SW_MAGIC to users > > Thanks, > Mark. >