Not a direct answer to your question, but the Linux port gets around
this by storing the hart id in the thread_info struct, which it always
knows how to get to from the stack pointer. So it only ever needs to
execute the SBI call on boot.
Il 19/nov/2016 19:07, "Stefan O'Rear" <sor...@gmail.com> ha scritto:
>
> On Wed, Nov 16, 2016 at 1:57 PM, ron minnich <rmin...@gmail.com> wrote:
> > on many CPUs getting a core id involves reading a register. riscv envisions,
> > as I understand it, an SBI call.
>
> Thinking about this for a bit I think the solution is more subtle than
> that. Generally speaking you don't want a hart id for its own sake.
> You want a hart id in order to locate per-hart data structures, which
> means you want a pointer which can be set per-hart, and the ABI
> already reserves a GPR for exactly that purpose: x4/tp. S-mode trap
> entry code will use sscratch, directly or indirectly, to set tp, and
> U-mode code gets tp set from above by context switches.
U-mode would use tp for per-thread data structures, not per-hart. I suppose that the OS, if it desired to provide a fast access to the hartid, could place it on migration at a well-known offset from tp, but this additional complication may be a side effect with security implications.
> You only actually need the hartid once when setting up the per-hart
> struct, so my proposal is:
>
> Eliminate sbi_hart_id and add a hart_id parameter to the S-mode entry point.
Speaking of which, what does the spec say of SMP bring-up?
Paolo
> ("shartid" is a bad idea _because_ it is state that would require
> hypervisor context switching that is effectively redundant with
> sscratch+tp)
>
> -s
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
> To post to this group, send email to isa...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CADJ6UvOdr_U6-6jJ_fFd7asR_XWG1E_rtg3dLoFqVUYpofV3Hw%40mail.gmail.com.
I think only a bootstrap hart should start executing the kernel. There should be an SBI service to stop execution of the current processor, and one to start execution of a stopped processor from another. A stopped processor stays in M- or H-mode until woken up.
The set of hart ids at startup should be sent through the configuration string/device tree. If hotplug is ever going to be supported, one would need an event mechanism as part of the SEE, but that is way in the future.
Paolo
> -s
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
> To post to this group, send email to isa...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CADJ6UvOWjSUBk5wt%3DfeG_Yd2vG95hm2GEkSNvoi3TujDne_akQ%40mail.gmail.com.