arm架構的linux內核中,clrex指令的作用是什么
《arm architecture reference manual》B2-1292以下簡(jiǎn)稱(chēng)arm arm手冊
本文引用地址:http://dyxdggzs.com/article/201611/317220.htmThe ClearExclusiveLocal() procedure takes as arguments the processor identifier processorid . The procedure clearsthe local record of processor processorid for which an address has had a request for an exclusive access. It isIMPLEMENTATION DEFINED whether this operation also clears the global record of processor processorid that anaddress has had a request for an exclusive access
該指令的作用就是在獨占訪(fǎng)問(wèn)結束時(shí),清除cpu中本地處理器針對某塊內存區域的獨占訪(fǎng)問(wèn)標志(核中的某個(gè)狀態(tài)寄存器),以防在未清除時(shí)的其他操作,對系統產(chǎn)生影響。對于是否同時(shí)清除全局的獨占訪(fǎng)問(wèn)標志,需要在設計cpu時(shí)的架構師決定。
2. clrex指令的作用很獨特,在linux內核中用在什么地方呢?
用在如下地方:
(1)數據中止異常、指令預取中止異常的處理時(shí)調用
(調用linaro-aarch64/arch/arm/mm/abort-ev7.s v7_early_abort==》clrex)
(2)從svc模式下的irq異常、未定義指令異常、數據中止異常、指令預取中止異常,處理結束返回時(shí)調用
(調用宏:linaro-aarch64/arch/arm/kernel/entry-header.s svc_exit)
(3) 返回到用戶(hù)層的快速系統調用/慢速系統調用(ret_slow_syscall,ret_fast_syscall==》
調用宏:linaro-aarch64/arch/arm/kernel/entry-header.s restore_user_regs==》clrex)
(4) run_all_tests 函數調用(==》kprobe_arm_test_cases==》TEST_UNSUPPORTED("clrex") ==》clrex)
該函數是一個(gè)驅動(dòng)模塊,可以動(dòng)態(tài)加載。
如上所示:基本所有的異常都要用到該指令,系統調用的返回也能用到。
雖然異常和系統調用的代碼在內核中不多,但是當內核運行起來(lái)時(shí),異常和系統調用的執行頻率特別高!
所以該指令還是非常有用的。
評論