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

[PATCH] VT-d: prune super-page related capability macros


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 12 Nov 2021 10:51:26 +0100
  • 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=2m/CJIfKmCp42iGpSLQV6mSLgNROe0X3B1g+LDTuDN4=; b=Zh6ANy8esEue9zPNZgUQdB7RL1dzw31u+nEIYKh5TUWmKH24PirUN7jwM8keSrehOSTKpv48C3uMfyT9WpbjyLp7RVAf6dVVMriyXR5pY7lLEsjXpn6iG6Nj8CbU8NBG/QRuuSj0Jf2j9nThxQqtnDPL1KJYiHVwJSJlwSq6YIn3fIcRY7Y9G8CJ4NIq26pqlfuT9qyFobrlNngoYY8GUWygouv4TavLLkA1zErr8O65IvB0CrZpdIuIW3zp/M+HMOJiTgzJzj2MD6FY4uyCTrJTNgHzaASSNsNTYJ9s1y9YCjfDdLQ/udRmmS49xmQtcDQg5b7R3zQfRTDL2C7EIQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H1SNmvVLvsPuESPPC3mfBP3O0yJBRFdV1yA9GuwP14VE5giDW1kwkkcCV0kWqeJW7/XsEq+sKCs3KppPYuzh+1zuA0buAjNW8KH0jP+sCs7/ik+V1RRFg8XOEkfiy0SdNLEBEpcx1yc+j7CK/Oxs36CyrlA+yZtb+V1BOkysHZXxg0c8vnQwUEbQoPSIdupeyIlAcnS11F1UbcnaDSjSo1MRwp1vxNAvy8YQNBv0jmMkySsOkEjXsGqEYMW9XLF7NIG8JksQ37AOTMrFhd3VizELY5qBUHbHthkHUXg+eBd6HY+Wvb6WBNSgDNgGtPa5JWMHustyIizI4Tps808ssw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Fri, 12 Nov 2021 09:51:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

cap_super_page_val() and cap_super_offset() are unused (apart from the
latter using the former). I don't see how cap_super_offset() can be
useful in its current shape: cap_super_page_val()'s result is not an
lvalue and hence can't have its address taken. Plus a user would have
to check the capability register field is non-zero, for
find_first_bit() (or find_first_set_bit(), if suitably corrected) to be
valid in the first place. Yet as per the spec when the field is non-zero
the low bit would always be set, so the result would be independent of
the actual value the field holds.

Further zap cap_sps_512gb() and cap_sps_1tb(). While earlier versions
of the spec had things spelled out that way, the current version marks
the two bits as reserved. And "48-bit offset to page frame" wasn't in
line with 1Tb pages anyway - clearly 256Tb pages would have been meant
here.

Finally properly parenthesize parameter uses in the remaining two
macros.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/iommu.h
+++ b/xen/drivers/passthrough/vtd/iommu.h
@@ -68,13 +68,8 @@
 #define cap_num_fault_regs(c)  ((((c) >> 40) & 0xff) + 1)
 #define cap_pgsel_inv(c)       (((c) >> 39) & 1)
 
-#define cap_super_page_val(c)  (((c) >> 34) & 0xf)
-#define cap_super_offset(c)    (((find_first_bit(&cap_super_page_val(c), 4)) \
-                                 * OFFSET_STRIDE) + 21)
-#define cap_sps_2mb(c)         ((c >> 34) & 1)
-#define cap_sps_1gb(c)         ((c >> 35) & 1)
-#define cap_sps_512gb(c)       ((c >> 36) & 1)
-#define cap_sps_1tb(c)         ((c >> 37) & 1)
+#define cap_sps_2mb(c)         (((c) >> 34) & 1)
+#define cap_sps_1gb(c)         (((c) >> 35) & 1)
 
 #define cap_fault_reg_offset(c)    ((((c) >> 24) & 0x3ff) * 16)
 




 


Rackspace

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