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

[PATCH] tools: ROUNDUP() related adjustments


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 10 Aug 2021 12:03: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-SenderADCheck; bh=WASWLKZN8MtP8doE1BjpB/TSY8bi/cZ8dhbemMvQ6HA=; b=G5l0PvWmbpsnKKMwxeRlXJ+5IILCKjCw+ada3cdV3qx4+WfFpSnH76k6ikt4DB4J5HLt3VUsCnmQV83+DJ2aTMihyfUC/GX7tMLE1jQJYFof5XEOUL0AtyXVp6lcdd9ZfvBUtm6g3Z11mkIXAXjS5DmF3vWszgsc0KvF9xqn7BPKmgGu9DdIe8Kx7IDEV9hlUCybpDCv3d4MpruRLoYbOoOnHhBxr9jRkhl80Me1MQJKI7+gNU+KJ5XJusSspy50oDsVnzbrXEqZSWnD2kB+OlOGkYmka1kotACWQ9nE2Kx5X4ojq9+7Z3GrKvMT2Jfx9JGeIAiW+DlXA72tLU5mIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/iLAIwb+GW9D65eBS4xuy0Qp2qO4LlLURqPN7zZ2OPFeg/RjXmbNhE5iF0f0lr8JO5N+JHRwnVm4zq4jaNpnOH6laOa9AXXdp8KH04B+4bh3Yi6rwJM5/gTJ6PqmDDR3vCYR/nKysk0ntt6FKVX+uOO+cb3fVXkumVlsK1Vb2UX49+jiI9BoPE3HjDAYGsluS5o+FD6L3DTR9whmZw+NzyaRHsj4+qJ6NkLyDbaIiQVR0UUngTP8jwJn6T5+Qbztj73R+fnY7rb3+QURVUYQeOM3ns0xhEnM9bZ4+IuTXwzpAyu2Bw7b6ux7RIe4mjqSlDG/foFZpATxvZb1uJfFw==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=suse.com;
  • Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Tue, 10 Aug 2021 10:03:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

For one xc_private.h needlessly repeats xen-tools/libs.h's definition.

And then there are two suspicious uses (resulting from the inconsistency
with the respective 2nd parameter of DIV_ROUNDUP()): While the one in
tools/console/daemon/io.c - as per the code comment - intentionally uses
8 as the second argument (meaning to align to a multiple of 256), the
one in alloc_magic_pages_hvm() pretty certainly does not: There the goal
is to align to a uint64_t boundary, for the following module struct to
end up aligned.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xg_dom_x86.c's HVM guest command line handling has further oddities: The
command line gets copied twice, yet in only one case enforcing the
MAX_GUEST_CMDLINE upper bound on the length. The length calculation also
doesn't take this bound into account, despite the assumption that all of
start info fits into a single page. A terminating nul character gets
forced in place in only one of the two cases, too.

--- a/tools/libs/ctrl/xc_private.h
+++ b/tools/libs/ctrl/xc_private.h
@@ -63,8 +63,6 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 #define DECLARE_DOMCTL struct xen_domctl domctl
 #define DECLARE_SYSCTL struct xen_sysctl sysctl
 #define DECLARE_PHYSDEV_OP struct physdev_op physdev_op
--- a/tools/libs/guest/xg_dom_x86.c
+++ b/tools/libs/guest/xg_dom_x86.c
@@ -678,7 +678,7 @@ static int alloc_magic_pages_hvm(struct
     {
         if ( dom->cmdline )
         {
-            dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
+            dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 3);
             start_info_size += dom->cmdline_size;
         }
     }




 


Rackspace

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