From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751478AbdBOQmI (ORCPT ); Wed, 15 Feb 2017 11:42:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47488 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbdBOQmH (ORCPT ); Wed, 15 Feb 2017 11:42:07 -0500 Subject: Re: [RFC PATCH] x86/boot: make ELF kernel multiboot-able To: Chao Peng , linux-kernel@vger.kernel.org, x86@kernel.org, grub-devel@gnu.org References: <1487169716-58415-1-git-send-email-chao.p.peng@linux.intel.com> Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Juergen Gross , "Luis R. Rodriguez" , Borislav Petkov , Josh Poimboeuf , Thomas Garnier , Al Viro , "Michael S. Tsirkin" , Amnon Ilan From: Paolo Bonzini Message-ID: Date: Wed, 15 Feb 2017 17:42:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <1487169716-58415-1-git-send-email-chao.p.peng@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Feb 2017 16:42:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/02/2017 15:41, Chao Peng wrote: > Multiboot specification (http://git.savannah.gnu.org/cgit/grub.git/tree/doc/multiboot.texi?h=multiboot2) > is an open standard that provides kernels with a uniform way to be booted > by multiboot-compliant bootloaders (like grub). > > This patch is trying to make Linux ELF kernel image to be a > multiboot-compliant OS so that it can be loaded by a multiboot-comliant > bootloader. The benefit is eliminating the maintainance for realmode and > decompression code and especially when the kernel is loaded in a virtual > machine, the reducing for these code can greatly cuts down the boot time. > > However, the current version of multiboot spec doesn't support 64 bit > well so for 64 bit kernel we need stub code to jump from 32 bit code to > 64 bit code. Besides, there are still some other issues: > 1). '-z max-page-size=0x1000' is used so the text segment start is in > multiboot header search scope because GNU LD has default page size of > 0x00200000 for ELF64, which will fail multiboot test. > > 2). The bootloader like grub has support for ELF kernel (even for ELF64) > which makes the patch easier. However, the current grub implementaion > thinks the entry address should be a VA. E.g. for 64 bit kernel, the entry > address (0x1000000) is actually phiscial address, grub refuses to load it > by saying: 'entry point isn't in a segment'. For kvm-unit-tests, we do "objcopy -O elf32-i386 dest.32bit dest.64bit" and pass the resulting 32bit ELF file to grub. Out of curiosity, what happens if you pass the resulting multiboot file to QEMU's -kernel option? Thanks, Paolo > This patch is sent out as RFC in case you have some ideas. > > Signed-off-by: Chao Peng