From nobody Fri May 10 20:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1675178092; cv=pass; d=zohomail.com; s=zohoarc; b=jndp6OUXdxGrYVncxpOxb/gbnpv56PEu5Iq7OMd3KGbqzLRNulKwNPue6U4opvyznnsEoq92IZ7j96eqL+F2uG9/gviFwg8HuM2kWv0No+29wm6mmDhSDkNvmjIOyTH2/+5vYXpnBx83biISNM/CHrMFWNSl69zZHfwqTQJlLAQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675178092; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3PnjvfUKhMVAdYzSmtJaKp16nTOZivuM1huY1HnWKtg=; b=YcjY1mG7502bL5JuNT/F00HSfrSPLQ7WDKwKiFsOk/sJ0EW/7UFMT1gwohFXMbK+Uba0jmMJyLrOs6oofc+SXeZYiMzDdkjadt3HcHMQjBkDPg49Aux0cShvkwEAd+SWOsxfqKst9QXGqI4vsZK0MlH+/8lY+qWzVQpQV+EKkR4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1675178092736906.466826301975; Tue, 31 Jan 2023 07:14:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.487704.755370 (Exim 4.92) (envelope-from ) id 1pMsKt-0004PL-TO; Tue, 31 Jan 2023 15:14:15 +0000 Received: by outflank-mailman (output) from mailman id 487704.755370; Tue, 31 Jan 2023 15:14:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pMsKt-0004PE-QA; Tue, 31 Jan 2023 15:14:15 +0000 Received: by outflank-mailman (input) for mailman id 487704; Tue, 31 Jan 2023 15:14:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pMsKr-0004A7-Qq for xen-devel@lists.xenproject.org; Tue, 31 Jan 2023 15:14:13 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060c.outbound.protection.outlook.com [2a01:111:f400:fe59::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ea9867b8-a179-11ed-933c-83870f6b2ba8; Tue, 31 Jan 2023 16:14:13 +0100 (CET) Received: from BN0PR02CA0018.namprd02.prod.outlook.com (2603:10b6:408:e4::23) by SA1PR12MB6871.namprd12.prod.outlook.com (2603:10b6:806:25f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 15:14:09 +0000 Received: from BN8NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e4:cafe::3) by BN0PR02CA0018.outlook.office365.com (2603:10b6:408:e4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 15:14:09 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT065.mail.protection.outlook.com (10.13.177.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.22 via Frontend Transport; Tue, 31 Jan 2023 15:14:08 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 31 Jan 2023 09:14:07 -0600 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 31 Jan 2023 09:14:06 -0600 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ea9867b8-a179-11ed-933c-83870f6b2ba8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eWVB5kY93w5hQ7p1s0ORVx6QjjlvZHxv/mebwjEP6vO7a3wUwB9P28mlNyZU6w1ITR2qhutm6ZwbTMpBO4gy4b3VXKXKtWdSGRGzVRDNI57e0rFVjkZgxpLQg+pNaXnPwc4sfSH7tfvN8cboniisFD16LBkleqP72yDEBgChoqR0MnFKDfuKGmXGYqedkHhtfsogKVqP/TXzCVsAotqP39YcGW07HZVecg9eiDIT1t6nim5ME+eK5bhgQP1fnfpC+tS7fE1GMYcw5thbqxHq0tJ1pPiJH6+g4/IUX9Wqp8KKw023/1IICW9Ly86+pn+9uGvtWZniDgcuGgUwh8sdLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3PnjvfUKhMVAdYzSmtJaKp16nTOZivuM1huY1HnWKtg=; b=LkxqSfSgjCvwFgifLGhqYeuxvVtQDyIhxYw4yb6b3uHCypT8uDnuONuUCreofmYUc+xY3jaeVVpA/nt3nn/fDxCOQfM+oxNh/mjbGd/k+n5e58kAqS3ulXDE1IZFtyCpk69vn29fmKJ58g6ZFfdC1E5+H5js15GDyP3kyABb7kaPIVLbM3MzRaVSxMh5FSkyoBoXElkuvStG+Yp67+5HaDnNFz1UJZ0q44p8qjQILPWenQBkXYSDvRKvIPEFmRPxPK1pxzmhenUcXE7pB659FCw/6BeOPfpQQ2Lh2qNyiCmCZTxhVHJKPwX1rhQgOtmRp6uJU3hqhWnP2+wTmZrp7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3PnjvfUKhMVAdYzSmtJaKp16nTOZivuM1huY1HnWKtg=; b=m8Vebu3HKbEHlAi2S7BFHmqBCdnUqDV2d0qyInj8YVV9pMZA+vsVPSWnci97B9qyffFyIKVT3UgInbbdAnm985PekrHhURiPjwLtPtDnhShioojjxQ9twBkgYEtFyMzaHkW4voqTmxm3mJi8ryKjImCpMndXm+d9OQoH7mkKjhs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Subject: [PATCH 1/2] xen/arm: Move kernel_uimage_probe definition after kernel_decompress Date: Tue, 31 Jan 2023 16:13:53 +0100 Message-ID: <20230131151354.25943-2-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131151354.25943-1-michal.orzel@amd.com> References: <20230131151354.25943-1-michal.orzel@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT065:EE_|SA1PR12MB6871:EE_ X-MS-Office365-Filtering-Correlation-Id: 27b4f85e-0882-4450-51f9-08db039dccca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: byzLgpcIEQu0LTdEyjaeiRJ1vq/vjb5EvNKJlIZX5TD5J2lSgGOmL20MUFkyUOdroiwQU2UMD+ANQuyCVTNouKU/wz8dwcfom4xYSOHiA7jws77xZm+5QNVrIvSx2g8k84LQEyGecfr283DeG/Mv4ARy9vb+iE71O/S8+iPhBtIl8He9a7qRlThFHbTMx7tJZL0WD4RUp9eqIlG+h3vC+BaT2XmrVXj79hwjXOO8g4asg5Bg6zgyAwIQWnyiu1PMMSEtAttRq7OTpQ4o6nc8aiBOkwXUDaKvDbwTzpWadL9yKKGgVDhCDnON7698vSN37+2x5Ei96AwsLElx0KETQ8H0kv00gQOz2Mb2uaKweBVKqLUhydgguLhr+TsirPHQ3yCCXdBcRD5Hcug+87AiF4H1/fVVyb5b1xv6mNEX/cpP4gvyHH1pXxSX98yPV7F5OLBtzoKBdyx7zVVyq8sD1RFKwC5sz4bj5l0VvOdu+6LxH84TdXeoxNEezfkEu7N4EuSWGMmkdhMSL/4Pxf6o5uSVQ6CCodHZkfNuL6Yl3RiRcUIfjHhxZ1gUGelpx8ZEQ9HhKTHLLKpGItJLZRyIuvjy83VbNzmFFYtRRJs8NJPCqfHICjDmR72jqtTyCLPuUK6lUNpXpKX05FnV+V5Wj01xQjwOkynMkQz7F245979EwOG4sQ9XUV+Gv4hPUKjHTrj7f27O2at72y07BNuP4IMASZkav0Wmjs5bspAthEA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199018)(36840700001)(46966006)(40470700004)(44832011)(83380400001)(426003)(86362001)(2616005)(47076005)(336012)(81166007)(82740400003)(82310400005)(356005)(2906002)(36756003)(40460700003)(186003)(1076003)(26005)(36860700001)(478600001)(6666004)(8936002)(4326008)(70206006)(70586007)(41300700001)(40480700001)(8676002)(5660300002)(54906003)(6916009)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 15:14:08.3148 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27b4f85e-0882-4450-51f9-08db039dccca X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6871 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1675178094358100003 Content-Type: text/plain; charset="utf-8" In a follow-up patch, we will be calling kernel_decompress function from within kernel_uimage_probe to support booting compressed images with u-boot header. Therefore, move the kernel_uimage_probe definition after kernel_decompress so that the latter is visible to the former. No functional change intended. Signed-off-by: Michal Orzel Acked-by: Julien Grall Reviewed-by: Ayan Kumar Halder --- xen/arch/arm/kernel.c | 146 +++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 36081e73f140..068fbf88e492 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -186,6 +186,79 @@ static void __init kernel_zimage_load(struct kernel_in= fo *info) iounmap(kernel); } =20 +static __init uint32_t output_length(char *image, unsigned long image_len) +{ + return *(uint32_t *)&image[image_len - 4]; +} + +static __init int kernel_decompress(struct bootmodule *mod) +{ + char *output, *input; + char magic[2]; + int rc; + unsigned int kernel_order_out; + paddr_t output_size; + struct page_info *pages; + mfn_t mfn; + int i; + paddr_t addr =3D mod->start; + paddr_t size =3D mod->size; + + if ( size < 2 ) + return -EINVAL; + + copy_from_paddr(magic, addr, sizeof(magic)); + + /* only gzip is supported */ + if ( !gzip_check(magic, size) ) + return -EINVAL; + + input =3D ioremap_cache(addr, size); + if ( input =3D=3D NULL ) + return -EFAULT; + + output_size =3D output_length(input, size); + kernel_order_out =3D get_order_from_bytes(output_size); + pages =3D alloc_domheap_pages(NULL, kernel_order_out, 0); + if ( pages =3D=3D NULL ) + { + iounmap(input); + return -ENOMEM; + } + mfn =3D page_to_mfn(pages); + output =3D __vmap(&mfn, 1 << kernel_order_out, 1, 1, PAGE_HYPERVISOR, = VMAP_DEFAULT); + + rc =3D perform_gunzip(output, input, size); + clean_dcache_va_range(output, output_size); + iounmap(input); + vunmap(output); + + if ( rc ) + { + free_domheap_pages(pages, kernel_order_out); + return rc; + } + + mod->start =3D page_to_maddr(pages); + mod->size =3D output_size; + + /* + * Need to free pages after output_size here because they won't be + * freed by discard_initial_modules + */ + i =3D PFN_UP(output_size); + for ( ; i < (1 << kernel_order_out); i++ ) + free_domheap_page(pages + i); + + /* + * Free the original kernel, update the pointers to the + * decompressed kernel + */ + fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0); + + return 0; +} + /* * Uimage CPU Architecture Codes */ @@ -289,79 +362,6 @@ static int __init kernel_uimage_probe(struct kernel_in= fo *info, return 0; } =20 -static __init uint32_t output_length(char *image, unsigned long image_len) -{ - return *(uint32_t *)&image[image_len - 4]; -} - -static __init int kernel_decompress(struct bootmodule *mod) -{ - char *output, *input; - char magic[2]; - int rc; - unsigned int kernel_order_out; - paddr_t output_size; - struct page_info *pages; - mfn_t mfn; - int i; - paddr_t addr =3D mod->start; - paddr_t size =3D mod->size; - - if ( size < 2 ) - return -EINVAL; - - copy_from_paddr(magic, addr, sizeof(magic)); - - /* only gzip is supported */ - if ( !gzip_check(magic, size) ) - return -EINVAL; - - input =3D ioremap_cache(addr, size); - if ( input =3D=3D NULL ) - return -EFAULT; - - output_size =3D output_length(input, size); - kernel_order_out =3D get_order_from_bytes(output_size); - pages =3D alloc_domheap_pages(NULL, kernel_order_out, 0); - if ( pages =3D=3D NULL ) - { - iounmap(input); - return -ENOMEM; - } - mfn =3D page_to_mfn(pages); - output =3D __vmap(&mfn, 1 << kernel_order_out, 1, 1, PAGE_HYPERVISOR, = VMAP_DEFAULT); - - rc =3D perform_gunzip(output, input, size); - clean_dcache_va_range(output, output_size); - iounmap(input); - vunmap(output); - - if ( rc ) - { - free_domheap_pages(pages, kernel_order_out); - return rc; - } - - mod->start =3D page_to_maddr(pages); - mod->size =3D output_size; - - /* - * Need to free pages after output_size here because they won't be - * freed by discard_initial_modules - */ - i =3D PFN_UP(output_size); - for ( ; i < (1 << kernel_order_out); i++ ) - free_domheap_page(pages + i); - - /* - * Free the original kernel, update the pointers to the - * decompressed kernel - */ - fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0); - - return 0; -} - #ifdef CONFIG_ARM_64 /* * Check if the image is a 64-bit Image. --=20 2.25.1 From nobody Fri May 10 20:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1675178092; cv=pass; d=zohomail.com; s=zohoarc; b=OnCIzfqutaOsjhVPJe7R+4QZimOoo1ragrwiZ0MvqAAvUdEAk/ZRbqPoA/2e1Zagf6dliywhFgH3wcBnb7TjXVucpMAPVEo/bNxn9TNBB4yazgDDy3bEXZA1voqthGpp9przCu825GwYfXOVLKcjPQUv3QqMfdFjU7Zyww3i1YE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675178092; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JNe9aseWivHMHPuq28/4HWwkjR5Ct14+G2rm7fTg36Y=; b=aIQK1H5WjCMchpyj4NIfw3YcCDEECuAMEm3KngMpy+/2SO2KwB5rvRfNtXHK6j43B8hXByrewI8D0bgDcT3lnxkEyOHs3Frk2yaxH+P+8TdWEn9D7Rg2fg1FdTZnMOQ49Q4yToJHQ+fsykbPas5gEjFgWZgOQzV+TPr+5t/2qzY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1675178092546161.250616066033; Tue, 31 Jan 2023 07:14:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.487705.755382 (Exim 4.92) (envelope-from ) id 1pMsKz-0004gO-7P; Tue, 31 Jan 2023 15:14:21 +0000 Received: by outflank-mailman (output) from mailman id 487705.755382; Tue, 31 Jan 2023 15:14:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pMsKz-0004gB-26; Tue, 31 Jan 2023 15:14:21 +0000 Received: by outflank-mailman (input) for mailman id 487705; Tue, 31 Jan 2023 15:14:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pMsKx-0004eZ-82 for xen-devel@lists.xenproject.org; Tue, 31 Jan 2023 15:14:19 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061e.outbound.protection.outlook.com [2a01:111:f400:7e89::61e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec478786-a179-11ed-b63b-5f92e7d2e73a; Tue, 31 Jan 2023 16:14:16 +0100 (CET) Received: from BN9PR03CA0593.namprd03.prod.outlook.com (2603:10b6:408:10d::28) by CY5PR12MB6323.namprd12.prod.outlook.com (2603:10b6:930:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 15:14:10 +0000 Received: from BN8NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::fb) by BN9PR03CA0593.outlook.office365.com (2603:10b6:408:10d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 15:14:10 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT090.mail.protection.outlook.com (10.13.177.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.22 via Frontend Transport; Tue, 31 Jan 2023 15:14:09 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 31 Jan 2023 09:14:09 -0600 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 31 Jan 2023 09:14:08 -0600 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ec478786-a179-11ed-b63b-5f92e7d2e73a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/XQYafhuPgq7Oph46gN87TD/SGXM7axcGm53RaU9hgENHW/aKejvzcZpvKPjnl4MJAHMhGAsF5mxgkeoO/8FV6gullTGBsFl16psu2/JBS0Btokruc4u5MBxRi+psO+gu3habfIcbkPyXyGasS/FPq+kFg80d48RUIYj+MIy1XQHGQKPD8bLCkgYrWHSSetxDJwmGNhKHfn38Pjgc+hOEqQB+nga2XyzdWDI8IP3lp/pe5be4RsQ2+DJWQmFnxx0T59suAeMG7mrNOskLjIBpThBxj8BxYF8TeUM99Q7mc+fwRNurGjrFLYOW+q7O5qYiWsn9T8O+BcZl6GUrjFPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JNe9aseWivHMHPuq28/4HWwkjR5Ct14+G2rm7fTg36Y=; b=WxTUEwyK9TJdWEZpas6+07qCCr3whDRrcda22U7kISvaZRWuUYedlzhsDi5LlGT+LAUYo+RppODQAzBO9RSOyU0TRPWF00LzWTXOv6VaUOYUU/SVzsWE3kY8CciB9YV5MxKlyUV+/nT6t/x2f880tipCGZpFEoHBX2TREdm9wukWDoLIdjR7jQSQZLfbCBnx5yn1iVmjed9ENSfN5X6YRkM1Cek6LlCZ4fRD/LF3w5s9EXLA8pc9dPNpstEH/ZCJDyxYrHYusB1HSOLrvno0rOzQUQtC32uAPB4kI53aucE07HGNcbQrEX+mMebhZit4AIGuhoB1DQnFvSgDUmDEnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JNe9aseWivHMHPuq28/4HWwkjR5Ct14+G2rm7fTg36Y=; b=FKE04ibgvEz3a84ML11S4OAf5Xv5QPYGyOBePO3rJiIv9n2I0gZjtWu2xnZ/nIiPhs0hAXgdMnBVfcELGDb2VJRxm6kfJg7pIEAC55Tw5fOktDHUrrgZ1OiXFmwJP573TTEv00u6BxzDCLFRKPCODHZXgTwPS9AqPDV5qDIg5GM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Subject: [PATCH 2/2] xen/arm: Add support for booting gzip compressed uImages Date: Tue, 31 Jan 2023 16:13:54 +0100 Message-ID: <20230131151354.25943-3-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131151354.25943-1-michal.orzel@amd.com> References: <20230131151354.25943-1-michal.orzel@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT090:EE_|CY5PR12MB6323:EE_ X-MS-Office365-Filtering-Correlation-Id: 34b32970-ae76-4a0c-534f-08db039dcdc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LOH9+Y8mvLBgKxyxWQe1YKdd3+tQ1Sjaccwtu7cH66guy4EUGE5y8IFP+b9JQ4wubreVpW+Usv+HEGfHptBVT11NlsZDidU5qsAcCeNFqti7aatjVayFDMOZwf/dlbNbqZGB3CxNXaDjlB6O1bSDQa5wzpLaguX5LieptCJDNiAR1/2Y1L9bC9FgvQNlJuSuZg2hm324kUfSj6BExF/0/L8tLUjqOGS5XsOqJEIQgA86qRmzcNRHkRGKc23JKLE279CKgx+NP9X61uhJ9KTYFS1gDqWYIdOBzW0uEbqTgKUIALfKqNBw/NlJXOQOip8ttGdqkfoys0iLZveOUcTiZBEWNTFyrSIMYttOoahujUwAApc18p5tsa1qQ04pONkn9kURaBi1AcIHaaPWskgbPqke9YemL2RVK0wQ3SGRm/Ge1BCD8dlReb5lDzTJX/M1Y0E+1bqR3qv+yBGP0yFnAdc1uyHmZwhzfJyjdvNIpJ6sXH8McVYIl4fvbHsXPglVXRHfzf1Hd9VEDLh7XV5pyzMAlY0HeI4rTmjiIS//r+tDc3yWikpiG5bdwZjYK33rJQlfymKj4BUfYSrN2NB75hWahoSSR1qWjw/YauMmFkrysugvDxQzwKIYUIXaK2NmaPPNfi51QopNUa0BvfszWLn915bP+B9qDp0OegOa9pilxf3GQGrk7bYDHswdKGFtXofFi0waHF7CkEdSY5D684LKXmqYyXvtPL7k44lpRPE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(26005)(186003)(478600001)(6916009)(70206006)(8676002)(83380400001)(6666004)(1076003)(70586007)(316002)(54906003)(4326008)(36860700001)(5660300002)(41300700001)(44832011)(2616005)(82740400003)(8936002)(2906002)(356005)(86362001)(81166007)(82310400005)(336012)(47076005)(426003)(40460700003)(36756003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 15:14:09.9729 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34b32970-ae76-4a0c-534f-08db039dcdc7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6323 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1675178094219100001 Content-Type: text/plain; charset="utf-8" At the moment, Xen does not support booting gzip compressed uImages. This is because we are trying to decompress the kernel before probing the u-boot header. This leads to a failure as the header always appears at the top of the image (and therefore obscuring the gzip header). Move the call to kernel_uimage_probe before kernel_decompress and make the function self-containing by taking the following actions: - take a pointer to struct bootmodule as a parameter, - check the comp field of a u-boot header to determine compression type, - in case of compressed image, modify boot module start address and size by taking the header size into account and call kernel_decompress, - set up zimage.{kernel_addr,len} accordingly, - return -ENOENT in case of a u-boot header not found to distinguish it amongst other return values and make it the only case for falling through to try to probe other image types. This is done to avoid splitting the uImage probing into 2 stages (executed before and after decompression) which otherwise would be necessary to properly update boot module start and size before decompression and zimage.{kernel_addr,len} afterwards. Remove the limitation from the booting.txt documentation. Signed-off-by: Michal Orzel --- docs/misc/arm/booting.txt | 3 --- xen/arch/arm/kernel.c | 51 ++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/docs/misc/arm/booting.txt b/docs/misc/arm/booting.txt index bd7bfe7f284a..02f7bb65ec6d 100644 --- a/docs/misc/arm/booting.txt +++ b/docs/misc/arm/booting.txt @@ -50,9 +50,6 @@ Also, it is to be noted that if user provides the legacy = image header on top of zImage or Image header, then Xen uses the attributes of legacy image header to determine the load address, entry point, etc. =20 -Known limitation: compressed kernels with a uboot headers are not -working. - =20 Firmware/bootloader requirements -------------------------------- diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 068fbf88e492..ea5f9618169e 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -265,11 +265,14 @@ static __init int kernel_decompress(struct bootmodule= *mod) #define IH_ARCH_ARM 2 /* ARM */ #define IH_ARCH_ARM64 22 /* ARM64 */ =20 +/* uImage Compression Types */ +#define IH_COMP_GZIP 1 + /* * Check if the image is a uImage and setup kernel_info */ static int __init kernel_uimage_probe(struct kernel_info *info, - paddr_t addr, paddr_t size) + struct bootmodule *mod) { struct { __be32 magic; /* Image Header Magic Number */ @@ -287,6 +290,8 @@ static int __init kernel_uimage_probe(struct kernel_inf= o *info, } uimage; =20 uint32_t len; + paddr_t addr =3D mod->start; + paddr_t size =3D mod->size; =20 if ( size < sizeof(uimage) ) return -EINVAL; @@ -294,13 +299,21 @@ static int __init kernel_uimage_probe(struct kernel_i= nfo *info, copy_from_paddr(&uimage, addr, sizeof(uimage)); =20 if ( be32_to_cpu(uimage.magic) !=3D UIMAGE_MAGIC ) - return -EINVAL; + return -ENOENT; =20 len =3D be32_to_cpu(uimage.size); =20 if ( len > size - sizeof(uimage) ) return -EINVAL; =20 + /* Only gzip compression is supported. */ + if ( uimage.comp && uimage.comp !=3D IH_COMP_GZIP ) + { + printk(XENLOG_ERR + "Unsupported uImage compression type %"PRIu8"\n", uimage.co= mp); + return -EOPNOTSUPP; + } + info->zimage.start =3D be32_to_cpu(uimage.load); info->entry =3D be32_to_cpu(uimage.ep); =20 @@ -330,8 +343,26 @@ static int __init kernel_uimage_probe(struct kernel_in= fo *info, return -EINVAL; } =20 - info->zimage.kernel_addr =3D addr + sizeof(uimage); - info->zimage.len =3D len; + if ( uimage.comp ) + { + int rc; + + /* Prepare start and size for decompression. */ + mod->start +=3D sizeof(uimage); + mod->size -=3D sizeof(uimage); + + rc =3D kernel_decompress(mod); + if ( rc ) + return rc; + + info->zimage.kernel_addr =3D mod->start; + info->zimage.len =3D mod->size; + } + else + { + info->zimage.kernel_addr =3D addr + sizeof(uimage); + info->zimage.len =3D len; + } =20 info->load =3D kernel_zimage_load; =20 @@ -561,6 +592,16 @@ int __init kernel_probe(struct kernel_info *info, printk("Loading ramdisk from boot module @ %"PRIpaddr"\n", info->initrd_bootmodule->start); =20 + /* + * uImage header always appears at the top of the image (even compress= ed), + * so it needs to be probed first. Note that in case of compressed uIm= age, + * kernel_decompress is called from kernel_uimage_probe making the fun= ction + * self-containing (i.e. fall through only in case of a header not fou= nd). + */ + rc =3D kernel_uimage_probe(info, mod); + if ( rc !=3D -ENOENT ) + return rc; + /* if it is a gzip'ed image, 32bit or 64bit, uncompress it */ rc =3D kernel_decompress(mod); if ( rc && rc !=3D -EINVAL ) @@ -570,8 +611,6 @@ int __init kernel_probe(struct kernel_info *info, rc =3D kernel_zimage64_probe(info, mod->start, mod->size); if (rc < 0) #endif - rc =3D kernel_uimage_probe(info, mod->start, mod->size); - if (rc < 0) rc =3D kernel_zimage32_probe(info, mod->start, mod->size); =20 return rc; --=20 2.25.1