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:
@@ -118,12 +118,15 @@ bootrom_var_mem_handler(struct vcpu *vcpu __unused, int dir, uint64_t addr,
|
|||||||
void
|
void
|
||||||
init_bootrom(struct vmctx *ctx)
|
init_bootrom(struct vmctx *ctx)
|
||||||
{
|
{
|
||||||
|
vm_paddr_t highmem;
|
||||||
|
|
||||||
romptr = vm_create_devmem(ctx, VM_BOOTROM, "bootrom", BOOTROM_SIZE);
|
romptr = vm_create_devmem(ctx, VM_BOOTROM, "bootrom", BOOTROM_SIZE);
|
||||||
if (romptr == MAP_FAILED)
|
if (romptr == MAP_FAILED)
|
||||||
err(4, "%s: vm_create_devmem", __func__);
|
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_allocbot = gpa_base;
|
||||||
gpa_alloctop = (1ULL << 32) - 1;
|
gpa_alloctop = highmem - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -1509,7 +1509,8 @@ init_pci(struct vmctx *ctx)
|
|||||||
pci_emul_iobase = PCI_EMUL_IOBASE;
|
pci_emul_iobase = PCI_EMUL_IOBASE;
|
||||||
pci_emul_membase32 = PCI_EMUL_MEMBASE32;
|
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_membase64 = roundup2(pci_emul_membase64, PCI_EMUL_MEMSIZE64);
|
||||||
pci_emul_memlim64 = pci_emul_membase64 + PCI_EMUL_MEMSIZE64;
|
pci_emul_memlim64 = pci_emul_membase64 + PCI_EMUL_MEMSIZE64;
|
||||||
|
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ static struct smbios_template_entry smbios_template[] = {
|
|||||||
{ NULL,NULL, NULL }
|
{ 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 uint16_t type16_handle;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -831,8 +831,8 @@ smbios_type19_initializer(const struct smbios_structure *template_entry,
|
|||||||
curaddr, endaddr, n);
|
curaddr, endaddr, n);
|
||||||
type19 = (struct smbios_table_type19 *)curaddr;
|
type19 = (struct smbios_table_type19 *)curaddr;
|
||||||
type19->arrayhand = type16_handle;
|
type19->arrayhand = type16_handle;
|
||||||
type19->xsaddr = 4*GB;
|
type19->xsaddr = guest_himem_base;
|
||||||
type19->xeaddr = type19->xsaddr + guest_himem;
|
type19->xeaddr = guest_himem_base + guest_himem;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -891,6 +891,7 @@ smbios_build(struct vmctx *ctx)
|
|||||||
|
|
||||||
guest_lomem = vm_get_lowmem_size(ctx);
|
guest_lomem = vm_get_lowmem_size(ctx);
|
||||||
guest_himem = vm_get_highmem_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);
|
startaddr = paddr_guest2host(ctx, SMBIOS_BASE, SMBIOS_MAX_LENGTH);
|
||||||
if (startaddr == NULL) {
|
if (startaddr == NULL) {
|
||||||
|
|||||||
@@ -758,8 +758,8 @@ vm_snapshot_mem(struct vmctx *ctx, int snapfd, size_t memsz, const bool op_wr)
|
|||||||
if (highmem == 0)
|
if (highmem == 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = vm_snapshot_mem_part(snapfd, lowmem, baseaddr + 4*GB,
|
ret = vm_snapshot_mem_part(snapfd, lowmem,
|
||||||
highmem, totalmem, op_wr);
|
baseaddr + vm_get_highmem_base(ctx), highmem, totalmem, op_wr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf(stderr, "%s: Could not %s highmem\r\n",
|
fprintf(stderr, "%s: Could not %s highmem\r\n",
|
||||||
__func__, op_wr ? "write" : "read");
|
__func__, op_wr ? "write" : "read");
|
||||||
|
|||||||
Reference in New Issue
Block a user