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

Re: [Xen-devel] [PATCH v2 02/10] AMD/IOMMU: use bit field for extended feature register


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Tue, 16 Jul 2019 16:02:03 +0000
  • Accept-language: en-US
  • 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-SenderADCheck; bh=CealdGfqW4R3jrkKkMaG6poW8g/XKDxDjeqhV89W/3I=; b=k7ELg4dXw8SCc2gAJuB/X43BIZBnUMSkMg1OEQdlpytJ5zmyZ6Figr4QhTmgqM9jJxoRyCcO08Nc2/QOSaMEJwIWAT/UBhPt9Qd+YTvAivC+Vg0iRsX2tPPYThBxjwBqUX79tnttKg1B/wKRPPRlqi7vGQnPHS+J+UNIUL9qfHBUPcbZFzfDX8Xz8NG5814bkp83L3ZyY3s5Z7W3OMrk0oB6jjmyHqpbMTnWh7MQ2KHc4wIy6FUdQBqNaG22/nsF0HrjQYalpRa//q+SN0RfN3uL+n1ah8ThRb0FqHjIhpj2jMNBFMheFxqOiePZHV9iVz7UiPup32qCOw5e1vvkzw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNZ6HT75C0v0+1seTnmTZW/h+RtowZemBeFypOLYXLWK+R0KnneJmRK5i9diH8/L7RxBYzyVKEW6ImLu9e07Mo4vO0K7GGyMDOSrFqRyndXzxD/nVKITNdbkIpbxsIblnbm0+ZENargh2Jf1HESBjtXf+j02NV8MbnZ/0ZGXlgxKph/r5Y297CcYJDkQ3i2YKzowo4m9fJQNTDJ184Wluchhq/2yyq2+FODLb3OodhqhKisNRGuFV8NHWcQcUBEzvGQFZyT/8pseFZ7femnSGd3gnjopgOQBtmevohz7XLeydn1E8c8IUFDSVd2UMljh1I6euaxt2+yWgrsgElCYaw==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: Brian Woods <brian.woods@xxxxxxx>, Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
  • Delivery-date: Tue, 16 Jul 2019 16:07:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVMM8ahTOfdYIYMkGKpA4vuokia6bNffIA
  • Thread-topic: [PATCH v2 02/10] AMD/IOMMU: use bit field for extended feature register

On 02.07.2019 14:09, Andrew Cooper wrote:
> On 27/06/2019 16:19, Jan Beulich wrote:
>>       printk("AMD-Vi: IOMMU Extended Features:\n");
>>   
>> -    while ( feature_str[i] )
>> +#define MASK(fld) ((union amd_iommu_ext_features){ .flds.fld = ~0 }).raw
>> +#define FEAT(fld, str) do { \
>> +    if ( MASK(fld) & (MASK(fld) - 1) ) \
>> +        printk( "- " str ": %#x\n", iommu->features.flds.fld); \
>> +    else if ( iommu->features.raw & MASK(fld) ) \
>> +        printk( "- " str "\n"); \
>> +} while ( false )
> 
> Sadly, Clang dislikes this construct.
> 
> https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/243795095
> (Click on the "Complete Raw" button)

It it possible that this has expired in the meantime? I can't seem to
be able to access it. But then, with what you write below, I probably
also have enough information.

> iommu_detect.c:90:5: error: implicit truncation from 'int' to bitfield 
> changes value from -1 to 1 [-Werror,-Wbitfield-constant-conversion]
>      FEAT(pref_sup,           "Prefetch Pages Command");
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> iommu_detect.c:84:10: note: expanded from macro 'FEAT'
>      if ( MASK(fld) & (MASK(fld) - 1) ) \
>           ^~~~~~~~~
> iommu_detect.c:82:64: note: expanded from macro 'MASK'
> #define MASK(fld) ((union amd_iommu_ext_features){ .flds.fld = ~0 }).raw
>                                                                 ^~
> 
> 
> which is a shame.  Furthermore, switching to ~(0u) won't work either,
> because that will then get a truncation warning.
> 
> Clever as this trick is, this is write-once code and isn't going to
> change moving forward.  I'd do away with the compile-time cleverness and
> have simple FEAT() and MASK() macros, and use the correct one below.

If only I knew what you mean with "simple FEAT() and MASK() macros".
I can't think of variants not requiring to also introduce literal
numbers to use as constants. I'll (not just) therefore try to modify
the original approach such that hopefully there won't be any overflow
detected anymore. I can't see any such issue with the clang I use
anyway.

Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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