From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wen Congyang Subject: Re: [SeaBIOS] [RFC PATCH 9/9] enable memory devices if e820 entry is present Date: Thu, 26 Apr 2012 08:58:00 +0800 Message-ID: <4F989D98.6040506@cn.fujitsu.com> References: <1334844527-18869-1-git-send-email-vasilis.liaskovitis@profitbricks.com> <1334844527-18869-10-git-send-email-vasilis.liaskovitis@profitbricks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org, avi@redhat.com To: Vasilis Liaskovitis Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:46194 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751695Ab2DZAyj convert rfc822-to-8bit (ORCPT ); Wed, 25 Apr 2012 20:54:39 -0400 In-Reply-To: <1334844527-18869-10-git-send-email-vasilis.liaskovitis@profitbricks.com> Sender: kvm-owner@vger.kernel.org List-ID: At 04/19/2012 10:08 PM, Vasilis Liaskovitis Wrote: > On a reboot, seabios regenerates srat/ssdt objects. If a valid e820 = entry is > found spanning the whole address range of a hotplug memory device, t= he device > will be enabled. This ensures persistency of hotplugged memory slots= across VM > reboots. >=20 > Signed-off-by: Vasilis Liaskovitis > --- > src/acpi.c | 6 +++++- > src/memmap.c | 15 +++++++++++++++ > 2 files changed, 20 insertions(+), 1 deletions(-) >=20 > diff --git a/src/acpi.c b/src/acpi.c > index 5580099..2ebed2e 100644 > --- a/src/acpi.c > +++ b/src/acpi.c > @@ -601,7 +601,11 @@ build_memssdt(void) > for (i =3D 0; i < nb_memdevs; i++) { > mem_base =3D (((u64)(entry->base_addr_high) << 32 )| entry->= base_addr_low); > mem_len =3D (((u64)(entry->length_high) << 32 )| entry->leng= th_low); > - *(ssdt_ptr++) =3D 0x00; > + if (find_e820(mem_base, mem_len, E820_RAM)) { This line will break the building: Compilation complete. 0 Errors, 16 Warnings, 0 Remarks, 259 Optimizatio= ns Compiling whole program out/ccode32flat.o src/acpi.c: In function =91build_memssdt=92: src/acpi.c:604: warning: implicit declaration of function =91find_e820=92 src/memmap.c:137: note: previous definition of =91find_e820=92 was here src/acpi.c:604: error: =91E820_RAM=92 undeclared (first use in this fun= ction) src/acpi.c:604: error: (Each undeclared identifier is reported only onc= e src/acpi.c:604: error: for each function it appears in.) make: *** [out/ccode32flat.o] Error 1 You should declare the function find_e820() in src/memmap.h and include this header file in src/acpi.c. Thanks Wen Congyang > + *(ssdt_ptr++) =3D 0x01; > + } > + else > + *(ssdt_ptr++) =3D 0x00; > entry++; > } > build_header((void*)ssdt, SSDT_SIGNATURE, ssdt_ptr - ssdt, 1); > diff --git a/src/memmap.c b/src/memmap.c > index 56865b4..9790da1 100644 > --- a/src/memmap.c > +++ b/src/memmap.c > @@ -131,6 +131,21 @@ add_e820(u64 start, u64 size, u32 type) > //dump_map(); > } > =20 > +// Check if an e820 entry exists that covers the memory range > +// [start, start+size) with same type as type. > +int > +find_e820(u64 start, u64 size, u32 type) > +{ > + int i; > + for (i=3D0; i + struct e820entry *e =3D &e820_list[i]; > + if ((e->start <=3D start) && (e->size >=3D (size + start - e= ->start)) && > + (e->type =3D=3D type)) > + return 1; > + } > + return 0; > +} > + > // Report on final memory locations. > void > memmap_finalize(void)