[PATCH] aarch64 trace: make compiler pick a register instead of x0

5 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Aug 28, 2022, 6:36:37 PM8/28/22
to osv...@googlegroups.com, Waldemar Kozaczuk
This subtle 1-character patch fixes a nasty bug that causes interrupts
to be enabled instead of correctly restored to the state it was when
saving the state. This bug would affect the tracing logic and result in
crashes described by the issues #1158 and #1195.

This bug in inline assembly was most likely a typo as I am sure
the intention was to use '%0' instead of 'x0' to let compiler
correctly pick a register instead of using any garbage in the x0
register.

Fixes #1158
Fixes #1195

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
arch/aarch64/arch.hh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/aarch64/arch.hh b/arch/aarch64/arch.hh
index c07e9999..abee0984 100644
--- a/arch/aarch64/arch.hh
+++ b/arch/aarch64/arch.hh
@@ -79,7 +79,7 @@ inline void irq_flag_notrace::save() {
}

inline void irq_flag_notrace::restore() {
- asm volatile("msr daif, x0" :: "r"(daif) : "memory");
+ asm volatile("msr daif, %0" :: "r"(daif) : "memory");
}

inline bool irq_flag_notrace::enabled() const {
--
2.34.1

Commit Bot

unread,
Aug 30, 2022, 11:59:28 AM8/30/22
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

aarch64 trace: make compiler pick a register instead of x0

This subtle 1-character patch fixes a nasty bug that causes interrupts
to be enabled instead of correctly restored to the state it was when
saving the state. This bug would affect the tracing logic and result in
crashes described by the issues #1158 and #1195.

This bug in inline assembly was most likely a typo as I am sure
the intention was to use '%0' instead of 'x0' to let compiler
correctly pick a register instead of using any garbage in the x0
register.

Fixes #1158
Fixes #1195

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/arch/aarch64/arch.hh b/arch/aarch64/arch.hh

Nadav Har'El

unread,
Aug 30, 2022, 12:14:39 PM8/30/22
to Waldemar Kozaczuk, Osv Dev
What a difference one character makes :-)

--
Nadav Har'El
n...@scylladb.com


--
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000fa038905e77776fc%40google.com.
Reply all
Reply to author
Forward
0 new messages