[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: Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Thu, 8 Dec 2022 16:43:16 +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=6uBjLKKpDPL2N6TFYF+fPQL5JbTMW/VvE9QKLNfh9lg=; b=mOG2vQHcYcxGBFgK6lB9NBMqpvupWqSckTXJcb0sPtvDDUumJsYxPkzdk8WkE7MP8YtmNJACPHO6nnE0eHSy156+ReKUinbSKgdMt1Us1LcKbFMkF6vWn1sqWzbhMY/9g7Q+kdCBKlLLd2smRU6Wyxmn1n2AWOuWE/IFxDCbUZzhq4M5JEhftlcFCgMQRsc1VWyu59UXwv+pBmW5s1DGGjF9SqMd0yCUwtUgtoRGHG77EjJvdJ3CpYQ0O9LlfNoPTVB3EoMv6gXUDLGOBv3ui62Gzzno6zQuvXEecJhW8BRp8fhXEZFnz5PWL/l646OspscTkJzeYFSiZGp2rKyDJg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ineSjuaZmzKVlRlQgXmiDYBQ2y8yJEPFltHGumnM6Syu+mGxYC1ADcynl6D2G1lLQVTQJvYfBVtHmf3QKQZ+22khvULvUt4XGeeYVz9ArfYgB/YQgJHLB/vQzxoxkF7ykzuvE9BjyliI4gc6KuTKczqaFT6akujcseoUu9RCWka/q5qzmupAcGmjEz/UIk9rJpN2/xsfywUC2PZWuvy7TsU3+xuFDgoFquOyXqaTC9jEJRxDWPQ0vjUFWWK0HVYecZb7weHOwy82Sb2F/Syl+xlz96ZIMwYdb2zv+fjEHC1o8SXpYNZ6/r6iDssw3rSmfbBLtp8AgkeB3QRODtL+2A==
  • 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: Thu, 08 Dec 2022 16:43:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 08/12/2022 15:24, Michal Orzel wrote:
Hi,
Hi,

On 08/12/2022 14:51, Julien Grall wrote:
Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


Hi,

Title extra NIT: I have seen it multiple time and so far refrain to say
it. Please use 'arm' rather than 'Arm'. This is for consistency in the
way we name the subsystem in the title.

On 08/12/2022 12:49, Ayan Kumar Halder wrote:
Currently, kernel_uimage_probe() does not set info->zimage.start. As a
result, it contains the default value (ie 0). This causes,
kernel_zimage_place() to treat the binary (contained within uImage) as
position independent executable. Thus, it loads it at an incorrect address.

The correct approach would be to read "uimage.ep" and set
info->zimage.start. This will ensure that the binary is loaded at the
correct address.
In non-statically allocated setup, a user doesn't know where the memory
for dom0/domU will be allocated.

So I think this was correct to ignore the address. In fact, I am worry
that...

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---

I uncovered this issue while loading Zephyr as a dom0less domU with Xen on
R52 FVP. Zephyr builds with static device tree. Thus, the load address is
always fixed.

   xen/arch/arm/kernel.c | 2 ++
   1 file changed, 2 insertions(+)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index 2556a45c38..e4e8c67669 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -222,6 +222,8 @@ static int __init kernel_uimage_probe(struct kernel_info 
*info,
       if ( len > size - sizeof(uimage) )
           return -EINVAL;

+    info->zimage.start = be32_to_cpu(uimage.ep);
... this will now ended up to break anyone that may have set an address
but didn't care where it should be loaded.

I also understand your use case but now, we have contradictory
approaches. I am not entirely sure how we can solve it. We may have to
break those users (Cc some folks that may use it). But we should figure
out what is the alternative for them.

If we decide to break those users, then this should be documented in the
commit message and in docs/misc/arm/booting.txt (which interestingly
didn't mention uImage).

So the first issue with Zephyr is that it does not support zImage protocol for 
arm32.
Volodymyr added support only for Image header for arm64 Zephyr.
I guess this is why Ayan, willing to boot it on Xen (arm32), decided to add 
u-boot header.

Now, there is also a question about supporting arm64 uImage kernels. In Xen 
kernel_zimage_place,
we do:
#ifdef CONFIG_ARM_64
     if ( info->type == DOMAIN_64BIT )
         return info->mem.bank[0].start + info->zimage.text_offset;
#endif

So if we modify the uImage behavior for arm32, we will break consistency with 
arm64
(we would take uImage entry point address into account for arm32 but not for 
arm64).
At the moment at least they are in sync.

IIUC, at present arm64 and arm32 are not in sync.

For Arm32, we do not consider "info->zimage.text_offset".

- Ayan



Cheers,

--
Julien Grall
~Michal



 


Rackspace

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