Skip to contentSkip to conversation

xen: PCI runqemu issue follow-up

PATCH In review Michal Orzel 4 participants 10 messages Jun 9, 2022 – Jun 20, 2022

lore
Share & tools
lore
#0 lore raw

cover xen: PCI runqemu issue follow-up

This series acts as a follow-up to the commit:
fb0a7b97db4f ("xen: Disable PCI on qemuarm with Xen")

This wants to be backported to kirkstone.

Michal Orzel (2):
Revert "xen: Disable PCI on qemuarm with Xen"
xen: Disable highmem on qemuarm

 classes/qemuboot-xen-defaults.bbclass |  6 ++++--
 classes/qemuboot-xen-dtb.bbclass      | 22 ----------------------
 2 files changed, 4 insertions(+), 24 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 Revert "xen: Disable PCI on qemuarm with Xen"

This reverts commit fb0a7b97db4f419b82309f98a4944ae3330d1e2e.

Justification:
Commit fb0a7b97db4f removed the PCI node from the qemu device tree due to the issue when trying to access PCI configuration space that was causing Linux running on top of Xen to end up in an infinite loop. The investigation showed that the problem occurs due to qemu placing ECAM space at 256GiB mark. Even though Xen officially supports on arm32 up to 12GiB of physical address space, it is able to map it correctly for dom0. However, when Linux tries to access the ECAM space and the stage2 translation fault occurs, HPFAR register contains incorrect IPA. We can say it is incorrect because using hardware AT instruction or software lookup, we can obtain the correct IPA from the same VA. This can suggest that the problem is related to QEMU fault handling.

Instead of removing the PCI node the follow-up commit will disable highmem option in qemu which will cause placing ECAM space in the 32-bit space.

---
 classes/qemuboot-xen-dtb.bbclass | 22 ----------------------
 1 file changed, 22 deletions(-)
classes/qemuboot-xen-dtb.bbclass +0 -22
index 1f17a86..d43d23a 100644
@@ -63,21 +63,6 @@ write_lops_xen_section() {
 EOF
 }
 
-write_lop_rm_pci() {
-    cat <<EOF >"$1"
-/dts-v1/;
-/ {
-    compatible = "system-device-tree-v1";
-    lops {
-        lop_1 {
-            compatible = "system-device-tree-v1,lop,modify";
-            modify = "/pcie@10000000::";
-        };
-     };
-};
-EOF
-}
-
 write_lop_add_to_xen_cmdline() {
     EXTRA_XEN_BOOTARGS="$2"
     cat <<EOF >"$1"
@@ -150,13 +135,6 @@ generate_xen_qemuboot_dtb() {
     write_lop_add_to_xen_cmdline "${B}/lop-xen-cmdline.dts" \
         "${QB_XEN_CMDLINE_EXTRA}"
 
-    # On Qemu Arm32, Dom0 accessing PCI config space ends up in an
-    # infinite loop. Remove pci node from the device tree
-    if [ "${MACHINE}" = "qemuarm" ]; then
-        write_lop_rm_pci "${B}/lop-rm-pci.dts"
-        LOP_MODULE_ARGS="${LOP_MODULE_ARGS} -i ${B}/lop-rm-pci.dts"
-    fi
-
     if [ -z "${QB_XEN_DOMAIN_MODULES}" ]; then
         bbwarn "No domain modules: please set QB_XEN_DOMAIN_MODULES"
     fi
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [meta-virtualization] [PATCH 1/2] Revert "xen: Disable PCI on qemuarm with Xen"

Hi Michal,

Quoted 17 lines · Michal Orzel via lists.yoctoproject.org

This reverts commit fb0a7b97db4f419b82309f98a4944ae3330d1e2e.

Justification:
Commit fb0a7b97db4f removed the PCI node from the qemu device tree due to the issue when trying to access PCI configuration space that was causing Linux running on top of Xen to end up in an infinite loop. The investigation showed that the problem occurs due to qemu placing ECAM space at 256GiB mark. Even though Xen officially supports on arm32 up to 12GiB of physical address space, it is able to map it correctly for dom0. However, when Linux tries to access the ECAM space and the stage2 translation fault occurs, HPFAR register contains incorrect IPA. We can say it is incorrect because using hardware AT instruction or software lookup, we can obtain the correct IPA from the same VA. This can suggest that the problem is related to QEMU fault handling.

Quoted 5 lines

Instead of removing the PCI node the follow-up commit will disable highmem option in qemu which will cause placing ECAM space in the 32-bit space.

Also tested on kirkstone and dom0 boots fine and pci is working.

Thanks a lot
Cheers
Bertrand

Quoted 56 lines

---
classes/qemuboot-xen-dtb.bbclass | 22 ----------------------

1 file changed, 22 deletions(-)
classes/qemuboot-xen-dtb.bbclass +0 -0
index 1f17a86..d43d23a 100644
@@ -63,21 +63,6 @@ write_lops_xen_section() {

EOF
}

classes/qemuboot-xen-dtb.bbclass +0 -15
-write_lop_rm_pci() {
-    cat <<EOF >"$1"
-/dts-v1/;
-/ {
-    compatible = "system-device-tree-v1";
-    lops {
-        lop_1 {
-            compatible = "system-device-tree-v1,lop,modify";
-            modify = "/pcie@10000000::";
-        };
-     };
-};
-EOF
-}
-
write_lop_add_to_xen_cmdline() {
    EXTRA_XEN_BOOTARGS="$2"
    cat <<EOF >"$1"
classes/qemuboot-xen-dtb.bbclass +0 -7
@@ -150,13 +135,6 @@ generate_xen_qemuboot_dtb() {
    write_lop_add_to_xen_cmdline "${B}/lop-xen-cmdline.dts" \
        "${QB_XEN_CMDLINE_EXTRA}"
 
-    # On Qemu Arm32, Dom0 accessing PCI config space ends up in an
-    # infinite loop. Remove pci node from the device tree
-    if [ "${MACHINE}" = "qemuarm" ]; then
-        write_lop_rm_pci "${B}/lop-rm-pci.dts"
-        LOP_MODULE_ARGS="${LOP_MODULE_ARGS} -i ${B}/lop-rm-pci.dts"
-    fi
-
    if [ -z "${QB_XEN_DOMAIN_MODULES}" ]; then
        bbwarn "No domain modules: please set QB_XEN_DOMAIN_MODULES"
    fi
Signature · 10 lines
2.25.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7351): https://lists.yoctoproject.org/g/meta-virtualization/message/7351
Mute This Topic: https://lists.yoctoproject.org/mt/91642063/3619089
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by
#3 lore raw

Re: [meta-virtualization] [PATCH 1/2] Revert "xen: Disable PCI on qemuarm with Xen"

Quoted 20 lines · Bertrand Marquis

Hi Michal,

Quoted 17 lines · Michal Orzel via lists.yoctoproject.org

This reverts commit fb0a7b97db4f419b82309f98a4944ae3330d1e2e.

Justification:
Commit fb0a7b97db4f removed the PCI node from the qemu device tree due to the issue when trying to access PCI configuration space that was causing Linux running on top of Xen to end up in an infinite loop. The investigation showed that the problem occurs due to qemu placing ECAM space at 256GiB mark. Even though Xen officially supports on arm32 up to 12GiB of physical address space, it is able to map it correctly for dom0. However, when Linux tries to access the ECAM space and the stage2 translation fault occurs, HPFAR register contains incorrect IPA. We can say it is incorrect because using hardware AT instruction or software lookup, we can obtain the correct IPA from the same VA. This can suggest that the problem is related to QEMU fault handling.

Quoted 6 lines
Quoted 5 lines

Instead of removing the PCI node the follow-up commit will disable highmem option in qemu which will cause placing ECAM space in the 32-bit space.

Quoted 2 lines

Also tested on kirkstone and dom0 boots fine and pci is working.

Thanks for this

Christopher

Quoted 62 lines

Thanks a lot
Cheers
Bertrand

Quoted 56 lines

---
classes/qemuboot-xen-dtb.bbclass | 22 ----------------------

1 file changed, 22 deletions(-)
classes/qemuboot-xen-dtb.bbclass +0 -0
index 1f17a86..d43d23a 100644
@@ -63,21 +63,6 @@ write_lops_xen_section() {

EOF
}

classes/qemuboot-xen-dtb.bbclass +0 -15
-write_lop_rm_pci() {
-    cat <<EOF >"$1"
-/dts-v1/;
-/ {
-    compatible = "system-device-tree-v1";
-    lops {
-        lop_1 {
-            compatible = "system-device-tree-v1,lop,modify";
-            modify = "/pcie@10000000::";
-        };
-     };
-};
-EOF
-}
-
write_lop_add_to_xen_cmdline() {
    EXTRA_XEN_BOOTARGS="$2"
    cat <<EOF >"$1"
classes/qemuboot-xen-dtb.bbclass +0 -8
@@ -150,13 +135,6 @@ generate_xen_qemuboot_dtb() {
    write_lop_add_to_xen_cmdline "${B}/lop-xen-cmdline.dts" \
        "${QB_XEN_CMDLINE_EXTRA}"
 
-    # On Qemu Arm32, Dom0 accessing PCI config space ends up in an
-    # infinite loop. Remove pci node from the device tree
-    if [ "${MACHINE}" = "qemuarm" ]; then
-        write_lop_rm_pci "${B}/lop-rm-pci.dts"
-        LOP_MODULE_ARGS="${LOP_MODULE_ARGS} -i ${B}/lop-rm-pci.dts"
-    fi
-
    if [ -z "${QB_XEN_DOMAIN_MODULES}" ]; then
        bbwarn "No domain modules: please set QB_XEN_DOMAIN_MODULES"
    fi
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7351): https://lists.yoctoproject.org/g/meta-virtualization/message/7351
Mute This Topic: https://lists.yoctoproject.org/mt/91642063/3619089
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

PATCH 2/2 xen: Disable highmem on qemuarm

In reply to Michal Orzel

By default, highmem option is enabled for machine types later than virt-2.12. This allows qemu to place devices and RAM in physical address space above 32-bits. This can cause issues as according to the documentation Xen supports up to 12GiB of physical address space. Recently the issue was observed using runqemu, that was causing Linux running on top of Xen to stall when trying to access ECAM space placed by qemu at 256GiB mark. Even though this issue is most probably related to QEMU and not Xen (the investigation showed that it can map ECAM space correctly), it is best to avoid such issues by disabling highmem on qemuarm.

---
 classes/qemuboot-xen-defaults.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
classes/qemuboot-xen-defaults.bbclass +4 -2
index f1550cc..460cbe6 100644
@@ -23,8 +23,10 @@ QB_DEFAULT_KERNEL:qemuarm = "xen-${MACHINE}"
 
 # 64-bit Arm: gic version 3
 QB_MACHINE:qemuarm64 = "-machine virt,gic-version=3 -machine virtualization=true"
-# 32-bit Arm
-QB_MACHINE:qemuarm = "-machine virt -machine virtualization=true"
+# 32-bit Arm: highmem=off
+# Disable highmem so that qemu does not use highmem IO regions that end up
+# being placed at the 256GiB mark (e.g. ECAM space) and can cause issues in Xen.
+QB_MACHINE:qemuarm = "-machine virt,highmem=off -machine virtualization=true"
 
 # Increase the default qemu memory allocation to allow for the hypervisor.
 # Use a weak assignment to allow for change of default and override elsewhere.
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [meta-virtualization] [PATCH 2/2] xen: Disable highmem on qemuarm

Hi Michal,

Quoted 13 lines · Michal Orzel via lists.yoctoproject.org

By default, highmem option is enabled for machine types later than virt-2.12. This allows qemu to place devices and RAM in physical address space above 32-bits. This can cause issues as according to the documentation Xen supports up to 12GiB of physical address space. Recently the issue was observed using runqemu, that was causing Linux running on top of Xen to stall when trying to access ECAM space placed by qemu at 256GiB mark. Even though this issue is most probably related to QEMU and not Xen (the investigation showed that it can map ECAM space correctly), it is best to avoid such issues by disabling highmem on qemuarm.

Quoted 1 line

Also tested on kirkstone and dom0 boots fine and pci is working.

Thanks a lot
Cheers
Bertrand

Quoted 33 lines

---
classes/qemuboot-xen-defaults.bbclass | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
classes/qemuboot-xen-defaults.bbclass +0 -0
index f1550cc..460cbe6 100644
@@ -23,8 +23,10 @@ QB_DEFAULT_KERNEL:qemuarm = "xen-${MACHINE}"
 
 # 64-bit Arm: gic version 3

QB_MACHINE:qemuarm64 = "-machine virt,gic-version=3 -machine virtualization=true"

classes/qemuboot-xen-defaults.bbclass +4 -2
-# 32-bit Arm
-QB_MACHINE:qemuarm = "-machine virt -machine virtualization=true"
+# 32-bit Arm: highmem=off
+# Disable highmem so that qemu does not use highmem IO regions that end up
+# being placed at the 256GiB mark (e.g. ECAM space) and can cause issues in Xen.
+QB_MACHINE:qemuarm = "-machine virt,highmem=off -machine virtualization=true"

# Increase the default qemu memory allocation to allow for the hypervisor. # Use a weak assignment to allow for change of default and override elsewhere.

Signature · 10 lines
2.25.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7352): https://lists.yoctoproject.org/g/meta-virtualization/message/7352
Mute This Topic: https://lists.yoctoproject.org/mt/91642064/3619089
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by
#6 lore raw

Re: [meta-virtualization] [PATCH 2/2] xen: Disable highmem on qemuarm

Quoted 16 lines · Bertrand Marquis

Hi Michal,

Quoted 13 lines · Michal Orzel via lists.yoctoproject.org

By default, highmem option is enabled for machine types later than virt-2.12. This allows qemu to place devices and RAM in physical address space above 32-bits. This can cause issues as according to the documentation Xen supports up to 12GiB of physical address space. Recently the issue was observed using runqemu, that was causing Linux running on top of Xen to stall when trying to access ECAM space placed by qemu at 256GiB mark. Even though this issue is most probably related to QEMU and not Xen (the investigation showed that it can map ECAM space correctly), it is best to avoid such issues by disabling highmem on qemuarm.

Quoted 2 lines
Quoted 1 line
Quoted 2 lines

Also tested on kirkstone and dom0 boots fine and pci is working.

Thanks,

Christopher

Quoted 39 lines

Thanks a lot
Cheers
Bertrand

Quoted 33 lines

---
classes/qemuboot-xen-defaults.bbclass | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
classes/qemuboot-xen-defaults.bbclass +0 -0
index f1550cc..460cbe6 100644
@@ -23,8 +23,10 @@ QB_DEFAULT_KERNEL:qemuarm = "xen-${MACHINE}"
 
 # 64-bit Arm: gic version 3

QB_MACHINE:qemuarm64 = "-machine virt,gic-version=3 -machine virtualization=true"

classes/qemuboot-xen-defaults.bbclass +4 -2
-# 32-bit Arm
-QB_MACHINE:qemuarm = "-machine virt -machine virtualization=true"
+# 32-bit Arm: highmem=off
+# Disable highmem so that qemu does not use highmem IO regions that end up
+# being placed at the 256GiB mark (e.g. ECAM space) and can cause issues in Xen.
+QB_MACHINE:qemuarm = "-machine virt,highmem=off -machine virtualization=true"

# Increase the default qemu memory allocation to allow for the hypervisor. # Use a weak assignment to allow for change of default and override elsewhere. --
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7352): https://lists.yoctoproject.org/g/meta-virtualization/message/7352
Mute This Topic: https://lists.yoctoproject.org/mt/91642064/3619089
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw
In reply to Michal Orzel

I was waiting to hear from Christopher on this one, so I'll let it soak a few more days before staging.

Bruce

Quoted 17 lines · Michal Orzel

This series acts as a follow-up to the commit:
fb0a7b97db4f ("xen: Disable PCI on qemuarm with Xen")

This wants to be backported to kirkstone.

Michal Orzel (2):
Revert "xen: Disable PCI on qemuarm with Xen"
xen: Disable highmem on qemuarm

 classes/qemuboot-xen-defaults.bbclass |  6 ++++--
 classes/qemuboot-xen-dtb.bbclass      | 22 ----------------------
 2 files changed, 4 insertions(+), 24 deletions(-)

--
2.25.1

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#8 lore raw
Quoted 12 lines · Bruce Ashfield

I was waiting to hear from Christopher on this one, so I'll let it soak a few more days before staging.

Bruce

Quoted 5 lines · Michal Orzel

This series acts as a follow-up to the commit:
fb0a7b97db4f ("xen: Disable PCI on qemuarm with Xen")

This wants to be backported to kirkstone.

Thanks for these patches and for working out what was needed for the fix, Michal.

Apologies for the slow review - am catching up now after a few days down with an injury (should be ok).

Christopher

Quoted 18 lines
Quoted 5 lines

Michal Orzel (2):
Revert "xen: Disable PCI on qemuarm with Xen"
xen: Disable highmem on qemuarm

Quoted 7 lines
 classes/qemuboot-xen-defaults.bbclass |  6 ++++--
 classes/qemuboot-xen-dtb.bbclass      | 22 ----------------------
 2 files changed, 4 insertions(+), 24 deletions(-)

--
2.25.1

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

#9 lore raw

Hi,

Quoted 15 lines · Christopher Clark via lists.yoctoproject.org
Quoted 11 lines · Bruce Ashfield

I was waiting to hear from Christopher on this one, so I'll let it soak a few more days before staging.

Bruce

Quoted 4 lines · Michal Orzel

This series acts as a follow-up to the commit:
fb0a7b97db4f ("xen: Disable PCI on qemuarm with Xen")

Quoted 7 lines
Quoted 1 line
Quoted 1 line

This wants to be backported to kirkstone.

Thanks for these patches and for working out what was needed for the fix, Michal.

Apologies for the slow review - am catching up now after a few days down with an injury (should be ok).

I would also suggest to push this to kirkstone branch.

Cheers
Bertrand

Quoted 30 lines

Christopher

Quoted 14 lines
Quoted 5 lines

Michal Orzel (2):
Revert "xen: Disable PCI on qemuarm with Xen"
xen: Disable highmem on qemuarm

Quoted 7 lines

classes/qemuboot-xen-defaults.bbclass | 6 ++++-- classes/qemuboot-xen-dtb.bbclass | 22 ----------------------

2 files changed, 4 insertions(+), 24 deletions(-)

--
2.25.1

Quoted 4 lines

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7389): https://lists.yoctoproject.org/g/meta-virtualization/message/7389
Mute This Topic: https://lists.yoctoproject.org/mt/91642062/3619089
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-