Memory API
RFC v5 86/86 440fx: fix PAM, PCI holes
In reply to Avi KivityThe current implementation of PAM and the PCI holes is broken in several ways:
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
- PCI devices do not respect PAM (if a PCI device maps a region while PAM maps the region to RAM, the request will be honored)
This patch fixes things by introducing a pci address space, and using memory region aliases to represent PAM regions, SMRAM, and PCI holes.
The memory hierarchy looks something like
system_memory
|
+--- low memory alias (0-0xe0000000)
| |
| +-- ram@0
|
+--- high memory alias (0x100000000-EOM)
| |
| +-- ram@0xe0000000
|
+--- pam[n] (0xc0000-0xc3fff etc) (when set to pci, priority 1)
| |
| +-- pci@0xc4000 etc
|
+--- smram (0xa0000-0xbffff) (when set to pci/vga, priority 1)
|
+-- pci@0xa0000 etcram (simple ram region)
pci
|
+--- BARn | +--- VGA 0xa0000-0xbffff | +--- ROMs
--- hw/pc.c | 11 +++-- hw/pc.h | 13 +++++- hw/pc_piix.c | 21 +++++++--- hw/piix_pci.c | 114 ++++++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 113 insertions(+), 46 deletions(-)
hw/pc.c +7 -4
@@ -963,7 +963,9 @@ void pc_memory_init(MemoryRegion *system_memory,const char *kernel_cmdline, const char *initrd_filename, ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size) + ram_addr_t above_4g_mem_size, + MemoryRegion *pci_memory, + MemoryRegion **ram_memory) { char *filename;int ret, linux_boot, i;
@@ -981,6 +983,7 @@ void pc_memory_init(MemoryRegion *system_memory, ram =qemu_malloc (sizeof (*ram));memory_region_init_ram (ram,NULL ,"pc.ram" , below_4g_mem_size + above_4g_mem_size); + *ram_memory = ram; ram_below_4g =qemu_malloc (sizeof (*ram_below_4g));memory_region_init_alias (ram_below_4g,"ram-below-4g" , ram,0 , below_4g_mem_size);
@@ -1025,7 +1028,7 @@ void pc_memory_init(MemoryRegion *system_memory, isa_bios =qemu_malloc (sizeof (*isa_bios));memory_region_init_alias (isa_bios,"isa-bios" , bios, bios_size - isa_bios_size, isa_bios_size); -memory_region_add_subregion_overlap (system_memory, +memory_region_add_subregion_overlap (pci_memory,0x100000 - isa_bios_size, isa_bios,1 );
@@ -1033,13 +1036,13 @@ void pc_memory_init(MemoryRegion *system_memory, option_rom_mr =qemu_malloc (sizeof (*option_rom_mr));memory_region_init_ram (option_rom_mr,NULL ,"pc.rom" ,PC_ROM_SIZE ); -memory_region_add_subregion_overlap (system_memory, +memory_region_add_subregion_overlap (pci_memory,PC_ROM_MIN_VGA , option_rom_mr,1 );/* map all the bios at the top of memory */ -memory_region_add_subregion (system_memory, +memory_region_add_subregion (pci_memory, (uint32_t )(-bios_size), bios);
hw/pc.h +10 -3
@@ -136,7 +136,9 @@ void pc_memory_init(MemoryRegion *system_memory,const char *kernel_cmdline, const char *initrd_filename, ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size); + ram_addr_t above_4g_mem_size, + MemoryRegion *pci_memory, + MemoryRegion **ram_memory);qemu_irq *pc_allocate_cpu_irq (void );void pc_vga_init (PCIBus *pci_bus); void pc_basic_device_init(qemu_irq *isa_irq,
@@ -182,8 +184,13 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, - ram_addr_t ram_size); -void i440fx_init_memory_mappings (PCII440FXState *d); + ram_addr_t ram_size, + target_phys_addr_t pci_hole_start, + target_phys_addr_t pci_hole_size, + target_phys_addr_t pci_hole64_start, + target_phys_addr_t pci_hole64_size, + MemoryRegion *pci_memory, + MemoryRegion *ram_memory);/* piix4.c */ extern PCIDevice *piix4_dev;
hw/pc_piix.c +15 -6
@@ -93,6 +93,8 @@ static void pc_init1(MemoryRegion *system_memory,DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];BusState *idebus[MAX_IDE_BUS ];ISADevice *rtc_state; +MemoryRegion *ram_memory; +MemoryRegion *pci_memory;pc_cpus_init (cpu_model);
@@ -108,11 +110,16 @@ static void pc_init1(MemoryRegion *system_memory, below_4g_mem_size = ram_size; } + pci_memory =QEMU_NEW (MemoryRegion); +memory_region_init (pci_memory,"pci" ,UINT64_MAX ); +memory_region_add_subregion_overlap (system_memory,0 , pci_memory,1 ); +/* allocate ram and load rom/bios */ if (!xen_enabled ()) {pc_memory_init (system_memory, kernel_filename, kernel_cmdline, initrd_filename, - below_4g_mem_size, above_4g_mem_size); + below_4g_mem_size, above_4g_mem_size, + pci_memory, &ram_memory); }if (!xen_enabled ()) {
@@ -130,7 +137,13 @@ static void pc_init1(MemoryRegion *system_memory,if (pci_enabled) { pci_bus =i440fx_init (&i440fx_state, &piix3_devfn, isa_irq, - system_memory, system_io, ram_size); + system_memory, system_io, ram_size, +0xe0000000 ,0x1fe00000 , +0x100000000 + above_4g_mem_size, + (sizeof (target_phys_addr_t) ==32 + ?0 + : ((uint64_t )1 <<63 )), + pci_memory, ram_memory); }else { pci_bus =NULL ; i440fx_state =NULL ;
@@ -198,10 +211,6 @@ static void pc_init1(MemoryRegion *system_memory,smbus_eeprom_init (smbus,8 ,NULL ,0 ); } -if (i440fx_state) { -i440fx_init_memory_mappings (i440fx_state); - } -if (pci_enabled) {pc_pci_device_init (pci_bus); }
hw/piix_pci.c +81 -33
200 lines not on this page · raw message
Signature · 1 line
1.7.5.3
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 4 lines · Avi Kivity
The current implementation of PAM and the PCI holes is broken in several ways:
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
Technically, a BAR can be mapped to any non-RAM memory location.
Quoted 2 lines
- PCI devices do not respect PAM (if a PCI device maps a region while PAM maps the region to RAM, the request will be honored)
I assume you mean SMM shadowing, right? PAM doesn't cover an area that's ever forwarded to the PCI bus.
Quoted 8 lines
This patch fixes things by introducing a pci address space, and using memory region aliases to represent PAM regions, SMRAM, and PCI holes.
The memory hierarchy looks something like
system_memory
|
+--- low memory alias (0-0xe0000000)
According to the spec, PCI memory doesn't start at e00... but rather at the top of RAM. In fact, this is what the spec says:
"The address range from the top of main DRAM to 4 Gbytes (top of physical memory space supported by the 440FX PCIset) is normally mapped to PCI. The PMC forwards all accesses within this address range to PCI. There are two sub-ranges within this address range defined as APIC Configuration Space and High BIOS Address Range."
So the right thing to do is to forward all accesses from low_memory_memsize ... 4GB to the PCI bus.
Regards,
Anthony Liguori
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 7 lines · Anthony Liguori
Quoted 4 lines · Avi Kivity
The current implementation of PAM and the PCI holes is broken in several ways:
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
Quoted 5 lines
Quoted 3 lines
- PCI devices do not respect PAM (if a PCI device maps a region while PAM maps the region to RAM, the request will be honored)
I assume you mean SMM shadowing, right? PAM doesn't cover an area that's ever forwarded to the PCI bus.
No, PAM. And all of the PAM address space is forwarded to the PCI bus (the ROMs are satisfied by PIIX which is a PCI device).
Here at least the spec is clear, see 3.2.18.
Quoted 10 lines
Quoted 9 lines
This patch fixes things by introducing a pci address space, and using memory region aliases to represent PAM regions, SMRAM, and PCI holes.
The memory hierarchy looks something like
system_memory
|
+--- low memory alias (0-0xe0000000)
Quoted 7 lines
According to the spec, PCI memory doesn't start at e00... but rather at the top of RAM. In fact, this is what the spec says:
"The address range from the top of main DRAM to 4 Gbytes (top of physical memory space supported by the 440FX PCIset) is normally mapped to PCI. The PMC forwards all accesses within this address range to PCI. There are two sub-ranges within this address range defined as APIC Configuration Space and High BIOS Address Range."
So the right thing to do is to forward all accesses from
low_memory_memsize... 4GB to the PCI bus.
We could do that. However what happens if we implement memory hotplug?
Maybe we should implement memory hotplug on a newer chipset anyway.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity
The current implementation of PAM and the PCI holes is broken in several ways:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
PIIX3 spec:
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h Default Value: 02h Attribute: Read/Write
--
Gleb.
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 13 lines · Gleb Natapov
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity
The current implementation of PAM and the PCI holes is broken in several ways:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
Quoted 7 lines
PIIX3 spec:
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h Default Value: 02h Attribute: Read/Write
What's it doing in PIIX3? Is it the same TOM?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Gleb Natapov
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity
The current implementation of PAM and the PCI holes is broken in several ways:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
- PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
PIIX3 spec:
Quoted 8 lines
Quoted 5 lines
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h Default Value: 02h Attribute: Read/WriteWhat's it doing in PIIX3? Is it the same TOM?
Good question. Looks like it is not:
This register enables the forwarding of ISA or DMA memory cycles to the PCI Bus and sets the top of main
memory accessible by ISA or DMA devices. In addition, this register controls the forwarding of ISA or DMA
accesses to the lower BIOS region (E0000–EFFFFh) and the 512–640-Kbyte main memory region (80000–
9FFFFh). The Top Of Memory configuration register must be set by the BIOS.
--
Gleb.
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
In reply to Avi KivityQuoted 18 lines · Avi Kivity
Quoted 17 lines · Gleb Natapov
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Anthony Liguori
Quoted 1 line · Avi Kivity
The current implementation of PAM and the PCI holes is broken in
several
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
ways:
- PCI BARs are not restricted to the PCI hole (a BAR may hide
memory)
Quoted 6 lines
Quoted 2 lines
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
PIIX3 spec:
Quoted 8 lines
Quoted 5 lines
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h Default Value: 02h Attribute: Read/WriteWhat's it doing in PIIX3? Is it the same TOM?
That's the ISA TOM (15MB hole and friends).
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 25 lines · Avi Kivity
Quoted 24 lines · Avi Kivity
Quoted 22 lines · Gleb Natapov
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Anthony Liguori
Quoted 1 line · Avi Kivity
The current implementation of PAM and the PCI holes is
broken in several
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
ways:
- PCI BARs are not restricted to the PCI hole (a BAR may
hide memory)
Quoted 6 lines
Quoted 2 lines
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
PIIX3 spec:
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h Default Value: 02h Attribute: Read/Write
Quoted 5 lines
Quoted 2 lines
What's it doing in PIIX3? Is it the same TOM?
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERS
from 440fx spec?
--
Gleb.
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 8 lines · Gleb Natapov
Quoted 3 lines
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERSfrom 440fx spec?
Maybe. But we can't use that, since it ignores address line 31.
(440fx supports only 1GB RAM, and we're ignoring that)
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 3 lines
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERS
Quoted 6 lines
Quoted 2 lines
from 440fx spec?
Maybe. But we can't use that, since it ignores address line 31.
(440fx supports only 1GB RAM, and we're ignoring that)
What are we trying to do?
Can't we just register highest RAM address under 4G to 4G as PCI memory and call it a day?
Do we really need a guest visible register to do this?
Regards,
Anthony Liguori
Quoted 1 line
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 3 lines
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERS
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
from 440fx spec?
Maybe. But we can't use that, since it ignores address line 31.
(440fx supports only 1GB RAM, and we're ignoring that)
What are we trying to do?
I just tried to answer Avi's question about TOM register.
Quoted 3 lines
Can't we just register highest RAM address under 4G to 4G as PCI memory and call it a day?
It is good idea to emulate existing functionality as close as possible, but if existing functionality does not satisfy us (like in our case) then yes, we can.
Quoted 7 lines
Do we really need a guest visible register to do this?
Regards,
Anthony Liguori
Quoted 1 line
--
Gleb.
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
In reply to Anthony LiguoriQuoted 13 lines · Anthony Liguori
Quoted 12 lines · Avi Kivity
Quoted 8 lines · Gleb Natapov
Quoted 3 lines
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERSfrom 440fx spec?
Maybe. But we can't use that, since it ignores address line 31.
Quoted 7 lines
Quoted 1 line
(440fx supports only 1GB RAM, and we're ignoring that)
What are we trying to do?
Can't we just register highest RAM address under 4G to 4G as PCI memory and call it a day?
Do we really need a guest visible register to do this?
Why not use 3.5GB and call it a day? It's safer for memory hotplug, if we ever get it.
The guest will never put a PCI BAR below that anyway.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 21 lines · Avi Kivity
Quoted 20 lines · Anthony Liguori
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 3 lines
That's the ISA TOM (15MB hole and friends).
Correct. What about:
3.2.19. DRB[0:7] DRAM ROW BOUNDARY REGISTERSQuoted 6 lines
Quoted 2 lines
from 440fx spec?
Maybe. But we can't use that, since it ignores address line 31.
(440fx supports only 1GB RAM, and we're ignoring that)
What are we trying to do?
Can't we just register highest RAM address under 4G to 4G as PCI memory and call it a day?
Quoted 6 lines
Quoted 1 line
Do we really need a guest visible register to do this?
Why not use 3.5GB and call it a day? It's safer for memory hotplug, if we ever get it.
The guest will never put a PCI BAR below that anyway.
My entire concern is that they will.
We're not just talking about Windows or Linux here, but any odd DOS application that's smart enough to switch into 32-bit mode, bootloaders, etc.
It's a significant behaviorial change that goes against the spec for no obviously good reason.
Even if we supported hot plug, we could easily just hot plug above the 4GB mark.
Regards,
Anthony Liguori
Quoted 1 line
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 12 lines · Anthony Liguori
Quoted 4 lines
Why not use 3.5GB and call it a day? It's safer for memory hotplug, if we ever get it.
The guest will never put a PCI BAR below that anyway.
My entire concern is that they will.
We're not just talking about Windows or Linux here, but any odd DOS application that's smart enough to switch into 32-bit mode, bootloaders, etc.
It's a significant behaviorial change that goes against the spec for no obviously good reason.
Okay, I'll update the patch.
Quoted 1 line
Even if we supported hot plug, we could easily just hot plug above the 4GB mark.
Or change the PCI hole dynamically.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC v5 86/86] 440fx: fix PAM, PCI holes
In reply to Avi KivityQuoted 18 lines · Avi Kivity
Quoted 17 lines · Gleb Natapov
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Anthony Liguori
Quoted 1 line · Avi Kivity
The current implementation of PAM and the PCI holes is broken in
several
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
ways:
- PCI BARs are not restricted to the PCI hole (a BAR may hide
memory)
Quoted 6 lines
Quoted 2 lines
Technically, a BAR can be mapped to any non-RAM memory location.
I understood TOM (Top Of Memory) to be fixed - can't find a register for it - but maybe I misread the spec.
PIIX3 spec:
Quoted 7 lines
Quoted 5 lines
2.2.11. TOM—TOP OF MEMORY REGISTER (Function 0)
Address Offset: 69h
Default Value: 02h
Attribute: Read/WriteWhat's it doing in PIIX3? Is it the same TOM?
This is a programmable register used to indicate the TOM for the purposes of forwarding ISA DMA transactions.
It is unrelated to the I440FX notion of top of memory.
Regards,
Anthony Liguori
Quoted 1 line
Re: [RFC v5 86/86] 440fx: fix PAM, PCI holes
In reply to Avi KivityOn Wed, Jul 20, 2011 at 9:50 AM, Avi Kivity <[email protected]> wrote:
[...]
hw/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 143
Quoted 9 lines
hw/pc_piix.c +4
-1@@ -130,7 +137,13 @@ static void pc_init1(MemoryRegion *system_memory, if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, - system_memory, system_io, ram_size); + system_memory, system_io, ram_size, + 0xe0000000, 0x1fe00000, + 0x100000000 + above_4g_mem_size, + (sizeof(target_phys_addr_t) == 32
sizeof(target_phys_addr_t) == 8 ?
Quoted 6 lines
hw/pc_piix.c +3
-0+ ? 0 + : ((uint64_t)1 << 63)), + pci_memory, ram_memory); } else { pci_bus = NULL; i440fx_state = NULL;
Re: [RFC v5 86/86] 440fx: fix PAM, PCI holes
Quoted 12 lines · Eric Northup
On Wed, Jul 20, 2011 at 9:50 AM, Avi Kivity<[email protected]> wrote:
[...]Quoted 9 lines
@@ -130,7 +137,13 @@ static void pc_init1(MemoryRegion
*system_memory,if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state,&piix3_devfn, isa_irq, - system_memory, system_io, ram_size); + system_memory, system_io, ram_size, + 0xe0000000, 0x1fe00000, + 0x100000000 + above_4g_mem_size, + (sizeof(target_phys_addr_t) == 32
Quoted 1 line
sizeof(target_phys_addr_t)== 8 ?
Good catch. Fixed
(== 4).
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer any destructive operations in the tree (IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holes
This on top fixes standard VGA dirty logging:
hw/cirrus_vga.c +0 -2
@@ -2944,8 +2944,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)memory_region_add_subregion (&s->pci_bar,0x1000000 , &s->cirrus_linear_bitblt_io); -vga_dirty_log_start (&s->vga); -/* setup memory space */ /* memory #0 LFB */ /* memory #1 memory-mapped I/O */
hw/vga.c +1 -0
@@ -2195,6 +2195,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size) s->update_retrace_info = vga_precise_update_retrace_info;break ; } +vga_dirty_log_start (s); }/* used by both ISA and PCI */
Cirrus is still broken (test case: grub), debugging ATM.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 9 lines · Jan Kiszka
Quoted 6 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer any destructive operations in the tree (IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holesThis on top fixes standard VGA dirty logging:
Both work for me without any patches.
Maybe the F15 window manager is polling the display?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer anydestructive
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
operations in the tree (
IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holesThis on top fixes standard VGA dirty logging:
Both work for me without any patches.
Impossible! ;)
VGA frame buffer cannot work as no one enabled dirty logging for that range so far. Try -vga std with vga=0x314 in the guest.
Quoted 3 lines
Maybe the F15 window manager is polling the display?
Only if that continuously enforces a full window refresh.
As expected, there were dirty logging issues around removing a subregion on cirrus bank pointer updates. This makes linear vram mappings work again:
memory.c +0 -0
@@ -1093,9 +1093,26 @@ void
memory_region_add_subregion_overlap(MemoryRegion *mr,
void memory_region_del_subregion(MemoryRegion *mr,
MemoryRegion *subregion)
{
+ MemoryRegion *target_region;
+ ram_addr_t base, offs;
+
assert(subregion->parent == mr);
subregion->parent = NULL;
QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link);+
+ if (subregion->alias) {
+ base = subregion->alias_offset;
+ target_region = subregion->alias;
+ } else {
+ base = 0;
+ target_region = subregion;
+ }
+ if (target_region->dirty_log_mask) {
+ for (offs = 0; offs < subregion->size; offs += TARGET_PAGE_SIZE) {
+ memory_region_set_dirty(target_region, base + offs);
+ }
+ }
+
memory_region_update_topology();
}
Debugging provided some more insights:
- address_space_update_topology is not very successful in avoiding needless mapping updates. kvm_client_set_memory is called much more frequently than with the old code.
- The region update pattern delete old / add new, e.g. to move the cirrus bank pointer, will never allow an optimal number of memory client calls. We either need some memory_region_update or a transaction API. I would favor the former, should also simplify the usage.
- memory_region_update_topology should take a hint if all or just a specific address space need updating.
- Something makes the startup of graphical grub under cirrus horribly slow, likely some bug that prevents linear vram mode during the screen setup. But once it is fully painted for the first time, grub feels as fast as with the old code.
Jan
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer anydestructive
Quoted 4 lines
operations in the tree (
IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holes
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
This on top fixes standard VGA dirty logging:
Both work for me without any patches.
Impossible! ;)
VGA frame buffer cannot work as no one enabled dirty logging for that range so far. Try -vga std with vga=0x314 in the guest.
Right, actually booting into X showed that. But I don't understand how it worked before - my patches only change how vga_start_dirty_log() is implemented, not when/where it is called.
Quoted 5 lines
Quoted 3 lines
Maybe the F15 window manager is polling the display?
Only if that continuously enforces a full window refresh.
Turned out to be a tester issue.
Quoted 3 lines
As expected, there were dirty logging issues around removing a subregion on cirrus bank pointer updates. This makes linear vram mappings work again:
Please sign off patches!
Quoted 19 lines
memory.c +7
-0@@ -1093,9 +1093,26 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr, void memory_region_del_subregion(MemoryRegion *mr, MemoryRegion *subregion) { + MemoryRegion *target_region; + ram_addr_t base, offs; + assert(subregion->parent == mr); subregion->parent = NULL; QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link); + + if (subregion->alias) { + base = subregion->alias_offset; + target_region = subregion->alias;
memory.c void · line 1116
Quoted 10 lines
memory.c +10
-0+ }else { + base =0 ; + target_region = subregion; + } +if (target_region->dirty_log_mask) { +for (offs =0 ; offs< subregion->size; offs +=TARGET_PAGE_SIZE ) { +memory_region_set_dirty (target_region, base + offs); + } + } +
The subregion may be partially or fully obstructed. This needs to be done at the FlatRange level (as_memory_range_del(), most likely).
Quoted 4 lines
memory.c +0
-0memory_region_update_topology (); }
Quoted 9 lines
Debugging provided some more insights:
-address_space_update_topologyis not very successful in avoiding needless mapping updates.kvm_client_set_memoryis called much more frequently than with the old code.
- The region update pattern delete old / add new, e.g. to move the cirrus bank pointer, will never allow an optimal number of memory client calls. We either need somememory_region_updateor a transaction API. I would favor the former, should also simplify the usage.
I had the same thoughts. In-place updates will get more and more complicated, though. Perhaps we can do a memory_region_replace() (_del and _add)? That can atomically replace both banks in one go.
Note you can emulate _replace() by adding a new region with a higher priority, then removing the old one underneath.
Quoted 2 lines
-
memory_region_update_topologyshould take a hint if all or just a specific address space need updating.
It's a nice optimization but I want to defer that to later (when memory.c actually supersedes ram_addr_t).
Quoted 4 lines
- Something makes the startup of graphical grub under cirrus horribly slow, likely some bug that prevents linear vram mode during the screen setup. But once it is fully painted for the first time, grub feels as fast as with the old code.
I haven't seen that. How slow is slow? maybe my eyes aren't fast enough.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 18 lines · Avi Kivity
Quoted 17 lines · Jan Kiszka
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer anydestructive
Quoted 4 lines
operations in the tree (
IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holesQuoted 3 lines
Quoted 1 line
This on top fixes standard VGA dirty logging:
Both work for me without any patches.
Impossible! ;)
Quoted 7 lines
Quoted 3 lines
VGA frame buffer cannot work as no one enabled dirty logging for that range so far. Try -vga std with vga=0x314 in the guest.
Right, actually booting into X showed that. But I don't understand how it worked before - my patches only change how
vga_start_dirty_log()is implemented, not when/where it is called.
To answer this question as well: You dropped all the vga_start_dirty_log originally performed during PCI mapping.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Maybe the F15 window manager is polling the display?
Only if that continuously enforces a full window refresh.
Quoted 7 lines
Turned out to be a tester issue.
Quoted 3 lines
As expected, there were dirty logging issues around removing a subregion on cirrus bank pointer updates. This makes linear vram mappings work again:
Please sign off patches!
Always - once they are done.
Quoted 26 lines
Quoted 26 lines
memory.c +13
-0@@ -1093,9 +1093,26 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr, void memory_region_del_subregion(MemoryRegion *mr, MemoryRegion *subregion) { + MemoryRegion *target_region; + ram_addr_t base, offs; + assert(subregion->parent == mr); subregion->parent = NULL; QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link); + + if (subregion->alias) { + base = subregion->alias_offset; + target_region = subregion->alias; + } else { + base = 0; + target_region = subregion; + } + if (target_region->dirty_log_mask) { + for (offs = 0; offs< subregion->size; offs +=
Quoted 8 lines
memory.c void · line 1117
Quoted 5 lines
memory.c +4
-0TARGET_PAGE_SIZE) { +memory_region_set_dirty (target_region, base + offs); + } + } +The subregion may be partially or fully obstructed. This needs to be done at the FlatRange level (
as_memory_range_del(), most likely).
Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Avi Kivity
Quoted 20 lines · Jan Kiszka
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
New in this version:
- more mindless conversions; I believe there are no longer anydestructive
Quoted 4 lines
operations in the tree (
IO_MEM_UNASSIGNED)
- fix memory map generation bug (patch 13)
- proper 440FX PAM/SMRAM and PCI holesQuoted 3 lines
Quoted 1 line
This on top fixes standard VGA dirty logging:
Both work for me without any patches.
Impossible! ;)
VGA frame buffer cannot work as no one enabled dirty logging for that range so far. Try -vga std with vga=0x314 in the guest.
Quoted 7 lines
Quoted 3 lines
Right, actually booting into X showed that. But I don't understand how it worked before - my patches only change how
vga_start_dirty_log()is implemented, not when/where it is called.To answer this question as well: You dropped all the
vga_start_dirty_logoriginally performed during PCI mapping.
Ah, I see it now, in vga_map(). Thanks.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
@@ -1093,9 +1093,26 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr,
void memory_region_del_subregion(MemoryRegion *mr,
MemoryRegion *subregion)
{
+ MemoryRegion*target_region;
+ram_addr_tbase, offs;
+assert(subregion->parent == mr); subregion->parent = NULL; QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link);+
+ if (subregion->alias) {
+ base =subregion->alias_offset;
+target_region=subregion->alias;
+ } else {
+ base = 0;
+target_region= subregion;
+ }
+ if (target_region->dirty_log_mask) {
+ for (offs = 0; offs<subregion->size; offs +=
TARGET_PAGE_SIZE) {
+memory_region_set_dirty(target_region, base + offs);
+ }
+ }
+
Quoted 5 lines
Quoted 2 lines
The subregion may be partially or fully obstructed. This needs to be done at the FlatRange level (
as_memory_range_del(), most likely).Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
What do you mean? There is a known issue with kvm here, this is a just workaround.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 27 lines · Avi Kivity
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
@@ -1093,9 +1093,26 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr,
void memory_region_del_subregion(MemoryRegion *mr,
MemoryRegion *subregion)
{
+ MemoryRegion*target_region;
+ram_addr_tbase, offs;
+assert(subregion->parent == mr); subregion->parent = NULL; QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link);+
+ if (subregion->alias) {
+ base =subregion->alias_offset;
+target_region=subregion->alias;
+ } else {
+ base = 0;
+target_region= subregion;
+ }
+ if (target_region->dirty_log_mask) {
+ for (offs = 0; offs<subregion->size; offs +=
TARGET_PAGE_SIZE) {
+memory_region_set_dirty(target_region, base + offs);
+ }
+ }
+
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The subregion may be partially or fully obstructed. This needs to be done at the FlatRange level (
as_memory_range_del(), most likely).Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
What do you mean? There is a known issue with kvm here, this is a just workaround.
Then the logic indeed belongs to kvm-all.c, not memory.c.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 8 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines
Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
What do you mean? There is a known issue with kvm here, this is a just workaround.
Then the logic indeed belongs to
kvm-all.c, notmemory.c.
Does kvm-all.c have all the information?
btw, where do you see the issue? which guest?
Somehow you see a lot more problems than I do.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines
Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
What do you mean? There is a known issue with kvm here, this is a just workaround.
Then the logic indeed belongs to
kvm-all.c, notmemory.c.Does
kvm-all.chave all the information?
If should as it keeps a record of the active slots with the logging flag. So, if a slot with logging on is changed, the dirty bits should be set.
Quoted 4 lines
btw, where do you see the issue? which guest?
Somehow you see a lot more problems than I do.
Stock OpenSUSE 11.4 with grub2 in graphical mode, -vga cirrus.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines
Makes some sense. I even wonder if this isn't a KVM deficit and should be handled there when a logged region is unmapped.
What do you mean? There is a known issue with kvm here, this is a just workaround.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Then the logic indeed belongs to
kvm-all.c, notmemory.c.Does
kvm-all.chave all the information?If should as it keeps a record of the active slots with the logging flag. So, if a slot with logging on is changed, the dirty bits should be set.
Ok. We'd need to teach it about the memory API as well - there is no longer a global ram_addr_t that can be used. But that's not too hard.
Quoted 6 lines
Quoted 4 lines
btw, where do you see the issue? which guest?
Somehow you see a lot more problems than I do.
Stock OpenSUSE 11.4 with grub2 in graphical mode, -vga cirrus.
Ah, I use regular grub. Will try g2.
Signature · 1 line
error compiling committee.c: too many arguments to function