[PATCH 0/4] x86/PVH: Dom0 building adjustments

Jan Beulich posted 4 patches 3 years, 3 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
[PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
The code building PVH Dom0 made use of sequences of P2M changes
which are disallowed as of XSA-378. First of all population of the
first Mb of memory needs to be redone. Then, largely as a
workaround, checking introduced by XSA-378 needs to be slightly
relaxed.

Note that with these adjustments I get Dom0 to start booting on my
development system, but the Dom0 kernel then gets stuck. Since it
was the first time for me to try PVH Dom0 in this context (see
below for why I was hesitant), I cannot tell yet whether this is
due further fallout from the XSA, or some further unrelated
problem. Dom0's BSP is in VPF_blocked state while all APs are
still in VPF_down. The 'd' debug key, unhelpfully, doesn't produce
any output, so it's non-trivial to check whether (like PV likes to
do) Dom0 has panic()ed without leaving any (visible) output.

[And there was another rather basic issue to fight first (patch
 will be submitted separately): vPCI wasn't aware of hidden PCI
 devices, hitting an ASSERT(). Obviously I couldn't afford not
 having a functioning serial console.]

In the course I ran into an oom condition while populating Dom0's
RAM. Hence next some re-work of dom0_compute_nr_pages(). In turn
in the course of putting that together I did notice that PV Dom0,
when run in shadow mode, wouldn't have its shadow allocation
properly set.

1: PVH: de-duplicate mappings for first Mb of Dom0 memory
2: P2M: relax guarding of MMIO entries
3: PVH: improve Dom0 memory size calculation
4: PV: properly set shadow allocation for Dom0

Jan


Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
On 30.08.2021 15:01, Jan Beulich wrote:
> The code building PVH Dom0 made use of sequences of P2M changes
> which are disallowed as of XSA-378. First of all population of the
> first Mb of memory needs to be redone. Then, largely as a
> workaround, checking introduced by XSA-378 needs to be slightly
> relaxed.
> 
> Note that with these adjustments I get Dom0 to start booting on my
> development system, but the Dom0 kernel then gets stuck. Since it
> was the first time for me to try PVH Dom0 in this context (see
> below for why I was hesitant), I cannot tell yet whether this is
> due further fallout from the XSA, or some further unrelated
> problem. Dom0's BSP is in VPF_blocked state while all APs are
> still in VPF_down. The 'd' debug key, unhelpfully, doesn't produce
> any output, so it's non-trivial to check whether (like PV likes to
> do) Dom0 has panic()ed without leaving any (visible) output.

Correction: I did mean '0' here, producing merely

(XEN) '0' pressed -> dumping Dom0's registers
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) *** Dumping Dom0 vcpu#1 state: ***
(XEN) *** Dumping Dom0 vcpu#2 state: ***
(XEN) *** Dumping Dom0 vcpu#3 state: ***

'd' output supports the "system is idle" that was also visible from
'q' output.

Jan


Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Roger Pau Monné 3 years, 3 months ago
On Tue, Aug 31, 2021 at 10:53:59AM +0200, Jan Beulich wrote:
> On 30.08.2021 15:01, Jan Beulich wrote:
> > The code building PVH Dom0 made use of sequences of P2M changes
> > which are disallowed as of XSA-378. First of all population of the
> > first Mb of memory needs to be redone. Then, largely as a
> > workaround, checking introduced by XSA-378 needs to be slightly
> > relaxed.
> > 
> > Note that with these adjustments I get Dom0 to start booting on my
> > development system, but the Dom0 kernel then gets stuck. Since it
> > was the first time for me to try PVH Dom0 in this context (see
> > below for why I was hesitant), I cannot tell yet whether this is
> > due further fallout from the XSA, or some further unrelated
> > problem.

Iff you have some time could you check without the XSA applied? I have
to admit I haven't been testing staging, so it's possible some
breakage as slipped in (however osstest seemed fine with it).

> > Dom0's BSP is in VPF_blocked state while all APs are
> > still in VPF_down. The 'd' debug key, unhelpfully, doesn't produce
> > any output, so it's non-trivial to check whether (like PV likes to
> > do) Dom0 has panic()ed without leaving any (visible) output.

Not sure it would help much, but maybe you can post the Xen+Linux
output?

Do you have iommu debug/verbose enabled to catch iommu faults?

