From nobody Wed Apr 10 15:19:16 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 4VF61c6sqLz5HHKK; Wed, 10 Apr 2024 15:19:16 +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 4VF61c5VH1z4mxm; Wed, 10 Apr 2024 15:19:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762356; 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=K7j+q+Nxhe/JGjUAxBWE+x8aFxVilWPYhXfMctl0ZT8=; b=RZTof6t0qwD10PzndKntVNluuJoWUZAmz8mD1SITJXfpUjZT96Nnqx1ilhG0ujfNC6muRY PMW/8JBVjufYtQxqwEqtpdyhBmJjInblUT780IeiiR2bOt7EhGJhgXGk/rm4pJY6ik5zmd lgbYnlzI1KeO0mHVIXTHtLaPHBjz+kF8/fD0koP1leB1YHxhREioNpo6RuHgaTuoX4G7Hi 8JXjTamET3QcgmXhPLBFZh3HFDGpC5TpVadYBxc1j+b7RTvLTOjUZFpJTb7D2ml5tCsdlK osZH6OVGSRT7f13mDT5Uzb4fyv5xB2OMpvO+iW2Hv/4Y9ULPRiTOVUwqVqeGNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762356; a=rsa-sha256; cv=none; b=K3X0+YwWva3TU+aPwNIm8lFH/qL0JxztCu8JTfvRxVoGz6DUlZAPs6z1mxCFEb0TXXeEZo DxexQMnnD/HIWdM6ngEpQ+TIbdeHG9ykhxREbzsDtvAJoobzPjcg5h4+mRdbkJnKHMhf+g +mNUSKqxjukKv4LEX81kJfKnp7wwBkNK1n96B/cd0Mikjsy9dE/jMsbretGhZQFlyX+2jk 29KzBR3EKBi4vNNVAgvFdemlQFhi1hcBBIpK1SWu0+uIotShJy1cto1jK1HVvGPGnZxkNV Q5mblexkziZdm1cfWzScsVxVWnFffxdPoMnigREXShaevQjr4lz2OK8ly6rE0w== 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=1712762356; 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=K7j+q+Nxhe/JGjUAxBWE+x8aFxVilWPYhXfMctl0ZT8=; b=fC4iVUT1gWiwR3EWm0an2c1Pub+dHvVZmdSTJsrBNxlSGNqI8WWwPbUXHlH07Bth9eByyF 14EfMUJyLnmEeMKJiKxBlbxDsiKTE48eWdDTNJWxYjJfYbVBMhb8MNukV4gSU7Eq/8KRhJ LW/ZnFl/kHTGJUHsvMQD757RFiFnAMaaNajn60wlgkVRDUgVaQkpp2+OOstLh1Xl4DmCF7 CO1MKhMK+kWuAI+KjS3vsKqrbbA6RyJ2ro0nInY0VuzsUQlL9891qS3EDuVkoGryVlv2rq /ww8BXtVc0GLBSQ+/s/3dlFwbxSDxJJeNRoltT59nsAM0UBb5KzunHRtLUjXjg== 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 4VF61c52LlzjXj; Wed, 10 Apr 2024 15:19:16 +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 43AFJGMO093320; Wed, 10 Apr 2024 15:19:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJGZK093317; Wed, 10 Apr 2024 15:19:16 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:16 GMT Message-Id: <202404101519.43AFJGZK093317@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: f286f746f4ac - main - bhyve: Add PCI mappings for arm64 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: f286f746f4ac32c58969834aeb6f9b5076b52c86 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f286f746f4ac32c58969834aeb6f9b5076b52c86 commit f286f746f4ac32c58969834aeb6f9b5076b52c86 Author: Mark Johnston AuthorDate: 2024-04-03 17:11:37 +0000 Commit: Mark Johnston CommitDate: 2024-04-10 15:17:56 +0000 bhyve: Add PCI mappings for arm64 - The extended config space and BAR ranges are listed in the FDT. - Avoid referencing I/O ports in ACPI tables. Currently the arm64 port does not support ACPI in any case. Reviewed by: corvink, jhb MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D41739 --- usr.sbin/bhyve/pci_emul.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 9df05fda5866..2da97e0a522f 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -129,20 +129,31 @@ struct boot_device { static TAILQ_HEAD(boot_list, boot_device) boot_devices = TAILQ_HEAD_INITIALIZER( boot_devices); +#if defined(__amd64__) #define PCI_EMUL_IOBASE 0x2000 #define PCI_EMUL_IOLIMIT 0x10000 +#define PCI_EMUL_IOMASK 0xffff +/* + * OVMF always uses 0xc0000000 as base address for 32 bit PCI MMIO. Don't + * change this address without changing it in OVMF. + */ +#define PCI_EMUL_MEMBASE32 0xc0000000 +#elif defined(__aarch64__) +#define PCI_EMUL_IOBASE 0x00df00000UL +#define PCI_EMUL_IOLIMIT 0x00e000000UL +#define PCI_EMUL_MEMBASE32 0x0a0000000UL +#else +#error Unsupported platform +#endif -#define PCI_EMUL_ROMSIZE 0x10000000 +#define PCI_EMUL_ROMSIZE 0x10000000 #define PCI_EMUL_ECFG_BASE 0xE0000000 /* 3.5GB */ #define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */ +#ifdef __amd64__ SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE); +#endif -/* - * OVMF always uses 0xC0000000 as base address for 32 bit PCI MMIO. Don't - * change this address without changing it in OVMF. - */ -#define PCI_EMUL_MEMBASE32 0xC0000000 #define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE #define PCI_EMUL_MEMSIZE64 (32*GB) @@ -1635,13 +1646,25 @@ init_pci(struct vmctx *ctx) } /* - * The guest physical memory map looks like the following: + * The guest physical memory map looks like the following on amd64: * [0, lowmem) guest system memory * [lowmem, 0xC0000000) memory hole (may be absent) * [0xC0000000, 0xE0000000) PCI hole (32-bit BAR allocation) * [0xE0000000, 0xF0000000) PCI extended config window * [0xF0000000, 4GB) LAPIC, IOAPIC, HPET, firmware - * [4GB, 4GB + highmem) + * [4GB, 4GB + highmem) guest system memory + * [roundup(4GB + highmem, 32GB), ...) PCI 64-bit BAR allocation + * + * On arm64 the guest physical memory map looks like this: + * [0x0DF00000, 0x10000000) PCI I/O memory + * [0xA0000000, 0xE0000000) PCI 32-bit BAR allocation + * [0xE0000000, 0xF0000000) PCI extended config window + * [4GB, 4GB + highmem) guest system memory + * [roundup(4GB + highmem, 32GB), ...) PCI 64-bit BAR allocation + * + * "lowmem" is guest memory below 0xC0000000. amd64 guests provisioned + * with less than 3GB of RAM will have no memory above the 4GB boundary. + * System memory for arm64 guests is all above the 4GB boundary. */ /* @@ -1750,6 +1773,7 @@ pci_bus_write_dsdt(int bus) dsdt_line(" 0x0001, // Length"); dsdt_line(" ,, )"); +#ifdef __amd64__ if (bus == 0) { dsdt_indent(3); dsdt_fixed_ioport(0xCF8, 8); @@ -1780,6 +1804,7 @@ pci_bus_write_dsdt(int bus) goto done; } } +#endif assert(bi != NULL); /* i/o window */ @@ -1855,7 +1880,9 @@ pci_bus_write_dsdt(int bus) } } dsdt_unindent(2); +#ifdef __amd64__ done: +#endif dsdt_line(" }"); } @@ -2337,7 +2364,9 @@ pci_cfgrw(int in, int bus, int slot, int func, int coff, int bytes, break; case PCIBAR_IO: addr = *valp & mask; - addr &= 0xffff; +#if defined(PCI_EMUL_IOMASK) + addr &= PCI_EMUL_IOMASK; +#endif bar = addr | pi->pi_bar[idx].lobits; /* * Register the new BAR value for interception