Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eAdsO-0004EW-6G for mharc-grub-devel@gnu.org; Fri, 03 Nov 2017 11:27:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAdsL-0004EO-Ji for grub-devel@gnu.org; Fri, 03 Nov 2017 11:27:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAdsI-00058Z-E1 for grub-devel@gnu.org; Fri, 03 Nov 2017 11:27:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:55431) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eAdsI-000582-4r for grub-devel@gnu.org; Fri, 03 Nov 2017 11:27:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 941E8AD4C; Fri, 3 Nov 2017 15:27:11 +0000 (UTC) Subject: Re: [Xen-devel] Xen PVH support in grub2 To: Boris Ostrovsky , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: The development of GNU GRUB , Daniel Kiper , xen-devel References: <11dda1ae-5b70-41fe-a592-39750a74e5d7@suse.com> <20170929152439.iibhzqtwfmqi4yx2@dhcp-3-128.uk.xensource.com> <230ef18e-6739-58c6-1f95-b04e7245beaf@suse.com> <20170929155104.45wv3c7civz6uif6@dhcp-3-128.uk.xensource.com> <20171103121750.jztbuimjjt34efk6@dhcp-3-128.uk.xensource.com> <7d4ea582-e936-35bf-fadb-58e11b1315ee@suse.com> <20171103140722.lrlokgese4mttojs@dhcp-3-128.uk.xensource.com> <25996301-31b8-a9d9-90d0-5221292801c4@suse.com> <92edc5f4-3ab0-1010-0a7d-b27b78f8eb6b@oracle.com> From: Juergen Gross Message-ID: <82a3aa2a-dc63-01c0-737c-8c0529850d6d@suse.com> Date: Fri, 3 Nov 2017 16:27:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <92edc5f4-3ab0-1010-0a7d-b27b78f8eb6b@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 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: Fri, 03 Nov 2017 15:27:18 -0000 On 03/11/17 16:10, Boris Ostrovsky wrote: > On 11/03/2017 10:59 AM, Juergen Gross wrote: >> On 03/11/17 15:36, Boris Ostrovsky wrote: >>> On 11/03/2017 10:24 AM, Juergen Gross wrote: >>>> On 03/11/17 15:07, Roger Pau Monn=C3=A9 wrote: >>>>> On Fri, Nov 03, 2017 at 01:50:11PM +0100, Juergen Gross wrote: >>>>>> On 03/11/17 13:17, Roger Pau Monn=C3=A9 wrote: >>>>>>> On Fri, Nov 03, 2017 at 01:00:46PM +0100, Juergen Gross wrote: >>>>>>>> On 29/09/17 17:51, Roger Pau Monn=C3=A9 wrote: >>>>>>>>> On Fri, Sep 29, 2017 at 03:33:58PM +0000, Juergen Gross wrote: >>>>>>>>>> On 29/09/17 17:24, Roger Pau Monn=C3=A9 wrote: >>>>>>>>>>> On Fri, Sep 29, 2017 at 02:46:53PM +0000, Juergen Gross wrote= : >>>>>>>>>>> Then, I also wonder whether it would make sense for this grub= to load >>>>>>>>>>> the kernel using the PVH entry point or the native entry poin= t. Would >>>>>>>>>>> it be possible to boot a Linux kernel up to the point where c= puid can >>>>>>>>>>> be used inside of a PVH container? >>>>>>>>>> I don't think today's Linux allows that. This has been discuss= ed >>>>>>>>>> very thoroughly at the time Boris added PVH V2 support to the = kernel. >>>>>>>>> OK, I'm not going to insist on that, but my plans for FreeBSD i= s to >>>>>>>>> make the native entry point capable of booting inside of a PVH >>>>>>>>> container up to the point where cpuid (or whatever method) can = be used >>>>>>>>> to detect the environment. >>>>>>>> Looking more thoroughly into the Linux boot code I think this co= uld >>>>>>>> work for Linux, too. But only if we can tell PVH from HVM in the= guest. >>>>>>>> How would you do that in FreeBSD? Via flags in the boot params? = This >>>>>>>> would the have to be done in the boot loader (e.g. grub or OVMF)= . >>>>>>> My plan was not to differentiate between HVM and PVH, but rather = to >>>>>>> make use of the ACPI information in order to decide which devices= are >>>>>>> available and which are not inside of a PVH guest. >>>>>>> >>>>>>> For example in the FADT "IA-PC Boot Architecture Flags" field for= PVH >>>>>>> we already set "VGA Not Present" and "CMOS RTC Not Present". Ther= e >>>>>>> might be other flags/fields that must be set, but I would like to >>>>>>> avoid having a CPUID bit or similar saying "PVH", because then Xe= n >>>>>>> will be tied to always providing the same set of devices in PVH >>>>>>> containers. >>>>>> Why? This would depend on the semantics tied to the flag. It could= just >>>>>> mean "don't assume availability of legacy stuff" (e.g. BIOS calls)= . >>>>>> >>>>>> Linux would have a problem with the ACPI approach as it would try = BIOS >>>>>> calls way before it is initializing its ACPI handling. So in Linux= I'd >>>>>> need another way to tell I'm running in PVH mode, e.g. a "no legac= y" >>>>>> bit in the Xen HVM cpuid leaf. >>>>> If you are booted from the PVH entry point, there's no BIOS or UEFI >>>>> (ie: no firmware), if you are booted from the BIOS entry point ther= e's >>>>> a BIOS and the same applies to UEFI. How does Linux differentiate >>>>> whether it's booted from BIOS or UEFI? >>>> They use different entries. >>> In fact, we had a discussion with Matt Fleming (Linux EFI maintainer)= to >>> see if we can use EFI entry point to also be able to boot PVH guest b= ut >>> found some issues with that approach, which is why we ended up with a >>> dedicated PVH entry point. >>> >>> I am curious though, Juergen --- what do we need besides zeropage to >>> allow us to boot PVH from startup_64? >> Oh, you are right. I managed to get lost in the early boot paths. >> >> Only setting up the hyperpage seems to be missing, but this should be >> doable. And setting xen_pvh, of course. >=20 > That last part was actually my question --- do we need to have xen_pvh > set before we get to xen-specific code for the first time (which I thin= k > is init_hypervisor_platform()) from startup_64? >=20 > Because if we do --- who will set it? This should be easily testable: Just set an internal indicator in xen_prepare_pvh() and copy that to xen_pvh in init_hypervisor_platform() and see whether the kernel still comes up in PVH mode. The same can be done with setting up the hypercall page. Just building a kernel trying that... Juergen