Skip to contentSkip to conversation

Unable to use EFI firmware in Xen ARM guest after 41f8901

DISCUSSION Julien Grall 5 participants 8 messages Oct 1, 2015 – Oct 2, 2015 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

We tried today to use the UEFI binary provided by Linaro for Xen [1] and noticed the guest doesn't boot anymore.

My bisector fingered the commit 41f890164bc201f69841309c6b55e24c64121960 "ArmPkg/Mmu: Fix literal number left shift bug".

I've tried to use the DEBUG firmware but didn't get any output at all.

The guest has been created with 512MB in one memory bank (0x40000000-0x60000000). The binary are loaded at:
UEFI firmware: 0x40080000
DTB: 0x48000000

Does anyone have any insight what could go wrong?

Regards,

[1]
http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/282/XEN-AARCH64/

Signature · 1 line
Julien Grall
#1 lore raw
Quoted 5 lines · Julien Grall

Hi,

We tried today to use the UEFI binary provided by Linaro for Xen [1] and noticed the guest doesn't boot anymore.

Thanks for reporting. My LAVA job appears to have been offline for a while because the Xen mustang dom0 kernel has disappeared.

Quoted 3 lines

My bisector fingered the commit 41f890164bc201f69841309c6b55e24c64121960 "ArmPkg/Mmu: Fix literal number left shift bug".

Do you mean reverting just this patch fixes it for you?

Quoted 9 lines

I've tried to use the DEBUG firmware but didn't get any output at all.

The guest has been created with 512MB in one memory bank (0x40000000-0x60000000). The binary are loaded at:

   UEFI firmware: 0x40080000
   DTB: 0x48000000

Does anyone have any insight what could go wrong?

