mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@suse.de>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Logan Gunthorpe <logang@deltatee.com>
Cc: Peter Anvin <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Tony Luck <tony.luck@intel.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	the arch/x86 maintainers <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Question Regarding ERMS memcpy
Date: Sun, 5 Mar 2017 20:54:33 +0100	[thread overview]
Message-ID: <20170305195432.6occvwaujq3l4ejl@pd.tnic> (raw)
In-Reply-To: <CA+55aFykpsWoZeHKV1Bnr=ok9ocBhiSR5gNJepjFXStO1NGuoA@mail.gmail.com>

On Sun, Mar 05, 2017 at 11:19:42AM -0800, Linus Torvalds wrote:
> Actually, the "fromio/toio" code should never use regular memcpy().
> There used to be devices that literally broke on 64-bit accesses due
> to broken PCI crud.
> 
> We seem to have broken this *really* long ago, though.

I wonder why nothing blew up or failed strangely by now...

> On x86-64 we used to have a special __inline_memcpy() that copies our
> historical

It is still there in arch/x86/include/asm/string_64.h.

The comment "Only used for special circumstances." over it is grossly
understating it.

> 32-bit thing, and was used for memcpy_fromio() and memcpy_toio(). That
> was then undone by commit 6175ddf06b61 ("x86: Clean up mem*io
> functions")
> 
> That commit says
> 
>    "Iomem has no special significance on x86"
> 
> but that's not strictly true. iomem is in the same address space and
> uses the same access instructions as regular memory, but iomem _is_
> special.
> 
> And I think it's a bug that we use "memcpy()" on it. Not because of
> any gcc issues, but simply because our own memcpy() optimizations are
> not appropriate for iomem.
> 
> For example, "rep movsb" really is the right thing to use on normal
> memory on modern CPU's.

So Logan's box is a SNB and it doesn't have the ERMS optimizations. Are
you saying, regardless, we should let gcc put REP; MOVSB for smaller
sizes?

Because gcc does generate a REP; MOVSB there when it puts its own
memcpy, see mail upthread. (Even though that is wrong to do on iomem.)

> But it is *not* the right thing to use on IO memory, because the CPU
> only does the magic cacheline access optimizations on cacheable
> memory!

Ah, yes.

> So I think we should re-introduce that old "__inline_memcpy()" as that
> special "safe memcpy" thing. Not just for KMEMCHECK, and not just for
> 64-bit.

Logan, wanna give that a try, see if it takes care of your issue?

Oh, and along with the revert we would need a big fat warning explaining
why we need that special memcpy for IO memory.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

  reply	other threads:[~2017-03-05 20:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 20:08 Logan Gunthorpe
2017-03-04 22:43 ` Borislav Petkov
     [not found]   ` <c675a6c8-e87a-ece2-2350-cdd079b1b610@deltatee.com>
2017-03-04 23:55     ` hpa
2017-03-05  0:14       ` Borislav Petkov
2017-03-05  0:23         ` hpa
2017-03-05  0:33           ` Borislav Petkov
2017-03-05  0:56             ` hpa
2017-03-05  9:50               ` Borislav Petkov
2017-03-05 11:18                 ` Borislav Petkov
2017-03-05 13:05                   ` Borislav Petkov
2017-03-05 19:19                 ` Linus Torvalds
2017-03-05 19:54                   ` Borislav Petkov [this message]
2017-03-05 20:19                     ` Linus Torvalds
2017-03-06  7:01                     ` Logan Gunthorpe
2017-03-06  7:28                       ` H. Peter Anvin
2017-03-06 17:12                         ` Logan Gunthorpe
2017-03-06 18:53                           ` hpa
2017-03-06 13:33                       ` Borislav Petkov
2017-03-06 13:41                         ` hpa
2017-03-06 14:00                           ` Borislav Petkov
2017-03-05  4:58             ` Logan Gunthorpe
2017-03-05  9:54               ` Borislav Petkov

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=20170305195432.6occvwaujq3l4ejl@pd.tnic \
    --to=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --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

all inboxes | Powered by JetHome®