From: Doug Goldstein Subject: Re: [PATCH v11 07/13] x86: add multiboot2 protocol support for EFI platforms Date: Thu, 12 Jan 2017 16:23:59 -0600 Message-ID: References: <1480976718-12198-1-git-send-email-daniel.kiper@oracle.com> <1480976718-12198-8-git-send-email-daniel.kiper@oracle.com> <96e86b22-8940-dce2-d1b9-92d1c132ad0e@cardoe.com> <20170111194714.GZ32675@olila.local.net-space.pl> <66b5b99e-14fc-5125-492e-83a692f816a9@cardoe.com> <20170112125036.GG32675@olila.local.net-space.pl> <819f2a11-5750-a0c3-055b-8b7879b21179@cardoe.com> <20170112202827.GK32675@olila.local.net-space.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0216326757974701246==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRnmv-0007Nt-QC for xen-devel@lists.xenproject.org; Thu, 12 Jan 2017 22:24:05 +0000 Received: by mail-it0-f68.google.com with SMTP id v14so3328914itb.0 for ; Thu, 12 Jan 2017 14:24:03 -0800 (PST) In-Reply-To: <20170112202827.GK32675@olila.local.net-space.pl> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Daniel Kiper Cc: jgross@suse.com, sstabellini@kernel.org, andrew.cooper3@citrix.com, pgnet.dev@gmail.com, ning.sun@intel.com, julien.grall@arm.com, jbeulich@suse.com, xen-devel@lists.xenproject.org, qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============0216326757974701246== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jPPr6Bq3JkKE8EFJrDbb5ktFHgQ6WMp1" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9jPPr6Bq3JkKE8EFJrDbb5ktFHgQ6WMp1 Content-Type: multipart/mixed; boundary="F87QonTWPcEB3slaL3SmwRNbHl4K9Tg2H"; protected-headers="v1" From: Doug Goldstein To: Daniel Kiper Cc: xen-devel@lists.xenproject.org, andrew.cooper3@citrix.com, fu.wei@linaro.org, gang.wei@intel.com, jbeulich@suse.com, jgross@suse.com, julien.grall@arm.com, konrad.wilk@oracle.com, ning.sun@intel.com, pgnet.dev@gmail.com, qiaowei.ren@intel.com, sstabellini@kernel.org Message-ID: Subject: Re: [PATCH v11 07/13] x86: add multiboot2 protocol support for EFI platforms References: <1480976718-12198-1-git-send-email-daniel.kiper@oracle.com> <1480976718-12198-8-git-send-email-daniel.kiper@oracle.com> <96e86b22-8940-dce2-d1b9-92d1c132ad0e@cardoe.com> <20170111194714.GZ32675@olila.local.net-space.pl> <66b5b99e-14fc-5125-492e-83a692f816a9@cardoe.com> <20170112125036.GG32675@olila.local.net-space.pl> <819f2a11-5750-a0c3-055b-8b7879b21179@cardoe.com> <20170112202827.GK32675@olila.local.net-space.pl> In-Reply-To: <20170112202827.GK32675@olila.local.net-space.pl> --F87QonTWPcEB3slaL3SmwRNbHl4K9Tg2H Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 1/12/17 2:28 PM, Daniel Kiper wrote: > On Thu, Jan 12, 2017 at 09:52:15AM -0600, Doug Goldstein wrote: >> On 1/12/17 6:50 AM, Daniel Kiper wrote: >>> On Wed, Jan 11, 2017 at 02:20:15PM -0600, Doug Goldstein wrote: >>>> On 1/11/17 1:47 PM, Daniel Kiper wrote: >>>>> On Tue, Jan 10, 2017 at 02:51:27PM -0600, Doug Goldstein wrote: >>>>>> On 1/9/17 7:37 PM, Doug Goldstein wrote: >>>>>>> On 12/5/16 4:25 PM, Daniel Kiper wrote: >>>>>> >>>>>>>> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-= boot.h >>>>>>>> index 62c010e..dc857d8 100644 >>>>>>>> --- a/xen/arch/x86/efi/efi-boot.h >>>>>>>> +++ b/xen/arch/x86/efi/efi-boot.h >>>>>>>> @@ -146,6 +146,8 @@ static void __init efi_arch_process_memory_m= ap(EFI_SYSTEM_TABLE *SystemTable, >>>>>>>> { >>>>>>>> struct e820entry *e; >>>>>>>> unsigned int i; >>>>>>>> + /* Check for extra mem for mbi data if Xen is loaded via mu= ltiboot2 protocol. */ >>>>>>>> + UINTN extra_mem =3D efi_enabled(EFI_LOADER) ? 0 : (64 << 10= ); >>>>>>> >>>>>>> Just wondering where the constant came from? And if there should = be a >>>>>>> little bit of information about it. To me its just weird to shift= 64. >>>>>> >>>>>> Its the size of the stack used in the assembly code. >>>>> >>>>> No, it is trampoline region size. >>>> >>>> trampoline + stack in head.S We take the address where we're going t= o >>>> copy the trampoline and set the stack to 0x10000 past it. >>> >>> I suppose that you think about this: >>> >>> /* Switch to low-memory stack. */ >>> mov sym_fs(trampoline_phys),%edi >>> lea 0x10000(%edi),%esp >>> >>> However, trampoline region size is (should be) 64 KiB. No way. Please= >>> look below for more details. >> >> The trampoline + stack are 64kb together. The stack grows down and the= >> trampoline grows up. The stack starts at 64kb past the start of the >> trampoline. %edi is the start of the trampoline. >=20 > Yep. I think that right now we are on the same boat. >=20 >>>>>>>> /* Populate E820 table and check trampoline area availabili= ty. */ >>>>>>>> e =3D e820map - 1; >>>>>>>> @@ -168,7 +170,8 @@ static void __init efi_arch_process_memory_m= ap(EFI_SYSTEM_TABLE *SystemTable, >>>>>>>> /* fall through */ >>>>>>>> case EfiConventionalMemory: >>>>>>>> if ( !trampoline_phys && desc->PhysicalStart + len = <=3D 0x100000 && >>>>>>>> - len >=3D cfg.size && desc->PhysicalStart + len= > cfg.addr ) >>>>>>>> + len >=3D cfg.size + extra_mem && >>>>>>>> + desc->PhysicalStart + len > cfg.addr ) >>>>>>>> cfg.addr =3D (desc->PhysicalStart + len - cfg.s= ize) & PAGE_MASK; >>>>>>> >>>>>>> So this is where the current series blows up and fails on real ha= rdware. >>>>>> >>>>>> Honestly this was my misunderstanding and this shouldn't ever be u= sed to >>>>>> get memory for the trampoline. This also has the bug in it that it= needs >>>>>> to be: >>>>>> >>>>>> ASSERT(cfg.size > 0); >>>>>> cfg.addr =3D (desc->PhysicalStart + len - (cfg.size + extra_mem) &= PAGE_MASK; >>>>> >>>>> As I said earlier. This extra_mem stuff is (maybe) wrong and should= be fixed >>>>> in one way or another. Hmmm... It looks OK. I will double check it = because >>>>> I do not looked at this code long time and maybe I am missing somet= hing. >>>> >>>> cfg.size needs to be the size of the trampolines + stack. >>> >>> It looks that during some code rearrangement I moved one instruction = too >>> much to trampoline_bios_setup. So, I can agree that right now cfg.siz= e >>> should be properly initialized. Though it should be cfg.size =3D 64 <= < 10. >>> Then extra_mem should be dropped. >> >> That's fine as long as its clear that 64kb is for the trampoline + the= >> stack. >=20 > OK, but there are two stacks. We talk about "low-memory stack". I will = improve > the comment. >=20 > [...] >=20 >>>>>> memory region). You need to use AllocatePages() otherwise you are >>>>>> trampling memory that might have been allocated by the bootloader = or any >>>>> >>>>> Bootloader code/data should be dead here. >>>> >>>> Correct. Unfortunately on my Lenovo laptop and my Intel NUCs I can't= >>>> currently call ExitBootServices and a timer that iPXE has wired up h= as >>> >>> If you disable an important wheel in a machine you should not expect >>> that the machine will work. Sorry! No way! >> >> Speak to your co-workers Konrad and Boris. We've had long email thread= s >> about how certain hardware does not work with the way Xen calls >> ExitBootServices. >=20 > Could you be more precise what is wrong? Or at least send links to > relevant threads. There have been several on the ML over the past 2 years. A quick Google search turns these up. http://xen.markmail.org/message/f6lx2ab4o2fch35r https://lists.xenproject.org/archives/html/xen-devel/2015-01/msg03164.htm= l >=20 >>>> some memory reserved down there and it was getting trampled. The rea= l >>> >>> I still do not know why remnants of iPXE should run at this Xen boot = stage. >>> It looks like an iPXE bug and IMO it should be fixed first. >> >> Like I said above, its because on this machine I am unable to call Xen= 's >> EBS. >=20 > I do not understand how ExitBootServices() call is related to iPXE time= r remnants > or so. Though if it is related somehow then I think that you should bla= me machine > and/or iPXE designer/developer not Xen developer. iPXE registers a callback for when EBS is called to clean up a timer. >=20 >>>> answer is that we need to fix up stock Xen to be able to always call= EBS. >>> >>> It looks that ExitBootServices() is always called. So, I do not think= that >>> anything have to be fixed. >> >> It is commented out of this board using the patchset that Konrad >> submitted to the ML years ago. >=20 > I do not know what patchset do you mean. Could you send it? >=20 See the above link. --=20 Doug Goldstein --F87QonTWPcEB3slaL3SmwRNbHl4K9Tg2H-- --9jPPr6Bq3JkKE8EFJrDbb5ktFHgQ6WMp1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0 iQJ8BAEBCgBmBQJYeAH/XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNTM5MEQ2RTNFMTkyNzlCNzVDMzIwOTVB MkJDMDNEQzg3RUQxQkQ0AAoJEKK8A9yH7RvUE1EP/jPExBbA6XjKbjp8ntHQeGW3 3AwlpxI/FgGKHc7VCY2iJEQQhmlGIK0+u/1rDIYJMoXlFSP6jPimfC4bnLw01PUg ceikHEhMcSngBis9+tChGo50AGaXZ5MD1jr3Vo0CwaAtL6vg+dbAnh58k/E8pDlH gR+rqM9b7TPoSCGISGhotrm7pT9s6x1fFG4Bsz3s4NX+vPI91yQ7/6KdMbdQoOo+ ygkB6TPNS1LeAPTmdAZzk7QJl/bumfPaDj1nKVuoX4/i7+i/mZRAjFTVLVdHoJZ4 KGZAbn06F1LH5zm5FbnV17No+PgEjgmEeLCJmS1tkftoMCudUvxHCpAR/dn8uvuk 50MQIvD/nJogpvm8//DNphEL3IMZol5k5WNXdnFOyk0ZuS4MvNDp/dLEQwniHBlo l5YN8C09bnyOTf0X0nytHzluIu2PwdNSHobKTIrgeKsw7P12cMWWxkxzq+HXyTXN ucS8C+sBmR9TYOCsYDRN4AGsarXJxuVHouClDUf/eZHe/Y7j/imMZ3eExSDZbQyX jPaFVFwlDNJrUlnFQvuE+kVFcA8/S2OdMbbmg4mP6HctfX07V6dHnw3uw+dOFBFv e6IV8JWWlGeCCbVXmj+rNvOSsWziHNkOaVP47Cax86/RHYNU5TUbgK5ayY2ySPRS qh0e1B5qqPUR+ov/Fiwa =H0iq -----END PGP SIGNATURE----- --9jPPr6Bq3JkKE8EFJrDbb5ktFHgQ6WMp1-- --===============0216326757974701246== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============0216326757974701246==--