Page MenuHomeFreeBSD

bhyve: add allocation function to E820
ClosedPublic

Authored by corvink on Apr 13 2023, 7:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 21 2024, 5:34 PM
Unknown Object (File)
Oct 22 2024, 6:08 AM
Unknown Object (File)
Oct 3 2024, 3:58 AM
Unknown Object (File)
Oct 2 2024, 11:56 PM
Unknown Object (File)
Oct 2 2024, 11:23 PM
Unknown Object (File)
Sep 27 2024, 11:47 PM
Unknown Object (File)
Sep 22 2024, 3:25 PM
Unknown Object (File)
Sep 21 2024, 1:30 AM
Subscribers

Details

Summary

This function makes it easy to allocate new E820 entries. It will be
used to allocate graphics memory for Intel integrated graphic devices.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 50876
Build 47767: arc lint + arc unit

Event Timeline

Is there any mechanism to ensure that no new entries are added once the table is passed to fwcfg?

usr.sbin/bhyve/e820.c
343

e820_add_entry() would be a more descriptive name IMO.

369

Missing parens around return values in this function.

Is there any mechanism to ensure that no new entries are added once the table is passed to fwcfg?

The table isn't passed directly to the guest. e820_get_fwcfg_item converts the current table into a fwcfg item. So, changes of the table aren't reflected by the fwcfg item.

corvink added inline comments.
usr.sbin/bhyve/e820.c
343

e820_add_entry already exists. This function tries is a wrapper around e820_add_entry to add an entry at a specific address.

usr.sbin/bhyve/e820.c
287

It's hard to understand what this function is doing. Is it supposed to find holes between existing entries, or does it replace existing entries of type E820_TYPE_MEMORY?

usr.sbin/bhyve/e820.c
287

It allocates a region in E820_TYPE_MEMORY and marks it as another memory type. So, it replaces existing E820_TYPE_MEMORY entries. E.g.:

dump_table:
  0x0000 - 0x1000 E820_TYPE_MEMORY

alloc_highest(0xFFFF, 0x0100, 0, E820_TYPE_RESERVED);

dump_table:
  0x0000 - 0x0E00 E820_TYPE_MEMORY
  0x0E00 - 0x1000 E820_TYPE_RESERVED
markj added inline comments.
usr.sbin/bhyve/e820.c
299

Why do you check that end - length != 0?

328

What's wrong with base == 0?

This revision is now accepted and ready to land.Apr 25 2023, 1:29 PM
usr.sbin/bhyve/e820.c
299

Same reason as base == 0 for alloc_lowest. If end - length == 0, we'll end up allocating address 0 which should be avoided in most cases.

328

We shouldn't allocate memory at address 0. Not sure if the caller or the callee should be responsible to avoid it.

usr.sbin/bhyve/e820.c
299

I think some brief comments would help here.

This revision was automatically updated to reflect the committed changes.