c - How to check msr.le at runtime using built-ins? -
this question came in power8 in-core crypto patch. patch provides aes using power8 built-ins. when loading vsx register need perform 128-bit endian reversal when running on little-endian machine ensure vsx register loads proper value.
at compile time can check macros __byte_order__. however, believe supposed check machine status register @ runtime. if msr.le=1, perform endian swap. see altivec programming environment manual, section 3.1.4, p. 3-5.
how check machine status register @ runtime using built-ins?
you don't need - it's known @ compile time. instructions encoded incorrectly if you're running in opposite endianness of compiled code. so, os ensure program running in correct msr[le] setting endianness of executable.
in essence: msr[le] bit controls instructions data loads/stores.
there tricks can use detect endianness if have no idea, unless you're writing super boot code, won't need that.
Comments
Post a Comment