[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 01/21] AMD/IOMMU: correct potentially-UB shifts


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 3 May 2022 16:34:33 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ORzGMUqT0Fv8u+AtgY9rL8u0IqW8rFi2nntxokHzZ8E=; b=FBNpNTbj9Olq0U4nIFT58ctqu3kTJtZl2XszRh/Z2uEhptPyLq/iYVClij2x86DuLDMqUeoj0MnS06g6NCGi9moOvsiaYsicI6fyDsoq/2wEJk7EBsUkkJwNox8CMDzTvbJhySJnUvj5OeH6ri4WTtAYL4DgpDevn/1gMysHXFZltZl7ukKhn6jC73rCCjHQ1yqXULMCh7XC4UDPke5Ixug2Co02pCOz2EfH3jpup2kTyCVZWVhOArgfYsEN6/QA6uV3rIBTUL2OQFxPXZVkrX4TQ1on6v1PEt4Prw1ZMNqtLbPLaSNH2pRaRz+ilgHf/2xWPI+V2iZKlFydLVcweQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LvvcIBRk8BitzEoQfQsF6rq3a1rc9aFLKEQwM+DCBbMNlBg5kf1gfBHC6oK7bY4EDZjNP40Uk/6krkHxSbx00YXYKaCWPfzeb8hVJcQSdeXXpH+GSKiBDZGNkQrGYKMXCEb2cLEQDTZrNHUL7a5mg1Y4HiV/DP/QsEt5KWrE4WsQ0kUn4gV4YAdBk4oFsFyeykszoI51Al+dtZ9cFjr10BlKQeNd48rBNpP3kUtI0gjXwPEDTe1GVpfpBHpi2/frRT+eefmljUJn5YyEszBYjI4NIYeqZscboABMlaU+Gn7ztSPQkenEa1mCbLhWUTm3XeLQZ4lVgSdhnXmHC+B3gw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Tue, 03 May 2022 14:34:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.05.2022 12:10, Roger Pau Monné wrote:
> On Mon, Apr 25, 2022 at 10:30:33AM +0200, Jan Beulich wrote:
>> Recent changes (likely 5fafa6cf529a ["AMD/IOMMU: have callers specify
>> the target level for page table walks"]) have made Coverity notice a
>> shift count in iommu_pde_from_dfn() which might in theory grow too
>> large. While this isn't a problem in practice, address the concern
>> nevertheless to not leave dangling breakage in case very large
>> superpages would be enabled at some point.
>>
>> Coverity ID: 1504264
>>
>> While there also address a similar issue in set_iommu_ptes_present().
>> It's not clear to me why Coverity hasn't spotted that one.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

>> --- a/xen/drivers/passthrough/amd/iommu_map.c
>> +++ b/xen/drivers/passthrough/amd/iommu_map.c
>> @@ -89,11 +89,11 @@ static unsigned int set_iommu_ptes_prese
>>                                             bool iw, bool ir)
>>  {
>>      union amd_iommu_pte *table, *pde;
>> -    unsigned int page_sz, flush_flags = 0;
>> +    unsigned long page_sz = 1UL << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
> 
> Seeing the discussion from Andrews reply, nr_pages might be more
> appropriate while still quite short.

Yes and no - it then would be ambiguous as to what size pages are
meant.

> I'm not making my Rb conditional to that change though.

Good, thanks. But I guess I'm still somewhat stuck unless hearing
back from Andrew (although one might not count a conditional R-b
as a "pending objection"). I'll give him a few more days, but I
continue to think this ought to be a separate change (if renaming
is really needed in the 1st place) ...

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.