Skip to contentSkip to conversation

issue with dom0_pvh on Xen 4.20

DISCUSSION Manuel Bouyer 4 participants 29 messages Sep 2, 2025 – Sep 3, 2025

lore
Share & tools
lore
#0 lore raw

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

thanks

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#1 lore raw
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

Your best bet is to instrument hvm_triple_fault().  e.g.

xen/arch/x86/hvm/hvm.c +0 -0
index 23bd7f078a1d..0f960576b3e6 100644
@@ -1746,14 +1746,22 @@ void hvm_hlt(unsigned int eflags)


 void hvm_triple_fault(void)
 {
+    const struct cpu_user_regs *regs = guest_cpu_user_regs(); struct vcpu *v = current;
     struct domain *d = v->domain;
     u8 reason = d->arch.hvm.params[HVM_PARAM_TRIPLE_FAULT_REASON]; +    char insns[32];

     gprintk(XENLOG_ERR,
             "Triple fault - invoking HVM shutdown action %d\n", reason);
     vcpu_show_execution_state(v);
+
+    if ( copy_from_user_hvm(insns, _p(regs->rip), ARRAY_SIZE(insns)) ) +        printk("Guest code stream: %32ph\n", insns);
+    else
+        printk("Bad pagetables for %%rip\n");
+
     domain_shutdown(d, reason);
 }

will try and get you the instruction which finally caused the fault. (compile tested only)

Given that 4.18 works and 4.20 doesn't, it's probably to do with the initial memory map of the guest.  Do you have the full logs of both boots?

Just for sanity sake (I don't know if it's going to be relevant or not), boot with dom0=pvh,pf-fixup  which just might highlight if we've got a mixup with the memory map presented to the guest vs the system.

~Andrew

#2 lore raw
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 4 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#3 lore raw
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

~Andrew

#4 lore raw
Quoted 63 lines · Andrew Cooper
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 6 lines

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

it's an old intel system:
cpu0: "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz"
cpu0: Intel Xeon 36xx & 56xx, i7, i5 and i3 (686-class), 2667.30 MHz
cpu0: family 0x6 model 0x2c stepping 0x2 (id 0x206c2)

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#10 lore raw
In reply to Manuel Bouyer
Quoted 56 lines · Manuel Bouyer
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 7 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Can you perhaps check this guess against the %esp value seen? From the hypervisor's triple fault handling, you may want to actually log stack contents as well (in addition to what Andrew suggested), assuming %esp looks sane to you.

Jan

#11 lore raw
Quoted 65 lines · Jan Beulich
Quoted 56 lines · Manuel Bouyer
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 7 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 4 lines

Can you perhaps check this guess against the %esp value seen? From the hypervisor's triple fault handling, you may want to actually log stack contents as well (in addition to what Andrew suggested), assuming %esp looks sane to you.

%esp is sane. I forgot to mention, this happens very early, while we're still in 32bits real mode. No function call did happen at this point, and on the stack there's only one 32bit value: the %ebp that we just pushed

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#5 lore raw
In reply to Manuel Bouyer
Quoted 67 lines · Manuel Bouyer
Quoted 66 lines · Andrew Cooper
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Quoted 7 lines
Quoted 2 lines

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

it's an old intel system:
cpu0: "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz"
cpu0: Intel Xeon 36xx & 56xx, i7, i5 and i3 (686-class), 2667.30 MHz
cpu0: family 0x6 model 0x2c stepping 0x2 (id 0x206c2)

Hmm.  Westmere EP.  Are you running with EPT active, or with Shadow Paging?

~Andrew

#13 lore raw
In reply to Manuel Bouyer
Quoted 56 lines · Manuel Bouyer
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

         cmpl    $0,%ecx                 ;       /* zero-sized? */       \
         je      2f                      ; \
         pushl   %ebp                    ; \
         movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
         movl    %eax,(%ebx)             ;       /* store phys addr */   \
         addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
         addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
         loop    1b                      ; \
         popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 8 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

Juergen

#6 lore raw
In reply to Andrew Cooper
Quoted 70 lines · Andrew Cooper
Quoted 69 lines · Manuel Bouyer
Quoted 68 lines · Andrew Cooper
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

Quoted 7 lines
Quoted 5 lines

it's an old intel system:
cpu0: "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz"
cpu0: Intel Xeon 36xx & 56xx, i7, i5 and i3 (686-class), 2667.30 MHz
cpu0: family 0x6 model 0x2c stepping 0x2 (id 0x206c2)

Hmm.  Westmere EP.  Are you running with EPT active, or with Shadow Paging?

How do I know ?
Note that the same problem shows up on much newer systems: an i9, and a Xeon W-2223. Both boots fine with the same NetBSD kernel and Xen 4.18 or 4.15.

I'm using this old Xeon for debug because this one has a serial console.

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#14 lore raw
In reply to Juergen Gross
Quoted 66 lines · Juergen Gross
Quoted 56 lines · Manuel Bouyer
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0  x86_64  debug=y  Tainted:   C    ]---- (XEN) CPU:    7
(XEN) RIP:    0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006   CONTEXT: hvm guest (d0v0)
(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7 (XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000 (XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000 (XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000 (XEN) ds: 0010   es: 0010   fs: 0000   gs: 0000   ss: 0010   cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:
         cmpl    $0,%ecx                 ;       /* zero-sized? */       \
         je      2f                      ; \
         pushl   %ebp                    ; \
         movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
         movl    %eax,(%ebx)             ;       /* store phys addr */   \
         addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
         addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
         loop    1b                      ; \
         popl    %ebp                    ; \
2:                                      ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN)  [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 8 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0

So virt_kentry is very near to the RIP.

Juergen

#23 lore raw
In reply to Juergen Gross
Quoted 66 lines · Juergen Gross
Quoted 56 lines · Manuel Bouyer
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

         cmpl    $0,%ecx                 ;       /* zero-sized? */       \
         je      2f                      ; \
         pushl   %ebp                    ; \
         movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
         movl    %eax,(%ebx)             ;       /* store phys addr */   \
         addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
         addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
         loop    1b                      ; \
         popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 8 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 3 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault

AFAIK it can't be as we're still in real mode

Quoted 4 lines

- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

No. RIP shouldn't end up there in any way. the assembly code is quite simple, it's just a loop and I'm quite confident that we did enter the loop with sane values

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#24 lore raw
Quoted 67 lines · Manuel Bouyer
Quoted 66 lines · Juergen Gross
Quoted 64 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

         cmpl    $0,%ecx                 ;       /* zero-sized? */       \
         je      2f                      ; \
         pushl   %ebp                    ; \
         movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
         movl    %eax,(%ebx)             ;       /* store phys addr */   \
         addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
         addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
         loop    1b                      ; \
         popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 4 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 5 lines
Quoted 3 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault

AFAIK it can't be as we're still in real mode

It's protected mode, but with paging still off.

Quoted 8 lines
Quoted 4 lines

- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

No. RIP shouldn't end up there in any way. the assembly code is quite simple, it's just a loop and I'm quite confident that we did enter the loop with sane values

Yet Jürgen has a point - entry point and what is being modified are on the same page (and despite paging still being off, you writing page tables here makes pages a relevant unit). Considering
- entry point @ 0x20e4d0
- %ecx = 0xdfeb7
- %ebx = 0x20e260
the loop continuing a little further will overwrite the entry point code. And with the entry point not at an even (e.g page-aligned) address, other code (like the one here) could conceivably live immediately ahead of it. (Of course this overwriting may be intentional, but it looks suspicious in this context.)

Jan

#15 lore raw
In reply to Juergen Gross
Quoted 81 lines · Juergen Gross
Quoted 70 lines · Juergen Gross
Quoted 60 lines · Manuel Bouyer
Quoted 59 lines · Andrew Cooper
Quoted 57 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0  x86_64  debug=y  Tainted:   C    ]---- (XEN) CPU:    7
(XEN) RIP:    0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006   CONTEXT: hvm guest (d0v0)
(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7 (XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000 (XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000 (XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000 (XEN) ds: 0010   es: 0010   fs: 0000   gs: 0000   ss: 0010   cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:
         cmpl    $0,%ecx                 ;       /* zero-sized? */       \
         je      2f                      ; \
         pushl   %ebp                    ; \
         movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
         movl    %eax,(%ebx)             ;       /* store phys addr */   \
         addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
         addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
         loop    1b                      ; \
         popl    %ebp                    ; \
2:                                      ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN)  [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Any idea, including how to debug this further, welcome

Quoted 8 lines
Quoted 2 lines

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

Quoted 8 lines
(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0

So virt_kentry is very near to the RIP.

thanks, I missed this point and got my math off by 0x100000 it seems.

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#7 lore raw
In reply to Manuel Bouyer
Quoted 71 lines · Manuel Bouyer
Quoted 70 lines · Andrew Cooper
Quoted 69 lines · Manuel Bouyer
Quoted 68 lines · Andrew Cooper
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

it's an old intel system:
cpu0: "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz"
cpu0: Intel Xeon 36xx & 56xx, i7, i5 and i3 (686-class), 2667.30 MHz
cpu0: family 0x6 model 0x2c stepping 0x2 (id 0x206c2)

Hmm.  Westmere EP.  Are you running with EPT active, or with Shadow Paging?

How do I know ?

Something like:

HVM: Hardware Assisted Paging (HAP) detected

on boot.

Quoted 4 lines

Note that the same problem shows up on much newer systems: an i9, and a Xeon W-2223. Both boots fine with the same NetBSD kernel and Xen 4.18 or 4.15.

I'm using this old Xeon for debug because this one has a serial console.

Sure.  It's just that HAP vs Shadow is also relevant to breaking apart a triple fault.

~Andrew

#12 lore raw
In reply to Manuel Bouyer
Quoted 66 lines · Manuel Bouyer
Quoted 65 lines · Jan Beulich
Quoted 63 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 4 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 8 lines
Quoted 4 lines

Can you perhaps check this guess against the %esp value seen? From the hypervisor's triple fault handling, you may want to actually log stack contents as well (in addition to what Andrew suggested), assuming %esp looks sane to you.

%esp is sane. I forgot to mention, this happens very early, while we're still in 32bits real mode. No function call did happen at this point, and on the stack there's only one 32bit value: the %ebp that we just pushed

Which by implication means no earlier exception(s).

Jan

#25 lore raw
In reply to Jan Beulich
Quoted 17 lines · Jan Beulich
Quoted 5 lines
Quoted 3 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault

AFAIK it can't be as we're still in real mode

It's protected mode, but with paging still off.

Quoted 8 lines
Quoted 4 lines

- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

No. RIP shouldn't end up there in any way. the assembly code is quite simple, it's just a loop and I'm quite confident that we did enter the loop with sane values

Quoted 11 lines

Yet Jürgen has a point - entry point and what is being modified are on the same page (and despite paging still being off, you writing page tables here makes pages a relevant unit). Considering
- entry point @ 0x20e4d0
- %ecx = 0xdfeb7
- %ebx = 0x20e260
the loop continuing a little further will overwrite the entry point code. And with the entry point not at an even (e.g page-aligned) address, other code (like the one here) could conceivably live immediately ahead of it. (Of course this overwriting may be intentional, but it looks suspicious in this context.)

Indeed. Now the exact same kernel is booting fine with Xen 4.18 (and also the same bootstrap is used for domU PVH which works with Xen 4.20). I guess something changed in the way Xen sets up the dom0 kernel.

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#8 lore raw
In reply to Andrew Cooper
Quoted 77 lines · Andrew Cooper
Quoted 76 lines · Manuel Bouyer
Quoted 75 lines · Andrew Cooper
Quoted 74 lines · Manuel Bouyer
Quoted 62 lines · Andrew Cooper
Quoted 54 lines · Manuel Bouyer
Quoted 53 lines · Andrew Cooper
Quoted 52 lines · Manuel Bouyer

Hello,
I'm trying to boot a NetBSD PVH dom0 on Xen 4.20.
The same NetBSD kernel works fine with Xen 4.18

The boot options are:
menu=Boot netbsd-current PVH Xen420:dev hd0f:;load /netbsd-PVH console=com0 root=wd0f; multiboot /xen420-debug.gz dom0_mem=1024M console=com1 com1=38400,8n1 loglvl=all guest_loglvl=all gnttab_max_nr_frames=64 sync_console=1 dom0=pvh

and the full log from serial console is attached.

With 4.20 the boot fails with:

(XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) Freed 664kB init memory
(XEN) d0v0 Triple fault - invoking HVM shutdown action 1
(XEN) *** Dumping Dom0 vcpu#0 state: ***
(XEN) ----[ Xen-4.20.2-pre_20250821nb0 x86_64 debug=y Tainted: C ]----
(XEN) CPU: 7
(XEN) RIP: 0008:[<000000000020e268>]
(XEN) RFLAGS: 0000000000010006 CONTEXT: hvm guest (d0v0)

(XEN) rax: 000000002024c003   rbx: 000000000020e260   rcx: 00000000000dfeb7
(XEN) rdx: 0000000000100000   rsi: 0000000000103000   rdi: 000000000013e000
(XEN) rbp: 0000000080000000   rsp: 00000000014002e4   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000
(XEN) fsb: 0000000000000000   gsb: 0000000000000000   gss: 0000000000000000

(XEN) ds: 0010 es: 0010 fs: 0000 gs: 0000 ss: 0010 cs: 0008

because of the triple fault the RIP above doens't point to the code.

I tracked it down to this code:

        cmpl    $0,%ecx                 ;       /* zero-sized? */       \
        je      2f                      ; \
        pushl   %ebp                    ; \
        movl    RELOC(nox_flag),%ebp    ; \
1:      movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
        movl    %eax,(%ebx)             ;       /* store phys addr */   \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ; \
        popl    %ebp                    ; \

2: ;

there are others pushl/popl before so I don't think that's the problem (in fact the exact same fragment is called just before with different inputs and it doesn't fault). So the culprit it probably the write to (%ebx), which would be 0x20e260
This is in the range:
(XEN) [0000000000100000, 0000000040068e77] (usable)
so I can't see why this would be a problem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any idea, including how to debug this further, welcome

Even though triple fault's are aborts, they're generally accurate under virt, so 0x20e268 is most likely where things die.

but that's the RIP of the last fault, not the first one, right ? 0x20e268 isn't in the text segment of the kernel, my guess is that the first fault triggers an exception, but the exeption handler isn't set up yet so we end up jumping to some random value.

Quoted 6 lines

Double and Triple faults occur when trying to deliver an exception generates an exception.  So while multiple faults are involved, only one instruction typically is.

Is this an Intel or an AMD system?  One thing virt can do is break apart a triple fault, but the logic to do so is vendor specific.

it's an old intel system:
cpu0: "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz"
cpu0: Intel Xeon 36xx & 56xx, i7, i5 and i3 (686-class), 2667.30 MHz
cpu0: family 0x6 model 0x2c stepping 0x2 (id 0x206c2)

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Hmm.  Westmere EP.  Are you running with EPT active, or with Shadow Paging?

How do I know ?

Something like:

HVM: Hardware Assisted Paging (HAP) detected

on boot.

Sorry - i missed the log on the root of the conversation.  You do have HAP on this system.

~Andrew

#26 lore raw
In reply to Manuel Bouyer
Quoted 30 lines · Manuel Bouyer
Quoted 17 lines · Jan Beulich
Quoted 5 lines
Quoted 3 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault

AFAIK it can't be as we're still in real mode

It's protected mode, but with paging still off.

Quoted 8 lines
Quoted 4 lines

- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

No. RIP shouldn't end up there in any way. the assembly code is quite simple, it's just a loop and I'm quite confident that we did enter the loop with sane values

Quoted 11 lines

Yet Jürgen has a point - entry point and what is being modified are on the same page (and despite paging still being off, you writing page tables here makes pages a relevant unit). Considering
- entry point @ 0x20e4d0
- %ecx = 0xdfeb7
- %ebx = 0x20e260
the loop continuing a little further will overwrite the entry point code. And with the entry point not at an even (e.g page-aligned) address, other code (like the one here) could conceivably live immediately ahead of it. (Of course this overwriting may be intentional, but it looks suspicious in this context.)

Quoted 3 lines

Indeed. Now the exact same kernel is booting fine with Xen 4.18 (and also the same bootstrap is used for domU PVH which works with Xen 4.20). I guess something changed in the way Xen sets up the dom0 kernel.

Hence why Andrew asked for full logs of both boots, to put side by side.

Jan

#9 lore raw
In reply to Andrew Cooper
Quoted 2 lines · Andrew Cooper

HVM: Hardware Assisted Paging (HAP) detected
on boot.

So it is:
(XEN) HVM: ASIDs enabled.
(XEN) VMX: Disabling executable EPT superpages due to CVE-2018-12207 (XEN) HVM: VMX enabled
(XEN) HVM: Hardware Assisted Paging (HAP) detected
(XEN) HVM: HAP page sizes: 4kB, 2MB, 1GB

but the RIP printed by Xen may be right, after all

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#27 lore raw
In reply to Jan Beulich
Quoted 1 line · Jan Beulich

Hence why Andrew asked for full logs of both boots, to put side by side.

Sorry I missed this.
Here's both log. 4.20 may be different from the one I posted earlier; I did another boot to make sure it's the exact same kernel for both logs.

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#16 lore raw
In reply to Juergen Gross
Quoted 10 lines · Juergen Gross
Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

Quoted 8 lines
(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0

So virt_kentry is very near to the RIP.

thanks to this, I think I found the issue:
with Xen 4.18, the kernel is started with ebx=17bb018; with 4.20 it's 100018.

The bootstrap code assumes that the kernel is after the kernel, and the kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#17 lore raw
Quoted 18 lines · Manuel Bouyer
Quoted 17 lines · Juergen Gross
Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0
Quoted 7 lines
Quoted 1 line

So virt_kentry is very near to the RIP.

thanks to this, I think I found the issue:
with Xen 4.18, the kernel is started with ebx=17bb018; with 4.20 it's 100018.

The bootstrap code assumes that the kernel is after the kernel, and the

DYM "start info is after the kernel" or some such, seeing that that's what %ebx is about?

Quoted 5 lines

kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

You'll need to handle that internally, I expect, perhaps from properties of your (ELF) binary.

Jan

#22 lore raw
In reply to Manuel Bouyer
Quoted 17 lines · Manuel Bouyer
Quoted 16 lines · Juergen Gross
Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0
Quoted 6 lines
Quoted 1 line

So virt_kentry is very near to the RIP.

thanks to this, I think I found the issue:
with Xen 4.18, the kernel is started with ebx=17bb018; with 4.20 it's 100018.

The bootstrap code assumes that the kernel is after the kernel,

kernel after kernel?

Quoted 6 lines

and the
kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

ebx points to the PVH info.  This is arbitrary, like multiboot info, and you shouldn't make assumptions about it's position relative to the other modules loaded.

~Andrew

#18 lore raw
In reply to Jan Beulich
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Manuel Bouyer
Quoted 18 lines · Juergen Gross
Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0

So virt_kentry is very near to the RIP.

Quoted 8 lines
Quoted 5 lines

thanks to this, I think I found the issue:
with Xen 4.18, the kernel is started with ebx=17bb018; with 4.20 it's 100018.

The bootstrap code assumes that the kernel is after the kernel, and the

DYM "start info is after the kernel" or some such, seeing that that's what %ebx is about?

yes, sorry

Quoted 9 lines
Quoted 6 lines

kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

You'll need to handle that internally, I expect, perhaps from properties of your (ELF) binary.

But I don't have access to the ELF headers from the kernel binary (nor do I know which kernel was booted).

Hum, maybe a I can hardcode this info in some const of the binary with a ld trick ?

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#19 lore raw
Quoted 39 lines · Manuel Bouyer
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Manuel Bouyer
Quoted 18 lines · Juergen Gross
Quoted 7 lines

What puzzles me is that:

- %cr2 is 0, so probably the first fault wasn't a page fault
- RIP is %ebx + 8, so maybe the code was just clobbered by the loop?

Could it be the code has been moved to this location, or is about to be moved away afterwards?

And indeed: from the full boot log I can see:

(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x200000
(XEN)     virt_kend        = 0x17bab90
(XEN)     virt_entry       = 0x20e4d0

So virt_kentry is very near to the RIP.

Quoted 8 lines
Quoted 5 lines

thanks to this, I think I found the issue:
with Xen 4.18, the kernel is started with ebx=17bb018; with 4.20 it's 100018.

The bootstrap code assumes that the kernel is after the kernel, and the

DYM "start info is after the kernel" or some such, seeing that that's what %ebx is about?

yes, sorry

Quoted 6 lines
Quoted 5 lines

kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

Quoted 8 lines
Quoted 2 lines

You'll need to handle that internally, I expect, perhaps from properties of your (ELF) binary.

But I don't have access to the ELF headers from the kernel binary (nor do I know which kernel was booted).

Hum, maybe a I can hardcode this info in some const of the binary with a ld trick ?

For the symbol table to be loaded, it needs to live in some loadable section. You should be able to mark that section's end (or the end of the symbol table in the section, in case there's more stuff there) with a symbol in the linker script (which I assume you use). If you used the GNU toolchain, you could also consider using the assembler's .startof. / .sizeof. operators (producing symbols that the linker then recognizes and resolves accordingly).

Or wait - are you perhaps using the thing we call "bsd_symtab" in our libelf? Then, as per the scheme in elf_load_bsdsyms(), can't you find the start of the ELF header from the end of your kernel? At least that's how I understand it's supposed to work.

Jan

#20 lore raw
Quoted 15 lines · Jan Beulich
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

kernel symbol table. That seems to be no longer true with Xen 4.20 and a PVH dom0 (but probably still true in all other cases).

I can deal with that, but with the new layout how do I get the end of the symbol table ?

Quoted 8 lines
Quoted 2 lines

You'll need to handle that internally, I expect, perhaps from properties of your (ELF) binary.

But I don't have access to the ELF headers from the kernel binary (nor do I know which kernel was booted).

Hum, maybe a I can hardcode this info in some const of the binary with a ld trick ?

Quoted 8 lines

For the symbol table to be loaded, it needs to live in some loadable section. You should be able to mark that section's end (or the end of the symbol table in the section, in case there's more stuff there) with a symbol in the linker script (which I assume you use). If you used the GNU toolchain, you could also consider using the assembler's .startof. / .sizeof. operators (producing symbols that the linker then recognizes and resolves accordingly).

Or wait - are you perhaps using the thing we call "bsd_symtab" in our libelf?

yes, that's it. I'm looking at how it's loaded right now

Quoted 3 lines

Then, as per the scheme in elf_load_bsdsyms(), can't you find the start of the ELF header from the end of your kernel? At least that's how I understand it's supposed to work.

I can, but at this point I can't easily call C code, and doing it in assembly doesn't look easy :(

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#21 lore raw
Quoted 8 lines · Manuel Bouyer

yes, that's it. I'm looking at how it's loaded right now

Quoted 3 lines

Then, as per the scheme in elf_load_bsdsyms(), can't you find the start of the ELF header from the end of your kernel? At least that's how I understand it's supposed to work.

I can, but at this point I can't easily call C code, and doing it in assembly doesn't look easy :(

Oh, it looks like Xen stores the size just before the ELF header. if that's the case, all good !

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--