bhyve: Use vm_get_highmem_base() instead of hard-coding the value

This reduces the coupling between libvmmapi (which creates the highmem
segment) and bhyve, in preparation for the arm64 port.

No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40992
This commit is contained in:
Mark Johnston 2024-04-03 12:51:37 -04:00
parent eaff4c4f92
commit e497fe8657
4 changed files with 13 additions and 8 deletions

View file

@ -118,12 +118,15 @@ bootrom_var_mem_handler(struct vcpu *vcpu __unused, int dir, uint64_t addr,
void
init_bootrom(struct vmctx *ctx)
{
vm_paddr_t highmem;
romptr = vm_create_devmem(ctx, VM_BOOTROM, "bootrom", BOOTROM_SIZE);
if (romptr == MAP_FAILED)
err(4, "%s: vm_create_devmem", __func__);
gpa_base = (1ULL << 32) - BOOTROM_SIZE;
highmem = vm_get_highmem_base(ctx);
gpa_base = highmem - BOOTROM_SIZE;
gpa_allocbot = gpa_base;
gpa_alloctop = (1ULL << 32) - 1;
gpa_alloctop = highmem - 1;
}
int

View file

@ -1509,7 +1509,8 @@ init_pci(struct vmctx *ctx)
pci_emul_iobase = PCI_EMUL_IOBASE;
pci_emul_membase32 = PCI_EMUL_MEMBASE32;
pci_emul_membase64 = 4*GB + vm_get_highmem_size(ctx);
pci_emul_membase64 = vm_get_highmem_base(ctx) +
vm_get_highmem_size(ctx);
pci_emul_membase64 = roundup2(pci_emul_membase64, PCI_EMUL_MEMSIZE64);
pci_emul_memlim64 = pci_emul_membase64 + PCI_EMUL_MEMSIZE64;

View file

@ -600,7 +600,7 @@ static struct smbios_template_entry smbios_template[] = {
{ NULL,NULL, NULL }
};
static uint64_t guest_lomem, guest_himem;
static uint64_t guest_lomem, guest_himem, guest_himem_base;
static uint16_t type16_handle;
static int
@ -831,8 +831,8 @@ smbios_type19_initializer(const struct smbios_structure *template_entry,
curaddr, endaddr, n);
type19 = (struct smbios_table_type19 *)curaddr;
type19->arrayhand = type16_handle;
type19->xsaddr = 4*GB;
type19->xeaddr = type19->xsaddr + guest_himem;
type19->xsaddr = guest_himem_base;
type19->xeaddr = guest_himem_base + guest_himem;
}
return (0);
@ -891,6 +891,7 @@ smbios_build(struct vmctx *ctx)
guest_lomem = vm_get_lowmem_size(ctx);
guest_himem = vm_get_highmem_size(ctx);
guest_himem_base = vm_get_highmem_base(ctx);
startaddr = paddr_guest2host(ctx, SMBIOS_BASE, SMBIOS_MAX_LENGTH);
if (startaddr == NULL) {

View file

@ -758,8 +758,8 @@ vm_snapshot_mem(struct vmctx *ctx, int snapfd, size_t memsz, const bool op_wr)
if (highmem == 0)
goto done;
ret = vm_snapshot_mem_part(snapfd, lowmem, baseaddr + 4*GB,
highmem, totalmem, op_wr);
ret = vm_snapshot_mem_part(snapfd, lowmem,
baseaddr + vm_get_highmem_base(ctx), highmem, totalmem, op_wr);
if (ret) {
fprintf(stderr, "%s: Could not %s highmem\r\n",
__func__, op_wr ? "write" : "read");