Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Mar 2017 09:11:09 +0200
From:      Toomas Soome <tsoome@me.com>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: input/output error @boot
Message-ID:  <63EAF6F6-D5E4-46F9-9AA1-C721DAC64C11@me.com>
In-Reply-To: <MWHPR03MB26696FB5963990FE4455609CBF210@MWHPR03MB2669.namprd03.prod.outlook.com>
References:  <CACnPvjLv_QhhxYvcbU44x=n0pk61xyFgUGWcTYh%2B6HaGUGJMFg@mail.gmail.com> <CACnPvjKG9NEuFDBWv=6qj5GZj4=-89qT8w75kEx-QaXjHNJzXg@mail.gmail.com> <6779d31b-a285-3002-8ecc-5738ac88df27@madpilot.net> <CANCZdfr_pTNuCpDx1rm9KcEimnhGTkCv3i2tNceAZsgrs_c%2BcQ@mail.gmail.com> <CANJ8om5Gri=%2B4Ju9BjdUONwQMW5zrzQhTpz2AzVWUKSVrSgdDA@mail.gmail.com> <CACnPvjJgLK-YtOTJOEE1Uad==pwzO39hSQ1Nk%2BnHND58EbTmvA@mail.gmail.com> <441BF371-53C4-4FE8-A39C-BFA8B25DE760@freebsd.org> <CACnPvjK%2Bb6x3SAD7Gu7uFTkx=iCm2afgt4boVquTT5BC_sF4Tg@mail.gmail.com> <MWHPR03MB2669AB5FFC455EE6BBAAE765BF2F0@MWHPR03MB2669.namprd03.prod.outlook.com> <CACnPvj%2BvrkYGR3b_CoDkORksB6ENZ5HLdzD6=ebJm1329LcfJQ@mail.gmail.com> <CACnPvj%2BQDZZjHzwU7VcsNFN784R4=gYe6qzhQb0NG0AQpov=5g@mail.gmail.com> <MWHPR03MB26699DF5E658361614D71A5EBF2E0@MWHPR03MB2669.namprd03.prod.outlook.com> <CACnPvjKW8di44raA=MxEbqfNPkYaoQ5uOCkgcT3tf1i733i1KA@mail.gmail.com> <CACnPvjJnTyxQu-4-MYB3rPWGZ4TJa%2B=niLkKdtaNTiO%2Bbw=hug@mail.gmail.com> <MWHPR03MB2669510547F2244091F676BCBF210@MWHPR03MB2669.namprd03.prod.outlook.com> <MWHPR03MB26696FB5963990FE4455609CBF210@MWHPR03MB2669.namprd03.prod.outlook.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> On 9. m=C3=A4rts 2017, at 8:00, Dexuan Cui <decui@microsoft.com> =
wrote:
>=20
> Hi Roberto,=20
> Thanks for sending me your memmap and this is a temporary workaround
> patch for you:
> =
https://github.com/dcui/freebsd/commit/0edd1db55fbbb56352d6024250e4ae7dd8a=
d31e3.patch
>=20
> I put the memmap info here for people who're interested:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D211746#c26
>=20
> We can notice there is a 4MB BootServicesCode range at [12MB, 16MB) .
> loader.efi just writes into this range by force -- this is unsafe =
anyway!
>=20
> To fix this correctly & thoroughly, IMO we need a relocatable kernel, =
but
> that would require a lot of complicated long term work:
> https://reviews.freebsd.org/D9686?id=3D25414#inline-56969
>=20
> For now, I suggest we should only apply the idea "reduce the size of =
the
> staging area if necessary" to VM running on Hyper-V, we should restore =
the
> old behavior on physical machines since that has been working for =
people
> for a long period of time, though it's  potentially unsafe.
>=20
> I think in the loader we can use CPUID to tell if we're running on =
Hyper-V or not.


IMO there are multiple issues around this problem and workaround.

First of all, to control UEFI memory allocation, the AllocatePages() has =
options:

AllocateAnyPages,
AllocateMaxAddress,
AllocateAddress

On x86, we use:

        staging =3D 1024*1024*1024;
        status =3D BS->AllocatePages(AllocateMaxAddress, EfiLoaderData,
            nr_pages, &staging);

Which means:

"Allocation requests of Type AllocateMaxAddress allocate any available =
range of pages whose uppermost address is less than or equal to the =
address pointed to by Memory on input.=E2=80=9D

So, we are asking for an amount of memory (64MB), with condition that =
all the pages should be below 1GB.

And we get it. If hyper-v is in fact returning us memory from already =
occupied area - there can be exactly one conclusion - it is bug in =
hyper-v.

Note, this allocation method does *not* set the starting point for =
allocation, it can return us *any* chunk of memory of given size, below =
1GB.

So the attempt to control such allocation by size, is unfortunately =
flawed - it really does not control the allocation.

Note that I have also seen AllocateAddress failures - there was nicely =
available chunk of memory, but the firmware just did not allocate with =
given address (it did happen with OVMF + qemu).

The secondary flaw there is also about firmware. Sure, with UEFI you can =
have =E2=80=9Crandom=E2=80=9D allocations and the actual control over =
memory is actually problem, but to plant an =E2=80=9Cegg=E2=80=9D  in =
1MB-1GB range, where you have most chances any OS will live - IMO this =
is just stupid.

The only real solution here is to either rise the MaxAddress limit or =
use AllocateAnyPages, get kernel loaded into the memory, and after =
switching off the boot services and before jumping to kernel, relocate =
the kernel to available location below 1GB=E2=80=A6=20

rgds,
toomas



>=20
> Thanks,
> -- Dexuan
>=20
>> -----Original Message-----
>> From: owner-freebsd-current@freebsd.org [mailto:owner-freebsd-
>> current@freebsd.org] On Behalf Of Dexuan Cui
>> Sent: Thursday, March 9, 2017 10:44
>> To: Roberto Rodriguez Jr <rob.rodz.jr9@gmail.com>
>> Cc: FreeBSD Current <freebsd-current@freebsd.org>
>> Subject: RE: input/output error @boot
>>=20
>> [This sender failed our fraud detection checks and may not be who =
they appear
>> to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]
>>=20
>> Hmm, Alex did report 314891 worked.
>>=20
>> Can you please post the full boot log of the loader?
>> Especially, when you see the =E2=80=9COK=E2=80=9D prompt, can you =
please run the =E2=80=9Cmemmap=E2=80=9D
>> command like this link ...
>>=20
>> You can take a photo of the screen and send it to me, if it=E2=80=99s =
too big.
>>=20
>> Thanks,
>> -- Dexuan
>=20
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to =
"freebsd-current-unsubscribe@freebsd.org"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?63EAF6F6-D5E4-46F9-9AA1-C721DAC64C11>