From: Jisheng Zhang <jszhang@kernel.org> To: Ard Biesheuvel <ardb@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@kernel.org>, Jason Baron <jbaron@akamai.com>, Steven Rostedt <rostedt@goodmis.org>, Mark Rutland <mark.rutland@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints Date: Thu, 6 Oct 2022 16:46:16 +0800 [thread overview] Message-ID: <Yz6V2Ffm5jSJJa1V@xhacker> (raw) In-Reply-To: <CAMj1kXEWm9WuvxYN8ks09m3Rv+pt1Hd7=DcXuTwm+Etw2Y-KOQ@mail.gmail.com> On Thu, Oct 06, 2022 at 10:17:44AM +0200, Ard Biesheuvel wrote: > On Thu, 6 Oct 2022 at 10:05, Jisheng Zhang <jszhang@kernel.org> wrote: > > > > 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> > > --- > > arch/arm64/include/asm/jump_label.h | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h > > index cea441b6aa5d..48ddc0f45d22 100644 > > --- a/arch/arm64/include/asm/jump_label.h > > +++ b/arch/arm64/include/asm/jump_label.h > > @@ -15,8 +15,8 @@ > > > > #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE > > > > -static __always_inline bool arch_static_branch(struct static_key *key, > > - bool branch) > > +static __always_inline bool arch_static_branch(struct static_key * const key, > > + const bool branch) > > { > > asm_volatile_goto( > > "1: nop \n\t" > > Is this still necessary if we specify the constraints in a more > reasonable manner: > > " .quad %c0 - . + %1 \n\t" > : : "i"(key), "i"(branch) : : l_yes); Just tried this locally with the simple external kernel module, the asm operand 0 probably does not match constraints can still be reproduced with "O0". Thanks > > instead of the horrid hack with the char* cast and using a bool as an > array index? > > > > > > @@ -32,8 +32,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, > > return true; > > } > > > > -static __always_inline bool arch_static_branch_jump(struct static_key *key, > > - bool branch) > > +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" > > -- > > 2.37.2 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Jisheng Zhang <jszhang@kernel.org> To: Ard Biesheuvel <ardb@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@kernel.org>, Jason Baron <jbaron@akamai.com>, Steven Rostedt <rostedt@goodmis.org>, Mark Rutland <mark.rutland@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints Date: Thu, 6 Oct 2022 16:46:16 +0800 [thread overview] Message-ID: <Yz6V2Ffm5jSJJa1V@xhacker> (raw) In-Reply-To: <CAMj1kXEWm9WuvxYN8ks09m3Rv+pt1Hd7=DcXuTwm+Etw2Y-KOQ@mail.gmail.com> On Thu, Oct 06, 2022 at 10:17:44AM +0200, Ard Biesheuvel wrote: > On Thu, 6 Oct 2022 at 10:05, Jisheng Zhang <jszhang@kernel.org> wrote: > > > > 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> > > --- > > arch/arm64/include/asm/jump_label.h | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h > > index cea441b6aa5d..48ddc0f45d22 100644 > > --- a/arch/arm64/include/asm/jump_label.h > > +++ b/arch/arm64/include/asm/jump_label.h > > @@ -15,8 +15,8 @@ > > > > #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE > > > > -static __always_inline bool arch_static_branch(struct static_key *key, > > - bool branch) > > +static __always_inline bool arch_static_branch(struct static_key * const key, > > + const bool branch) > > { > > asm_volatile_goto( > > "1: nop \n\t" > > Is this still necessary if we specify the constraints in a more > reasonable manner: > > " .quad %c0 - . + %1 \n\t" > : : "i"(key), "i"(branch) : : l_yes); Just tried this locally with the simple external kernel module, the asm operand 0 probably does not match constraints can still be reproduced with "O0". Thanks > > instead of the horrid hack with the char* cast and using a bool as an > array index? > > > > > > @@ -32,8 +32,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, > > return true; > > } > > > > -static __always_inline bool arch_static_branch_jump(struct static_key *key, > > - bool branch) > > +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" > > -- > > 2.37.2 > >
next prev parent reply other threads:[~2022-10-06 8:57 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-06 7:55 [PATCH 0/2] arm64: constify arguments to satisfy asm constraints Jisheng Zhang 2022-10-06 7:55 ` Jisheng Zhang 2022-10-06 7:55 ` [PATCH 1/2] arm64: jump_label: mark arguments as const " Jisheng Zhang 2022-10-06 7:55 ` Jisheng Zhang 2022-10-06 8:17 ` Ard Biesheuvel 2022-10-06 8:17 ` Ard Biesheuvel 2022-10-06 8:46 ` Jisheng Zhang [this message] 2022-10-06 8:46 ` Jisheng Zhang 2022-10-06 8:55 ` Jisheng Zhang 2022-10-06 8:55 ` Jisheng Zhang 2022-10-06 9:08 ` Ard Biesheuvel 2022-10-06 9:08 ` Ard Biesheuvel 2022-10-06 11:04 ` Jisheng Zhang 2022-10-06 11:04 ` Jisheng Zhang 2022-10-06 10:14 ` Mark Rutland 2022-10-06 10:14 ` Mark Rutland 2022-10-06 11:53 ` Jisheng Zhang 2022-10-06 11:53 ` Jisheng Zhang 2022-10-06 7:55 ` [PATCH 2/2] arm64: alternative: constify alternative_has_feature_* argument Jisheng Zhang 2022-10-06 7:55 ` Jisheng Zhang 2022-11-07 19:08 ` [PATCH 0/2] arm64: constify arguments to satisfy asm constraints Will Deacon 2022-11-07 19:08 ` Will Deacon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Yz6V2Ffm5jSJJa1V@xhacker \ --to=jszhang@kernel.org \ --cc=ardb@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=jbaron@akamai.com \ --cc=jpoimboe@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=peterz@infradead.org \ --cc=rostedt@goodmis.org \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.