From: "H. Peter Anvin" <hpa@zytor.com>
To: Andy Lutomirski <luto@kernel.org>,
Uros Bizjak <uros_bizjak1@t-2.net>,
linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Uros Bizjak <ubizjak@gmail.com>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: ASM flags in general
Date: Mon, 27 Jul 2015 14:04:45 -0700 [thread overview]
Message-ID: <55B69CED.8050709@zytor.com> (raw)
In-Reply-To: <55B696B2.3000702@kernel.org>
On 07/27/2015 01:38 PM, Andy Lutomirski wrote:
>
> As long as we're thinking about this stuff, there are bunch of places
> where we use exception fixups and do awful things involving translating
> them to error codes. Ideally they'd use as goto instead, but last time
> I checked, GCC was quite picky and didn't like output constraints and
> asm goto at the same time. Maybe GCC could fix this at some point, but
> using condition code outputs might be reasonable, too.
>
> Doing this would make put_user_ex and similar completely unnecessary, I
> think.
>
No, I think this is wrong. Exceptions and flags are almost each others
opposites. Since C doesn't have native exception handling (except
setjmp/longjmp) we pretty much hack it.
asm goto() would indeed be the better way to do this, but again, would
in most cases require asm goto to support outputs.
However, get_user_ex and put_user_ex we really don't want to go away.
They produce extremely efficient code -- just a bunch of mov operations
-- for the common path, and that's the way we like it.
That being said, there probably are a couple of patterns where we could
do, say "stc" in the exception path, and emit CF as an output:
bool err;
int errno;
asm volatile("xor %1,%1\n" /* Clears CF */
"1: something %3,%0\n"/* Leaves CF unchanged, or clears */
"2:\n"
".section .fixup.\"ax\"\n"
"3: mov %4,%1\n"
" stc\n"
" jmp 2b"
_ASM_EXTABLE(1b,3b)
: "=X" (output), "=r" (errno), "=@ccc" (err)
: "Y" (input), "i" (-EIO));
This would make "err" immediately testable. However, it also might make
gcc generate extra code to save and restore err, since it wouldn't
understand the invariant that err = !!errno.
-hpa
next prev parent reply other threads:[~2015-07-27 21:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 17:48 [PATCH v2] x86: Introduce ASM flags to bitops Uros Bizjak
2015-07-27 19:04 ` ASM flags in general H. Peter Anvin
2015-07-27 20:01 ` Uros Bizjak
2015-07-27 21:14 ` H. Peter Anvin
2015-07-27 20:38 ` Andy Lutomirski
2015-07-27 21:04 ` H. Peter Anvin [this message]
2015-07-27 22:43 ` Andy Lutomirski
[not found] ` <BFA94A6B-8E68-4990-8737-F1F470D47F6A@zytor.com>
2015-07-27 23:36 ` Andy Lutomirski
[not found] ` <E2EE4512-30B2-4E73-B91A-DC1A9AA0AF6C@zytor.com>
2015-07-27 23:49 ` Andy Lutomirski
2015-07-27 23:56 ` H. Peter Anvin
2015-07-27 23:58 ` Andy Lutomirski
2015-07-28 0:03 ` H. Peter Anvin
2015-07-28 0:35 ` H. Peter Anvin
2015-07-28 0:41 ` Andy Lutomirski
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=55B69CED.8050709@zytor.com \
--to=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=ubizjak@gmail.com \
--cc=uros_bizjak1@t-2.net \
--cc=x86@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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox