From: Alex Williamson <alex.williamson@redhat.com>
To: "Hook, Gary" <ghook@amd.com>
Cc: Peter Xu <peterx@redhat.com>,
iommu@lists.linux-foundation.org, dwmw2@infradead.org,
linux-kernel@vger.kernel.org, tursulin@ursulin.net
Subject: Re: [PATCH] iommu/vt-d: Fix shift overflow in qi_flush_dev_iotlb
Date: Wed, 13 Dec 2017 10:15:18 -0700 [thread overview]
Message-ID: <20171213101518.7807ae4b@t450s.home> (raw)
In-Reply-To: <ae778a81-a500-d8d2-5c7e-10630fe42734@amd.com>
On Wed, 13 Dec 2017 10:41:47 -0600
"Hook, Gary" <ghook@amd.com> wrote:
> On 12/13/2017 9:58 AM, Alex Williamson wrote:
> > On Wed, 13 Dec 2017 15:13:55 +0800
> > Peter Xu <peterx@redhat.com> wrote:
> >
> >> On Tue, Dec 12, 2017 at 03:43:08PM -0700, Alex Williamson wrote:
> >>
> >> [...]
> >>
> >>> diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> >>> index 9a7ffd13c7f0..87888b102057 100644
> >>> --- a/drivers/iommu/dmar.c
> >>> +++ b/drivers/iommu/dmar.c
> >>> @@ -1345,7 +1345,9 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
> >>> struct qi_desc desc;
> >>>
> >>> if (mask) {
> >>> - BUG_ON(addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1));
> >>> + BUG_ON((mask > MAX_AGAW_PFN_WIDTH) ||
> >>> + ((mask == MAX_AGAW_PFN_WIDTH) && addr) ||
> >>> + (addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1)));
> >>
> >> Could it work if we just use 1ULL instead of 1 here? Thanks,
> >
> > In either case we're talking about shifting off the end of the
> > variable, which I understand to be undefined. Right? Thanks,
>
> How so? Bits fall off the left (MSB) end, zeroes fill in the right (LSB)
> end. I believe that behavior is pretty set.
Maybe I'm relying too much on stackoverflow, but:
https://stackoverflow.com/questions/11270492/what-does-the-c-standard-say-about-bitshifting-more-bits-than-the-width-of-type
Thanks,
Alex
next prev parent reply other threads:[~2017-12-13 17:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 22:43 Alex Williamson
2017-12-13 7:13 ` Peter Xu
2017-12-13 15:58 ` Alex Williamson
2017-12-13 16:41 ` Hook, Gary
2017-12-13 17:15 ` Alex Williamson [this message]
2017-12-13 17:31 ` Hook, Gary
2017-12-15 7:29 ` Peter Xu
2017-12-15 3:12 ` kbuild test robot
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=20171213101518.7807ae4b@t450s.home \
--to=alex.williamson@redhat.com \
--cc=dwmw2@infradead.org \
--cc=ghook@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=tursulin@ursulin.net \
/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®