ARM 程序集“retne"操作说明 [英] ARM assembly "retne" instruction

查看:23
本文介绍了ARM 程序集“retne"操作说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在了解引导 Linux 内核需要什么.我正在浏览 Linux 内核源代码树,尤其是 ARM 架构,直到我在 arch/arm/kernel/hyp-stub.S

I am currently in the process of understanding what it takes for the Linux kernel to boot. I was browsing through the Linux kernel source tree, in particular for the ARM architecture, until I stumbled upon this assembly instruction retne lr in arch/arm/kernel/hyp-stub.S

从概念上讲,很容易理解,如果 Z 标志为 0,则该指令假定返回存储在链接寄存器中的地址.我要查找的是实际记录此 ARM 汇编指令的位置.

Conceptually, it's easily understood that the instruction is suppose to return to the address stored in the link register if the Z-flag is 0. What I am looking for is where this ARM assembly instruction is actually documented.

我在 ARM 中搜索Architecture Reference Manual ARMv7-A and ARMv7-R edition section A8.8 找不到指令说明.

I searched in the ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition section A8.8 and could not find the description of the instruction.

获取源代码并查看它是否是 ARM 特定的 GNU AS 扩展a> 没有特别提到任何东西.

Grepping the sources and seeing if it was an ARM specific GNU AS extension did not turn up anything in particular.

使用查询arm assembly ret 指令"、arm return 指令"和任何类似内容的谷歌搜索也没有找到任何有用的信息.肯定是我找错地方了,否则我一定遗漏了什么.

A google search with the queries "arm assembly ret instruction", "arm return instruction" and anything similar along the lines did not turn up anything useful either. Surely I must be looking in the wrong places or I must be missing something.

任何澄清将不胜感激.

推荐答案

架构汇编语言是一回事,现实世界的代码是另一回事.一旦汇编器伪操作和宏开始发挥作用,熟悉工具链和相关代码库就会大有帮助.Linux 尤其令人讨厌,因为大部分汇编源代码都包含多层汇编宏和 CPP 宏.如果您知道要查找什么,请按照标题路径 arch/arm/include/asm/assembler.h,你最终会发现这个复杂的野兽:

The architectural assembly language is one thing, real world code is another. Once assembler pseudo-ops and macros come into play, a familiarity with both the toolchain and the codebase in question helps a lot. Linux is particularly nasty as much of the assembly source contains multiple layers of both assembler macros and CPP macros. If you know what to look for, and follow the header trail to arch/arm/include/asm/assembler.h, you eventually find this complicated beast:

.irp    c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo
.macro  ret\c, reg
#if __LINUX_ARM_ARCH__ < 6
        mov\c   pc, \reg
#else
        .ifeqs  "\reg", "lr"
        bx\c    \reg
        .else
        mov\c   pc, \reg
        .endif
#endif
        .endm
        .endr

这样做的目的是为了具有返回堆栈的微架构,同时允许相同的代码仍可针对旧架构进行编译.

The purpose of this is to emit the architecturally-preferred return instruction for the benefit of microarchitectures with a return stack, whilst allowing the same code to still compile for older architectures.

这篇关于ARM 程序集“retne"操作说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