From: Joerg Roedel <jroedel@suse.de>
To: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/amd: Do not re-fetch iommu->cmd_buf_tail
Date: Wed, 30 Oct 2019 10:20:14 +0100 [thread overview]
Message-ID: <20191030092014.GO838@suse.de> (raw)
In-Reply-To: <20191024125410.19224-1-dvlasenk@redhat.com>
On Thu, Oct 24, 2019 at 02:54:10PM +0200, Denys Vlasenko wrote:
> The compiler is not smart enough to realize that iommu->cmd_buf_tail
> can't be modified across memcpy:
>
> 41 8b 45 74 mov 0x74(%r13),%eax # iommu->cmd_buf_tail
> 44 8d 78 10 lea 0x10(%rax),%r15d # += sizeof(*cmd)
> 41 81 e7 ff 1f 00 00 and $0x1fff,%r15d # %= CMD_BUFFER_SIZE
> 49 03 45 68 add 0x68(%r13),%rax # target = iommu->cmd_buf + iommu->cmd_buf_tail
> 45 89 7d 74 mov %r15d,0x74(%r13) # store to iommu->cmd_buf_tail
> 49 8b 34 24 mov (%r12),%rsi # memcpy
> 49 8b 7c 24 08 mov 0x8(%r12),%rdi # memcpy
> 48 89 30 mov %rsi,(%rax) # memcpy
> 48 89 78 08 mov %rdi,0x8(%rax) # memcpy
> 49 8b 55 38 mov 0x38(%r13),%rdx # iommu->mmio_base
> 41 8b 45 74 mov 0x74(%r13),%eax # redundant load of iommu->cmd_buf_tail
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 89 82 08 20 00 00 mov %eax,0x2008(%rdx) # writel
>
> CC: Tom Lendacky <thomas.lendacky@amd.com>
> CC: Joerg Roedel <jroedel@suse.de>
> CC: linux-kernel@vger.kernel.org
> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
> ---
> drivers/iommu/amd_iommu.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
Applied, thanks.
prev parent reply other threads:[~2019-10-30 9:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 12:54 [PATCH] iommu/amd: Do not re-fetch iommu->cmd_buf_tail Denys Vlasenko
2019-10-30 9:20 ` Joerg Roedel [this message]
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=20191030092014.GO838@suse.de \
--to=jroedel@suse.de \
--cc=dvlasenk@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thomas.lendacky@amd.com \
/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 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.