From patchwork Sun Apr 30 03:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Cruz X-Patchwork-Id: 1775331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=f3BloVT3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q8B3Y2ZZwz1ydX for ; Sun, 30 Apr 2023 13:02:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA7C638582BD for ; Sun, 30 Apr 2023 03:02:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA7C638582BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682823760; bh=BijywOK7HZ05Vtr4ONV9rO7EFOKbAkNiWWzfq93V8Js=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=f3BloVT3u5nuneBAPsKseDf0X3Xmu53aV+Yct06qd9ptkXeigMa63NdezzRAAfcPM PvWOh0e0+JkHLwBMAB4woYRVwB273WWWJYgy5W4B8t4RNCwznUZ2zFqdh9CDFol3Xy lnGrt0TOsMwhJmZnBwfa/UQ4HBOBIbIWE8kVCvfk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by sourceware.org (Postfix) with ESMTPS id 9D62D3858D28 for ; Sun, 30 Apr 2023 03:02:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D62D3858D28 Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-b99f374179bso1971987276.3 for ; Sat, 29 Apr 2023 20:02:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682823743; x=1685415743; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BijywOK7HZ05Vtr4ONV9rO7EFOKbAkNiWWzfq93V8Js=; b=Hlp4tq7lCdDpWVaeLLLewD9ofbPWWYiDp+raGF89BErm2uuq4sNt/m/8QW4GyGUlbY ni6AqLhiwm+yJSNjXnaCNj1dlnTb9JNv4eAIPjY5eDZaLoivtVUwSt38FoLE0wsIMzOO hI3KN9wEMbn9k0ILONgGoblm8vEKorrQnnFuq4eYKGpA36VlBShvVDiuxwXZvO3MwdjZ YLE3g2JqE7TxNlywgR41zA8CtTUc3ObJ7EX/p/5Ou+XUUdbgrKnhXefn/e2ZyxiNVFc1 BTr2KlWkCO7avncRtgXsDR8gY7JRBQYG5HynTQAT6WSqF+4t6cbuhKSYc00FIWfD985s L/EQ== X-Gm-Message-State: AC+VfDzwt06XacPYDsepVveeTMIKYH6cEZ0l8bq0UsDBcNw1e3gQgvxZ 5ZYjryBr35lUISCZotuX2MEQEsdzmw== X-Google-Smtp-Source: ACHHUZ4kX/9eXqkslDHytS3nFUl9HtZdNxXClUMSDigz/hHatG1UOcmUGcev3M3p1relDJOq82E0xg== X-Received: by 2002:a25:3246:0:b0:b9d:67a5:a725 with SMTP id y67-20020a253246000000b00b9d67a5a725mr5688831yby.15.1682823742753; Sat, 29 Apr 2023 20:02:22 -0700 (PDT) Received: from jupiter.tail36e24.ts.net ([24.154.253.225]) by smtp.gmail.com with ESMTPSA id s3-20020a254503000000b00b9ba6a3b675sm1448952yba.50.2023.04.29.20.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Apr 2023 20:02:22 -0700 (PDT) Date: Sat, 29 Apr 2023 23:02:20 -0400 To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: samuel.thibault@gnu.org Subject: [PATCH] Make __mach_msg_destroy portable for x86_64 Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Flavio Cruz via Libc-alpha From: Flavio Cruz Reply-To: Flavio Cruz Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" 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);