Skip to contentSkip to conversation

hw/arm/virt-acpi-build: Fix wrong size of flash

PATCH Applied [email protected] 5 participants 5 messages Sep 17, 2015 – Sep 18, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/virt-acpi-build: Fix wrong size of flash

From: Shannon Zhao <[email protected]>

While virt machine creates two flash devices with total size 0x08000000, it wrongly uses this total size for each one. So it will overlap other MMIO spaces.

---
 hw/arm/virt-acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +1 -1
index 2073573..bc858c8 100644
@@ -114,7 +114,7 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
 {
     Aml *dev, *crs;
     hwaddr base = flash_memmap->base;
-    hwaddr size = flash_memmap->size;
+    hwaddr size = flash_memmap->size / 2;
 
     dev = aml_device("FLS0");
     aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));
Signature · 1 line
2.1.0
Tested-by on v1 1/1
#1 lore raw

This is an urgent fix as it completely breaks booting with ACPI. Success is only a matter of luck with device probing order.

Graeme

Quoted 27 lines · On 17 September 2015 at 02:57, <[email protected]> wrote:

From: Shannon Zhao <[email protected]>

While virt machine creates two flash devices with total size 0x08000000, it wrongly uses this total size for each one. So it will overlap other MMIO spaces.

---
 hw/arm/virt-acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +1 -2
index 2073573..bc858c8 100644
@@ -114,7 +114,7 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
 {
     Aml *dev, *crs;
     hwaddr base = flash_memmap->base;
-    hwaddr size = flash_memmap->size;
+    hwaddr size = flash_memmap->size / 2;
 
     dev = aml_device("FLS0");
     aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));
--

2.1.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 28 lines · On Thu, Sep 17, 2015 at 09:57:21AM +0800, [email protected] wrote:

From: Shannon Zhao <[email protected]>

While virt machine creates two flash devices with total size 0x08000000, it wrongly uses this total size for each one. So it will overlap other MMIO spaces.

---
 hw/arm/virt-acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +1 -1
index 2073573..bc858c8 100644
@@ -114,7 +114,7 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
 {
     Aml *dev, *crs;
     hwaddr base = flash_memmap->base;
-    hwaddr size = flash_memmap->size;
+    hwaddr size = flash_memmap->size / 2;
 
     dev = aml_device("FLS0");
     aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));
Signature · 1 line
2.1.0

A sentence in the commit message saying that the DT generation also gives each device one half the total size would be nice

Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 17 lines · On 09/16/2015 08:57 PM, [email protected] wrote:

From: Shannon Zhao <[email protected]>

While virt machine creates two flash devices with total size 0x08000000, it wrongly uses this total size for each one. So it will overlap other MMIO spaces.

---
 hw/arm/virt-acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +0 -0
index 2073573..bc858c8 100644

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap) · line 120

Quoted 8 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -114,7 +114,7 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
 {
     Aml *dev, *crs;
     hwaddr base = flash_memmap->base;
-    hwaddr size = flash_memmap->size;
+    hwaddr size = flash_memmap->size / 2;
 
     dev = aml_device("FLS0");
     aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));

In current code, it looks like both FLS0 and FLS1 are using up the whole space. That would invade into the VIRT_CPUPERIPHS address space, which apparently is wrong.

#4 lore raw
In reply to [email protected]
Quoted 7 lines · On 17 September 2015 at 02:57, <[email protected]> wrote:

From: Shannon Zhao <[email protected]>

While virt machine creates two flash devices with total size 0x08000000, it wrongly uses this total size for each one. So it will overlap other MMIO spaces.

Applied to target-arm.next, thanks.

Andrew suggested an update to the commit message, so I have edited it:

hw/arm/virt-acpi-build: Fix wrong size of flash in ACPI table

While virt machine creates two flash devices with total size 0x08000000, the ACPI table generation code was wrongly using this total size as the size of each flash device, so it would overlap other MMIO spaces. Make each device entry in the table half the total; this brings the ACPI table into line with the code which generates the device tree and which creates the flash devices themselves.

thanks
-- PMM