xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hvmloader: write extra memory in CMOS
@ 2013-11-12 15:32 Wei Liu
  2013-11-29 10:16 ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2013-11-12 15:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu

There's a conventional protocol for virt BIOSes such as Boches, Seabios and
OVMF to have the size of extra memory above 4GB be written to certain
locations (0x5b-0x5d) in CMOS. So update these locations as well.

Note that Seabios in Xen doesn't need this as it gets e820 directly from
Xen. Rombios doesn't read this value.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/firmware/hvmloader/hvmloader.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index 1cc8cf2..9f692fb 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -146,6 +146,7 @@ static void init_hypercalls(void)
 static void cmos_write_memory_size(void)
 {
     uint32_t base_mem = 640, ext_mem, alt_mem;
+    uint64_t extra_mem = 0;
 
     alt_mem = ext_mem = hvm_info->low_mem_pgend << PAGE_SHIFT;
     ext_mem = (ext_mem > 0x0100000) ? (ext_mem - 0x0100000) >> 10 : 0;
@@ -153,6 +154,15 @@ static void cmos_write_memory_size(void)
         ext_mem = 0xffff;
     alt_mem = (alt_mem > 0x1000000) ? (alt_mem - 0x1000000) >> 16 : 0;
 
+    /* According to hvm_info:
+     *  0x100000000 to page_to_phys(high_mem_pgend)-1:
+     *   RAM above 4GB
+     * extra_mem written to CMOS is represented as 64kb chunks
+     */
+    extra_mem = hvm_info->high_mem_pgend;
+    extra_mem = (extra_mem > 0x100000) ?
+        (((extra_mem - 0x100000) << PAGE_SHIFT) >> 16) : 0;
+
     /* All BIOSes: conventional memory (CMOS *always* reports 640kB). */
     cmos_outb(0x15, (uint8_t)(base_mem >> 0));
     cmos_outb(0x16, (uint8_t)(base_mem >> 8));
@@ -166,6 +176,13 @@ static void cmos_write_memory_size(void)
     /* Some BIOSes: alternative extended memory (64kB chunks above 16MB). */
     cmos_outb(0x34, (uint8_t)( alt_mem >> 0));
     cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
+
+    /* Used by virt BIOSes such as Boches, Seabios, OVMF etc: extra
+     * memory (64kB chunks above 4GB)
+     */
+    cmos_outb(0x5d, (uint8_t)( extra_mem >> 16));
+    cmos_outb(0x5c, (uint8_t)( extra_mem >> 8));
+    cmos_outb(0x5b, (uint8_t)( extra_mem >> 0));
 }
 
 /*
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] hvmloader: write extra memory in CMOS
  2013-11-12 15:32 [PATCH v2] hvmloader: write extra memory in CMOS Wei Liu
@ 2013-11-29 10:16 ` Ian Campbell
  2013-11-29 11:20   ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2013-11-29 10:16 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel

On Tue, 2013-11-12 at 15:32 +0000, Wei Liu wrote:
> There's a conventional protocol for virt BIOSes such as Boches, Seabios and
> OVMF to have the size of extra memory above 4GB be written to certain
> locations (0x5b-0x5d) in CMOS. So update these locations as well.
> 
> Note that Seabios in Xen doesn't need this as it gets e820 directly from
> Xen. Rombios doesn't read this value.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Is this patch now obsolete given the hvmloader/ovmf integration work you
are doing?

> ---
>  tools/firmware/hvmloader/hvmloader.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
> index 1cc8cf2..9f692fb 100644
> --- a/tools/firmware/hvmloader/hvmloader.c
> +++ b/tools/firmware/hvmloader/hvmloader.c
> @@ -146,6 +146,7 @@ static void init_hypercalls(void)
>  static void cmos_write_memory_size(void)
>  {
>      uint32_t base_mem = 640, ext_mem, alt_mem;
> +    uint64_t extra_mem = 0;
>  
>      alt_mem = ext_mem = hvm_info->low_mem_pgend << PAGE_SHIFT;
>      ext_mem = (ext_mem > 0x0100000) ? (ext_mem - 0x0100000) >> 10 : 0;
> @@ -153,6 +154,15 @@ static void cmos_write_memory_size(void)
>          ext_mem = 0xffff;
>      alt_mem = (alt_mem > 0x1000000) ? (alt_mem - 0x1000000) >> 16 : 0;
>  
> +    /* According to hvm_info:
> +     *  0x100000000 to page_to_phys(high_mem_pgend)-1:
> +     *   RAM above 4GB
> +     * extra_mem written to CMOS is represented as 64kb chunks
> +     */
> +    extra_mem = hvm_info->high_mem_pgend;
> +    extra_mem = (extra_mem > 0x100000) ?
> +        (((extra_mem - 0x100000) << PAGE_SHIFT) >> 16) : 0;
> +
>      /* All BIOSes: conventional memory (CMOS *always* reports 640kB). */
>      cmos_outb(0x15, (uint8_t)(base_mem >> 0));
>      cmos_outb(0x16, (uint8_t)(base_mem >> 8));
> @@ -166,6 +176,13 @@ static void cmos_write_memory_size(void)
>      /* Some BIOSes: alternative extended memory (64kB chunks above 16MB). */
>      cmos_outb(0x34, (uint8_t)( alt_mem >> 0));
>      cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
> +
> +    /* Used by virt BIOSes such as Boches, Seabios, OVMF etc: extra
> +     * memory (64kB chunks above 4GB)
> +     */
> +    cmos_outb(0x5d, (uint8_t)( extra_mem >> 16));
> +    cmos_outb(0x5c, (uint8_t)( extra_mem >> 8));
> +    cmos_outb(0x5b, (uint8_t)( extra_mem >> 0));
>  }
>  
>  /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] hvmloader: write extra memory in CMOS
  2013-11-29 10:16 ` Ian Campbell
@ 2013-11-29 11:20   ` Wei Liu
  2013-11-29 11:27     ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2013-11-29 11:20 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Wei Liu

