All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/arm64: Zero the top 32 bits of gp registers on entry...
@ 2021-12-06 14:20 Michal Orzel
  2021-12-06 14:45 ` Jan Beulich
  2021-12-06 15:29 ` Julien Grall
  0 siblings, 2 replies; 26+ messages in thread
From: Michal Orzel @ 2021-12-06 14:20 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Julien Grall, Volodymyr Babchuk, Bertrand Marquis

to hypervisor when switching to AArch32 state.

According to section D1.20.2 of Arm Arm(DDI 0487A.j):
"If the general-purpose register was accessible from AArch32 state the
upper 32 bits either become zero, or hold the value that the same
architectural register held before any AArch32 execution.
The choice between these two options is IMPLEMENTATIONDEFINED"

Currently Xen does not ensure that the top 32 bits are zeroed and this
needs to be fixed.

Fix this bug by zeroing the upper 32 bits of these registers on an
entry to hypervisor when switching to AArch32 state.

Set default value of parameter compat of macro entry to 0 (AArch64 mode
as we are on 64-bit hypervisor) to avoid checking if parameter is blank
when not passed.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
---
 xen/arch/arm/arm64/entry.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S
index fc3811ad0a..d364128175 100644
--- a/xen/arch/arm/arm64/entry.S
+++ b/xen/arch/arm/arm64/entry.S
@@ -109,8 +109,16 @@
  * If 0, we rely on the on x0/x1 to have been saved at the correct
  * position on the stack before.
  */
-        .macro  entry, hyp, compat, save_x0_x1=1
+        .macro  entry, hyp, compat=0, save_x0_x1=1
         sub     sp, sp, #(UREGS_SPSR_el1 - UREGS_LR) /* CPSR, PC, SP, LR */
+
+        /* Zero the upper 32 bits of the registers when switching to AArch32 */
+        .if \compat == 1      /* AArch32 mode */
+        .irp nr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29
+        mov w\nr, w\nr
+        .endr
+        .endif
+
         push    x28, x29
         push    x26, x27
         push    x24, x25
-- 
2.29.0



^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-12-16  7:15 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 14:20 [PATCH] xen/arm64: Zero the top 32 bits of gp registers on entry Michal Orzel
2021-12-06 14:45 ` Jan Beulich
2021-12-06 15:29 ` Julien Grall
2021-12-07  8:37   ` Michal Orzel
2021-12-07  9:05     ` Bertrand Marquis
2021-12-07  9:55     ` Jan Beulich
2021-12-07 19:25       ` Julien Grall
2021-12-07 19:11     ` Julien Grall
2021-12-08  7:20       ` Jan Beulich
2021-12-08  9:55         ` Julien Grall
2021-12-08 10:18           ` Jan Beulich
2021-12-14  9:17           ` Michal Orzel
2021-12-14  9:33             ` Julien Grall
2021-12-14  9:51               ` Michal Orzel
2021-12-14 10:01                 ` Jan Beulich
2021-12-14 10:10                   ` Michal Orzel
2021-12-14 11:01                   ` Julien Grall
2021-12-14 11:30                     ` Julien Grall
2021-12-15  9:27                       ` Michal Orzel
2021-12-15  9:35                         ` Jan Beulich
2021-12-15  9:48                           ` Michal Orzel
2021-12-15 10:32                             ` Jan Beulich
2021-12-15 10:40                               ` Michal Orzel
2021-12-15 18:25                                 ` Julien Grall
2021-12-16  7:14                                   ` Michal Orzel
2021-12-15 18:20                           ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.