mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-12-22 03:53:43 +00:00
Inspired by x86 commit 864b435514b2("x86/jump_label: Mark arguments as
const to satisfy asm constraints"), mark arch_static_branch()'s and
arch_static_branch_jump()'s arguments as const to satisfy asm
constraints. And Steven in [1] also pointed out that "The "i"
constraint needs to be a constant."
Tested with building a simple external kernel module with "O0".
[1]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://lore.kernel.org/r/20221006075542.2658-2-jszhang@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2013 Huawei Ltd.
|
|
* Author: Jiang Liu <liuj97@gmail.com>
|
|
*
|
|
* Based on arch/arm/include/asm/jump_label.h
|
|
*/
|
|
#ifndef __ASM_JUMP_LABEL_H
|
|
#define __ASM_JUMP_LABEL_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/types.h>
|
|
#include <asm/insn.h>
|
|
|
|
#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE
|
|
|
|
static __always_inline bool arch_static_branch(struct static_key * const key,
|
|
const bool branch)
|
|
{
|
|
asm_volatile_goto(
|
|
"1: nop \n\t"
|
|
" .pushsection __jump_table, \"aw\" \n\t"
|
|
" .align 3 \n\t"
|
|
" .long 1b - ., %l[l_yes] - . \n\t"
|
|
" .quad %c0 - . \n\t"
|
|
" .popsection \n\t"
|
|
: : "i"(&((char *)key)[branch]) : : l_yes);
|
|
|
|
return false;
|
|
l_yes:
|
|
return true;
|
|
}
|
|
|
|
static __always_inline bool arch_static_branch_jump(struct static_key * const key,
|
|
const bool branch)
|
|
{
|
|
asm_volatile_goto(
|
|
"1: b %l[l_yes] \n\t"
|
|
" .pushsection __jump_table, \"aw\" \n\t"
|
|
" .align 3 \n\t"
|
|
" .long 1b - ., %l[l_yes] - . \n\t"
|
|
" .quad %c0 - . \n\t"
|
|
" .popsection \n\t"
|
|
: : "i"(&((char *)key)[branch]) : : l_yes);
|
|
|
|
return false;
|
|
l_yes:
|
|
return true;
|
|
}
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
#endif /* __ASM_JUMP_LABEL_H */
|