Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: add C wrappers for SET_PSTATE_*()

To make callsites easier to read, add trivial C wrappers for the
SET_PSTATE_*() helpers, and convert trivial uses over to these. The new
wrappers will be used further in subsequent patches.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201113124937.20574-3-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Mark Rutland and committed by
Catalin Marinas
515d5c8a f80d0340

+7 -3
+4
arch/arm64/include/asm/sysreg.h
··· 98 98 #define SET_PSTATE_SSBS(x) __emit_inst(0xd500401f | PSTATE_SSBS | ((!!x) << PSTATE_Imm_shift)) 99 99 #define SET_PSTATE_TCO(x) __emit_inst(0xd500401f | PSTATE_TCO | ((!!x) << PSTATE_Imm_shift)) 100 100 101 + #define set_pstate_pan(x) asm volatile(SET_PSTATE_PAN(x)) 102 + #define set_pstate_uao(x) asm volatile(SET_PSTATE_UAO(x)) 103 + #define set_pstate_ssbs(x) asm volatile(SET_PSTATE_SSBS(x)) 104 + 101 105 #define __SYS_BARRIER_INSN(CRm, op2, Rt) \ 102 106 __emit_inst(0xd5000000 | sys_insn(0, 3, 3, (CRm), (op2)) | ((Rt) & 0x1f)) 103 107
+1 -1
arch/arm64/kernel/cpufeature.c
··· 1598 1598 WARN_ON_ONCE(in_interrupt()); 1599 1599 1600 1600 sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0); 1601 - asm(SET_PSTATE_PAN(1)); 1601 + set_pstate_pan(1); 1602 1602 } 1603 1603 #endif /* CONFIG_ARM64_PAN */ 1604 1604
+2 -2
arch/arm64/kernel/proton-pack.c
··· 538 538 539 539 if (spectre_v4_mitigations_off()) { 540 540 sysreg_clear_set(sctlr_el1, 0, SCTLR_ELx_DSSBS); 541 - asm volatile(SET_PSTATE_SSBS(1)); 541 + set_pstate_ssbs(1); 542 542 return SPECTRE_VULNERABLE; 543 543 } 544 544 545 545 /* SCTLR_EL1.DSSBS was initialised to 0 during boot */ 546 - asm volatile(SET_PSTATE_SSBS(0)); 546 + set_pstate_ssbs(0); 547 547 return SPECTRE_MITIGATED; 548 548 } 549 549