Skip to contentSkip to conversation

A quick question about ASID on KPTI

DISCUSSION FF 2 participants 2 messages Mar 3, 2020

lore
Share & tools
lore

FF

author
#0 lore raw

hi folks,

i am look at some patches about the KPTI on ARM64, a quick question about the ASDI on KPTI:
On KPIT, it will allocate a pairs ASID for a process, when the process running on kernel space, it will set the even ASID into TTBR1 register in tramp_map_kernel function, when the process running on User space, it will set the odd ASID into the TTBR1 register in tramp_unmap_kernel function. my question is, when the process running in kernel space, if the process want to access the userspace address by copy_to/from_user(), the CPU will look-up the TLB with even ASID or odd ASID? if it use even ASID to look-up  TLB for userspace, it will always TLB miss, that will be performance impact. is it right? pls correct me if i am wrong.

Best
Ben
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#1 lore raw
Quoted 7 lines · FF

i am look at some patches about the KPTI on ARM64, a quick question about the ASDI on KPTI:
On KPIT, it will allocate a pairs ASID for a process, when the process running on kernel space, it will set the even ASID into TTBR1 register in tramp_map_kernel function, when the process running on User space, it will set the odd ASID into the TTBR1 register in tramp_unmap_kernel function.

Correct.

Quoted 3 lines

my question is, when the process running in kernel space, if the process want to access the userspace address by copy_to/from_user(), the CPU will look-up the TLB with even ASID or odd ASID?

The even ASID as that's the current one.

Quoted 2 lines

if it use even ASID to look-up  TLB for userspace, it will always TLB miss, that will be performance impact. is it right?

As with any other TLB miss, a TLB entry will be allocated and may or may not be removed, depending on what other activities happen on the CPU. In theory, there is a small performance impact but I don't think it's significant in practice (with real-world benchmarks).

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel