Skip to contentSkip to conversation

Moving the e820 table creation

RFC PATCH In review Stefan Berger 2 participants 7 messages Nov 6, 2006 – Nov 7, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Moving the e820 table creation

This patch tries to move the e820 table creation out of libxc into the hvmloader in order to properly account for the ACPI space using the #defines for the ACPI memory region. I implemented some functions around the e820 table for being able to add RAM and reserve memory regions from it. I have so far not removed the libxc e820 table creation, but use it to compare the results. I first dump the e820 table created by libxc in hvmloader and then write over it and let vmxassist dump it again. The patch imports a lot of code from vmxassist, such as functions like printf.

There's one problem, though, and that is when the table is created in libxc, the amount of bytes available to an HVM domain is on my test machine 0xbffd000 bytes for a 192MB domain, which is correct according to the calculation done in libxc where 3 pages at the highest end are cut off. When I use the hypercall in hvmloader/e820.c to read the number of pages available to a domain I get a number that leads to 0x20000 bytes less in that domain, 0xbfdd000. What happend to those 128kb?

xen-unstable.hg/tools/firmware/hvmloader/Makefile +1 -1
Index: root/xen-unstable.hg/tools/firmware/hvmloader/Makefile
===================================================================
@@ -40,7 +40,7 @@ OBJCOPY  = objcopy
 CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
 LDFLAGS  = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
 
-SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c acpi_utils.c
+SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c acpi_utils.c e820.c
 OBJS = $(patsubst %.c,%.o,$(SRCS))
 
 .PHONY: all
xen-unstable.hg/tools/firmware/hvmloader/e820.c new file +187 -0

187 lines not on this page · raw message

xen-unstable.hg/tools/firmware/hvmloader/util.h +3 -0
Index: root/xen-unstable.hg/tools/firmware/hvmloader/util.h
===================================================================
@@ -37,5 +37,8 @@ void uuid_to_string(char *dest, uint8_t 
 
 /* Debug output */
 void puts(const char *s);
+int printf(const char *fmt, ...);
+
+
 
 #endif /* __HVMLOADER_UTIL_H__ */
xen-unstable.hg/tools/firmware/hvmloader/e820.h new file +12 -0
Index: root/xen-unstable.hg/tools/firmware/hvmloader/e820.h
===================================================================
@@ -0,0 +1,12 @@
+#ifndef E820_H
+#define E820_H
+
+#include "acpi/acpi2_0.h"
+#include <xen/hvm/e820.h>
+#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET)
+#define E820_MAP    ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET))
+
+void print_e820_map(struct e820entry *map, int entries);
+int build_e820_map(unsigned char *start);
+
+#endif
xen-unstable.hg/tools/firmware/hvmloader/util.c +115 -0

124 lines not on this page · raw message

xen-unstable.hg/tools/firmware/hvmloader/hvmloader.c +6 -0
Index: root/xen-unstable.hg/tools/firmware/hvmloader/hvmloader.c
===================================================================
@@ -27,6 +27,7 @@
 #include "util.h"
 #include "acpi_utils.h"
 #include "smbios.h"
+#include "e820.h"
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 
@@ -175,6 +176,11 @@ main(void)
 	puts("Loading ROMBIOS ...\n");
 	memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
 
+	/* print old map built by libxc */
+	print_e820_map(E820_MAP, *E820_MAP_NR);
+	/* build e820 map (overwrite libxc-created one) */
+	build_e820_map((unsigned char *)E820_MAP);
+
         create_mp_tables();
 	
 	if (cirrus_check()) {

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

#1 lore raw
Quoted 3 lines · Stefan Berger

When I use the hypercall in hvmloader/e820.c to read the number of pages available to a domain I get a number that leads to 0x20000 bytes less in that domain, 0xbfdd000. What happend to those 128kb?

0xA0000-0xC0000 is a memory hole (VGA region).

-- Keir

#2 lore raw

[email protected] wrote on 11/06/2006 05:13:55 PM:

Quoted 10 lines · Stefan Berger
Quoted 4 lines

When I use the hypercall in hvmloader/e820.c to read the number of pages available to a domain I get a number that leads to 0x20000 bytes less in that domain, 0xbfdd000. What happend to those 128kb?

0xA0000-0xC0000 is a memory hole (VGA region).

So I guess simply adding 0x20000 solves the problem in all cases.

Stefan

Quoted 9 lines

-- Keir

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

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

#3 lore raw
Quoted 9 lines · Stefan Berger
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

When I use the hypercall in hvmloader/e820.c to read the number of pages available to a domain I get a number that leads to 0x20000 bytes less in that domain, 0xbfdd000. What happend to those 128kb?

0xA0000-0xC0000 is a memory hole (VGA region).

So I guess simply adding 0x20000 solves the problem in all cases.

Stefan

Yeah... I¹m not sure that moving e820 creation out of libxc is really for the best. After all, it sets up the memory layout so it knows with certainty how to construct the e820. It¹s also a bunch simpler now as I stripped out all the Xen-specific e820 type codes.

The main advantage of not having it in libxc is that we don¹t have to squirrel it away at a Œwell-known¹ address. But I¹m not sure that¹s any worse than having Œwell-known¹ hardcoded fudge factors like 0x20000 encoded in hvmloader though. :-)

Actually I haven¹t looked at your patch yet, so maybe it does turn out cleaner. Also it sounds like you added support for dynamic modification of e820? Is that useful?

-- Keir

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

#4 lore raw

[email protected] wrote on 11/07/2006 03:14:17 AM:

Quoted 17 lines · Stefan Berger
Quoted 6 lines
Quoted 4 lines

When I use the hypercall in hvmloader/e820.c to read the number of pages available to a domain I get a number that leads to 0x20000 bytes less in that domain, 0xbfdd000. What happend to those 128kb?

0xA0000-0xC0000 is a memory hole (VGA region).

So I guess simply adding 0x20000 solves the problem in all cases.

Stefan

Yeah... I?m not sure that moving e820 creation out of libxc is really for the best. After all, it sets up the memory layout so it knows with certainty how to construct the e820. It?s also a bunch simpler now as I stripped out all the Xen-specific e820 type codes.

Quoted 4 lines

The main advantage of not having it in libxc is that we don?t have to squirrel it away at a ?well-known? address. But I?m not sure that?s any worse than having ?well-known? hardcoded fudge factors like 0x20000 encoded in hvmloader though. :-)

