안녕하세요.
아래 코드에서 질문이 있어서 남겨봅니다.
SYM_FUNC_START(__cpu_setup)
tlbi vmalle1 // Invalidate local TLB
dsb nsh
"__create_page_tables()" 에서 idmap_pg_dir과 init_pg_dir을 생성하고 __cpu_setup을 통해 MMU를 enable하기 전에 TLB를 invalidate해주고 있는 코드입니다. 궁금한 점은:
* "tlbi vmalle1" 명령어는 local TLB, 즉 이 명령어를 실행하는 core에 대해서만 영향이 있다라고 해석 [1] 하였는데 그렇다면 이 invlidation은 TLB-l1에서만 invalidate해주는 것일까요? 만약 그렇다면 TLB-l2에는 아직 stale entry들이 존재할 수 있는데 그 부분은 나중 코드 어디서 해결해주고 있을까요?
* 만약 "tlbi vmalle1" 명령어가 TLB-l2의 entry들도 invalidate해주고 있다면 "tlbi vmalle1"와 "tlbi vmalle1is"의 차이가 무엇일까요?
[1] ARM DDI 0487F.c, ID072120, C5.5.73 TLBI VMALLE1, TLB Invalidate by VMID, All at stage 1, EL1
The invalidation applies to the PE that executes this System instruction.
댓글 5
-
구본규
2022.09.19 03:08
-
컴퓨터
2022.09.19 04:07
> TLB-l1, TLB-l2라는 용어는 각 코어 내부의 micro tlb와 main tlb로 쓰신 건 같은데요
그렇다면 micro tlb와 main tlb 모두 코어 하나마다 존재하는 것으로 이해해도 괜찮을까요? main tlb가 코어들과 공유하는 TLB는 아닌건가요?
제가 찾아본 바로는 i/d-micro tlb와 main tlb 모두 per core로 존재함으로 각 코어에서 cpu_setup()함수를 통해 각각의 tlb invalidation해주면 충분하다는 것을 알게되었습니다.
-
구본규
2022.09.20 01:06
네. TLB는 translation cache인데, MMU가 각 코어마다 존재하니 main tlb도 코어마다 존재하는 게 맞죠.
-
컴퓨터
2022.09.22 19:50
일반 cache에 대해서 생각해보면 L2-cache도 main TLB처럼 unified 인데 코어 밖에서 다른 코어와 공유하고 있습니다. 하지만 왜 main TLB는 core마다 존재해야하는지 이유에 대해서 생각해봤는데요
제 추측에는 main tlb에서 miss가 일어나면 (설정이 가능하지만) translation walk를 할때, 다음 레벨 페이지테이블의 base address를 메모리에서 walk하기 전에 일반 cache에서 먼저 lookup하는데, 이때 core밖에 있는 main tlb에서 다시 core안에 있는 l1-cache로 다시 갔다 오는게 사실 비효율적이라 main tlb를 per-core로 설계한게 아닌가 하는 생각이 들었습니다.
-
문c(문영일)
2022.09.21 09:25
조금 더 정보를 보태보면 최근에는 ARM도 x86등과 같이 uTLB와 mainTLB의 조합이 L1 I-TLB + L1 D-TLB + L2 TLB 형태로 진화되고 있습니다.
L2 TLB는 명령(I)과 데이터(D)가 통합(U)된 TLB 캐시이며 역시 core 별로 동작하는 것은 동일합니다.
.
TLBI VMALLE1, TLBI VMALLE1NXS, TLB Invalidate by VMID, All at stage 1, EL1
The invalidation applies to the PE that executes this System instruction. 명령을 실행한 PE에만 적용
The entry is a stage 1 translation table entry, from any level of the translation table walk.
TLBI VMALLE1IS, TLBI VMALLE1ISNXS, TLB Invalidate by VMID, All at stage 1, EL1, Inner Shareable
The invalidation applies to all PEs in the same Inner Shareable shareability domain as the PE that executes this System instruction. 명령을 실행한 PE와 같은 Inner Shareable shareability domain의 모든 PE들에 적용
TLBI VMALLS12E1, TLBI VMALLS12E1NXS, TLB Invalidate by VMID, All at Stage 1 and 2, EL1
The invalidation applies to the PE that executes this System instruction.
The entry is a stage 1 or stage 2 translation table entry, from any level of the translation table walk.
- PE마다 TLB 보유
- virtualization에서 stage 2 translation
https://developer.arm.com/documentation/den0024/a/The-Memory-Management-Unit/Translations-at-EL2-and-EL3
https://developer.arm.com/documentation/102142/0100/Stage-2-translation
- TLB-l1, TLB-l2라는 용어는 각 코어 내부의 micro tlb와 main tlb로 쓰신 건 같은데요, ARM 문서의 용어 그대로 이해하시면 될 것 같습니다.
5.2.1 Micro TLB
The first level of caching for the translation table information is a micro TLB of ten entries that is implemented on each of the instruction and data sides. All main TLB related maintenance operations affect both the instruction and data micro TLBs, causing them to be flushed.
5.2.2 Main TLB
A unified main TLB handles misses from the micro TLBs. This is a 512-entry, 4-way, set-associative structure. The main TLB supports all VMSAv8 block sizes, except 1GB. If a 1GB block is fetched, it is split into 512MB blocks and the appropriate block for the lookup stored.