On Fri, Nov 29, 2013 at 10:16 AM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> On Tue, 2013-11-12 at 15:32 +0000, Wei Liu wrote:
>> There's a conventional protocol for virt BIOSes such as Boches, Seabios and
>> OVMF to have the size of extra memory above 4GB be written to certain
>> locations (0x5b-0x5d) in CMOS. So update these locations as well.
>>
>> Note that Seabios in Xen doesn't need this as it gets e820 directly from
>> Xen. Rombios doesn't read this value.
>>
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>
> Is this patch now obsolete given the hvmloader/ovmf integration work you
> are doing?
>

Yes, it's obsolete now.

Wei.

>> ---
>>  tools/firmware/hvmloader/hvmloader.c |   17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
>> index 1cc8cf2..9f692fb 100644
>> --- a/tools/firmware/hvmloader/hvmloader.c
>> +++ b/tools/firmware/hvmloader/hvmloader.c
>> @@ -146,6 +146,7 @@ static void init_hypercalls(void)
>>  static void cmos_write_memory_size(void)
>>  {
>>      uint32_t base_mem = 640, ext_mem, alt_mem;
>> +    uint64_t extra_mem = 0;
>>
>>      alt_mem = ext_mem = hvm_info->low_mem_pgend << PAGE_SHIFT;
>>      ext_mem = (ext_mem > 0x0100000) ? (ext_mem - 0x0100000) >> 10 : 0;
>> @@ -153,6 +154,15 @@ static void cmos_write_memory_size(void)
>>          ext_mem = 0xffff;
>>      alt_mem = (alt_mem > 0x1000000) ? (alt_mem - 0x1000000) >> 16 : 0;
>>
>> +    /* According to hvm_info:
>> +     *  0x100000000 to page_to_phys(high_mem_pgend)-1:
>> +     *   RAM above 4GB
>> +     * extra_mem written to CMOS is represented as 64kb chunks
>> +     */
>> +    extra_mem = hvm_info->high_mem_pgend;
>> +    extra_mem = (extra_mem > 0x100000) ?
>> +        (((extra_mem - 0x100000) << PAGE_SHIFT) >> 16) : 0;
>> +
>>      /* All BIOSes: conventional memory (CMOS *always* reports 640kB). */
>>      cmos_outb(0x15, (uint8_t)(base_mem >> 0));
>>      cmos_outb(0x16, (uint8_t)(base_mem >> 8));
>> @@ -166,6 +176,13 @@ static void cmos_write_memory_size(void)
>>      /* Some BIOSes: alternative extended memory (64kB chunks above 16MB). */
>>      cmos_outb(0x34, (uint8_t)( alt_mem >> 0));
>>      cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
>> +
>> +    /* Used by virt BIOSes such as Boches, Seabios, OVMF etc: extra
>> +     * memory (64kB chunks above 4GB)
>> +     */
>> +    cmos_outb(0x5d, (uint8_t)( extra_mem >> 16));
>> +    cmos_outb(0x5c, (uint8_t)( extra_mem >> 8));
>> +    cmos_outb(0x5b, (uint8_t)( extra_mem >> 0));
>>  }
>>
>>  /*
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] hvmloader: write extra memory in CMOS
  2013-11-29 11:20   ` Wei Liu
@ 2013-11-29 11:27     ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2013-11-29 11:27 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Wei Liu

On Fri, 2013-11-29 at 11:20 +0000, Wei Liu wrote:
> On Fri, Nov 29, 2013 at 10:16 AM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> > On Tue, 2013-11-12 at 15:32 +0000, Wei Liu wrote:
> >> There's a conventional protocol for virt BIOSes such as Boches, Seabios and
> >> OVMF to have the size of extra memory above 4GB be written to certain
> >> locations (0x5b-0x5d) in CMOS. So update these locations as well.
> >>
> >> Note that Seabios in Xen doesn't need this as it gets e820 directly from
> >> Xen. Rombios doesn't read this value.
> >>
> >> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> >
> > Is this patch now obsolete given the hvmloader/ovmf integration work you
> > are doing?
> >
> 
> Yes, it's obsolete now.

Dequeued. Thanks.

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-29 11:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12 15:32 [PATCH v2] hvmloader: write extra memory in CMOS Wei Liu
2013-11-29 10:16 ` Ian Campbell
2013-11-29 11:20   ` Wei Liu
2013-11-29 11:27     ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).