Yes, that's what makes this a bit ugly.

Quoted 4 lines

Actually I haven?t looked at your patch yet, so maybe it does turn out cleaner. Also it sounds like you added support for dynamic modification of e820? Is that useful?

In preparation for supporting this spec

https://www.trustedcomputinggroup.org/groups/server/TCG_ACPIGeneralSpecification_1-00_1-00_FINAL.pdf

where I plan on dyanmically reserving 64kb of room for ACPI data in the RAM region > 0x100 000 (starting from the end of that memory chunk) if probing for the device succeeds. A function for allocating memory from e820 is not there, yet.

Stefan

Quoted 5 lines

-- Keir_______________________________________________
Xen-devel mailing list [email protected]
http://lists.xensource.com/xen-devel

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

#5 lore raw
Quoted 9 lines · Stefan Berger

In preparation for supporting this spec

https://www.trustedcomputinggroup.org/groups/server/TCG_ACPIGeneralSpecificati
on_1-00_1-00_FINAL.pdf

where I plan on dyanmically reserving 64kb of room for ACPI data in the RAM region > 0x100 000 (starting from the end of that memory chunk) if probing for the device succeeds. A function for allocating memory from e820 is not there, yet.

Oh I see. Well, maybe hvm builder should create the basic e820 map, and hvmloader can add to it.

-- Keir

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

#6 lore raw

Keir Fraser <[email protected]> wrote on 11/07/2006 06:53:05 AM:

Quoted 10 lines · Stefan Berger

In preparation for supporting this spec

https://www.trustedcomputinggroup.
org/groups/server/TCG_ACPIGeneralSpecification_1-00_1-00_FINAL.pdf

Quoted 7 lines

where I plan on dyanmically reserving 64kb of room for ACPI data in the RAM region > 0x100 000 (starting from the end of that memory chunk) if probing for the device succeeds. A function for allocating memory from e820 is not there, yet.

Oh I see. Well, maybe hvm builder should create the basic e820 map, and hvmloader can add to it.

The libxc hvm builder should really also include the file hvmloader/acpi/acpi2_0.h to get the constants for where the ACPI data will be copied into and the size of the ACPI data block. All this can be done in hvmloader as well.

Stefan

Quoted 2 lines

-- Keir

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