From patchwork Tue Jan 23 14:47:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 125527 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1804422ljf; Tue, 23 Jan 2018 06:57:24 -0800 (PST) X-Google-Smtp-Source: AH8x2263EBwyp48g23FS5xyn768tgQ3KgC3iFSeYCCh9pzMIgXUzJwkqOqhBWuqsVrapG2trnWFW X-Received: by 10.129.182.31 with SMTP id u31mr2665335ywh.22.1516719444066; Tue, 23 Jan 2018 06:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516719444; cv=none; d=google.com; s=arc-20160816; b=TsnMO1f0fpLdrpYMiXgqP7WUJQ7R3xiT97PhUQ2uZMZgoOhqfv9ntW1PzzF6boYOeP dsmtwrYKmj8Dp/QZSkDnapr8HrO7LcB5Vh5QNIl2YlcRqBASLngfnG8sfP3ZGk7WHjPI wyLhKiSb9PiQKdSMMKzWIHc/68VEapkcvRrF++SuXhXN2MbuTj3DS7sMj7WXvbAtqNxl xIy64/5UkteVUuw2YCC0F0W+r5IrxtsYWyj8mb429fcAwQHkQoqr9O0LGMsDhVYhv+DZ tyUsjjyAQ+8ZByyIS+aFHFNUzrmOpM+7p4epbjrb4zuBrlp3SvE2W3kHC0M3e/TqvP7+ T3pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=gyPJx5Ctnxv4pveFzRH7oNE0Bz4F3exoW81Y/Oq0v4o=; b=cIA5/pycfL4c24o4iXMzbGpk4Sdf4NfixzH8XM42yDDO5rYOlXv/DpIyfFVUMw2R/2 ITKFKa1HW8If1iZ4zWJk0d0umI5RPvx0eAfUlX5ZVoygb067JNfhUpoPN7Vn3T6ip8Sp s4ce0HCFyJZu9pTSvHplbvmrcQp7MvMVCInU6oK11kFpbAZ57B6d4Q96bL4KpoLZWtg1 FUEAREwuvOx48s6HECAoHMboWvxh6ziEZqa2+o3r+G60MZ6xOklJ14mHnH43ksd1/4q1 ZCX9+YeQZSGeuJGvIuR97oSr2oiDU2qCtyTFZ1lOZpxjJobRDrJg0WsaU3xIrHf21+Kv tehA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i127si4008502ywb.662.2018.01.23.06.57.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 23 Jan 2018 06:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:33646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee00p-0006IX-Eh for patch@linaro.org; Tue, 23 Jan 2018 09:57:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edzs1-00075X-W8 for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edzrx-0002Ls-RO for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:18 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:49163) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edzrx-0002JK-FQ for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:13 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MEEHY-1ebq8R21Ps-00FUuk; Tue, 23 Jan 2018 15:48:11 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 23 Jan 2018 15:47:58 +0100 Message-Id: <20180123144807.5618-5-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180123144807.5618-1-laurent@vivier.eu> References: <20180123144807.5618-1-laurent@vivier.eu> X-Provags-ID: V03:K0:U236OxjhNZQP9sV1QSy+To9wxSYlGkkO6HXxMdRcj9GSzWb95zb PIamQUy2y29m3Fd/XT7zfsFuIhxVb3Yn0WBEKYTTe1gmb02wHdk1rWMUnytYBP+GRHNlHZx PgiPG/lkubsR6zYTnE3XzpP9/Jabr1C3XH8FaBxffjaYuqHcprTfLAXiqOTM19GxA/bOCWx f3N+eJLdYjtPFtBnEXOGw== X-UI-Out-Filterresults: notjunk:1; V01:K0:dtu6pRj9CSg=:bPThIwxMkrBJvN3OBa4ey9 wGzHFgTVBP6ff9E+1t1Z1Di4v+VoYbXMbOFxoLNJ+K9XpFWc3bEpUstQFMFoAy/554qq7lNdS CqShdWweYK2M06tBbUJbv+xVp9f7yFswQ/7HYZ8jvM7uG3kNjSsxwTf+NUGueIWdNwrq+khL3 vFnBksyjuftiJIxBnTVNEyI6ohy9nRIV0l6PTK3BzeHDf/eEVnx445dXI30sJmVPcCIj8rWTn nZLZjwpIKWpMFcOGuF3lx8yG5yP5RQUnU7ZWMJ9LFSasAVdJE27M7MsDrgfqvqyOos3FAMaTE gz1u8e5SeQ0DE/CMEgtiRX4uLZ9Q39HHFCVhyOMK7LD7Ne6ehzNUx0sqWnUikkRH7lmNGfG6J PIveNG77zDusgG7aNTEEPFYqLVC4FMR9shv+MiO/FeFvmIDLYmEgk1zKltI6fcX6MdLdFiWWA uH1hfOrjB/j2lQzAKuIh0uPm2PcUnhVmejs/CKEA2CfI0R3pEP2ZRd06MBc41Nulap53d3V5n CJmtowsBHRAIfHDYKxcYpi+OtnJNTFu3eGAS+rYw13Rd/O4Dox9D5WF3GFHrwe5YnYJ6UJquZ PtiNmWTK/hVNj9tBRBynnZsUJVX7y6Wj+fA4/cUuY2QkAGPXoWOH2IxtPJF4Su9lslLAGhRkd ihFghO+SGsBHiMr2f+xx0zse+ab6u1Pycj/c4GdCl/SxxGcTJBEBK0JNx/nXBuAqMdyyGGoBs 4eTmZKAmiuOwjyljRX1NoHPSfXXiFgBqJoJynQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.75 Subject: [Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The Linux struct cmsghdr is already guaranteed to be sufficiently aligned that CMSG_ALIGN(sizeof struct cmsghdr) is always equal to sizeof struct cmsghdr. Stop doing the unnecessary alignment arithmetic for host and target cmsghdr. This follows kernel commit 1ff8cebf49ed9e9ca2 and brings our TARGET_CMSG_* macros back into line with the kernel ones, as well as making them easier to understand. Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <1513345976-22958-3-git-send-email-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- linux-user/syscall_defs.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.14.3 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a1b9772a85..39553c81b6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1692,7 +1692,7 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh, void *target_data = TARGET_CMSG_DATA(target_cmsg); int len = tswapal(target_cmsg->cmsg_len) - - TARGET_CMSG_ALIGN(sizeof (struct target_cmsghdr)); + - sizeof(struct target_cmsghdr); space += CMSG_SPACE(len); if (space > msgh->msg_controllen) { @@ -1773,7 +1773,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, void *data = CMSG_DATA(cmsg); void *target_data = TARGET_CMSG_DATA(target_cmsg); - int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr)); + int len = cmsg->cmsg_len - sizeof(struct cmsghdr); int tgt_len, tgt_space; /* We never copy a half-header but may copy half-data; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index bec3680b94..a35c52a60a 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -303,9 +303,9 @@ struct target_cmsghdr { __target_cmsg_nxthdr(mhdr, cmsg, cmsg_start) #define TARGET_CMSG_ALIGN(len) (((len) + sizeof (abi_long) - 1) \ & (size_t) ~(sizeof (abi_long) - 1)) -#define TARGET_CMSG_SPACE(len) (TARGET_CMSG_ALIGN (len) \ - + TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr))) -#define TARGET_CMSG_LEN(len) (TARGET_CMSG_ALIGN (sizeof (struct target_cmsghdr)) + (len)) +#define TARGET_CMSG_SPACE(len) (sizeof(struct target_cmsghdr) + \ + TARGET_CMSG_ALIGN(len)) +#define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len)) static __inline__ struct target_cmsghdr * __target_cmsg_nxthdr(struct target_msghdr *__mhdr,