From: "Liu, Yi L" <yi.l.liu@linux.intel.com>
To: Peter Xu <peterx@redhat.com>
Cc: jasowang@redhat.com, yi.l.liu@intel.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] intel_iommu: a fix to vtd_dev_get_trans_type()
Date: Mon, 25 Dec 2017 14:19:33 +0800 [thread overview]
Message-ID: <20171225061933.GA21722@sky-dev> (raw)
In-Reply-To: <20171225054522.GI2443@xz-mi>
On Mon, Dec 25, 2017 at 01:45:22PM +0800, Peter Xu wrote:
> On Thu, Dec 21, 2017 at 02:15:19PM +0800, Liu, Yi L wrote:
> > vtd_ce_get_type() returns uin32_t and vtd_dev_get_trans_type() returns
> > the value from vtd_ce_get_type(). However, vtd_dev_get_trans_type()
> > returns int. This patch switchs to return the translation type by
> > parameter. It avoids unsigned to int transfer and also avoid potential
> > reading confusion.
>
> Frankly speaking I would still prefer the old way to do it: return
> type when >=0 and error when <0. After all we have a comment for
> vtd_dev_get_trans_type() already:
>
> /*
> * Fetch translation type for specific device. Returns <0 if error
> * happens, otherwise return the shifted type to check against
> * VTD_CONTEXT_TT_*.
> */
Peter,
I knew your point. It's not a bug. However, it depends on
vtd_ce_get_type(), if it returns a value with the most significant
bit=1, then it may be wrongly treated as a negative value. It is not
possible so far, but it may be an issue if future spec place the
translation type in bit 31:29, and type 3'b100 is valid. It's an
assumption. Then the return value of vtd_ce_get_type() is 0x80000000,
and it would be treated as -2147483648. This should be a mistake.
That's why I want to separate the return value and the translation type.
Thanks,
Yi L
next prev parent reply other threads:[~2017-12-25 6:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 6:15 [Qemu-devel] [PATCH] intel_iommu: a fix to vtd_dev_get_trans_type() Liu, Yi L
2017-12-21 6:39 ` no-reply
2017-12-21 6:53 ` no-reply
2017-12-25 5:45 ` Peter Xu
2017-12-25 6:19 ` Liu, Yi L [this message]
2017-12-25 6:57 ` Peter Xu
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=20171225061933.GA21722@sky-dev \
--to=yi.l.liu@linux.intel.com \
--cc=jasowang@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yi.l.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).