Skip to contentSkip to conversation

xen/arm64: entry: Actually skip do_trap_*() when an SError is triggered

PATCH In review Julien Grall 2 participants 4 messages Aug 6, 2024 – Aug 13, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm64: entry: Actually skip do_trap_*() when an SError is triggered

From: Julien Grall <[email protected]>

For SErrors, we support two configurations:
* Every SErrors will result to a panic in Xen
* We will forward SErrors triggered by a VM back to itself

For the latter case, we want to skip the call to do_trap_*() because the PC was already adjusted.

However, the alternative used to decide between the two configurations is inverted. This would result to the VM corrupting itself if:
* x19 is non-zero in the panic case
* advance PC too much in the second case

Solve the issue by switch from alternative_if to alternative_if_not.

Fixes a458d3bd0d25 ("xen/arm: entry: Ensure the guest state is synced when receiving a vSError")

----

This is a candidate to be backported to all supported tree.

I don't have a setup where I can easily inject SError. But this was tested by setting x19 to 1 just before the first alternative and use "serrors=panic".

Before this patch, Linux would get stuck.

---
 xen/arch/arm/arm64/entry.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/entry.S +1 -1
index 6251135ebdd2..fab10f8a0d26 100644
@@ -259,7 +259,7 @@
          * apart. The easiest way is to duplicate the few instructions
          * that need to be skipped.
          */
-        alternative_if SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
+        alternative_if_not SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT
         cbnz      x19, 1f
         mov       x0, sp
         bl        do_trap_\trap
Signature · 1 line
2.40.1
Acked-by on v1 1/1
#1 lore raw

Hi Julien,

Quoted 16 lines · Julien Grall

From: Julien Grall <[email protected]>

For SErrors, we support two configurations:
* Every SErrors will result to a panic in Xen
* We will forward SErrors triggered by a VM back to itself

For the latter case, we want to skip the call to do_trap_*() because the PC was already adjusted.

However, the alternative used to decide between the two configurations is inverted. This would result to the VM corrupting itself if:
* x19 is non-zero in the panic case
* advance PC too much in the second case

Quoted 4 lines

Solve the issue by switch from alternative_if to alternative_if_not.

Fixes a458d3bd0d25 ("xen/arm: entry: Ensure the guest state is synced when receiving a vSError")
Quoted 2 lines

----

3 instead of 4 dashes

~Michal

#2 lore raw
Quoted 21 lines · Michal Orzel

Hi Julien,

Quoted 18 lines · Julien Grall

From: Julien Grall <[email protected]>

For SErrors, we support two configurations:
* Every SErrors will result to a panic in Xen
* We will forward SErrors triggered by a VM back to itself

For the latter case, we want to skip the call to do_trap_*() because the PC was already adjusted.

However, the alternative used to decide between the two configurations is inverted. This would result to the VM corrupting itself if:
* x19 is non-zero in the panic case
* advance PC too much in the second case

Solve the issue by switch from alternative_if to alternative_if_not.

Quoted 7 lines
Quoted 2 lines
Fixes a458d3bd0d25 ("xen/arm: entry: Ensure the guest state is synced when receiving a vSError")
Quoted 2 lines

----

3 instead of 4 dashes

I will fixed it.

The patchqueue tool I am using will strip anything after "---". So I am using ---- to version changelog... I tend to forget that I need to manually call sed -i 's/^----/---/' *.patch before sending every patch.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw

Hi,

Quoted 29 lines · Julien Grall
Quoted 26 lines · Michal Orzel

Hi Julien,

Quoted 16 lines · Julien Grall

From: Julien Grall <[email protected]>

For SErrors, we support two configurations:
   * Every SErrors will result to a panic in Xen
   * We will forward SErrors triggered by a VM back to itself

For the latter case, we want to skip the call to do_trap_*() because the PC was already adjusted.

However, the alternative used to decide between the two configurations is inverted. This would result to the VM corrupting itself if:
   * x19 is non-zero in the panic case
   * advance PC too much in the second case

Quoted 4 lines

Solve the issue by switch from alternative_if to alternative_if_not.

Fixes a458d3bd0d25 ("xen/arm: entry: Ensure the guest state is synced when receiving a vSError")
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

----

3 instead of 4 dashes

I will fixed it.

The patchqueue tool I am using will strip anything after "---". So I am using ---- to version changelog... I tend to forget that I need to manually call sed -i 's/^----/---/' *.patch before sending every patch.

This is now committed.

Cheers,

Signature · 1 line
Julien Grall