Page MenuHomeFreeBSD

x86bios: use M_NOWAIT with mallocs
ClosedPublic

Authored by royger on Sep 3 2018, 9:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 12, 10:13 PM
Unknown Object (File)
Oct 28 2024, 7:44 PM
Unknown Object (File)
Oct 2 2024, 8:20 AM
Unknown Object (File)
Oct 2 2024, 1:27 AM
Unknown Object (File)
Sep 25 2024, 3:25 AM
Unknown Object (File)
Sep 21 2024, 5:55 AM
Unknown Object (File)
Sep 18 2024, 2:43 PM
Unknown Object (File)
Sep 7 2024, 7:13 PM
Subscribers

Details

Summary

Or else it triggers the following bug:

APIC: CPU 6 has ACPI ID 6
APIC: CPU 7 has ACPI ID 7
panic: vm_wait in early boot
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffffff826ff8d0
vpanic() at vpanic+0x1a3/frame 0xffffffff826ff930
panic() at panic+0x43/frame 0xffffffff826ff990
vm_wait_domain() at vm_wait_domain+0xf9/frame 0xffffffff826ff9c0
kmem_alloc_contig_domain() at kmem_alloc_contig_domain+0x252/frame 0xffffffff826ffa50
kmem_alloc_contig() at kmem_alloc_contig+0x6c/frame 0xffffffff826ffad0
contigmalloc() at contigmalloc+0x2e/frame 0xffffffff826ffb00
x86bios_modevent() at x86bios_modevent+0x225/frame 0xffffffff826ffb20
module_register_init() at module_register_init+0xc0/frame 0xffffffff826ffb50
mi_startup() at mi_startup+0x118/frame 0xffffffff826ffb70
start_kernel() at start_kernel+0x10

While there also make x86bios_unmap_mem idempotent.

Sponsored by: Citrix Systems R&D

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This is in fact worrying. How large are these requests ? If they cannot be satisfied at the early boot stage, then they cannot be at all, I think.

sys/compat/x86bios/x86bios.c
657 ↗(On Diff #47605)

Empty line is needed.

699 ↗(On Diff #47605)

Use consistent order for the flags, M_NOWAIT | M_ZERO.

In D17000#362579, @kib wrote:

This is in fact worrying. How large are these requests ? If they cannot be satisfied at the early boot stage, then they cannot be at all, I think.

They are not too large, what I see is: "contigmalloc - size: 0x1000 low: 0x1000 high: 0xa0000", which should be fulfillable. I guess there's something else that allocates this memory, but I have no idea of what yet. This is probably a glitch of running as a PVH guest, which has no BIOS and no reserved regions < 1MB.

They are not too large, what I see is: "contigmalloc - size: 0x1000 low: 0x1000 high: 0xa0000", which should be fulfillable. I guess there's something else that allocates this memory, but I have no idea of what yet. This is probably a glitch of running as a PVH guest, which has no BIOS and no reserved regions < 1MB.

Ah so it is low memory. Does it make sense to init bios at all, on such machine ? If yes, perhaps add a comment noting the situation ?

Anyway, with the style nits fixed, and perhaps with the comment added, the change is good code-wise.

This revision is now accepted and ready to land.Sep 3 2018, 10:20 AM
  • Add newline at the start of x86bios_unmap_mem.
  • Use consistent order for the flags.
This revision now requires review to proceed.Sep 3 2018, 10:20 AM
In D17000#362586, @kib wrote:

They are not too large, what I see is: "contigmalloc - size: 0x1000 low: 0x1000 high: 0xa0000", which should be fulfillable. I guess there's something else that allocates this memory, but I have no idea of what yet. This is probably a glitch of running as a PVH guest, which has no BIOS and no reserved regions < 1MB.

Ah so it is low memory. Does it make sense to init bios at all, on such machine ?

No, there's no BIOS on such guest type, so trying to initialise it is pointless. I guess some more checks should be added to prevent x86bios from trying to initialise, but in any case I can do this post-12.0.

If yes, perhaps add a comment noting the situation ?

I could add a comment to x86bios code noting that on certain Xen guests there's no BIOS at all, but I didn't want to pollute generic code with Xen specific nits.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 13 2018, 7:04 AM
This revision was automatically updated to reflect the committed changes.