piix: define a TOM register to report the base of PCI
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that one place
* Use APIpci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory, update memory region dynamically. TOM register are defined to one byte in PCI configure space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Is it really OK to just add registers to the PIIX like this? This is supposed to be emulating an actual real life device after all.
Perhaps an HVM param or some other out of band mechanism would be better here?
Ian.
Quoted 7 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that one place
* Use APIpci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.config
Quoted 7 lines
Define a TOM(top of memory) register to report the base of PCI memory, update memory region dynamically. TOM register are defined to one byte in PCI configure space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...
Quoted 201 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73 +++++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-9@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion *system_memory,if (pci_enabled) { pci_bus =i440fx_init (&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io, ram_size, - below_4g_mem_size, -0x100000000ULL - below_4g_mem_size, -0x100000000ULL + above_4g_mem_size, - (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +53
-20@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72 +/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level);static PCIINTxRoute piix3_route_intx_pin_to_irq (void *opaque,int pci_intx); static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; +hwaddr pci_hole_start, pci_hole_size, pci_hole64_start, pci_hole64_size; + + pci_hole_start =pci_default_read_config (&f->dev,I440FX_PCI_HOLE_BASE ,1 ) <<24 ; + pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { +memory_region_del_subregion (f->system_memory, &f->pci_hole); +if (pci_hole64_size) { +memory_region_del_subregion (f->system_memory, &f->pci_hole_64bit); + } + } + +memory_region_init_alias (&f->pci_hole,"pci-hole" , f->pci_address_space, + pci_hole_start, pci_hole_size); +memory_region_add_subregion (f->system_memory, pci_hole_start, &f->pci_hole); +memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { +memory_region_add_subregion (f->system_memory, pci_hole64_start, + &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; +pci_set_byte (dev->config +I440FX_PCI_HOLE_BASE , (uint8_t )(addr >>24 )); +cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char *device_name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_address_space, MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char *device_name, f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; -memory_region_init_alias (&f->pci_hole,"pci-hole" , f->pci_address_space, - pci_hole_start, pci_hole_size); -memory_region_add_subregion (f->system_memory, pci_hole_start, &f->pci_hole); -memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { -memory_region_add_subregion (f->system_memory, pci_hole64_start, - &f->pci_hole_64bit); - }memory_region_init_alias (&f->smram_region,"smram-region" , f->pci_address_space,0xa0000 ,0x20000 ); memory_region_add_subregion_overlap(f->system_memory, 0xa0000,@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char *device_name, (*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion *ram_memory) {@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, b =i440fx_common_init ("i440FX" , pi440fx_state, piix3_devfn, isa_bus, pic, address_space_mem, address_space_io, ram_size, - pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; }Signature · 1 line
1.7.12.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 31 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that oneplace
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>
Quoted 7 lines
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...
Hi, Ian and Stefano
Here adding this faking register in bios is a hack way.
However, what we emulated is not full real piece of hardware at all times, the max of TOM for i440fx is 1G, and we already adjust the TOM in qemu.
The faking register is only effective by bios and device model. This register is reserved by host bridge, so guest can't access this register, guest kernel should handle well when accessing a reserved region.
-Thanks
Xudong
Quoted 234 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 19 lines
hw/piix_pci.c +8
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 6 lines
hw/piix_pci.c +3
-0@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE, (uint8_t)(addr >>24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 269
Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 249
Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 346
Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 350
Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus,pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
A message that is not in the archive (sent off-list or not yet received): 403610A45A2B5242BD291EDAE8B37D300FF7C10B@SHSMSX102.ccr.corp.intel.com
For real i440fx, its TOM is fixed to 1G, I think Xen or other VMMs playing with Qemu should break this hardware rule. Maybe we can implement this register as a write-only one, so that OS can't see its existence. If OS reads this register, Qemu always return 0xff, and for any write operations to this register, it may impact hardware's behavior. This conforms to the behavior of OS accessing a reserved register.
Xiantao
Quoted 297 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hao, Xudong
Sent: Tuesday, February 26, 2013 11:33 AM
To: Stefano Stabellini; Ian Campbell
Cc: [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to reportthe
Quoted 7 lines
base of PCI
Quoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more thatone
Quoted 14 lines
place
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>Quoted 7 lines
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...Hi, Ian and Stefano
Here adding this faking register in bios is a hack way.
However, what we emulated is not full real piece of hardware at all times, the max of TOM for i440fx is 1G, and we already adjust the TOM in qemu. The faking register is only effective by bios and device model. This register is reserved by host bridge, so guest can't access this register, guest kernel should handle well when accessing a reserved region.-Thanks
XudongQuoted 234 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 19 lines
hw/piix_pci.c +8
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 6 lines
hw/piix_pci.c +3
-0@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE, (uint8_t)(addr >>24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 269
Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 249
Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 346
Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 350
Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus,pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
A message that is not in the archive (sent off-list or not yet received): B6C2EB9186482D47BD0C5A9A483456440343CD1C@SHSMSX101.ccr.corp.intel.com
Right, I think that reading as 0xff and write once would be important improvements for this patch.
I would like to see a document somewhere (maybe just a text file under xen-unstable/docs/misc) with a list of deviations of the i440fx we emulate and the real one.
Other than that, it would be OK for me.
Quoted 301 lines · Xiantao
For real i440fx, its TOM is fixed to 1G, I think Xen or other VMMs playing with Qemu should break this hardware rule. Maybe we can implement this register as a write-only one, so that OS can't see its existence. If OS reads this register, Qemu always return
0xff, and for any write operations to this register, it may impact hardware's behavior. This conforms to the behavior of OS accessing a reserved register.
XiantaoQuoted 297 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hao, Xudong
Sent: Tuesday, February 26, 2013 11:33 AM
To: Stefano Stabellini; Ian Campbell
Cc: [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to reportthe
Quoted 7 lines
base of PCI
Quoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more thatone
Quoted 14 lines
place
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>Quoted 7 lines
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...Hi, Ian and Stefano
Here adding this faking register in bios is a hack way.
However, what we emulated is not full real piece of hardware at all times, the max of TOM for i440fx is 1G, and we already adjust the TOM in qemu. The faking register is only effective by bios and device model. This register is reserved by host bridge, so guest can't access this register, guest kernel should handle well when accessing a reserved region.-Thanks
XudongQuoted 234 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 19 lines
hw/piix_pci.c +8
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 6 lines
hw/piix_pci.c +3
-0@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE, (uint8_t)(addr >>24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 269
Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 249
Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 346
Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 350
Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus,pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
Quoted 311 lines · Stefano Stabellini
Right, I think that reading as
0xffand write once would be important improvements for this patch.I would like to see a document somewhere (maybe just a text file under xen-unstable/docs/misc) with a list of deviations of the i440fx we emulate and the real one.
Other than that, it would be OK for me.
Quoted 301 lines · Xiantao
For real i440fx, its TOM is fixed to 1G, I think Xen or other VMMs playing with Qemu should break this hardware rule. Maybe we can implement this register as a write-only one, so that OS can't see its existence. If OS reads this register, Qemu always return
0xff, and for any write operations to this register, it may impact hardware's behavior. This conforms to the behavior of OS accessing a reserved register.
XiantaoQuoted 297 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hao, Xudong
Sent: Tuesday, February 26, 2013 11:33 AM
To: Stefano Stabellini; Ian Campbell
Cc: [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to reportthe
Quoted 7 lines
base of PCI
Quoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more thatone
Quoted 14 lines
place
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>Quoted 7 lines
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...Hi, Ian and Stefano
Here adding this faking register in bios is a hack way.
However, what we emulated is not full real piece of hardware at all times, the max of TOM for i440fx is 1G, and we already adjust the TOM in qemu. The faking register is only effective by bios and device model. This register is reserved by host bridge, so guest can't access this register, guest kernel should handle well when accessing a reserved region.-Thanks
XudongQuoted 234 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 19 lines
hw/piix_pci.c +8
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 6 lines
hw/piix_pci.c +3
-0@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE, (uint8_t)(addr >>24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 269
Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 249
Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 346
Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 350
Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus,pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Ian Campbell
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
And QEMU also provides the fw_cfg interface with this information.
Regards,
Anthony Liguori
Quoted 313 lines · Stefano Stabellini
Quoted 311 lines
Right, I think that reading as
0xffand write once would be important improvements for this patch.I would like to see a document somewhere (maybe just a text file under xen-unstable/docs/misc) with a list of deviations of the i440fx we emulate and the real one.
Other than that, it would be OK for me.
Quoted 301 lines · Xiantao
For real i440fx, its TOM is fixed to 1G, I think Xen or other VMMs playing with Qemu should break this hardware rule. Maybe we can implement this register as a write-only one, so that OS can't see its existence. If OS reads this register, Qemu always return
0xff, and for any write operations to this register, it may impact hardware's behavior. This conforms to the behavior of OS accessing a reserved register.
XiantaoQuoted 297 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hao, Xudong
Sent: Tuesday, February 26, 2013 11:33 AM
To: Stefano Stabellini; Ian Campbell
Cc: [email protected]; [email protected]; [email protected]; xen- [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to reportthe
Quoted 7 lines
base of PCI
Quoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more thatone
Quoted 14 lines
place
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>Quoted 7 lines
The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...Hi, Ian and Stefano
Here adding this faking register in bios is a hack way.
However, what we emulated is not full real piece of hardware at all times, the max of TOM for i440fx is 1G, and we already adjust the TOM in qemu. The faking register is only effective by bios and device model. This register is reserved by host bridge, so guest can't access this register, guest kernel should handle well when accessing a reserved region.-Thanks
XudongQuoted 234 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 19 lines
hw/piix_pci.c +8
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice *dev, range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 6 lines
hw/piix_pci.c +3
-0@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE, (uint8_t)(addr >>24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 269
Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 249
Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const char · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 346
Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,int
*piix3_devfn,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 350
Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus,pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
Quoted 3 lines
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
Actually, even in hardware, I believe there are many registers which are implemented with write-once attributes, and they are only used by firmware and reserved for OS. In addition, with this change, it can benefit all VMMs (not just Xen) which use Qemu as device model. If adopt xenstore way, perhaps other VMMs also have to write similar and duplicate logic for the same purpose.
Xiantao
Quoted 340 lines · Stefano Stabellini
Quoted 11 lines
Right, I think that reading as
0xffand write once would be important improvements for this patch.I would like to see a document somewhere (maybe just a text file under xen-unstable/docs/misc) with a list of deviations of the i440fx we emulate and the real one.
Other than that, it would be OK for me.
Quoted 1 line · Xiantao
For real i440fx, its TOM is fixed to 1G, I think Xen or other VMMs playing
with Qemu should break this hardware rule. Maybe we can implement this
register as a write-only one, so that OS can't see its existence. If OS reads this
register, Qemu always return0xff, and for any write operations to this register, it may impact hardware's behavior. This conforms to the behavior of OS accessing a reserved register.Quoted 5 lines
Quoted 5 lines
Xiantao
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] OnBehalf
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Of Hao, Xudong
Sent: Tuesday, February 26, 2013 11:33 AM
To: Stefano Stabellini; Ian Campbell
Cc: [email protected]; [email protected]; [email protected];xen-
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register toreport the
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
base of PCI
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] OnBehalf
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Of Stefano Stabellini
Sent: Tuesday, February 26, 2013 12:06 AM
To: Hao, Xudong
Cc: [email protected]; Stefano Stabellini; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register toreport
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
the
Quoted 7 lines
base of PCI
Quoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in morethat
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
one
Quoted 5 lines
place
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI
memory,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in
PCI
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
configure
Quoted 1 line
space, because that only upper 4 bit of PCI memory takes effect for
Xen, so
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>The patch is OK from my POV, but I think that Ian raised a valid
concern: we are supposed to emulate a real piece of hardware, maybe another mechanism (xenbus? hvmop?) to pass the information from hvmloader to QEMU would be a better fit than this. Otherwise at least we would need to advertize this feature somehow: if hvmloader can use it, the guest kernel can use it too...Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Hi, Ian and Stefano
Here adding this faking register in bios is a hack way. However, what we emulated is not full real piece of hardware at all times,
the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
max of TOM for i440fx is 1G, and we already adjust the TOM in qemu. The faking register is only effective by bios and device model. This
register is
Quoted 1 line
Quoted 1 line
Quoted 1 line
reserved by host bridge, so guest can't access this register, guest kernel
should
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
handle well when accessing a reserved region.
-Thanks
XudongQuoted 31 lines
Quoted 5 lines
hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
Quoted 25 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 5 lines
hw/pc_piix.c +0
-0@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion
*system_memory,Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 13 lines
hw/pc_piix.c +3
-3kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 14 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 10 lines
hw/piix_pci.c +8
-0+/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0 +static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice
*pci_dev, intQuoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory,
pci_hole_start,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
pci_hole64_start,Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
hw/piix_pci.c static void i440fx_write_config(PCIDevice
Quoted 9 lines
hw/piix_pci.c +5
-0+ &f->pci_hole_64bit); + } +} + +static void i440fx_update_memory_mappings (PCII440FXState *d) {int i;@@ -136,6 +181,9 @@ static void i440fx_write_config(PCIDevice*dev,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
hw/piix_pci.c +3
-0range_covers_byte(address, len, I440FX_SMRAM)) {i440fx_update_memory_mappings (d); } +if (range_covers_byte (address, len,I440FX_PCI_HOLE_BASE )) { +i440fx_update_pci_mem_hole (d, true); + } }Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
hw/piix_pci.c static int i440fx_initfn(PCIDevice *dev) · line 256
Quoted 8 lines
hw/piix_pci.c +3
-0static int i440fx_load_old (QEMUFile * f,void *opaque,int version_id)@@ -203,6 +251,10 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ; +/* Emulate top of memory, here use 0xe0000000 as default val*/ +uint32_t addr =xen_enabled () ?I440FX_XEN_TOM :I440FX_TOM ; + pci_set_byte(dev->config + I440FX_PCI_HOLE_BASE,(uint8_t)(addr >>
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
24));
hw/piix_pci.c static PCIBus *i440fx_common_init(const
Quoted 5 lines
hw/piix_pci.c +1
-0+cpu_smm_register (&i440fx_set_smm, d);return 0 ; }@@ -214,10 +266,6 @@ static PCIBus *i440fx_common_init(constchar
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 266
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_mem,hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 267
Quoted 1 line
hw/piix_pci.c +0
-0MemoryRegion
*address_space_io,Quoted 6 lines
hw/piix_pci.c +0
-4ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegionQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
*pci_address_space,hw/piix_pci.c static PCIBus *i440fx_common_init(const
Quoted 3 lines
hw/piix_pci.c +0
-0MemoryRegion *ram_memory) {@@ -244,16 +292,6 @@ static PCIBus *i440fx_common_init(constchar
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
*device_name,hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 247
Quoted 4 lines
hw/piix_pci.c +0
-1f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,Quoted 2 lines
hw/piix_pci.c +0
-2- pci_hole_start, pci_hole_size); - memory_region_add_subregion(f->system_memory,
pci_hole_start,Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
&f->pci_hole);hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 254
Quoted 5 lines
hw/piix_pci.c +0
-5-memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , - f->pci_address_space, - pci_hole64_start, pci_hole64_size); -if (pci_hole64_size) { - memory_region_add_subregion(f->system_memory,
pci_hole64_start,hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 296
Quoted 4 lines
hw/piix_pci.c +0
-2- &f->pci_hole_64bit); - } memory_region_init_alias(&f->smram_region, "smram-region", f->pci_address_space, 0xa0000,
0x20000);hw/piix_pci.c static PCIBus *i440fx_common_init(const · line 297
Quoted 1 line
hw/piix_pci.c +0
-0memory_region_add_subregion_overlap(f->system_memory,
0xa0000,hw/piix_pci.c static PCIBus *i440fx_common_init(const char
Quoted 1 line
hw/piix_pci.c +0
-0@@ -295,6 +333,7 @@ static PCIBus *i440fx_common_init(const char
*device_name,hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 8 lines
hw/piix_pci.c +1
-0(*pi440fx_state)->dev.config[0x57 ]=ram_size;i440fx_update_memory_mappings (f); +i440fx_update_pci_mem_hole (f, false);return b; }@@ -304,10 +343,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state, int
*piix3_devfn,Quoted 8 lines
hw/piix_pci.c +0
-4MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegionQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
*ram_memory)hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState
Quoted 3 lines
hw/piix_pci.c +0
-0{@@ -315,8 +350,6 @@ PCIBus *i440fx_init(PCII440FXState**pi440fx_state,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
int
*piix3_devfn,Quoted 2 lines
hw/piix_pci.c +0
-0b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn,
isa_bus,Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
pic,
hw/piix_pci.c PCIBus *i440fx_init(PCII440FXState · line 351
Quoted 1 line
hw/piix_pci.c +0
-0address_space_mem, address_space_io,
ram_size,Quoted 8 lines
hw/piix_pci.c +0
-3- pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory);return b; } --1.7.12.1
A message that is not in the archive (sent off-list or not yet received): B6C2EB9186482D47BD0C5A9A483456440343F776@SHSMSX101.ccr.corp.intel.com
I'm not sure about qemu-devel but on xen-devel the policy is not to top post so please could you avoid doping so.
Quoted 7 lines · Xiantao
Quoted 3 lines
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
Actually, even in hardware, I believe there are many registers which are implemented with write-once attributes, and they are only used by firmware and reserved for OS.
The i440fx does not have this register (be it write once or otherwise), which is my actual point -- you are adding a magic property to the emulation of this device which the real hardware doesn't have. It isn't really relevant that other hardware could implement write once registers, that's obviously the case.
Quoted 4 lines
In addition, with this change, it can benefit all VMMs (not just Xen) which use Qemu as device model. If adopt xenstore way, perhaps other VMMs also have to write similar and duplicate logic for the same purpose.
Which other VMM? AIUI qemu/kvm doesn't have a requirement to communicate this information from the VMM to qemu because qemu is the VMM and controls all of the hardware resources.
Ian.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ian Campbell
Sent: Wednesday, February 27, 2013 7:07 PM
To: Zhang, Xiantao
Cc: [email protected]; [email protected]; Stefano Stabellini; Hao, Xudong; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCII'm not sure about qemu-devel but on xen-devel the policy is not to top post so please could you avoid doping so.
Quoted 4 lines · Xiantao
Quoted 3 lines
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
Quoted 7 lines
Quoted 3 lines
Actually, even in hardware, I believe there are many registers which are implemented with write-once attributes, and they are only used by firmware and reserved for OS.
The i440fx does not have this register (be it write once or otherwise), which is my actual point -- you are adding a magic property to the emulation of this device which the real hardware doesn't have.
Sorry to response later.
But why faking a register that the real hardware doesn't have is not acceptant? I440fx device don't need this register for native environment, but for virtualization, adding such a register can simplify things.
Quoted 9 lines
It isn't
really relevant that other hardware could implement write once registers, that's obviously the case.Quoted 4 lines
In addition, with this change, it can benefit all VMMs (not just Xen) which use Qemu as device model. If adopt xenstore way, perhaps other VMMs also have to write similar and duplicate logic for the same purpose.
Quoted 5 lines
Which other VMM? AIUI qemu/kvm doesn't have a requirement to communicate
this information from the VMM to qemu because qemu is the VMM and controls all of the hardware resources.
I think our changes have better compatibility, we can't predict qemu will not be used for other VMMs, although changes only benefit xen till now.
Quoted 20 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ian Campbell
Sent: Wednesday, February 27, 2013 7:07 PM
To: Zhang, Xiantao
Cc: [email protected]; [email protected]; Stefano Stabellini; Hao, Xudong; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2] piix: define a TOM register to report the base of PCII'm not sure about qemu-devel but on xen-devel the policy is not to top post so please could you avoid doping so.
Quoted 4 lines · Xiantao
Quoted 3 lines
Given that Xen has at least two other mechanisms (xenstore and hvmparams) for passing this sort of information around I'm not sure why hacking the emulated i440fx device should be the preferred option.
Quoted 7 lines
Quoted 3 lines
Actually, even in hardware, I believe there are many registers which are implemented with write-once attributes, and they are only used by firmware and reserved for OS.
The i440fx does not have this register (be it write once or otherwise), which is my actual point -- you are adding a magic property to the emulation of this device which the real hardware doesn't have.
Sorry to response later.
But why faking a register that the real hardware doesn't have is not acceptant? I440fx device don't need this register for native environment, but for virtualization, adding such a register can simplify things.
Quoted 9 lines
It isn't
really relevant that other hardware could implement write once registers, that's obviously the case.Quoted 4 lines
In addition, with this change, it can benefit all VMMs (not just Xen) which use Qemu as device model. If adopt xenstore way, perhaps other VMMs also have to write similar and duplicate logic for the same purpose.
Quoted 5 lines
Which other VMM? AIUI qemu/kvm doesn't have a requirement to communicate
this information from the VMM to qemu because qemu is the VMM and controls all of the hardware resources.
I think our changes have better compatibility, we can't predict qemu will not be used for other VMMs, although changes only benefit xen till now.
Quoted 7 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that one place
* Use APIpci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.config
Quoted 7 lines
Define a TOM(top of memory) register to report the base of PCI memory, update memory region dynamically. TOM register are defined to one byte in PCI configure space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>
Could you supply some motivation for this patch?
Quoted 64 lines
--- hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73 +++++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-9@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion *system_memory,if (pci_enabled) { pci_bus =i440fx_init (&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io, ram_size, - below_4g_mem_size, -0x100000000ULL - below_4g_mem_size, -0x100000000ULL + above_4g_mem_size, - (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0
hw/piix_pci.c struct PCII440FXState { · line 95
Quoted 10 lines
hw/piix_pci.c +7
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72 +/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0
Do you have to use a fixed address? As others said, it's a hack. How about adding a special device for this hackery?
Quoted 35 lines
hw/piix_pci.c +28
-0+static void piix3_set_irq (void *opaque,int pirq,int level);static PCIINTxRoute piix3_route_intx_pin_to_irq (void *opaque,int pci_intx); static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; +hwaddr pci_hole_start, pci_hole_size, pci_hole64_start, pci_hole64_size; + + pci_hole_start =pci_default_read_config (&f->dev,I440FX_PCI_HOLE_BASE ,1 ) <<24 ; + pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { +memory_region_del_subregion (f->system_memory, &f->pci_hole); +if (pci_hole64_size) { +memory_region_del_subregion (f->system_memory, &f->pci_hole_64bit); + } + } + +memory_region_init_alias (&f->pci_hole,"pci-hole" , f->pci_address_space, + pci_hole_start, pci_hole_size); +memory_region_add_subregion (f->system_memory, pci_hole_start, &f->pci_hole);
hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) · line 148
Quoted 10 lines
hw/piix_pci.c +10
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { +memory_region_add_subregion (f->system_memory, pci_hole64_start, + &f->pci_hole_64bit); + } +} + +
If you do things like this, won't ACPI tables become incorrect?
Signature · 1 line
MST
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines
-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 6:50 PM
To: Hao, Xudong
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that oneplace
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
Quoted 9 lines
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>Could you supply some motivation for this patch?
It's a fix for Xen. Qemu want more information from Xen, copy Stefano's comments:
QEMU needs to know where the end of the guest's RAM is (because there is where it allocates the videoram and other stuff), so at least the size of the MMIO hole is important.
Thanks,
-Xudong
Quoted 131 lines
Quoted 4 lines
--- hw/pc.h | 7 +++--- hw/pc_piix.c | 12 +++------- hw/piix_pci.c | 73+++++++++++++++++++++++++++++++++++++++++++----------------
hw/pc_piix.c static void pc_init1(MemoryRegion
Quoted 43 lines
3 files changed, 59 insertions(+), 33 deletions(-)hw/pc.h +3
-4@@ -129,15 +129,14 @@ extern int no_hpet;struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; +#define I440FX_TOM 0xe0000000 +#define I440FX_XEN_TOM 0xf0000000 +PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,ISABus **isa_bus,qemu_irq *pic,MemoryRegion *address_space_mem,MemoryRegion *address_space_io,ram_addr_t ram_size, -hwaddr pci_hole_start, -hwaddr pci_hole_size, -hwaddr pci_hole64_start, -hwaddr pci_hole64_size,MemoryRegion *pci_memory,MemoryRegion *ram_memory);hw/pc_piix.c +3
-3@@ -93,9 +93,9 @@ static void pc_init1(MemoryRegion *system_memory,kvmclock_create (); } -if (ram_size >=0xe0000000 ) { - above_4g_mem_size = ram_size -0xe0000000 ; - below_4g_mem_size =0xe0000000 ; +if (ram_size >=I440FX_TOM ) { + above_4g_mem_size = ram_size -I440FX_TOM ; + below_4g_mem_size =I440FX_TOM ; }else { above_4g_mem_size =0 ; below_4g_mem_size = ram_size;@@ -130,12 +130,6 @@ static void pc_init1(MemoryRegion
*system_memory,hw/pc_piix.c static void pc_init1(MemoryRegion · line 132
Quoted 3 lines
hw/pc_piix.c +0
-0if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io,
ram_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 134
Quoted 2 lines
hw/pc_piix.c +0
-2- below_4g_mem_size, - 0x100000000ULL -
below_4g_mem_size,hw/pc_piix.c static void pc_init1(MemoryRegion · line 135
Quoted 1 line
hw/pc_piix.c +0
-1- 0x100000000ULL +
above_4g_mem_size,Quoted 11 lines
hw/pc_piix.c +0
-3- (sizeof (hwaddr) ==4 - ?0 - : ((uint64_t )1 <<62 )), pci_memory, ram_memory); }else { pci_bus =NULL ;hw/piix_pci.c +0
-0hw/piix_pci.c struct PCII440FXState { · line 95
Quoted 10 lines
hw/piix_pci.c +7
-0@@ -86,6 +86,14 @@ struct PCII440FXState {#define I440FX_PAM_SIZE 7#define I440FX_SMRAM 0x72 +/* The maximum vaule of TOM(top of memory) register in I440FX +* is 1G, so it doesn't meet any popular virutal machines, so +* define another register to report the base of PCI memory. +* Use one byte 0xb0 for the upper 8 bit, they are originally +* resevered for host bridge. +* */ +#define I440FX_PCI_HOLE_BASE 0xb0Do you have to use a fixed address? As others said, it's a hack. How about adding a special device for this hackery?
hw/piix_pci.c struct PCII440FXState { · line 98
Quoted 3 lines
hw/piix_pci.c +1
-0+static void piix3_set_irq (void *opaque,int pirq,int level); static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int
pci_intx);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int
Quoted 2 lines
hw/piix_pci.c +0
-0static void piix3_write_config_xen(PCIDevice *dev,@@ -101,6 +109,43 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int
pci_intx)hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 116
Quoted 8 lines
hw/piix_pci.c +5
-0return (pci_intx + slot_addend) &3 ; } + +static void i440fx_update_pci_mem_hole (PCII440FXState *f,bool del) +{ +ram_addr_t above_4g_mem_size; + hwaddr pci_hole_start, pci_hole_size, pci_hole64_start,
pci_hole64_size;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 118
Quoted 2 lines
hw/piix_pci.c +2
-0+ + pci_hole_start = pci_default_read_config(&f->dev,
I440FX_PCI_HOLE_BASE, 1) << 24;hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 130
Quoted 12 lines
hw/piix_pci.c +12
-0+ pci_hole_size =0x100000000ULL - pci_hole_start; + +if (ram_size >= pci_hole_start) { + above_4g_mem_size = ram_size - pci_hole_start; + }else { + above_4g_mem_size =0 ; + } + pci_hole64_start =0x100000000ULL + above_4g_mem_size; + pci_hole64_size =sizeof (hwaddr) ==4 ?0 : ((uint64_t )1 <<62 ); + +if (del) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 132
Quoted 2 lines
hw/piix_pci.c +2
-0+if (pci_hole64_size) { + memory_region_del_subregion(f->system_memory,
&f->pci_hole_64bit);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 136
Quoted 4 lines
hw/piix_pci.c +4
-0+ } + } + + memory_region_init_alias(&f->pci_hole, "pci-hole",
f->pci_address_space,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 138
Quoted 2 lines
hw/piix_pci.c +2
-0+ pci_hole_start, pci_hole_size); + memory_region_add_subregion(f->system_memory, pci_hole_start,
&f->pci_hole);hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 143
Quoted 5 lines
hw/piix_pci.c +5
-0+memory_region_init_alias (&f->pci_hole_64bit,"pci-hole64" , + f->pci_address_space, + pci_hole64_start, pci_hole64_size); +if (pci_hole64_size) { + memory_region_add_subregion(f->system_memory,
Quoted 9 lines
pci_hole64_start,hw/piix_pci.c static int pci_slot_get_pirq(PCIDevice *pci_dev, int · line 148
Quoted 5 lines
hw/piix_pci.c +5
-0+ &f->pci_hole_64bit); + } +} + +If you do things like this, won't ACPI tables become incorrect?
ACPI is built in guest firmware, and these things is reported from firmware by this faking register.
Am 18.03.2013 16:21, schrieb Hao, Xudong:
Quoted 28 lines
Quoted 28 lines
-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 6:50 PM
To: Hao, Xudong
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that oneplace
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>
Quoted 8 lines
Quoted 2 lines
Could you supply some motivation for this patch?
It's a fix for Xen. Qemu want more information from Xen, copy Stefano's comments:
QEMU needs to know where the end of the guest's RAM is (because there is where it allocates the videoram and other stuff), so at least the size of the MMIO hole is important.
Could you please reply to Anthony's comment that this information is already available via fw_cfg interface? hw/fw_cfg.h is designed so that it can be embedded elsewhere (e.g., in SeaBIOS and OpenBIOS). Reusing any information available through that interface would seem much easier than fiddling with reserved registers on emulated hardware.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 18.03.2013 16:21, schrieb Hao, Xudong:
Quoted 28 lines
Quoted 28 lines
-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 6:50 PM
To: Hao, Xudong
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] piix: define a TOM register to report the base of PCIQuoted 4 lines · Xudong Hao
v2:
* Use "piix: " in the subject rather than "qemu: "
* Define TOM register as one byte
* Define default TOM value instead of hardcode0xe0000000in more that oneplace
Quoted 4 lines
* Use API
pci_set_bytefor pci config access
* Usedev->configinstead of the indirectd->dev.configDefine a TOM(top of memory) register to report the base of PCI memory,
update
Quoted 1 line
memory region dynamically. TOM register are defined to one byte in PCI
configure
Quoted 5 lines
space, because that only upper 4 bit of PCI memory takes effect for Xen, so it requires bios set TOM with 16M-aligned.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>
Quoted 8 lines
Quoted 2 lines
Could you supply some motivation for this patch?
It's a fix for Xen. Qemu want more information from Xen, copy Stefano's comments:
QEMU needs to know where the end of the guest's RAM is (because there is where it allocates the videoram and other stuff), so at least the size of the MMIO hole is important.
Could you please reply to Anthony's comment that this information is already available via fw_cfg interface? hw/fw_cfg.h is designed so that it can be embedded elsewhere (e.g., in SeaBIOS and OpenBIOS). Reusing any information available through that interface would seem much easier than fiddling with reserved registers on emulated hardware.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg