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

Re: [XEN v1] 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: Mon, 12 Dec 2022 19:04:58 +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=KEZXZeErdk83RonLV+Lo70oeJpn/6T2RZsJL5Oy5xp8=; b=Czsyi4DWKYkkxtWI044Rn7L/+DatdkNAGwP0PLaREPtagblOnH5Xq6xuzddQrxW14JczM1DebmfWWggVkGwAfaALnd7FIxoYv6YNc0iLh3j7u10uOxHkp6lrf067OADcsDGUhhOvKAaS41ESs8WahnHp5TFKSQqgmrnPFbGlvHEyK4/ie7PQ3igext407kCKrwrixPIbC1DH6Rl5QbmNYBvPb08QcDkOVyxeyOQ2vkHMe7k6Hq+vwdfUUT2/ps14lh+D7G/bNMbJPkFJazJk8qiqHNy9HWjuMJYCGjujkzrPexYYoYhHOD3oI8YD3YAyX/K9QGcm1c7NwqUdrMDG2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYhnyXMVmvzyoXYPMrQ2V2fLwALrx9ACZVVkyavSCrxMqIqlNy5zS6gjdP6OZxpXxARjNuF4ppFYas9OW4Kh18sey1K5xj+dT6eB1tEo2gilqEA0zJ3yeTxtgbv5GMoCdwmJGg/h9S8Oya3pVqtCTR044iVGdOBkI5tu8HLRjRorf0HD3WJNnCpj4EXe4Di8juoxzg0PJQWDYHoaBLFx4Rj2KWYY6CRrC1G0F7fac2uPahfxAK12gsXyeElj8IOLjGaXCsP8EjCKIxW9TLD/reT2ug9/rvwpyKblID3tDGWpvDCStaVDc9Dc4jjZj3mXl8X7PxiN6/eXs9hRLUaoaQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: sstabellini@xxxxxxxxxx, stefanos@xxxxxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
  • Delivery-date: Mon, 12 Dec 2022 19:05:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 09/12/2022 19:19, Julien Grall wrote:
Hi Ayan,

Hi Julien,

I checked with the Zephyr mantainers. Their response is provided [1].


On 09/12/2022 19:10, Ayan Kumar Halder wrote:
zImage and Image are image protocols, uImage is not. It is just a legacy u-boot header (no requirements \wrt booting,memory,registers, etc.). It can be added on top of anything (even vmlinux or a text file). So I guess this is why Xen states that it supports zImage/Image and does not mention uImage. A header is one thing, the boot requirements are another. Supporting uImage is ok but if we specify
that it must be a u-boot header added on top of zImage/Image.

Let me first confine to Arm32 only.

zephyr.bin has to be loaded at a fixed address with which it has been built.

So, we could either use zImage header (where 'start_address' can be used to specify the load address).

Or uImage (where -a  is used to specify the load address).

Adding uImage header on top of zImage does not make sense.

Now for Arm64,  we do need to parse the zImage header

#ifdef CONFIG_ARM_64
     if ( info->type == DOMAIN_64BIT )
     {
         return info->mem.bank[0].start + info->zimage.text_offset;
     }
#endif

Again, adding uImage header on top of zImage header does not make sense as well.

Also, I believe zImage boot requirements are specific for linux kernel.

Correct. But then this is what Xen tries to adhere to when preparing the guest. So...

zephyr or any other RTOS may not follow the same boot requirements.

... if Zephyr or any other RTOS have different requirements, then we may need to modify Xen.

Can you describe the expectation of Zephyr for the following components:
  - State of the memory/cache:
    * Should the image be cleaned to PoC or more?
        * What about the area not part of the binary (e.g. BSS)?
        * What about the rest of the memory
Zephyr is expected to run as a baremetal binary. When loading from Xen or uboot, the interrupts should be disabled before jumping to Zephyr.

I/D caches need to be disabled as well.

The image should be cleaned to PoC. The BSS is cleared as part of the Zephyr boot process with z_bss_zero() and data is copied with z_data_copy(), see [2] for more details.

  - State of the co-processor registers:
        * Can we call the kernel with I-cache enabled?
I cache needs to be disabled before calling kernel.
        * ...
  - State of the general purpose registers:
        * For instance, Linux expects a pointer to the device-tree in r0

Zephyr does not make any assumption about the state of the GPR at boot. Also, Zephyr is built with a device tree.

- Ayan


Cheers,

[1] https://lists.zephyrproject.org/g/devel/message/8805

[2] https://github.com/zephyrproject-rtos/zephyr/blob/main/arch/arm64/core/prep_c.c#L54
--- Begin Message ---
On 12/12/2022 13:37, Ayan Kumar Halder wrote:
Hi Zephyr Arm Team,

Hello,

A) Zephyr is expected to run as a baremetal binary. When loading
from Xen or uboot, the interrupts should be disabled.

Correct. We disable the interrupts at boot for good measure before but
in theory you want the interrupts to be disabled before jumping to Zephyr.

There is nothing mentioned about the state of caches, but I assume I/D caches will have to be disabled. Otherwise, there is a chance of reading stale instructions from I cache.

Correct. When zephyr is chain-loaded by u-boot we usually disable I/D
caches from u-boot itself before jumping.

The state of the system should be similar to how it is out of reset state (SVC or EL1).

Yes, the only caveat is that in Zephyr you have to set CONFIG_ARMV8_A_NS
whether you are booting from EL3 or EL1.

When Zephyr is loaded in memory, I am expecting the image to be cleaned to PoC. However, I am not very sure on this.

The BSS is cleared as part of the boot process with z_bss_zero() and
data is copied with z_data_copy(), see [1] for more details.

A) I assume I cache needs to be disabled.

Yup.

A) The general purpose registers can be in an in-determinate state.

We do not make any assumption about the state of the GPR at boot. If
there is an hidden dependency, that is a bug to fix.

A) Zephyr is built with a device tree. Thus, it does not expect pre-determined values in r0, r1, etc.

Correct.

Ciao!

[1]
https://github.com/zephyrproject-rtos/zephyr/blob/main/arch/arm64/core/prep_c.c#L54

--
Carlo Caione


--- End Message ---

 


Rackspace

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