From patchwork Sun Dec 3 00:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1870974 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=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SjRrS4thKz1yT0 for ; Sun, 3 Dec 2023 11:05:11 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92307385783F for ; Sun, 3 Dec 2023 00:05:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id CFC1D3858C35 for ; Sun, 3 Dec 2023 00:04:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFC1D3858C35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CFC1D3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701561898; cv=none; b=c4S12yQUIHCRfqqJza3Ztva7VVvi4kDKrQYbtouunEqutNyu3LU58uWy6VrbTF2HMsTCSMRIsRtsN5o2oBOJmsD7dWs7GIWb3amBNlLUY5ewtzo/TyFVp6/oAwEXtZrxnUqj9I4P5WjlOGYioPXmWg/AClsCoiKL78wnI+5XW+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701561898; c=relaxed/simple; bh=XGgiBKR6rGp+AiZiorMs8rxA3jVaAMlIuo7QhL2/YzM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Gh+tYbKmldF/KxLKyYEOTlWaHyKpbum4pMNdm6/d3/eVS2Bm6qiBUEBRQBQ6qbFyQwL8E1ro2KGdtzlXEeuPuDe+YUg9LedPeBER5T3tlCgQor3zwtWYruSqJv4L8ciEXGtPt+B6ptYiTOHRJCTtLo3DguWAKVobG8DtDT8LEWc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 5732420103; Sun, 3 Dec 2023 01:04:55 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9_6qAQDjeIpS; Sun, 3 Dec 2023 01:04:55 +0100 (CET) Received: from begin.home (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 35E9C20101; Sun, 3 Dec 2023 01:04:55 +0100 (CET) Received: from samy by begin.home with local (Exim 4.97) (envelope-from ) id 1r9Zyg-00000005H9K-3g5I; Sun, 03 Dec 2023 01:04:54 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Flavio Cruz , commit-hurd@gnu.org Subject: [hurd, commited] Update code to handle the new ABI for sending inlined port rights. Date: Sun, 3 Dec 2023 01:04:54 +0100 Message-ID: <20231203000454.1257555-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org From: Flavio Cruz For i686, this change is no op but for x86_64 it forces all inlined port rights to be 8 bytes long. Message-ID: <20231124213041.952886-2-flaviocruz@gmail.com> --- hurd/intr-msg.c | 26 ++++++++++++++++++++++++-- mach/msg-destroy.c | 12 +++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/hurd/intr-msg.c b/hurd/intr-msg.c index 24184f827f..d52e90449e 100644 --- a/hurd/intr-msg.c +++ b/hurd/intr-msg.c @@ -199,6 +199,28 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg, __vm_deallocate (__mach_task_self (), (vm_address_t) data, length); } + inline void clean_inlined_ports (mach_port_name_inlined_t *ports) + { + mach_msg_type_number_t i; + switch (name) + { + case MACH_MSG_TYPE_MOVE_SEND: + for (i = 0; i < number; i++) + __mach_port_deallocate (__mach_task_self (), ports[i].name); + if (ty->msgtl_header.msgt_longform) + ty->msgtl_name = MACH_MSG_TYPE_COPY_SEND; + else + ty->msgtl_header.msgt_name = MACH_MSG_TYPE_COPY_SEND; + break; + case MACH_MSG_TYPE_COPY_SEND: + case MACH_MSG_TYPE_MOVE_RECEIVE: + break; + default: + if (MACH_MSG_TYPE_PORT_ANY (name)) + assert (! "unexpected port type in interruptible RPC"); + } + } + char *data; if (ty->msgtl_header.msgt_longform) { @@ -215,11 +237,11 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg, data = (char *) ty + sizeof (mach_msg_type_t); } + /* Calculate length of data in bytes. */ const vm_size_t length = ((number * size) + 7) >> 3; if (ty->msgtl_header.msgt_inline) { - /* Calculate length of data in bytes. */ - clean_ports_and_memory (data, length, 0); + clean_inlined_ports (data); /* Move to the next argument. */ ty = (void *) PTR_ALIGN_UP (data + length, __alignof__ (uintptr_t)); } diff --git a/mach/msg-destroy.c b/mach/msg-destroy.c index 19137baa62..8640c965bd 100644 --- a/mach/msg-destroy.c +++ b/mach/msg-destroy.c @@ -108,11 +108,17 @@ __mach_msg_destroy (mach_msg_header_t *msg) addr = is_inline ? saddr : * (vm_offset_t *) saddr; if (MACH_MSG_TYPE_PORT_ANY(name)) { - mach_port_t *ports = (mach_port_t *) addr; mach_msg_type_number_t i; - for (i = 0; i < number; i++) - mach_msg_destroy_port(*ports++, name); + if (is_inline) { + mach_port_name_inlined_t *inlined_ports = (mach_port_name_inlined_t *)addr; + for (i = 0; i < number; i++) + mach_msg_destroy_port(inlined_ports[i].name, name); + } else { + mach_port_t *ports = (mach_port_t *) addr; + for (i = 0; i < number; i++) + mach_msg_destroy_port(ports[i], name); + } } if (is_inline) {