From bdbbe011ae1e0e5aff0848e8d9c4134cf6faf6df Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sat, 27 Mar 2010 09:54:58 +0200 Subject: [PATCH] kvm: Fix bzImage setup sector default count If setup sectors is zero, the real value is 4 as per Documentation/x86/boot.txt. Signed-off-by: Pekka Enberg --- tools/kvm/kvm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index a0031c0d97bd..079df0ede9cc 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -194,8 +194,11 @@ static int load_flat_binary(struct kvm *kvm, int fd) static const char *BZIMAGE_MAGIC = "HdrS"; +#define BZ_DEFAULT_SETUP_SECTS 4 + static bool load_bzimage(struct kvm *kvm, int fd) { + unsigned long setup_sects; struct boot_params boot; ssize_t setup_size; void *p; @@ -209,7 +212,11 @@ static bool load_bzimage(struct kvm *kvm, int fd) if (memcmp(&boot.hdr.header, BZIMAGE_MAGIC, strlen(BZIMAGE_MAGIC)) != 0) return false; - setup_size = (boot.hdr.setup_sects + 1) * 512; + setup_sects = boot.hdr.setup_sects + 1; + if (setup_sects == 0) + setup_sects = BZ_DEFAULT_SETUP_SECTS; + + setup_size = setup_sects << 4; p = guest_addr_to_host(kvm, BZ_BOOT_LOADER_START); if (read(fd, p, setup_size) != setup_size) -- 2.39.5