Re: [PULL 15/32] tests/functional/aarch64: add tests for FEAT_RME

2025-01-25 Thread Alex Bennée
Pierrick Bouvier  writes:

> Hi Thomas,
>
> On 1/24/25 05:29, Thomas Huth wrote:
>> On 10/01/2025 14.17, Alex Bennée wrote:
>>> From: Pierrick Bouvier 
>>>
>>> This boot an OP-TEE environment, and launch a nested guest VM inside it
>>> using the Realms feature. We do it for virt and sbsa-ref platforms.
>>Hi,
>> FWIW, I just saw this test_aarch64_rme_virt test failing once.
>> Looking at
>> the console.log, it seems like the guest crashed somewhere at the end of the
>> firmware or very early in the kernel:
>> EFI stub: Booting Linux Kernel...
>> 2025-01-24 13:25:28,226:
>> 2025-01-24 13:25:28,226:
>> 2025-01-24 13:25:28,227: Synchronous Exception at 0xBF526498
>> 2025-01-24 13:25:28,227:
>> 2025-01-24 13:25:28,227:
>> 2025-01-24 13:25:28,228: Synchronous Exception at 0xBF526498
>> I wasn't able to reproduce it afterwards anymore, but in case
>> somebody runs
>> into this later again and wonders if it is a later regression: It happened
>> for me with commit cf86770c7aa31ebd.
>>Thomas
>> 
>
> I met this kind of error before (not on rme), and if I remember well,
> it's coming from EDK2.
>
> We might have a race condition here.

I'm measuring a 1-3% hit rates:

  retry.py -n 400 -c -- ./pyvenv/bin/meson test --setup thorough --suite 
func-thorough func-aarch64-aarch64_rme_virt func-aarch64-aarch64_rme_sbsaref -v

Gave:

  Results summary:
  0: 388 times (97.00%), avg time 196.924 (7.99 varience/2.83 deviation)
  1: 12 times (3.00%), avg time 1205.900 (0.00 varience/0.01 deviation)
  Ran command 400 times, 388 passes

It might be worth trying it under rr --chaos mode and seeing if that
shakes anything out.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro



Re: [PULL 15/32] tests/functional/aarch64: add tests for FEAT_RME

2025-01-24 Thread Pierrick Bouvier

Hi Thomas,

On 1/24/25 05:29, Thomas Huth wrote:

On 10/01/2025 14.17, Alex Bennée wrote:

From: Pierrick Bouvier 

This boot an OP-TEE environment, and launch a nested guest VM inside it
using the Realms feature. We do it for virt and sbsa-ref platforms.


   Hi,

FWIW, I just saw this test_aarch64_rme_virt test failing once. Looking at
the console.log, it seems like the guest crashed somewhere at the end of the
firmware or very early in the kernel:

EFI stub: Booting Linux Kernel...
2025-01-24 13:25:28,226:
2025-01-24 13:25:28,226:
2025-01-24 13:25:28,227: Synchronous Exception at 0xBF526498
2025-01-24 13:25:28,227:
2025-01-24 13:25:28,227:
2025-01-24 13:25:28,228: Synchronous Exception at 0xBF526498

I wasn't able to reproduce it afterwards anymore, but in case somebody runs
into this later again and wonders if it is a later regression: It happened
for me with commit cf86770c7aa31ebd.

   Thomas



I met this kind of error before (not on rme), and if I remember well, 
it's coming from EDK2.


We might have a race condition here.


Re: [PULL 15/32] tests/functional/aarch64: add tests for FEAT_RME

2025-01-24 Thread Thomas Huth

On 10/01/2025 14.17, Alex Bennée wrote:

From: Pierrick Bouvier 

This boot an OP-TEE environment, and launch a nested guest VM inside it
using the Realms feature. We do it for virt and sbsa-ref platforms.


 Hi,

FWIW, I just saw this test_aarch64_rme_virt test failing once. Looking at 
the console.log, it seems like the guest crashed somewhere at the end of the 
firmware or very early in the kernel:


EFI stub: Booting Linux Kernel...
2025-01-24 13:25:28,226:
2025-01-24 13:25:28,226:
2025-01-24 13:25:28,227: Synchronous Exception at 0xBF526498
2025-01-24 13:25:28,227:
2025-01-24 13:25:28,227:
2025-01-24 13:25:28,228: Synchronous Exception at 0xBF526498

I wasn't able to reproduce it afterwards anymore, but in case somebody runs 
into this later again and wonders if it is a later regression: It happened 
for me with commit cf86770c7aa31ebd.


 Thomas




[PULL 15/32] tests/functional/aarch64: add tests for FEAT_RME

2025-01-10 Thread Alex Bennée
From: Pierrick Bouvier 

This boot an OP-TEE environment, and launch a nested guest VM inside it
using the Realms feature. We do it for virt and sbsa-ref platforms.

Signed-off-by: Pierrick Bouvier 
Message-Id: <[email protected]>
[AJB: tweak ordering of setup, strip changelog from commit]
Signed-off-by: Alex Bennée 
Tested-by: Thomas Huth 
Message-Id: <[email protected]>

diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 7890dcb86d..bd3d903cfc 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -13,6 +13,8 @@ endif
 test_timeouts = {
   'aarch64_aspeed' : 600,
   'aarch64_raspi4' : 480,
+  'aarch64_rme_virt' : 1200,
+  'aarch64_rme_sbsaref' : 1200,
   'aarch64_sbsaref_alpine' : 720,
   'aarch64_sbsaref_freebsd' : 720,
   'aarch64_tuxrun' : 240,
@@ -60,6 +62,8 @@ tests_aarch64_system_thorough = [
   'aarch64_aspeed',
   'aarch64_raspi3',
   'aarch64_raspi4',
+  'aarch64_rme_virt',
+  'aarch64_rme_sbsaref',
   'aarch64_sbsaref',
   'aarch64_sbsaref_alpine',
   'aarch64_sbsaref_freebsd',
diff --git a/tests/functional/test_aarch64_rme_sbsaref.py 
b/tests/functional/test_aarch64_rme_sbsaref.py
new file mode 100755
index 00..93bb528338
--- /dev/null
+++ b/tests/functional/test_aarch64_rme_sbsaref.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Realms environment on sbsa-ref machine and a
+# nested guest VM using it.
+#
+# Copyright (c) 2024 Linaro Ltd.
+#
+# Author: Pierrick Bouvier 
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import time
+import os
+import logging
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command, wait_for_console_pattern
+from qemu_test import exec_command_and_wait_for_pattern
+from test_aarch64_rme_virt import test_realms_guest
+
+class Aarch64RMESbsaRefMachine(QemuSystemTest):
+
+# Stack is built with OP-TEE build environment from those instructions:
+# https://linaro.atlassian.net/wiki/spaces/QEMU/pages/29051027459/
+# https://github.com/pbo-linaro/qemu-rme-stack
+ASSET_RME_STACK_SBSA = Asset(
+('https://fileserver.linaro.org/s/KJyeBxL82mz2r7F/'
+ 'download/rme-stack-op-tee-4.2.0-cca-v4-sbsa.tar.gz'),
+ 'dd9ab28ec869bdf3b5376116cb3689103b43433fd5c4bca0f4a8d8b3c104999e')
+
+# This tests the FEAT_RME cpu implementation, by booting a VM supporting 
it,
+# and launching a nested VM using it.
+def test_aarch64_rme_sbsaref(self):
+self.set_machine('sbsa-ref')
+self.require_accelerator('tcg')
+
+self.vm.set_console()
+
+stack_path_tar_gz = self.ASSET_RME_STACK_SBSA.fetch()
+self.archive_extract(stack_path_tar_gz, format="tar")
+
+rme_stack = self.scratch_file('rme-stack-op-tee-4.2.0-cca-v4-sbsa')
+pflash0 = os.path.join(rme_stack, 'images', 'SBSA_FLASH0.fd')
+pflash1 = os.path.join(rme_stack, 'images', 'SBSA_FLASH1.fd')
+virtual = os.path.join(rme_stack, 'images', 'disks', 'virtual')
+drive = os.path.join(rme_stack, 'out-br', 'images', 'rootfs.ext4')
+
+self.vm.add_args('-cpu', 'max,x-rme=on,pauth-impdef=on')
+self.vm.add_args('-m', '2G')
+self.vm.add_args('-M', 'sbsa-ref')
+self.vm.add_args('-drive', f'file={pflash0},format=raw,if=pflash')
+self.vm.add_args('-drive', f'file={pflash1},format=raw,if=pflash')
+self.vm.add_args('-drive', f'file=fat:rw:{virtual},format=raw')
+self.vm.add_args('-drive', f'format=raw,if=none,file={drive},id=hd0')
+self.vm.add_args('-device', 'virtio-blk-pci,drive=hd0')
+self.vm.add_args('-device', 'virtio-9p-pci,fsdev=shr0,mount_tag=shr0')
+self.vm.add_args('-fsdev', 
f'local,security_model=none,path={rme_stack},id=shr0')
+self.vm.add_args('-device', 'virtio-net-pci,netdev=net0')
+self.vm.add_args('-netdev', 'user,id=net0')
+
+self.vm.launch()
+# Wait for host VM boot to complete.
+wait_for_console_pattern(self, 'Welcome to Buildroot')
+exec_command_and_wait_for_pattern(self, 'root', '#')
+
+test_realms_guest(self)
+
+if __name__ == '__main__':
+QemuSystemTest.main()
diff --git a/tests/functional/test_aarch64_rme_virt.py 
b/tests/functional/test_aarch64_rme_virt.py
new file mode 100755
index 00..42b9229b4c
--- /dev/null
+++ b/tests/functional/test_aarch64_rme_virt.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Realms environment on virt machine and a nested
+# guest VM using it.
+#
+# Copyright (c) 2024 Linaro Ltd.
+#
+# Author: Pierrick Bouvier 
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import time
+import os
+import logging
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command, wait_for_console_pattern
+from qemu_test import exec_command_and_wait_for_pattern
+
+def test_realms_guest(test_rme_instance):
+
+# Boot the (nest