Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1686096

Re: [tip:x86/urgent] x86/io: Mark target address as output in 'insb()' asm

From Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [tip:x86/urgent] x86/io: Mark target address as output in 'insb()' asm
Date 2017-07-13 00:50 +0200
Message-ID <u2yCd-5NI-11@gated-at.bofh.it> (permalink)
References <u1IaB-6eJ-1@gated-at.bofh.it> <u2pIC-g1-13@gated-at.bofh.it> <u2t9w-2g2-13@gated-at.bofh.it> <u2xGb-59T-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jul 12, 2017 at 2:47 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> The real fix is probably to just mark them as "clobbers memory" (ie
>> just add "memory" to the clobber list).
>>
>> If you want to be fancy, you can try to do what <asm/uaccess.h> does,
>> which is a disgusting hack, but has traditionally worked;
>>
>>   struct __large_struct { unsigned long buf[100]; };
>>   #define __m(x) (*(struct __large_struct __user *)(x))
>>
>> and then use your approach with "m" and "=m".
>
> Ok, I'll try both tomorrow and see where I end up.

Note that just adding the "memory" thing to the clobbers likely causes
slightly worse code generation (it basically says that the asm can
clobber anything at all, so cause re-loads etc that are entirely
unrelated to the asm).

But for something like "rep in/out", that really doesn't much matter.
PIO is very slow due to being fully serialized, and "rep ins/outs" is
just about the slowest thing you can do on a machine. So nobody really
does it, the main traditional user was the legacy PIO data transfer
for ST-506 disks. And, as you noticed a few *really* old network card
drivers.

So I suspect the big hammer memory clobber is the right thing to do.

> Would you expect that the missing clobber causes actual
> runtime bugs and the fix needs to be backported to stable
> kernels?

Probably not. "asm volatile" is already pretty serialized. It's not
entirely obvious what gcc will move around it, but almost certainly no
operations that matter for the network buffer.

And honestly, the wt3501 is basically an ISA card in PCMCIA format. I
don't think it's even cardbus (Cardbus aka Yenta is basically "hotplug
PCI"). So I don't think anybody even has that hardware.

It was a good card for its time. But its time was basically two decades ago.

                  Linus

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC 1/2] x86: mark target address as output in 'insb' asm Arnd Bergmann <arnd@arndb.de> - 2017-07-10 16:50 +0200
  [RFC 2/2] wl3501_cs: reduce stack size for KASAN Arnd Bergmann <arnd@arndb.de> - 2017-07-10 16:50 +0200
  [tip:x86/urgent] x86/io: Mark target address as output in 'insb()'  asm tip-bot for Arnd Bergmann <tipbot@zytor.com> - 2017-07-12 15:20 +0200
    Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-12 19:00 +0200
      Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Ingo Molnar <mingo@kernel.org> - 2017-07-12 21:30 +0200
      Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Arnd Bergmann <arnd@arndb.de> - 2017-07-12 23:50 +0200
        Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-13 00:50 +0200

csiph-web