From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 3E64E3858D39 for ; Sun, 30 Apr 2023 22:54:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E64E3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptFwB-0005hd-4F; Sun, 30 Apr 2023 18:54:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=R+3glJl1fSHCxdk7L66RPr9s/NY4LbbNNkmtck+kGow=; b=U17VT2mPHXRNke+7xoGg OwboO+9bod2U+RKVw85EPJ1zP+OEm5bD/GWmI3l9biJ9jzOt30CFK+bgt0PY4aJhYEyo1SZ5G6uWw cnBd+CZUgonMQxMngpv3VFu3iDh5E/9q4Fr3n9x+cnzRcjdXCDJ40Nh69eATWu51FYFVjHUXmhnH9 oPzvQQ0gNLCSpkPOV95b6+pyRParS0bv16x5YKXho6Qs9Gjd/scaVFeX3k81TwpCQTlxYaCD7GgzA Q3sc1O4U5++2HaMq6YxCFXHLX4SokbkgpaOS2Jd/KdcdyboRyyqu6ruOLlteJqaKoZfFNVCj38wpQ JRM3+BIKxIelEw==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptFwA-0001vy-JP; Sun, 30 Apr 2023 18:54:34 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1ptFw4-00EjoG-08; Mon, 01 May 2023 00:54:28 +0200 Date: Mon, 1 May 2023 00:54:27 +0200 From: Samuel Thibault To: Flavio Cruz Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org Subject: Re: [PATCH] Make __mach_msg_destroy portable for x86_64 Message-ID: <20230430225427.afe726obse5p2sxd@begin> Mail-Followup-To: Flavio Cruz , bug-hurd@gnu.org, libc-alpha@sourceware.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Flavio Cruz, le sam. 29 avril 2023 23:02:20 -0400, a ecrit: > We need to align on uintptr_t to make this work for x86_64, > otherwise things will go wrong when RPCs return errors. > --- > mach/msg-destroy.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/mach/msg-destroy.c b/mach/msg-destroy.c > index 7429ecbc2d..0a8b46c895 100644 > --- a/mach/msg-destroy.c > +++ b/mach/msg-destroy.c > @@ -38,6 +38,7 @@ > * > */ > > +#include > #if 1 > #include > #else > @@ -162,9 +163,10 @@ __mach_msg_destroy (mach_msg_header_t *msg) > saddr += sizeof(mach_msg_type_t); > } > > - /* calculate length of data in bytes, rounding up */ > - length = (((((number * size) + 7) >> 3) + sizeof (int) - 1) > - &~ (sizeof (int) - 1)); > + /* Calculate length of data in bytes... */ > + length = ((number * size) + 7) >> 3; > + /* ... and round up using uintptr_t alignment */ > + length = ALIGN_UP (length, __alignof__ (uintptr_t)); > > addr = is_inline ? saddr : * (vm_offset_t *) saddr; > > @@ -177,7 +179,6 @@ __mach_msg_destroy (mach_msg_header_t *msg) > } > > if (is_inline) { > - /* inline data sizes round up to int boundaries */ > saddr += length; > } else { > mach_msg_destroy_memory(addr, length); > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.