All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvmtool: handle x86 firmware smaller than 128k
@ 2017-11-06 11:48 Gerd Hoffmann
  2017-11-06 17:09 ` Jean-Philippe Brucker
  0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2017-11-06 11:48 UTC (permalink / raw)
  To: kvm; +Cc: jean-philippe.brucker, Gerd Hoffmann

---
 x86/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/boot.c b/x86/boot.c
index 61535eb57b..b7a4262d89 100644
--- a/x86/boot.c
+++ b/x86/boot.c
@@ -28,7 +28,7 @@ bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename)
 	if (st.st_size > MB_FIRMWARE_BIOS_SIZE)
 		die("firmware image %s is too big to fit in memory (%Lu KB).\n", firmware_filename, (u64)(st.st_size / 1024));
 
-	p = guest_flat_to_host(kvm, MB_FIRMWARE_BIOS_BEGIN);
+	p = guest_flat_to_host(kvm, MB_BIOS_END + 1 - st.st_size);
 
 	while ((nr = read(fd, p, st.st_size)) > 0)
 		p += nr;
-- 
2.9.3

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

* Re: [PATCH] kvmtool: handle x86 firmware smaller than 128k
  2017-11-06 11:48 [PATCH] kvmtool: handle x86 firmware smaller than 128k Gerd Hoffmann
@ 2017-11-06 17:09 ` Jean-Philippe Brucker
  2017-11-07  7:33   ` Gerd Hoffmann
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Philippe Brucker @ 2017-11-06 17:09 UTC (permalink / raw)
  To: Gerd Hoffmann, kvm

Hi Gerd,

This change deserves a comment, as it's not obvious what we're doing here.
How about:

"""
When using an external firmware on x86, kvmtool follows the legacy BIOS
standard, by entering firmware at address 0xffff0 in 16bit real mode.
SeaBIOS images built for emulators follow this convention by having their
reset vector 16 bytes before the end of the image. In order to support
images of arbitrary size, move the image at the end of the BIOS region.
"""

Thanks,
Jean

On 06/11/17 11:48, Gerd Hoffmann wrote:
> ---
>  x86/boot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/x86/boot.c b/x86/boot.c
> index 61535eb57b..b7a4262d89 100644
> --- a/x86/boot.c
> +++ b/x86/boot.c
> @@ -28,7 +28,7 @@ bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename)
>  	if (st.st_size > MB_FIRMWARE_BIOS_SIZE)
>  		die("firmware image %s is too big to fit in memory (%Lu KB).\n", firmware_filename, (u64)(st.st_size / 1024));
>  
> -	p = guest_flat_to_host(kvm, MB_FIRMWARE_BIOS_BEGIN);
> +	p = guest_flat_to_host(kvm, MB_BIOS_END + 1 - st.st_size);
>  
>  	while ((nr = read(fd, p, st.st_size)) > 0)
>  		p += nr;
> 

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

* Re: [PATCH] kvmtool: handle x86 firmware smaller than 128k
  2017-11-06 17:09 ` Jean-Philippe Brucker
@ 2017-11-07  7:33   ` Gerd Hoffmann
  0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2017-11-07  7:33 UTC (permalink / raw)
  To: Jean-Philippe Brucker, kvm

On Mon, 2017-11-06 at 17:09 +0000, Jean-Philippe Brucker wrote:
> Hi Gerd,
> 
> This change deserves a comment, as it's not obvious what we're doing
> here.
> How about:
> 
> """
> When using an external firmware on x86, kvmtool follows the legacy
> BIOS
> standard, by entering firmware at address 0xffff0 in 16bit real mode.

This has nothing to do with the legacy bios standards.  The cpu starts
executing at 0xffff0 after reset, no matter what the firmware is.  It's
the same for uefi and coreboot.

But, yes, mentioning the reset vector is reasonable, it you don't know
that x86 detail it isn't obvious indeed.  Sending v2 in a moment.

cheers,
  Gerd

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

end of thread, other threads:[~2017-11-07  7:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 11:48 [PATCH] kvmtool: handle x86 firmware smaller than 128k Gerd Hoffmann
2017-11-06 17:09 ` Jean-Philippe Brucker
2017-11-07  7:33   ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.