From: Andrew Jones <andrew.jones@linux.dev>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Cc: atishp@rivosinc.com, jamestiotio@gmail.com
Subject: [kvm-unit-tests PATCH 3/4] riscv: Fix secondary_entry
Date: Wed, 23 Oct 2024 15:21:34 +0200 [thread overview]
Message-ID: <20241023132130.118073-9-andrew.jones@linux.dev> (raw)
In-Reply-To: <20241023132130.118073-6-andrew.jones@linux.dev>
The last few instructions of secondary_entry had the right concept,
but were the totally wrong implementation. Without setting ra, then,
when the boot function doesn't stay in an infinite loop, like
do_idle() would, we'd go off into the weeds when trying to return
from it. Make sure we set ra to come back to where we can then call
do_idle() instead. The bug was found by inspection since nobody is
calling smp_boot_secondary() with anything other than do_idle() at
this time.
Fixes: 9c92b28e6b7b ("riscv: Add SMP support")
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
riscv/cstart.S | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/riscv/cstart.S b/riscv/cstart.S
index bae1d2f5b4d5..687173706d83 100644
--- a/riscv/cstart.S
+++ b/riscv/cstart.S
@@ -154,9 +154,9 @@ secondary_entry:
mv a0, sp
call secondary_cinit
addi sp, sp, SECONDARY_DATA_SIZE
- jr a0
- la a0, do_idle
- jr a0
+ jalr ra, a0
+ call do_idle
+ j . /* unreachable */
/*
* Save context to address in a0.
--
2.47.0
next prev parent reply other threads:[~2024-10-23 13:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 13:21 [kvm-unit-tests PATCH 0/4] riscv: A few SMP fixes Andrew Jones
2024-10-23 13:21 ` [kvm-unit-tests PATCH 1/4] riscv: Bump NR_CPUS to 256 Andrew Jones
2024-10-23 13:21 ` [kvm-unit-tests PATCH 2/4] riscv: Filter unmanaged harts from present mask Andrew Jones
2024-10-23 13:21 ` Andrew Jones [this message]
2024-10-23 13:21 ` [kvm-unit-tests PATCH 4/4] riscv: Rework smp_boot_secondary Andrew Jones
2024-11-11 14:37 ` [kvm-unit-tests PATCH 0/4] riscv: A few SMP fixes Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241023132130.118073-9-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=atishp@rivosinc.com \
--cc=jamestiotio@gmail.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox