From nobody Wed Apr 10 15:19:01 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VF61L260Wz5HHS6; Wed, 10 Apr 2024 15:19:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VF61L0bn3z4mk6; Wed, 10 Apr 2024 15:19:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rj6MiDmStsQxXM7CuuPfawtEkR8zrs6RTra4L379Evk=; b=DiP7zGjmigFoen5NQAvxZ3fD9yMn+TwXc1x1adRkZjtA35SLcSahzJhtn1xVZo+JBPsH+N IjhskvqWCpudRHl5gpETdt1/d6OH2nuw7Q6pvbg6h7B8N+E8g11XODiPt9b3HkszW9/Tb1 Rk4liFULszEckxN/pkj58OZ3CZioV/MUq1e1OOVK+jYF1/el5SSwwWUBYn/gt6jjfAc3Cq mujE0Ag8wuG5t/zH7txg4RBxCQp7yWGG9k1XSjfPSWiwvH7/5vqhGTfQensBQPB4/xPzdR rDVTErJiixLwYbnCYncV51XppjCCuWNlM9P8cp3K/ShsacOcb69aFj3ySH5SUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762342; a=rsa-sha256; cv=none; b=R4rGFDI0Yloj5RWKhGOmuEJSTDv292NzwF6ekbNQhXeQXejKSt0mxKpcvvluDnIGfGIR2h OFhU7WVY2KAw71VOJgvI4LvlYjg++hyZfdJIxiFk0E8a2ngk7hDS2poTxrfjTMf4C+PG3E q2FlNGq2xH6J6qeN/u7xLUe9qT89W1kBzprLZV6nMlEfGqI13s/zeDvd4dmGfdzSgBnS/k pfbTdismwtA+StAbVitYPd9hkLUAUNvQdUOUzc+Y5jZ2HfB9aLvouvrFKhHKaMCThun86i bQh3wFizdDhfA8JhB837es6GRx3MGaY6YpJVPNTs+rahWTDZrlOlEKGC7uRLLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rj6MiDmStsQxXM7CuuPfawtEkR8zrs6RTra4L379Evk=; b=LXZJ/jvL1PK6I10BJdr97lWdkX1SGleNAbj1WrbMkEP6QTLTWlGyiBnhpHIPxoyizxgOX2 rTm9stNZCdp0weCDwdYH0u2xKkSYvhnaiPPLkVhl97tbOJiNdkOz8AgbZnqNETAxcEAj2P F5ihIUb7hCMpxdiSGkUSXzOVwMGNAmxkpI1WrBUgu+9rLtDbfLmPQWne6nK3SMeVjdtN2L +oDbCnyU5/DU2UGVaOSvHZNhamORZoQvkpPk2xZVpBrTUP3w3ZCFGXoJaecAjw6EKWJOl2 1/DXRYnZKUSGrIpzxBlGVHkzMGRjt8Dl+fyzSt9jtWURF2xgscbvZ7/1UAVovA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VF61K6p0zzjjZ; Wed, 10 Apr 2024 15:19:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43AFJ12J092645; Wed, 10 Apr 2024 15:19:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJ1WY092642; Wed, 10 Apr 2024 15:19:01 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:01 GMT Message-Id: <202404101519.43AFJ1WY092642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e497fe865703 - main - bhyve: Use vm_get_highmem_base() instead of hard-coding the value List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-main+owner@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e497fe8657031bf52a27d28943e6517922e330ba Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e497fe8657031bf52a27d28943e6517922e330ba commit e497fe8657031bf52a27d28943e6517922e330ba Author: Mark Johnston AuthorDate: 2024-04-03 16:51:37 +0000 Commit: Mark Johnston CommitDate: 2024-04-10 15:17:55 +0000 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 --- usr.sbin/bhyve/bootrom.c | 7 +++++-- usr.sbin/bhyve/pci_emul.c | 3 ++- usr.sbin/bhyve/smbiostbl.c | 7 ++++--- usr.sbin/bhyve/snapshot.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bhyve/bootrom.c b/usr.sbin/bhyve/bootrom.c index 64f1921f901e..1d461ba76597 100644 --- a/usr.sbin/bhyve/bootrom.c +++ b/usr.sbin/bhyve/bootrom.c @@ -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 diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 3d6797c7168e..e5e9e56cc3c3 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -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; diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index 4a98278d5e61..e09fbc95fc9e 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -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) { diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 9bb7873f1d25..997faa254284 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -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");