On 2017-05-02 18:08, Ralf Ramsauer wrote:
> Hi,
> 
> is there a way on ARM to find out on which physical CPU I'm currently
> running on?
> 
> I need this information for interrupt routing. (In Jailhouse) GIC's
> ITARGETSR expects physical CPU IDs. Of course I could statically provide
> this information, but I'd like to find it out during runtime.
> 
> Reading the Multi Processor Affinity Register (MPIDR) [1] reports the
> "CPU ID". However, reading this register as a Jailhouse inmate always
> reports 0 for the primary boot CPU, regardless of the real physical CPU.

Yeah, it's virtualized: The ARM guests will see what we wrote into
VMPIDR_EL2, and that's virt_id.

> 
> Let's assume I have a quad-core system (e.g. Jetson TK1) and I assign
> the cpu_mask 0xc (phyical CPUs 2 and 3) to a cell, then reading MPIDR
> reports 0 for phys. CPU 2 and 1 for phys CPU 3.
> 
> This means that I'm able to logically differentiate between CPUs, but
> I'm not able to dynamically reconfigure IRQ routing, as I need physical
> CPU IDs.

That's done my Jailhouse for you when writing to ITARGETSR.

> 
> Thanks
>   Ralf
> 
> PS: I guess this might also be the reason why we always assign "reg =
> <0x0>;" in Linux Inmate DTs to primary boot CPUs and the real physical
> IDs, e.g., "reg = <0x3>;" to secondary CPUs. (cf.
> configs/dts/inmate-jetson-tk1.dts), right?

In theory, things should be virtualized properly. But there might be
remaining issues. I never really analyzed where this effect comes from.

Moreover, ARM64 decided to not virtualize the ID. We will have to look
into these nasty details again, at latest when trying to enable GICv3
for ARM64, because that variant currently relies on the virtualization.

> 
> BTW: Who actually fills MPIDR? Do reads trap to the hypervisor? If not,
> why does the hardware fill it with some sort of 'virtual' CPU IDs?
> 
> [1]
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html
> 

See above.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to