From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Fleming Subject: Re: [PATCH] Xen: EFI: Parse DT parameters for Xen specific UEFI Date: Wed, 11 May 2016 13:29:48 +0100 Message-ID: <20160511122948.GV2839@codeblueprint.co.uk> References: <1462523526-3172-1-git-send-email-zhaoshenglong@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-efi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mathieu Poirier Cc: Shannon Zhao , "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , Catalin Marinas , Will Deacon , sstabellini-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, stefano-yd54mjeZNzVBDgjK7y7TUQ@public.gmane.org, julien.grall-5wv7dgnIgG8@public.gmane.org, ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, xen-devel-GuqFBffKawuEi8DpZVb4nw@public.gmane.org, "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, peter.huangpeng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org List-Id: linux-efi@vger.kernel.org On Fri, 06 May, at 09:52:42AM, Mathieu Poirier wrote: > > +static int __init efi_remap_init(void) > > +{ > > + u64 mapsize; > > + > > + pr_info("Remapping and enabling EFI services.\n"); > > + > > + mapsize = memmap.map_end - memmap.map; > > + memmap.map = (__force void *)ioremap_cache(memmap.phys_map, > > + mapsize); > > + if (!memmap.map) { > > + pr_err("Failed to remap EFI memory map\n"); > > + return -ENOMEM; > > + } > > + memmap.map_end = memmap.map + mapsize; > > + efi.memmap = &memmap; > > + > > + efi.systab = (__force void *)ioremap_cache(efi_system_table, > > + sizeof(efi_system_table_t)); > > + if (!efi.systab) { > > Is there a reason why memmap.map isn't iounmap() in the error path? > The original code didn't have it either, hence the question. I suspect that is a bug. In reality, if you can't access the EFI System Table because you fail to map it I would guess you are going to crash very, very quickly anyhow. From mboxrd@z Thu Jan 1 00:00:00 1970 From: matt@codeblueprint.co.uk (Matt Fleming) Date: Wed, 11 May 2016 13:29:48 +0100 Subject: [PATCH] Xen: EFI: Parse DT parameters for Xen specific UEFI In-Reply-To: References: <1462523526-3172-1-git-send-email-zhaoshenglong@huawei.com> Message-ID: <20160511122948.GV2839@codeblueprint.co.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, 06 May, at 09:52:42AM, Mathieu Poirier wrote: > > +static int __init efi_remap_init(void) > > +{ > > + u64 mapsize; > > + > > + pr_info("Remapping and enabling EFI services.\n"); > > + > > + mapsize = memmap.map_end - memmap.map; > > + memmap.map = (__force void *)ioremap_cache(memmap.phys_map, > > + mapsize); > > + if (!memmap.map) { > > + pr_err("Failed to remap EFI memory map\n"); > > + return -ENOMEM; > > + } > > + memmap.map_end = memmap.map + mapsize; > > + efi.memmap = &memmap; > > + > > + efi.systab = (__force void *)ioremap_cache(efi_system_table, > > + sizeof(efi_system_table_t)); > > + if (!efi.systab) { > > Is there a reason why memmap.map isn't iounmap() in the error path? > The original code didn't have it either, hence the question. I suspect that is a bug. In reality, if you can't access the EFI System Table because you fail to map it I would guess you are going to crash very, very quickly anyhow. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752162AbcEKM3x (ORCPT ); Wed, 11 May 2016 08:29:53 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35335 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbcEKM3v (ORCPT ); Wed, 11 May 2016 08:29:51 -0400 Date: Wed, 11 May 2016 13:29:48 +0100 From: Matt Fleming To: Mathieu Poirier Cc: Shannon Zhao , "linux-arm-kernel@lists.infradead.org" , Catalin Marinas , Will Deacon , sstabellini@kernel.org, stefano@aporeto.com, julien.grall@arm.com, ard.biesheuvel@linaro.org, xen-devel@lists.xen.org, "devicetree@vger.kernel.org" , linux-efi@vger.kernel.org, "linux-kernel@vger.kernel.org" , shannon.zhao@linaro.org, peter.huangpeng@huawei.com Subject: Re: [PATCH] Xen: EFI: Parse DT parameters for Xen specific UEFI Message-ID: <20160511122948.GV2839@codeblueprint.co.uk> References: <1462523526-3172-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24+41 (02bc14ed1569) (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 06 May, at 09:52:42AM, Mathieu Poirier wrote: > > +static int __init efi_remap_init(void) > > +{ > > + u64 mapsize; > > + > > + pr_info("Remapping and enabling EFI services.\n"); > > + > > + mapsize = memmap.map_end - memmap.map; > > + memmap.map = (__force void *)ioremap_cache(memmap.phys_map, > > + mapsize); > > + if (!memmap.map) { > > + pr_err("Failed to remap EFI memory map\n"); > > + return -ENOMEM; > > + } > > + memmap.map_end = memmap.map + mapsize; > > + efi.memmap = &memmap; > > + > > + efi.systab = (__force void *)ioremap_cache(efi_system_table, > > + sizeof(efi_system_table_t)); > > + if (!efi.systab) { > > Is there a reason why memmap.map isn't iounmap() in the error path? > The original code didn't have it either, hence the question. I suspect that is a bug. In reality, if you can't access the EFI System Table because you fail to map it I would guess you are going to crash very, very quickly anyhow.