From: Mike Larkin Subject: Re: move pci mmio defs from vmm to vmd To: Dave Voutila Cc: tech@openbsd.org Date: Wed, 2 Oct 2024 09:38:13 -0700 On Wed, Oct 02, 2024 at 10:12:04AM -0400, Dave Voutila wrote: > No need for the kernel headers to contain this information nowadays as > vmd is responsible for telling vmm what memory regions should be treated > as "mmio" regions. > > This doesn't change the values used. Yes, in real hardware this isn't > all PCI in this region...that's a future detail to work on. > > ok? > ok mlarkin > diffstat refs/heads/master refs/heads/vmm-mmio-headers > M sys/arch/amd64/include/vmmvar.h | 0+ 3- > M usr.sbin/vmd/pci.c | 2+ 2- > M usr.sbin/vmd/pci.h | 3+ 0- > M usr.sbin/vmd/x86_vm.c | 7+ 7- > > 4 files changed, 12 insertions(+), 12 deletions(-) > > diff refs/heads/master refs/heads/vmm-mmio-headers > commit - c1e5f9e355c15e0953a568e8d696ee94ac23c40f > commit + a28ee5a6fe5626edec1fed2ca1b1c68d79755ca6 > blob - 6bc63d5ae3f470c12fecea910e7be247f82ac548 > blob + 1e9333b82cef44d380f5f6d6a1d0af3d8ffe1216 > --- sys/arch/amd64/include/vmmvar.h > +++ sys/arch/amd64/include/vmmvar.h > @@ -23,9 +23,6 @@ > > #define VMM_HV_SIGNATURE "OpenBSDVMM58" > > -#define VMM_PCI_MMIO_BAR_BASE 0xF0000000ULL > -#define VMM_PCI_MMIO_BAR_END 0xFFDFFFFFULL /* 2 MiB below 4 GiB */ > - > /* VMX: Basic Exit Reasons */ > #define VMX_EXIT_NMI 0 > #define VMX_EXIT_EXTINT 1 > blob - b159977f464c48f7e7e1f3c1fc664b2025c794c9 > blob + 7c3b4acc0ccc762c189cd1022c4b939c241e40be > --- usr.sbin/vmd/pci.c > +++ usr.sbin/vmd/pci.c > @@ -73,7 +73,7 @@ pci_add_bar(uint8_t id, uint32_t type, void *barfn, vo > /* Compute BAR address and add */ > bar_reg_idx = (PCI_MAPREG_START + (bar_ct * 4)) / 4; > if (type == PCI_MAPREG_TYPE_MEM) { > - if (pci.pci_next_mmio_bar >= VMM_PCI_MMIO_BAR_END) > + if (pci.pci_next_mmio_bar >= PCI_MMIO_BAR_END) > return (1); > > pci.pci_devices[id].pd_cfg_space[bar_reg_idx] = > @@ -216,7 +216,7 @@ pci_init(void) > uint8_t id; > > memset(&pci, 0, sizeof(pci)); > - pci.pci_next_mmio_bar = VMM_PCI_MMIO_BAR_BASE; > + pci.pci_next_mmio_bar = PCI_MMIO_BAR_BASE; > > #ifdef __amd64__ > pci.pci_next_io_bar = VM_PCI_IO_BAR_BASE; > blob - 0b05a9298d16296d5a155dc6d7657f8ad21491d2 > blob + 48b1a8dbcdd7d1946aef9b1aced4ff3947d7a83a > --- usr.sbin/vmd/pci.h > +++ usr.sbin/vmd/pci.h > @@ -34,6 +34,9 @@ > #define PCI_BAR_TYPE_IO 0x0 > #define PCI_BAR_TYPE_MMIO 0x1 > > +#define PCI_MMIO_BAR_BASE 0xF0000000ULL > +#define PCI_MMIO_BAR_END 0xFFDFFFFFULL /* 2 MiB below 4 GiB */ > + > #define PCI_MAX_PIC_IRQS 10 > > typedef int (*pci_cs_fn_t)(int dir, uint8_t reg, uint32_t *data); > blob - 729e0c5f9bd1aa7e99b896834be02b23354902a1 > blob + 4481f2bb099307dd0071141de1d9077027be14fb > --- usr.sbin/vmd/x86_vm.c > +++ usr.sbin/vmd/x86_vm.c > @@ -192,7 +192,7 @@ create_memory_map(struct vm_create_params *vcp) > > /* If we have less than 2MB remaining, still create a 2nd BIOS area. */ > if (mem_bytes <= MB(2)) { > - vcp->vcp_memranges[2].vmr_gpa = VMM_PCI_MMIO_BAR_END; > + vcp->vcp_memranges[2].vmr_gpa = PCI_MMIO_BAR_END; > vcp->vcp_memranges[2].vmr_size = MB(2); > vcp->vcp_memranges[2].vmr_type = VM_MEM_RESERVED; > vcp->vcp_nmemranges = 3; > @@ -204,8 +204,8 @@ create_memory_map(struct vm_create_params *vcp) > * boundary while making sure we do not place physical memory into > * MMIO ranges. > */ > - if (mem_bytes > VMM_PCI_MMIO_BAR_BASE - MB(1)) { > - above_1m = VMM_PCI_MMIO_BAR_BASE - MB(1); > + if (mem_bytes > PCI_MMIO_BAR_BASE - MB(1)) { > + above_1m = PCI_MMIO_BAR_BASE - MB(1); > above_4g = mem_bytes - above_1m; > } else { > above_1m = mem_bytes; > @@ -218,13 +218,13 @@ create_memory_map(struct vm_create_params *vcp) > vcp->vcp_memranges[2].vmr_type = VM_MEM_RAM; > > /* Fourth region: PCI MMIO range */ > - vcp->vcp_memranges[3].vmr_gpa = VMM_PCI_MMIO_BAR_BASE; > - vcp->vcp_memranges[3].vmr_size = VMM_PCI_MMIO_BAR_END - > - VMM_PCI_MMIO_BAR_BASE + 1; > + vcp->vcp_memranges[3].vmr_gpa = PCI_MMIO_BAR_BASE; > + vcp->vcp_memranges[3].vmr_size = PCI_MMIO_BAR_END - > + PCI_MMIO_BAR_BASE + 1; > vcp->vcp_memranges[3].vmr_type = VM_MEM_MMIO; > > /* Fifth region: 2nd copy of BIOS above MMIO ending at 4GB */ > - vcp->vcp_memranges[4].vmr_gpa = VMM_PCI_MMIO_BAR_END + 1; > + vcp->vcp_memranges[4].vmr_gpa = PCI_MMIO_BAR_END + 1; > vcp->vcp_memranges[4].vmr_size = MB(2); > vcp->vcp_memranges[4].vmr_type = VM_MEM_RESERVED; > >