GNU AS SPARC V8E 部分 WRPSR

GNU AS SPARC V8E partial WRPSR

SPARC V8 处理器状态寄存器 (PSR) 包含 enable/disable 陷阱 (ET) 的位,详见 SPARC 体系结构手册第 8 版,网址为 http://sparc.org/technical-documents/

禁用陷阱是非原子操作,如手册中明确所述:

If traps are enabled (ET=1), care must be taken if software is to disable them (ET=0). Since the “RDPSR, WRPSR” sequence is interruptible — allowing the PSR to be changed between the two instructions — this sequence is not a reliable mechanism to disable traps.

SPARC-V8 的嵌入式补充 SPARC-V8E 添加了部分 WRPSR 指令以缓解此问题:

When a WRPSR instruction with a non null RD is executed, only some fields of PSR are written rather than all the defined fields of PSR. The mapping “RD => fields” is tbd. However:

RD = 0 : all fields written (for compatibility)

RD = tbd : only ET is written.

第二点可以克服 V8 明确指出的弱点(上述 WRPSR 指令的编程说明)。

我桌上有一个支持它的实现,但我想知道如何使用它,因为据我所知,GNU 汇编程序 (GAS) 不支持该指令。我知道将立即数或寄存器值写入 %psr 的唯一方法是使用 mov:

mov %g0, %psr / mov 0, %psr

通过查看 GNU binutils GAS 源代码,我了解到没有语法来指定指令代码的 RD 部分,因此无法使用 GNU AS 自动设置 ET=0。还是我错过了什么?

我注意到 GAS 手册中的一些 -Av8plusX 命令行选项,但其中 none 似乎与 V8E 或部分 WRPSR 有关。

是否有任何 GAS 语法或其他方式将此指令发送到输出?如果不可能,我需要知道什么才能创建补丁?语法应该是什么样的?

是否有任何编译器完全支持部分 WRPSR?我最近检查了 LLVM 的 SPARC 支持,但它仍然是 experimental/incomplete.

谢谢。

与此同时,我了解到可以使用常量代替指令将其直接插入汇编代码,例如如下所示以禁用陷阱:

.word 0x83880000

请注意,如果您在没有此功能的处理器上使用部分 wrpsr 功能,那么它将充当普通 wrpsr,因此在系统之间移动软件时需要小心。

来源:https://groups.yahoo.com/neo/groups/LEON_SPARC/conversations/topics/24733