From patchwork Mon Jul 2 16:19:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 140827 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp139939ljj; Mon, 2 Jul 2018 09:21:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf/x5miXT5JleFFXgPvxlWZwRNcU2oIlsx+HecKXyxuuQSsZtDlI64PPS3z7dMS2VVKc8vU X-Received: by 2002:a24:6ed0:: with SMTP id w199-v6mr6630238itc.65.1530548497027; Mon, 02 Jul 2018 09:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530548497; cv=none; d=google.com; s=arc-20160816; b=kpaoL+FL9vvtSY77QDlmjwq/VaTFAvhdCKCK5QSInmHwBl5vZ6Nwrgf5bhLH7vPTnF Dl+bsdf0BtQ8O2VUiujX3x4LS+Jd6QygrQBTBTlPFWQWrf698E4mZ84DhMyygToxK0Xz b7uOkPpvkbwA36jzIWFp7Z1Ob055A1ZqeVfl9v73xQ7cS12LT9jmRgQsYvEXBVusLqMU cM8DCOyWoSWwQz88PgQAMIgnezuWOa5ANxUS200QYvijvU+99DQ121gR0rzO/G57KW+7 frGCIuy4y/uGZp09uY6vQOfHZz5SKWAw0xSBYr00rnXReCASfLnkoJpBbgipT7i875NV IlmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=yrzlOED1hRj9I4IOh9+k3EUQr+j+I2RQNE5/iEXiB5k=; b=lswfgaO0Ape/cmxLEGh03+UMzVj0MY3h+YklPwPXv4hD3kSXjUKRetDvPm9mcdhImx 1UoR7raE9gJhyQOdlfSXyt7qEYeMRUMTuTr4Zjw12D6m2mSinHclFmlhqKDKK3wN6q82 7dFfoRlNFh2sQh4lB1z/tTLDE5hBvNUHxEChu81bucE/jut9MeZBreV2BXgLy8DJ3Yow jStzg2PiuutoswCbR/ARjNh3sWBgq7Z1Gs+lwLjNXEvkuyKV5mz0FgmA16r0J7lrBeaU AVSKl4Lfvg4cjoKsF+sphU5jf4qFgmBoL0ElEF0bgbZPVEdN4C4Xuk9WAEP95ufpG/UW nhwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q80-v6si8328202ioe.237.2018.07.02.09.21.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 09:21:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fa1Xx-0006q1-4L; Mon, 02 Jul 2018 16:19:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fa1Xv-0006p0-Gs for xen-devel@lists.xen.org; Mon, 02 Jul 2018 16:19:23 +0000 X-Inumbo-ID: b0089c6f-7e13-11e8-ba45-cfc176a5991c Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id b0089c6f-7e13-11e8-ba45-cfc176a5991c; Mon, 02 Jul 2018 16:19:25 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CA2341529; Mon, 2 Jul 2018 09:19:22 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F87B3F5BA; Mon, 2 Jul 2018 09:19:21 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Jul 2018 17:19:07 +0100 Message-Id: <20180702161910.2013-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180702161910.2013-1-julien.grall@arm.com> References: <20180702161910.2013-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 4/7] xen/arm: Drop support for loading ELF Dom0 kernel X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , Stefano Stabellini MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The code has been around since the beginning of Xen Arm. However, I am not aware of any user and the code is pretty bogus: 1) It is assuming virtual address == physical address. 2) The cache is not cleaned after the Image is loaded but the Image is started with Cache disabled. 3) There are not clear ABI with the guest. Xen is currently supporting 3 other formats (zImage, Image, U-boot Image) as well as gzip compressed version of each formats. All of them are well documented and widely use. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Given the state, I doubt anyone is using the ELF format with Xen on Arm. By dropping this code, it also allows us to remove the built-in libelf (~1.2K lines) from Xen. Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/kernel.c | 77 --------------------------------------------------- xen/arch/arm/kernel.h | 10 +------ 2 files changed, 1 insertion(+), 86 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index b29028f7d0..000d9397e1 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -421,81 +421,6 @@ static int __init kernel_zimage32_probe(struct kernel_info *info, return 0; } -static void __init kernel_elf_load(struct kernel_info *info) -{ - /* - * TODO: can the ELF header be used to find the physical address - * to load the image to? Instead of assuming virt == phys. - */ - info->entry = info->elf.parms.virt_entry; - - place_modules(info, - info->elf.parms.virt_kstart, - info->elf.parms.virt_kend); - - printk("Loading ELF image into guest memory\n"); - info->elf.elf.dest_base = (void*)(unsigned long)info->elf.parms.virt_kstart; - info->elf.elf.dest_size = - info->elf.parms.virt_kend - info->elf.parms.virt_kstart; - - elf_load_binary(&info->elf.elf); - - printk("Free temporary kernel buffer\n"); - free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order); -} - -static int __init kernel_elf_probe(struct kernel_info *info, - paddr_t addr, paddr_t size) -{ - int rc; - - memset(&info->elf.elf, 0, sizeof(info->elf.elf)); - - info->elf.kernel_order = get_order_from_bytes(size); - info->elf.kernel_img = alloc_xenheap_pages(info->elf.kernel_order, 0); - if ( info->elf.kernel_img == NULL ) - panic("Cannot allocate temporary buffer for kernel"); - - copy_from_paddr(info->elf.kernel_img, addr, size); - - if ( (rc = elf_init(&info->elf.elf, info->elf.kernel_img, size )) != 0 ) - goto err; -#ifdef CONFIG_VERBOSE_DEBUG - elf_set_verbose(&info->elf.elf); -#endif - elf_parse_binary(&info->elf.elf); - if ( (rc = elf_xen_parse(&info->elf.elf, &info->elf.parms)) != 0 ) - goto err; - -#ifdef CONFIG_ARM_64 - if ( elf_32bit(&info->elf.elf) ) - info->type = DOMAIN_32BIT; - else if ( elf_64bit(&info->elf.elf) ) - info->type = DOMAIN_64BIT; - else - { - printk("Unknown ELF class\n"); - rc = -EINVAL; - goto err; - } -#endif - - info->load = kernel_elf_load; - - if ( elf_check_broken(&info->elf.elf) ) - printk("Xen: warning: ELF kernel broken: %s\n", - elf_check_broken(&info->elf.elf)); - - return 0; -err: - if ( elf_check_broken(&info->elf.elf) ) - printk("Xen: ELF kernel broken: %s\n", - elf_check_broken(&info->elf.elf)); - - free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order); - return rc; -} - int __init kernel_probe(struct kernel_info *info) { struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_KERNEL); @@ -528,8 +453,6 @@ int __init kernel_probe(struct kernel_info *info) rc = kernel_uimage_probe(info, mod->start, mod->size); if (rc < 0) rc = kernel_zimage32_probe(info, mod->start, mod->size); - if (rc < 0) - rc = kernel_elf_probe(info, mod->start, mod->size); return rc; } diff --git a/xen/arch/arm/kernel.h b/xen/arch/arm/kernel.h index 6d695097b5..47eacb5ba9 100644 --- a/xen/arch/arm/kernel.h +++ b/xen/arch/arm/kernel.h @@ -6,7 +6,6 @@ #ifndef __ARCH_ARM_KERNEL_H__ #define __ARCH_ARM_KERNEL_H__ -#include #include #include @@ -45,13 +44,6 @@ struct kernel_info { #endif paddr_t start; /* 32-bit zImage only */ } zimage; - - struct { - struct elf_binary elf; - struct elf_dom_parms parms; - unsigned kernel_order; - void *kernel_img; - } elf; }; }; @@ -60,7 +52,7 @@ struct kernel_info { * * Sets in info: * ->type - * ->load hook, and sets loader specific variables ->{zimage,elf} + * ->load hook, and sets loader specific variables ->zimage */ int kernel_probe(struct kernel_info *info);