Skip to content
  • Marc Zyngier's avatar
    arm64: alternative: Work around .inst assembler bugs · eb7c11ee
    Marc Zyngier authored
    
    
    AArch64 toolchains suffer from the following bug:
    
    $ cat blah.S
    1:
    	.inst	0x01020304
    	.if ((. - 1b) != 4)
    		.error	"blah"
    	.endif
    $ aarch64-linux-gnu-gcc -c blah.S
    blah.S: Assembler messages:
    blah.S:3: Error: non-constant expression in ".if" statement
    
    which precludes the use of msr_s and co as part of alternatives.
    
    We workaround this issue by not directly testing the labels
    themselves, but by moving the current output pointer by a value
    that should always be zero. If this value is not null, then
    we will trigger a backward move, which is expclicitely forbidden.
    This triggers the error we're after:
    
      AS      arch/arm64/kvm/hyp.o
    arch/arm64/kvm/hyp.S: Assembler messages:
    arch/arm64/kvm/hyp.S:1377: Error: attempt to move .org backwards
    scripts/Makefile.build:294: recipe for target 'arch/arm64/kvm/hyp.o' failed
    make[1]: *** [arch/arm64/kvm/hyp.o] Error 1
    Makefile:946: recipe for target 'arch/arm64/kvm' failed
    
    Not pretty, but at least works on the current toolchains.
    
    Acked-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    eb7c11ee