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)
Wed, May 22, 12:03 PM
Unknown Object (File)
Sun, May 19, 8:07 PM
Unknown Object (File)
Wed, May 8, 12:04 PM
Unknown Object (File)
Wed, May 8, 12:03 PM
Unknown Object (File)
Wed, May 8, 12:03 PM
Unknown Object (File)
Wed, May 8, 12:03 PM
Unknown Object (File)
Wed, May 8, 9:52 AM
Unknown Object (File)
Jan 26 2024, 6:57 PM
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 Not Applicable
Unit
Tests Not Applicable

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
350

e820_add_entry() would be a more descriptive name IMO.

376

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
350

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
294

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
294

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
306

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

335

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
306

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.

335

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
306

I think some brief comments would help here.

This revision was automatically updated to reflect the committed changes.