x86: setup: fixes to alloc_phys setup
Paolo Bonzini
maintainerPATCH 1/1 x86: setup: fixes to alloc_phys setup
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.
--- lib/x86/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/x86/setup.c +4 -4
@@ -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 )
Signature · 1 line
2.14.3
Quoted 31 lines · Paolo Bonzini
There were two thinkos in commit 937e239 ("x86: use
alloc_phys", 2017-11-02).First,
alloc_physis 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 <[email protected]>--- lib/x86/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/x86/setup.c +4
-0@@ -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 ;
lib/x86/setup.c void setup_multiboot(struct mbi_bootinfo *bootinfo) · line 62
Quoted 10 lines
lib/x86/setup.c +0
-4@@ -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 )
Looks good to me. (unfortunately had no time yet to review the original series)
Signature · 3 lines
Thanks, David / dhildenb