From: Paolo Bonzini Subject: [PATCH kvm-unit-tests] x86: setup: fixes to alloc_phys setup Date: Wed, 15 Nov 2017 09:20:58 +0100 Message-ID: <20171115082058.16576-1-pbonzini@redhat.com> To: kvm@vger.kernel.org Return-path: Received: from mail-wr0-f193.google.com ([209.85.128.193]:52918 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756114AbdKOIVS (ORCPT ); Wed, 15 Nov 2017 03:21:18 -0500 Received: by mail-wr0-f193.google.com with SMTP id o14so822233wrf.9 for ; Wed, 15 Nov 2017 00:21:17 -0800 (PST) Received: from donizetti.lan (94-39-170-107.adsl-ull.clienti.tiscali.it. [94.39.170.107]) by smtp.gmail.com with ESMTPSA id w76sm21358596wrc.79.2017.11.15.00.21.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Nov 2017 00:21:15 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: There were two thinkos in commit 937e239 ("x86: use alloc_phys", 2017-11-02). First, alloc_phys is not initialized if there are no multiboot modules, as is the case when invoking QEMU directly with a test kernel. Second, one "&" was missing, so the topmost memory address was passed as the size to phys_alloc_init. Signed-off-by: Paolo Bonzini --- lib/x86/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/x86/setup.c b/lib/x86/setup.c index f6a8ea8..ff7c8d3 100644 --- a/lib/x86/setup.c +++ b/lib/x86/setup.c @@ -46,6 +46,10 @@ void setup_multiboot(struct mbi_bootinfo *bootinfo) { struct mbi_module *mods; + /* TODO: use e820 */ + u64 end_of_memory = bootinfo->mem_upper * 1024ull; + phys_alloc_init((uintptr_t) &edata, end_of_memory - (uintptr_t) &edata); + if (bootinfo->mods_count != 1) return; @@ -53,10 +57,6 @@ void setup_multiboot(struct mbi_bootinfo *bootinfo) initrd = (char *)(uintptr_t) mods->start; initrd_size = mods->end - mods->start; - - /* TODO: use e820 */ - u64 end_of_memory = bootinfo->mem_upper * 1024ull; - phys_alloc_init((uintptr_t) &edata, end_of_memory - (uintptr_t)edata); } void setup_libcflat(void) -- 2.14.3