Skip to content

Commit 2016479

Browse files
peterfangacrnsi
authored andcommitted
dm: leave a gap for 32-bit PCI hole in E820 map
Guest OS (e.g. Linux) may rely on a gap in E820 map in the 32-bit memory space to determine the MMIO space for its PCI devices. Leave this gap when building E820 map to keep the guest's PCI subsystem working. After commit 7752d5cfe3d11ca0bb9c673ec38bd78ba6578f8e, Linux kernel no longer requires the MMCONFIG region to be reserved in the E820 map. Nonetheless, keep it in the reserved region to be on the safe side. Tracked-On: #2843 Signed-off-by: Peter Fang <peter.fang@intel.com> Acked-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 3be6c65 commit 2016479

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

devicemodel/core/sw_load_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ static char bootargs[STR_LEN];
5555
* 1: 0xA0000 - 0x100000 (reserved) 0x60000
5656
* 2: 0x100000 - lowmem RAM lowmem - 1MB
5757
* 3: lowmem - 0x80000000 (reserved) 2GB - lowmem
58-
* 4: 0x80000000 - 0x100000000 PCI hole, MMIO 2GB
59-
* 5: 0x100000000 - 0x140000000 PCI hole 1GB
58+
* 4: 0xE0000000 - 0x100000000 MCFG, MMIO 512MB
59+
* 5: 0x100000000 - 0x140000000 64-bit PCI hole 1GB
6060
* 6: 0x140000000 - highmem RAM highmem - 5GB
6161
*/
6262
const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
@@ -84,9 +84,9 @@ const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
8484
.type = E820_TYPE_RESERVED
8585
},
8686

87-
{ /* lowmem_limit to 4GB */
88-
.baseaddr = 0x80000000,
89-
.length = 0x80000000,
87+
{ /* ECFG_BASE to 4GB */
88+
.baseaddr = PCI_EMUL_ECFG_BASE,
89+
.length = (4 * GB) - PCI_EMUL_ECFG_BASE,
9090
.type = E820_TYPE_RESERVED
9191
},
9292

devicemodel/hw/pci/core.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ extern bool skip_pci_mem64bar_workaround;
9393
#define PCI_EMUL_IOBASE 0x2000
9494
#define PCI_EMUL_IOLIMIT 0x10000
9595

96-
#define PCI_EMUL_ECFG_BASE 0xE0000000 /* 3.5GB */
9796
#define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */
9897
SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE);
9998

@@ -1238,12 +1237,6 @@ pci_emul_ecfg_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
12381237
return 0;
12391238
}
12401239

1241-
uint64_t
1242-
pci_ecfg_base(void)
1243-
{
1244-
return PCI_EMUL_ECFG_BASE;
1245-
}
1246-
12471240
#define BUSIO_ROUNDUP 32
12481241
#define BUSMEM_ROUNDUP (1024 * 1024)
12491242

devicemodel/hw/platform/acpi/acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ basl_fwrite_mcfg(FILE *fp, struct vmctx *ctx)
603603
EFPRINTF(fp, "[0008]\t\tReserved : 0\n");
604604
EFPRINTF(fp, "\n");
605605

606-
EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", pci_ecfg_base());
606+
EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", PCI_EMUL_ECFG_BASE);
607607
EFPRINTF(fp, "[0002]\t\tSegment Group: 0000\n");
608608
EFPRINTF(fp, "[0001]\t\tStart Bus: 00\n");
609609
EFPRINTF(fp, "[0001]\t\tEnd Bus: FF\n");

devicemodel/include/pci_core.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
#define PCI_BARMAX PCIR_MAX_BAR_0 /* BAR registers in a Type 0 header */
3939
#define PCI_BDF(b, d, f) (((b & 0xFF) << 8) | ((d & 0x1F) << 3) | ((f & 0x7)))
4040

41-
#define PCI_EMUL_MEMBASE64 0x100000000UL
42-
#define PCI_EMUL_MEMLIMIT64 0x140000000UL
41+
#define PCI_EMUL_ECFG_BASE 0xE0000000UL /* 3.5GB */
42+
43+
#define PCI_EMUL_MEMBASE64 0x100000000UL /* 4GB */
44+
#define PCI_EMUL_MEMLIMIT64 0x140000000UL /* 5GB */
4345

4446
struct vmctx;
4547
struct pci_vdev;
@@ -310,7 +312,6 @@ uint64_t pci_emul_msix_tread(struct pci_vdev *pi, uint64_t offset, int size);
310312
int pci_count_lintr(int bus);
311313
void pci_walk_lintr(int bus, pci_lintr_cb cb, void *arg);
312314
void pci_write_dsdt(void);
313-
uint64_t pci_ecfg_base(void);
314315
int pci_bus_configured(int bus);
315316
int emulate_pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus,
316317
int slot, int func, int reg, int bytes, int *value);

0 commit comments

Comments
 (0)