> Correction: I did mean '0' here, producing merely
> 
> (XEN) '0' pressed -> dumping Dom0's registers
> (XEN) *** Dumping Dom0 vcpu#0 state: ***
> (XEN) *** Dumping Dom0 vcpu#1 state: ***
> (XEN) *** Dumping Dom0 vcpu#2 state: ***
> (XEN) *** Dumping Dom0 vcpu#3 state: ***
> 
> 'd' output supports the "system is idle" that was also visible from
> 'q' output.

Can you dump the state of the VMCS and see where the IP points to in
Linux?

Thanks, Roger.

Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
On 01.09.2021 15:56, Roger Pau Monné wrote:
> On Tue, Aug 31, 2021 at 10:53:59AM +0200, Jan Beulich wrote:
>> On 30.08.2021 15:01, Jan Beulich wrote:
>>> The code building PVH Dom0 made use of sequences of P2M changes
>>> which are disallowed as of XSA-378. First of all population of the
>>> first Mb of memory needs to be redone. Then, largely as a
>>> workaround, checking introduced by XSA-378 needs to be slightly
>>> relaxed.
>>>
>>> Note that with these adjustments I get Dom0 to start booting on my
>>> development system, but the Dom0 kernel then gets stuck. Since it
>>> was the first time for me to try PVH Dom0 in this context (see
>>> below for why I was hesitant), I cannot tell yet whether this is
>>> due further fallout from the XSA, or some further unrelated
>>> problem.
> 
> Iff you have some time could you check without the XSA applied? I have
> to admit I haven't been testing staging, so it's possible some
> breakage as slipped in (however osstest seemed fine with it).

Well, I'd rather try to use the time to find the actual issue. From
osstest being fine I'm kind of inferring this might be machine
specific, or this might be due to yet some other of the overly many
patches I'm carrying. So if I can't infer anything from the stack
once I can actually dump that, I may indeed need to bisect my pile,
which would then also include the XSA-378 patches (as I didn't have
time to re-base so far).

>>> Dom0's BSP is in VPF_blocked state while all APs are
>>> still in VPF_down. The 'd' debug key, unhelpfully, doesn't produce
>>> any output, so it's non-trivial to check whether (like PV likes to
>>> do) Dom0 has panic()ed without leaving any (visible) output.
> 
> Not sure it would help much, but maybe you can post the Xen+Linux
> output?

There's no Linux output yet by that point (and either
"earlyprintk=xen" doesn't work in PVH mode, or it's even too early
for that). All Xen has to say is

(XEN) Dom0 callback via changed to Direct Vector 0xf3
(XEN) vmx.c:3265:d0v0 RDMSR 0x0000064e unimplemented
(XEN) vmx.c:3265:d0v0 RDMSR 0x00000034 unimplemented

> Do you have iommu debug/verbose enabled to catch iommu faults?

I'll try to remember to check that, but since Linux hasn't
brought up APs yet I don't think there's any device activity
just yet.

>> Correction: I did mean '0' here, producing merely
>>
>> (XEN) '0' pressed -> dumping Dom0's registers
>> (XEN) *** Dumping Dom0 vcpu#0 state: ***
>> (XEN) *** Dumping Dom0 vcpu#1 state: ***
>> (XEN) *** Dumping Dom0 vcpu#2 state: ***
>> (XEN) *** Dumping Dom0 vcpu#3 state: ***
>>
>> 'd' output supports the "system is idle" that was also visible from
>> 'q' output.
> 
> Can you dump the state of the VMCS and see where the IP points to in
> Linux?

Both that and the register dumping I have meanwhile working tell
me that it's the HLT in default_idle(). IOW Dom0 gives the impression
of also being idle, at the first glance. The stack pointer, however,
is farther away from the stack top than I would have expected, so it
may still have entered default_idle() for other reasons.

The VMCS also told me that the last VM entry was to deliver an
interrupt at vector 0xf3 (i.e. the "callback" one).

Jan


Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
On 01.09.2021 16:19, Jan Beulich wrote:
> On 01.09.2021 15:56, Roger Pau Monné wrote:
>> Do you have iommu debug/verbose enabled to catch iommu faults?
> 
> I'll try to remember to check that, but since Linux hasn't
> brought up APs yet I don't think there's any device activity
> just yet.

No IOMMU faults, as expected.

Jan


Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
On 30.08.2021 15:01, Jan Beulich wrote:
> The code building PVH Dom0 made use of sequences of P2M changes
> which are disallowed as of XSA-378. First of all population of the
> first Mb of memory needs to be redone. Then, largely as a
> workaround, checking introduced by XSA-378 needs to be slightly
> relaxed.
> 
> Note that with these adjustments I get Dom0 to start booting on my
> development system, but the Dom0 kernel then gets stuck. Since it
> was the first time for me to try PVH Dom0 in this context (see
> below for why I was hesitant), I cannot tell yet whether this is
> due further fallout from the XSA, or some further unrelated
> problem. Dom0's BSP is in VPF_blocked state while all APs are
> still in VPF_down. The '0' debug key, unhelpfully, doesn't produce
> any output, so it's non-trivial to check whether (like PV likes to
> do) Dom0 has panic()ed without leaving any (visible) output.

