Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 May 2021 11:39:59 +0200
From:      Harry Schmalzbauer <freebsd@omnilan.de>
To:        Konstantin Belousov <kostikbel@gmail.com>, Wei Hu <weh@microsoft.com>
Cc:        Chris Knight <stryqx@gmail.com>, "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>
Subject:   Re: FreeBSD 12.1 i386 on Hyper-V Fails to Mount Root
Message-ID:  <22bbe4cd-82ed-b826-9ac0-05ef8aceba0e@omnilan.de>
In-Reply-To: <YKIRelPB9wmtBzzo@kib.kiev.ua>
References:  <CAHgj5TTKdiOU4bRu3SCBwKqnQaMqxUFynodh5MLBE7%2BycBiPYw@mail.gmail.com> <SG2P153MB0208B4185C3EB54120F10E74BB030@SG2P153MB0208.APCP153.PROD.OUTLOOK.COM> <c6013e67-4a37-43e1-4452-568d3ef6e5a7@omnilan.de> <ef85f9bb-ad8b-978e-da65-c887e8e8498e@omnilan.de> <PSAP153MB0440FD09AD1981FD569B7246BB2D9@PSAP153MB0440.APCP153.PROD.OUTLOOK.COM> <YKIDX/PjOlNc%2BtMa@kib.kiev.ua> <PSAP153MB0440A1511904E54767BF5344BB2D9@PSAP153MB0440.APCP153.PROD.OUTLOOK.COM> <YKIRelPB9wmtBzzo@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 17.05.2021 um 08:47 schrieb Konstantin Belousov:
> On Mon, May 17, 2021 at 06:33:19AM +0000, Wei Hu wrote:
>>> -----Original Message-----
>>> From: Konstantin Belousov <kostikbel@gmail.com>
>>> Sent: Monday, May 17, 2021 1:47 PM
>>> To: Wei Hu <weh@microsoft.com>
>>> Cc: Harry Schmalzbauer <freebsd@omnilan.de>; Chris Knight
>>> <stryqx@gmail.com>; freebsd-virtualization@freebsd.org
>>> Subject: Re: FreeBSD 12.1 i386 on Hyper-V Fails to Mount Root
>>>
>>> On Mon, May 17, 2021 at 04:12:20AM +0000, Wei Hu wrote:
:
:
:
>>>> separately. The workaround for this on amd64 is either build these
>>>> Hyper-V modules into the kernel or completely disable mitigation by
>>>> setting vm.pmap.pti="0" in /boot/loader.conf in the affect FreeBSD guests.
>>>>

Just to share some hopefully helpful pre-check's I've done so far:

Disabling PTI via vm.pmap.pti="0" in /boot/loader.conf doesn't make any 
difference for the i386 issue (at least x86/x86/local_apic.c always uses 
non-pti path; tried nontheless, with identical result).

As far as my analysis isn't completely wrong, the problem is about IDT 
pointer.
IDTVEC(rsvd) doesn't match in line 2180 of x86/x86/local_apic.c in 
native_lapic_ipi_alloc():
(ip->gd_hioffset << 16) | ip->gd_looffset;

Workign 11.4 shows these values:
11.4-i386 idx 251 (252-1 because no r363527, IPI_SWI) :
   hi =  (49417)            1100 0001 0000 1001
   lo =   (5472)            0001 0101 0110 0000
func =         1100 0001 0000 1001 0001 0101 0110 0000
IDTVEC(rsvd) = 1100 0001 0000 1001 0001 0101 0110 0000
== rsvd_pti

stable/13:
i386 idx 252 Nok:
   hi =  (65472)            1111 1111 1100 0000
   lo =  (12456)            0011 0000 1010 1000
func = 1111 1111 1100 0000 0011 0000 1010 1000
IDTVEC(rsvd) = 0 1110 0100 1011 1011 1110 1000
== rsvd_pti

My knowledge about IDT and it's handling by OS/FreeBSD is by far not 
enough to get a solution/explanation for the above.  I couldn't find the 
relevant paths in our source code (starting with the lack of basic asm 
skills).
For sure I'm missing the important path here, maybe I'm totaly wrong... 
if not this hopefully saves you some time.

I noticed r332489 too as a candidate for the regression beteween 12(.0) 
and 11(.2+).
I prepared a diff which applies to 11.4 (sources from iso) but 
recompiling 11.4 fails currently, I would need to rework the 
i386/i386/pmap.c adoption.


:
:
:
>> know the link to the patch or the commit if you already have checked in? I will
>> need to test and inform the parties who got affected.
> 
> It was mailed for you after your query, then I pinged you several times.
> Anyway, look at and try https://reviews.freebsd.org/D30310


I applied it to stable/13 and this doesn't make any difference, still 
the (ip->gd_hioffset << 16) | ip->gd_looffset; and 
(uintptr_t)IDTVEC(rsvd) differ with exactly the same values as shown above.

Thanks for your attention, best regards,
-harry





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?22bbe4cd-82ed-b826-9ac0-05ef8aceba0e>