Hello Bei,
On 08/22/12 18:38, Bei Guan wrote:
> I find the latest Ovmf doesn't work on Xen. The related change is:
> http://sourceforge.net/mailarchive/message.php?msg_id=29615810
(svn rev 13572)
> The issue may be the following code in OvmfPkg/PlatformPei/Platform.c
>
> + AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
> 0xFEC00000);
> + AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
> + AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
> + AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
>
> If change the
> AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
> 0xFEC00000);
> to
> AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
> 0xFEC00000 - TopOfMemory);
> it works.
AddIoMemoryRangeHob(): takes MemoryBase and (absolute) MemoryLimit
AddIoMemoryBaseSizeHob(): takes MemoryBase and (relative) MemorySize
The line
AddIoMemoryRangeHob (
TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFEC00000);
added by the patch selects the greater of {TopOfMemory, BASE_2GB} as
MemoryBase, and fixes MemoryLimit at 0xFEC00000, no matter what
MemoryBase was selected from the possible two.
This line added by the patch works equivalently (but in my opinion, more
clearly) to this removed section:
if (TopOfMemory < BASE_2GB) {
AddIoMemoryBaseSizeHob (BASE_2GB, 0xFC000000 - BASE_2GB);
} else {
AddIoMemoryBaseSizeHob (TopOfMemory, 0xFC000000 - TopOfMemory);
}
As MemoryBase, the same
max {TopOfMemory, BASE_2GB}
is selected. MemorySize is always calculated so that the absolute end
falls to 0xFC000000.
... And this is where I introduced an error :(
The logic seems OK, but the constant is wrong. 0xFEC00000 != 0xFC000000;
my patch reports [0xFC000000, 0xFEC00000), an extra 44 MB, as MMIO.
... Hmm yes, I can see the conflict in InitializeXen() in
"OvmfPkg/PlatformPei/Xen.c":
//
// Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
// This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
//
AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000);
The HVM loader needs the first 16 MB of that 44 MB.
Can you please try the attached patch? I went through the rest of svn
rev 13572 again, and it seems fine. (Famous last words...)
Laszlo
From 28c1f412e4b2cb5dfb8ca31f12a3de0d9b585278 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Wed, 22 Aug 2012 19:40:48 +0200
Subject: [PATCH] OvmfPkg: fix dyslexia (over-zealous MMIO) in
MemMapInitialization
... introduced in svn rev 13572. It caused a conflict with the
[0xFC000000, 0xFD000000) area reserved for Xen's HVM loader.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
OvmfPkg/PlatformPei/Platform.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 8f07265..b8cf15d 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -196,14 +196,15 @@ MemMapInitialization (
//
// address purpose size
// ------------ -------- -------------------------
- // max(top, 2g) PCI MMIO 0xFEC00000 - max(top, 2g)
+ // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g)
+ // 0xFC000000 gap 44 MB
// 0xFEC00000 IO-APIC 4 KB
// 0xFEC01000 gap 1020 KB
// 0xFED00000 HPET 1 KB
// 0xFED00400 gap 1023 KB
// 0xFEE00000 LAPIC 1 MB
//
- AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
0xFEC00000);
+ AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
0xFC000000);
AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
--
1.7.1
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel