Skip to contentSkip to conversation

automation: Modify static-mem check in qemu-smoke-dom0less-arm64.sh

PATCH In review Michal Orzel 4 participants 4 messages Jan 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 automation: Modify static-mem check in qemu-smoke-dom0less-arm64.sh

At the moment, the static-mem check relies on the way Xen exposes the memory banks in device tree. As this might change, the check should be modified to be generic and not to rely on device tree. In this case, let's use /proc/iomem which exposes the memory ranges in %08x format as follows:
<start_addr>-<end_addr> : <description>

This way, we can grep in /proc/iomem for an entry containing memory region defined by the static-mem configuration with "System RAM" description. If it exists, mark the test as passed. Also, take the opportunity to add 0x prefix to domu_{base,size} definition rather than adding it in front of each occurence.

---
Patch made as part of the discussion:
https://lore.kernel.org/xen-devel/[email protected]/

CC Julien, Ayan
---
 automation/scripts/qemu-smoke-dom0less-arm64.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +6 -7
index 2b59346fdcfd..182a4b6c18fc 100755
@@ -16,14 +16,13 @@ fi
 
 if [[ "${test_variant}" == "static-mem" ]]; then
     # Memory range that is statically allocated to DOM1
-    domu_base="50000000"
-    domu_size="10000000"
+    domu_base="0x50000000"
+    domu_size="0x10000000"
     passed="${test_variant} test passed"
     domU_check="
-current=\$(hexdump -e '16/1 \"%02x\"' /proc/device-tree/memory@${domu_base}/reg 2>/dev/null)
-expected=$(printf \"%016x%016x\" 0x${domu_base} 0x${domu_size})
-if [[ \"\${expected}\" == \"\${current}\" ]]; then
-	echo \"${passed}\"
+mem_range=$(printf \"%08x-%08x\" ${domu_base} $(( ${domu_base} + ${domu_size} - 1 )))
+if grep -q -x \"\${mem_range} : System RAM\" /proc/iomem; then
+    echo \"${passed}\"
 fi
 "
 fi
@@ -126,7 +125,7 @@ UBOOT_SOURCE="boot.source"
 UBOOT_SCRIPT="boot.scr"' > binaries/config
 
 if [[ "${test_variant}" == "static-mem" ]]; then
-    echo -e "\nDOMU_STATIC_MEM[0]=\"0x${domu_base} 0x${domu_size}\"" >> binaries/config
+    echo -e "\nDOMU_STATIC_MEM[0]=\"${domu_base} ${domu_size}\"" >> binaries/config
 fi
 
 if [[ "${test_variant}" == "boot-cpupools" ]]; then
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Michal Orzel

At the moment, the static-mem check relies on the way Xen exposes the memory banks in device tree. As this might change, the check should be modified to be generic and not to rely on device tree. In this case, let's use /proc/iomem which exposes the memory ranges in %08x format as follows:
<start_addr>-<end_addr> : <description>

Quoted 7 lines

This way, we can grep in /proc/iomem for an entry containing memory region defined by the static-mem configuration with "System RAM" description. If it exists, mark the test as passed. Also, take the opportunity to add 0x prefix to domu_{base,size} definition rather than adding it in front of each occurence.

Also you fixed the hard tab.

Quoted 42 lines

---
Patch made as part of the discussion:
https://lore.kernel.org/xen-devel/[email protected]/

CC Julien, Ayan
---
  automation/scripts/qemu-smoke-dom0less-arm64.sh | 13 ++++++-------
  1 file changed, 6 insertions(+), 7 deletions(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +6 -7
index 2b59346fdcfd..182a4b6c18fc 100755
@@ -16,14 +16,13 @@ fi
 
  if [[ "${test_variant}" == "static-mem" ]]; then
      # Memory range that is statically allocated to DOM1
-    domu_base="50000000"
-    domu_size="10000000"
+    domu_base="0x50000000"
+    domu_size="0x10000000"
      passed="${test_variant} test passed"
      domU_check="
-current=\$(hexdump -e '16/1 \"%02x\"' /proc/device-tree/memory@${domu_base}/reg 2>/dev/null)
-expected=$(printf \"%016x%016x\" 0x${domu_base} 0x${domu_size})
-if [[ \"\${expected}\" == \"\${current}\" ]]; then
-	echo \"${passed}\"
+mem_range=$(printf \"%08x-%08x\" ${domu_base} $(( ${domu_base} + ${domu_size} - 1 )))
+if grep -q -x \"\${mem_range} : System RAM\" /proc/iomem; then
+    echo \"${passed}\"
  fi
  "
  fi
@@ -126,7 +125,7 @@ UBOOT_SOURCE="boot.source"
  UBOOT_SCRIPT="boot.scr"' > binaries/config
 
  if [[ "${test_variant}" == "static-mem" ]]; then
-    echo -e "\nDOMU_STATIC_MEM[0]=\"0x${domu_base} 0x${domu_size}\"" >> binaries/config
+    echo -e "\nDOMU_STATIC_MEM[0]=\"${domu_base} ${domu_size}\"" >> binaries/config
  fi
 
  if [[ "${test_variant}" == "boot-cpupools" ]]; then
Signature · 1 line
Xenia
Reviewed-by
#2 lore raw
Quoted 15 lines · Xenia Ragiadakou
Quoted 13 lines · Michal Orzel

At the moment, the static-mem check relies on the way Xen exposes the memory banks in device tree. As this might change, the check should be modified to be generic and not to rely on device tree. In this case, let's use /proc/iomem which exposes the memory ranges in %08x format as follows:
<start_addr>-<end_addr> : <description>

This way, we can grep in /proc/iomem for an entry containing memory region defined by the static-mem configuration with "System RAM" description. If it exists, mark the test as passed. Also, take the opportunity to add 0x prefix to domu_{base,size} definition rather than adding it in front of each occurence.

Quoted 3 lines
Quoted 1 line
Quoted 48 lines

Also you fixed the hard tab.

Quoted 44 lines

---
Patch made as part of the discussion:
https://lore.kernel.org/xen-devel/[email protected]/

CC Julien, Ayan

---
  automation/scripts/qemu-smoke-dom0less-arm64.sh | 13 ++++++-------

  1 file changed, 6 insertions(+), 7 deletions(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +0 -0
index 2b59346fdcfd..182a4b6c18fc 100755
@@ -16,14 +16,13 @@ fi

    if [[ "${test_variant}" == "static-mem" ]]; then # Memory range that is statically allocated to DOM1 -    domu_base="50000000"
-    domu_size="10000000"
+    domu_base="0x50000000"
+    domu_size="0x10000000" passed="${test_variant} test passed" domU_check="
-current=\$(hexdump -e '16/1 \"%02x\"' /proc/device-tree/memory@${domu_base}/reg 2>/dev/null)

automation/scripts/qemu-smoke-dom0less-arm64.sh +1 -3
-expected=$(printf \"%016x%016x\" 0x${domu_base} 0x${domu_size})
-if [[ \"\${expected}\" == \"\${current}\" ]]; then
-    echo \"${passed}\"
+mem_range=$(printf \"%08x-%08x\" ${domu_base} $(( ${domu_base} + 

${domu_size} - 1 )))
+if grep -q -x \"\${mem_range} : System RAM\" /proc/iomem; then +    echo \"${passed}\"
  fi
  "
  fi

automation/scripts/qemu-smoke-dom0less-arm64.sh +0 -0
@@ -126,7 +125,7 @@ UBOOT_SOURCE="boot.source"

  UBOOT_SCRIPT="boot.scr"' > binaries/config
    if [[ "${test_variant}" == "static-mem" ]]; then
-    echo -e "\nDOMU_STATIC_MEM[0]=\"0x${domu_base} 0x${domu_size}\""

Quoted 1 line
Quoted 1 line

binaries/config

+    echo -e "\nDOMU_STATIC_MEM[0]=\"${domu_base} ${domu_size}\"" >> binaries/config
  fi
    if [[ "${test_variant}" == "boot-cpupools" ]]; then

Acked-by on v1 1/1
#3 lore raw
In reply to Michal Orzel
Quoted 7 lines · Michal Orzel

At the moment, the static-mem check relies on the way Xen exposes the memory banks in device tree. As this might change, the check should be modified to be generic and not to rely on device tree. In this case, let's use /proc/iomem which exposes the memory ranges in %08x format as follows:
<start_addr>-<end_addr> : <description>

Quoted 7 lines

This way, we can grep in /proc/iomem for an entry containing memory region defined by the static-mem configuration with "System RAM" description. If it exists, mark the test as passed. Also, take the opportunity to add 0x prefix to domu_{base,size} definition rather than adding it in front of each occurence.

Quoted 45 lines

---
Patch made as part of the discussion:
https://lore.kernel.org/xen-devel/[email protected]/

CC Julien, Ayan
---
 automation/scripts/qemu-smoke-dom0less-arm64.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
automation/scripts/qemu-smoke-dom0less-arm64.sh +6 -7
index 2b59346fdcfd..182a4b6c18fc 100755
@@ -16,14 +16,13 @@ fi
 
 if [[ "${test_variant}" == "static-mem" ]]; then
     # Memory range that is statically allocated to DOM1
-    domu_base="50000000"
-    domu_size="10000000"
+    domu_base="0x50000000"
+    domu_size="0x10000000"
     passed="${test_variant} test passed"
     domU_check="
-current=\$(hexdump -e '16/1 \"%02x\"' /proc/device-tree/memory@${domu_base}/reg 2>/dev/null)
-expected=$(printf \"%016x%016x\" 0x${domu_base} 0x${domu_size})
-if [[ \"\${expected}\" == \"\${current}\" ]]; then
-	echo \"${passed}\"
+mem_range=$(printf \"%08x-%08x\" ${domu_base} $(( ${domu_base} + ${domu_size} - 1 )))
+if grep -q -x \"\${mem_range} : System RAM\" /proc/iomem; then
+    echo \"${passed}\"
 fi
 "
 fi
@@ -126,7 +125,7 @@ UBOOT_SOURCE="boot.source"
 UBOOT_SCRIPT="boot.scr"' > binaries/config
 
 if [[ "${test_variant}" == "static-mem" ]]; then
-    echo -e "\nDOMU_STATIC_MEM[0]=\"0x${domu_base} 0x${domu_size}\"" >> binaries/config
+    echo -e "\nDOMU_STATIC_MEM[0]=\"${domu_base} ${domu_size}\"" >> binaries/config
 fi
 
 if [[ "${test_variant}" == "boot-cpupools" ]]; then
Signature · 1 line
2.25.1