From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ceBYZ-0007UF-It for mharc-grub-devel@gnu.org; Wed, 15 Feb 2017 21:12:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceBYW-0007Sv-Aa for grub-devel@gnu.org; Wed, 15 Feb 2017 21:12:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceBYT-00086V-6P for grub-devel@gnu.org; Wed, 15 Feb 2017 21:12:24 -0500 Received: from mga04.intel.com ([192.55.52.120]:57794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ceBYS-00085o-Sh for grub-devel@gnu.org; Wed, 15 Feb 2017 21:12:21 -0500 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2017 18:12:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,167,1484035200"; d="scan'208";a="66361106" Received: from pengc-desk.ccr.corp.intel.com ([10.255.27.23]) by fmsmga006.fm.intel.com with ESMTP; 15 Feb 2017 18:12:16 -0800 Message-ID: <1487211130.3019.7.camel@linux.intel.com> Subject: Re: [RFC PATCH] x86/boot: make ELF kernel multiboot-able From: Chao Peng To: Paolo Bonzini , linux-kernel@vger.kernel.org, x86@kernel.org, grub-devel@gnu.org 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 Date: Thu, 16 Feb 2017 10:12:10 +0800 In-Reply-To: References: <1487169716-58415-1-git-send-email-chao.p.peng@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.120 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Feb 2017 02:12:25 -0000 On Wed, 2017-02-15 at 17:42 +0100, Paolo Bonzini wrote: > > On 15/02/2017 15:41, Chao Peng wrote: > > > > Multiboot specification (http://git.savannah.gnu.org/cgit/grub.git/tree/doc/multiboot.texi?h=mul > > tiboot2) > > 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? > The resulting kernel is a multiboot2 kernel. QEMU however supports loading multiboot v1 only. Chao > Thanks, > > Paolo > > > > > This patch is sent out as RFC in case you have some ideas. > > > > Signed-off-by: Chao Peng