[PATCH v2 2/2] ARM: move device tree mapping out of linear region

Nicolas Pitre nico at fluxnic.net
Wed Oct 7 11:28:03 EDT 2020


On Wed, 7 Oct 2020, Ard Biesheuvel wrote:

> @@ -1078,13 +1078,18 @@ void __init hyp_mode_check(void)
>  void __init setup_arch(char **cmdline_p)
>  {
>  	const struct machine_desc *mdesc = NULL;
> +	void *atags_vaddr;
>  
>  	if (__atags_pointer)
> -		atags_vaddr = phys_to_virt(__atags_pointer);
> +		atags_vaddr = FDT_VIRT_ADDR(__atags_pointer);
>  
>  	setup_processor();
> -	if (atags_vaddr)
> +	if (atags_vaddr) {
>  		mdesc = setup_machine_fdt(atags_vaddr);

If __atags_pointer is zero, you'll end up with atags_vaddr being 
undefined here. I'm surprised the compiler didn't warn about that.

> @@ -947,7 +949,7 @@ static void __init create_mapping(struct map_desc *md)
>  		return;
>  	}
>  
> -	if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
> +	if (md->type == MT_DEVICE &&
>  	    md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START &&
>  	    (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
>  		pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",

Hmmm... I wonder why MT_ROM was there in the first place.

Digging into the history of this particular test (which has seen many 
slight variations over the years and could probably be simplified 
further nowdays) I finally found where that MT_ROM condition was 
introduced:

https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=457450ab3b94

Oh well...


Nicolas



More information about the linux-arm-kernel mailing list