lkml.org 
[lkml]   [2018]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: PROPOSAL: Extend inline asm syntax with size spec
Hi,

On Sat, 13 Oct 2018, Borislav Petkov wrote:
>
> Thoughts, suggestions, etc are most welcome.

I apologize for coming in late here with an alternative proposal, but would
you be happy if GCC gave you a way to designate a portion of the asm template
string that shouldn't be counted as its cost because it doesn't go into the
.text section? This wouldn't interact with your redefinitions of the inline
keyword, and you could do something like (assuming we go with %` ... %`
delimiters)

[if gcc-9 or compatible]

#define ASM_NONTEXT_START "%`\n"
#define ASM_NONTEXT_END "%`\n"

[else]

#define ASM_NONTEXT_START "\n"
#define ASM_NONTEXT_END "\n"

[endif]

#define _BUG_FLAGS(ins, flags) \
do { \
asm volatile("1:\t" ins "\n" \
ASM_NONTEXT_START \
".pushsection __bug_table,\"aw\"\n" \
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
"\t.word %c0" "\t# bug_entry::flags\n" \
"\t.org 2b+%c1\n" \
".popsection" \
ASM_NONTEXT_END \
: : "i" (flags), \
"i" (sizeof(struct bug_entry))); \
} while (0)


I think it's nicer because it also allows the compiler to estimate asm length
for branch range optimization more accurately.

Alexander

\
 
 \ /
  Last update: 2018-10-13 23:21    [W:0.193 / U:0.640 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site