Having made '0' work at least partly, I can now see that Dom0's
vCPU0 enters its idle loop after having gone through all normal
initialization. Clearly certain things must not have worked as
intended (no APs booted, no drivers loaded afaict), but I'm
having a hard time seeing how to find out what that might be
when there's no output at all. PV Dom0 does not require any
special command line option to do output to both the VGA console
and through hvc_xen (making its output also go to the serial
log) - is this perhaps different for PVH? I couldn't find
anything under docs/ ...

Jan


Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Juergen Gross 3 years, 3 months ago
On 01.09.21 17:06, Jan Beulich wrote:
> On 30.08.2021 15:01, Jan Beulich wrote:
>> The code building PVH Dom0 made use of sequences of P2M changes
>> which are disallowed as of XSA-378. First of all population of the
>> first Mb of memory needs to be redone. Then, largely as a
>> workaround, checking introduced by XSA-378 needs to be slightly
>> relaxed.
>>
>> Note that with these adjustments I get Dom0 to start booting on my
>> development system, but the Dom0 kernel then gets stuck. Since it
>> was the first time for me to try PVH Dom0 in this context (see
>> below for why I was hesitant), I cannot tell yet whether this is
>> due further fallout from the XSA, or some further unrelated
>> problem. Dom0's BSP is in VPF_blocked state while all APs are
>> still in VPF_down. The '0' debug key, unhelpfully, doesn't produce
>> any output, so it's non-trivial to check whether (like PV likes to
>> do) Dom0 has panic()ed without leaving any (visible) output.
> 
> Having made '0' work at least partly, I can now see that Dom0's
> vCPU0 enters its idle loop after having gone through all normal
> initialization. Clearly certain things must not have worked as
> intended (no APs booted, no drivers loaded afaict), but I'm
> having a hard time seeing how to find out what that might be
> when there's no output at all. PV Dom0 does not require any
> special command line option to do output to both the VGA console
> and through hvc_xen (making its output also go to the serial
> log) - is this perhaps different for PVH? I couldn't find
> anything under docs/ ...

Did you add earlyprintk=xen to the dom0 boot parameters?


Juergen
Re: [PATCH 0/4] x86/PVH: Dom0 building adjustments
Posted by Jan Beulich 3 years, 3 months ago
On 01.09.2021 17:24, Juergen Gross wrote:
> On 01.09.21 17:06, Jan Beulich wrote:
>> On 30.08.2021 15:01, Jan Beulich wrote:
>>> The code building PVH Dom0 made use of sequences of P2M changes
>>> which are disallowed as of XSA-378. First of all population of the
>>> first Mb of memory needs to be redone. Then, largely as a
>>> workaround, checking introduced by XSA-378 needs to be slightly
>>> relaxed.
>>>
>>> Note that with these adjustments I get Dom0 to start booting on my
>>> development system, but the Dom0 kernel then gets stuck. Since it
>>> was the first time for me to try PVH Dom0 in this context (see
>>> below for why I was hesitant), I cannot tell yet whether this is
>>> due further fallout from the XSA, or some further unrelated
>>> problem. Dom0's BSP is in VPF_blocked state while all APs are
>>> still in VPF_down. The '0' debug key, unhelpfully, doesn't produce
>>> any output, so it's non-trivial to check whether (like PV likes to
>>> do) Dom0 has panic()ed without leaving any (visible) output.
>>
>> Having made '0' work at least partly, I can now see that Dom0's
>> vCPU0 enters its idle loop after having gone through all normal
>> initialization. Clearly certain things must not have worked as
>> intended (no APs booted, no drivers loaded afaict), but I'm
>> having a hard time seeing how to find out what that might be
>> when there's no output at all. PV Dom0 does not require any
>> special command line option to do output to both the VGA console
>> and through hvc_xen (making its output also go to the serial
>> log) - is this perhaps different for PVH? I couldn't find
>> anything under docs/ ...
> 
> Did you add earlyprintk=xen to the dom0 boot parameters?

Yes (I did mention this before) - no difference at all. I guess I'll
try again, just in case I made a stupid mistake.

Jan