[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN v3] xen/arm: Probe the entry point address of an uImage correctly


  • To: Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Tue, 20 Dec 2022 17:07:41 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=OEhGUn/lQwdw2g/z3zvgUxb3zB1m0xeJzjd34kUn9Gc=; b=aeJWha45xKNNwKwbMj2mppwVpMrNOAC8BrNN9zydhJxG/SY2+33olo7vkrUq/2kEyatRlJtWedbkRNGEkO4/VRwXYCKiYuclY4/qK6V6bCdiSJ+i04zfqIxKMhquv0a/AkV1676gbQjrrJxVeoxLKxYlsL9iXJ+zuJjBc8/r4uaWlbTbxAvQUYPOK8N1Zx3An4NqfawjYGg+E1zdUfAzZp+wWsTzj4NG1+OfCzaqEzZPgyaDALBfKG1vjh+WE3BMBskd6OBxlxJMvs71CmENDy0LMVGK0aW3oWCl3ISeiSDpREGGmyjMudM8Xje01OifpVz85uOwq6NeXoYHtIVzDA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwnT9XFhIFyW8WuGpEdgOSVGePMoWVSuNT/3ky4pH0fxp79nyGslwMVjdFxo+qVCQUI446tJH7Pm+zVrQLJtqipGNnK4H6X8KSNOmsyDK9KkZWJI7T9Lb2dt1AosT00qrevXhCzW6U18aApaockaa9BB3r6WR8Or/PV45Ic3XphfW/B6fOJZ05Ju3OXz4KnConsteU2jrPBz+MBRMDW4G2xEUTEo6Q6Cba7XICiACEzMy3aSRE/yripg9sX/e0W15g8jcP9T2T2NK20rsb02fPACEltjXDsMrDY2zcEC1WoTHLaw12g+BFTcK4GvFKIsUwXFckXWVuMgkzzftkYh9w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: sstabellini@xxxxxxxxxx, stefano.stabellini@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx
  • Delivery-date: Tue, 20 Dec 2022 17:08:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

I need a clarification.

On 20/12/2022 12:51, Ayan Kumar Halder wrote:

On 20/12/2022 12:14, Julien Grall wrote:
Hi Ayan,
Hi Julien,

On 20/12/2022 10:44, Ayan Kumar Halder wrote:
+
+    /*
+     * Currently, we support uImage headers for uncompressed images only. +     * Thus, it is valid for the load address and start address to be the
+     * same. This is consistent with the uboot behavior (Refer
+     * "case IH_COMP_NONE" in image_decomp().
Please make it clear that you are referring to uboot function.

Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).

Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?

I could not find any documentation which states this. I found this from the following in uboot source code.

https://source.denx.de/u-boot/u-boot/-/blob/master/boot/image.c#L458

AFAIU when kernel_uimage_probe() get invoked, the image has already been decompressed. So, I added this as a limitation.

I e looked at the U-boot code and, AFAIU, the check is merely to avoid the memcpy() if the image start matches the start of the decompression area. So I don't understand why we need the limitation in Xen.

Now the lack of documentation (or at least I didn't find any) makes a bit more tricky to understand what the fields in the U-boot header are for. I have skimmed through the code and I disagree with the implementation you chose for Xen.

The comment for 'ih_ep' suggests this is the entry point address. That's may be different from the beginning of your blob. I think this is what ih_load is for.

So I think we want to load the blob at ih_load and then set pc to point to ih_ep. This will require a bit more work in Xen because the assumption so far is the entry point matches the start of the blob.

Please let me known if I missed anything.

I think you are correct. I will rework this to correctly handle load address and entry point.

Is it fine to keep these two constraints ?

    /*
     * While uboot considers 0x0 to be a valid load/start address, for Xen
     * to mantain parity with zimage, we consider 0x0 to denote position
     * independent image. That means Xen is free to load such an image at
     * any valid address.
     * Thus, we will print an appropriate message.
     */
    if ( info->zimage.start == 0 )
        printk(XENLOG_INFO
               "No load address provided. Xen will decide where to load it.\n");

    /*
     * If the image supports position independent execution, then user cannot      * provide an entry point as Xen will load such an image at any appropriate
     * memory address. Thus, we need to return error
     */
    if ( (info->zimage.start == 0) && (info->entry != 0) )
    {
        printk(XENLOG_ERROR
               "Entry point cannot be non zero for PIE image.\n");
        return -EINVAL;
    }

- Ayan


- Ayan


Cheers,




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.