I will investigate. The change itself seems obviously correct (but don't they always :-))

Signature · 1 line
Ard.

A message that is not in the archive (sent off-list or not yet received): CAKv+Gu8qQiO3W22u8i4bFfGdy-vuQozA6L8Kb0YC2Jv-Gihftg@mail.gmail.com

#3 lore raw
Quoted 10 lines · Ard Biesheuvel
Quoted 5 lines · Julien Grall

Hi,

We tried today to use the UEFI binary provided by Linaro for Xen [1] and noticed the guest doesn't boot anymore.

Thanks for reporting. My LAVA job appears to have been offline for a while because the Xen mustang dom0 kernel has disappeared.

FWIW, everything to support X-gene and Xen should be upstreamed. So you could use a normal Linux for Dom0.

FIY, Im planning to add a test in our CI loop to check the UEFI firmware.

Quoted 6 lines
Quoted 4 lines

My bisector fingered the commit 41f890164bc201f69841309c6b55e24c64121960 "ArmPkg/Mmu: Fix literal number left shift bug".

Do you mean reverting just this patch fixes it for you?

Yes, building the UEFI with the commit just before allows me to reach the UEFI console.

Quoted 7 lines
Quoted 7 lines

I've tried to use the DEBUG firmware but didn't get any output at all.

The guest has been created with 512MB in one memory bank (0x40000000-0x60000000). The binary are loaded at:

   UEFI firmware: 0x40080000
   DTB: 0x48000000
Quoted 5 lines
Quoted 2 lines

Does anyone have any insight what could go wrong?

I will investigate. The change itself seems obviously correct (but don't they always :-))

Thank you!

Regards,

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 10 lines · Julien Grall
Quoted 8 lines · Ard Biesheuvel
Quoted 5 lines · Julien Grall

Hi,

We tried today to use the UEFI binary provided by Linaro for Xen [1] and noticed the guest doesn't boot anymore.

Quoted 8 lines
Quoted 2 lines

Thanks for reporting. My LAVA job appears to have been offline for a while because the Xen mustang dom0 kernel has disappeared.

FWIW, everything to support X-gene and Xen should be upstreamed. So you could use a normal Linux for Dom0.

FIY, Im planning to add a test in our CI loop to check the UEFI firmware.

Great! Would be good to have some independent verification, especially since the (lack of) CI-to-LAVA integration still requires me to go look at the artifacts manually.

Quoted 23 lines
Quoted 6 lines
Quoted 4 lines

My bisector fingered the commit 41f890164bc201f69841309c6b55e24c64121960 "ArmPkg/Mmu: Fix literal number left shift bug".

Do you mean reverting just this patch fixes it for you?

Yes, building the UEFI with the commit just before allows me to reach the UEFI console.

Quoted 12 lines
Quoted 9 lines

I've tried to use the DEBUG firmware but didn't get any output at all.

The guest has been created with 512MB in one memory bank (0x40000000-0x60000000). The binary are loaded at:

   UEFI firmware: 0x40080000
   DTB: 0x48000000

Does anyone have any insight what could go wrong?

I will investigate. The change itself seems obviously correct (but don't they always :-))

OK, so the change was obviously correct, but the rest of the code is not.

Instead of erroneously mapping large naturally aligned regions down to 2 MB blocks, the MMU code now notices that the single cacheable 1:1 memory region that I define for Xen domU [which spans the entire (I)PA space] could potentially be mapped using level 0 block entries of 512 GB each. Only, the architecture does not actually support that.

Could you please try this patch and see if it fixes things?

--------8<----------

(quoted diff) +0 -0

b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
index d98769b06b75..c84c872dbe60 100644

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +1 -2
@@ -303,8 +303,9 @@ GetBlockEntryListFromAddress (
     }
   }
 
-  // Identify the Page Level the RegionStart must belongs to
-  PageLevel = 3 - ((BaseAddressAlignment - 12) / 9);
+  // Identify the Page Level the RegionStart must belong to. Note

that PageLevel
+ // should be at least 1 since block translations are not supported at level 0
+ PageLevel = MAX (3 - ((BaseAddressAlignment - 12) / 9), 1);

// If the required size is smaller than the current block size then
we need to go to the page below.
// The PageLevel was calculated on the Base Address alignment but
did not take in account the alignment
--------8<----------

As an aside, it is probably not necessary to make the 1:1 region as large as I am doing, especially since it now turns out that we need to map it in 1 GB blocks and use 4 levels. Is there any reasonable upper bound to the domU PA space other than what is communicated in the ID registers?

Signature · 1 line
Ard.

A message that is not in the archive (sent off-list or not yet received): CAKv+Gu-cPMdpcKvY0cR=vJOsE5B7CcqNMB=7xVHKo41FkLSVVw@mail.gmail.com

#6 lore raw
Quoted 2 lines · Ard Biesheuvel

Is there any reasonable upper bound to the domU PA space
other than what is communicated in the ID registers?

You mean the PASize bits/register? In which case that is it as far as the guest should be is concerned, yes.

Ian.

#7 lore raw
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Ard Biesheuvel

Is there any reasonable upper bound to the domU PA space
other than what is communicated in the ID registers?

You mean the PASize bits/register? In which case that is it as far as the guest should be is concerned, yes.

OK.

As discussed on IRC (#xenarm), the rationale of this approach is that Xen's stage2 attributes will ultimately override device mappings, so 1:1 mapping the whole address space cacheable is actually a reasonable thing to do. And in fact, 4 KB of translation tables for each 512 GB of address space is probably not such a big deal after all. So I am inclined to leave things are they are if the proposed patch works.

Signature · 1 line
Ard.

A message that is not in the archive (sent off-list or not yet received): CAKv+Gu_CJeQE-stGfqoaGa0DWoF_=f6XbsNx+UZbbNhCjA8XYw@mail.gmail.com

#9 lore raw
Quoted 10 lines · Ard Biesheuvel
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Ard Biesheuvel

Is there any reasonable upper bound to the domU PA space
other than what is communicated in the ID registers?

You mean the PASize bits/register? In which case that is it as far as the
guest should be is concerned, yes.

Quoted 7 lines

OK.

As discussed on IRC (#xenarm), the rationale of this approach is that Xen's stage2 attributes will ultimately override device mappings, so 1:1 mapping the whole address space cacheable is actually a reasonable thing to do. And in fact, 4 KB of translation tables for each 512 GB of address space is probably not such a big deal after all.

Well, I'm not going to commit to that always being the case, since its not part of the guest ABI, but given that OVMF would normally be supplied as part of the host rather than the guest if we ever break/change that assumption we do at least have the opportunity to get ovmf fixed/updated around the same time.

IOW I suppose this is tolerable.

Quoted 2 lines

So I am
inclined to leave things are they are if the proposed patch works.

Sure.

Ian.

#10 lore raw
In reply to a message not in the archive
Quoted 17 lines · Ard Biesheuvel
ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +1 -2
index d98769b06b75..c84c872dbe60 100644
@@ -303,8 +303,9 @@ GetBlockEntryListFromAddress (
     }
   }
 
-  // Identify the Page Level the RegionStart must belongs to
-  PageLevel = 3 - ((BaseAddressAlignment - 12) / 9);
+  // Identify the Page Level the RegionStart must belong to. Note

that PageLevel

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +2 -0
+  // should be at least 1 since block translations are not supported at level 0
+  PageLevel = MAX (3 - ((BaseAddressAlignment - 12) / 9), 1);
 
   // If the required size is smaller than the current block size then
Quoted 3 lines

we need to go to the page below.
// The PageLevel was calculated on the Base Address alignment but
did not take in account the alignment

It works.