From patchwork Sat Feb 18 20:37:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65217 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69FF638493E6 for ; Sat, 18 Feb 2023 20:37:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69FF638493E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752677; bh=kHUQysNl+lRIh2OlRIXwAEDdiPpu/39tpfdW9giRcTY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=SgYrpC35o0OcHXN6G9YaaF4VqvNP/qwkcf3lzMbUh0kpnHtUuD7h19W/SJVbUAiye l9BM83BsI4j67jeZtH8SKQlak/v5AgQbFXDfJJVNsKOOZjXTTlES2MnUwLEVsVZvof SMRQ4tBgfQexFRAuSgzjyRwYnyRXLkauP8q9z2UI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id C1DE33858D38 for ; Sat, 18 Feb 2023 20:37:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1DE33858D38 Received: by mail-lj1-x233.google.com with SMTP id j3so1396325lji.7 for ; Sat, 18 Feb 2023 12:37:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kHUQysNl+lRIh2OlRIXwAEDdiPpu/39tpfdW9giRcTY=; b=3pOCH1SGBStfZYTFdgR0p5gZE81AqLoGaoyKV/CFVSqAbnzKVn8AtzmJb3U+SgSe6R UdOo6JbU5DmzsoM2asI+9b/tdPWKH+IztGKoVbGSe2sqC7VIo4B7iVxCCCOFyMc4eDxY ENquVyHUPG1MxfsTUnrZpA9xJ3BqG2aBv46x4qx6c72FN25S3i5ipor9uJuS1q61/Bmz zW1LMQh4bE2zMeAIibBHAoDmgO1nn7gGUgDZaDSWzL9dy0HNpOVES7Tbh35LwFpOj33L vOKudrZUBf03qaLmfRL/d6g1pUR5oUWJw+xw1KX2huDTDzrkeQJlRDgaeNJKXwr6RxHD YgmQ== X-Gm-Message-State: AO0yUKUmBxyXILNa2bnkO/mXnQ4BIVfkJq7nKlzHh2t6bm983JZBs1M0 S8Q0Agxr5J1u5GQ10lgArYA= X-Google-Smtp-Source: AK7set/Ldrt1D4d6325tXG4G2gJvmI3X2cTUcuvmWuM3pR0NRniAePHGgDV5QA4bkzCmyN+I1NQJuA== X-Received: by 2002:a2e:a808:0:b0:290:4ddb:ed42 with SMTP id l8-20020a2ea808000000b002904ddbed42mr2592265ljq.21.1676752653200; Sat, 18 Feb 2023 12:37:33 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:31 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 1/9] hurd: Move thread state manipulation into _hurd_tls_new () Date: Sat, 18 Feb 2023 23:37:09 +0300 Message-Id: <20230218203717.373211-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This is going to be done differently on x86_64. Signed-off-by: Sergey Bugaev --- mach/setup-thread.c | 18 ++---------------- sysdeps/mach/hurd/i386/tls.h | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/mach/setup-thread.c b/mach/setup-thread.c index 6ce5c13d..ae24a149 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -83,25 +83,11 @@ weak_alias (__mach_setup_thread, mach_setup_thread) kern_return_t __mach_setup_tls (thread_t thread) { - kern_return_t error; - struct machine_thread_state ts; - mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; - tcbhead_t *tcb; - - tcb = _dl_allocate_tls (NULL); + tcbhead_t *tcb = _dl_allocate_tls (NULL); if (tcb == NULL) return KERN_RESOURCE_SHORTAGE; - if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, - (natural_t *) &ts, &tssize)) - return error; - assert (tssize == MACHINE_THREAD_STATE_COUNT); - - _hurd_tls_new (thread, &ts, tcb); - - error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, - (natural_t *) &ts, tssize); - return error; + return _hurd_tls_new (thread, tcb); } weak_alias (__mach_setup_tls, mach_setup_tls) diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index 590abd47..0f8dd241 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -378,16 +378,25 @@ _hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state) } static inline kern_return_t __attribute__ ((unused)) -_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) +_hurd_tls_new (thread_t child, tcbhead_t *tcb) { + error_t err; + /* Fetch the target thread's state. */ + struct i386_thread_state state; + mach_msg_type_number_t state_count = i386_THREAD_STATE_COUNT; + err = __thread_get_state (child, i386_REGS_SEGS_STATE, + (thread_state_t) &state, + &state_count); + if (err) + return err; + assert (state_count == i386_THREAD_STATE_COUNT); /* Fetch the selector set by _hurd_tls_init. */ int sel; asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); - if (sel == state->ds) /* _hurd_tls_init was never called. */ + if (sel == state.ds) /* _hurd_tls_init was never called. */ return 0; HURD_TLS_DESC_DECL (desc, tcb); - error_t err; tcb->tcb = tcb; tcb->self = child; @@ -397,8 +406,14 @@ _hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) else err = __i386_set_gdt (child, &sel, desc); - state->gs = sel; - return err; + if (err) + return err; + + /* Update gs to use the selector. */ + state.gs = sel; + return __thread_set_state (child, i386_REGS_SEGS_STATE, + (thread_state_t) &state, + state_count); } /* Global scope switch support. */ From patchwork Sat Feb 18 20:37:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65218 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 738F33864811 for ; Sat, 18 Feb 2023 20:38:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 738F33864811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752683; bh=s4UMt8rlCiCLWxn3gD+S6Da5U6kuYj2AgpmO+IqxvoQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yhZk4gRaGkapwi5pVy6sTk3+JjXMYOtUWhhuzyoN39llZxDARKXx9MtnyIRz7Jr/Q 15J0ljmT2xTAdODhAALlImayy/X97oT/DQ/0EazjHRzGhp/0BdECZ3o8BEzpOtmIR9 BIceg+/h4u0aYombJzv+nkvwGfLtAmrF4r+SWwdE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 218753858D3C for ; Sat, 18 Feb 2023 20:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 218753858D3C Received: by mail-lj1-x22e.google.com with SMTP id by19so1258070ljb.10 for ; Sat, 18 Feb 2023 12:37:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s4UMt8rlCiCLWxn3gD+S6Da5U6kuYj2AgpmO+IqxvoQ=; b=rGRXdKnmRWcM76ypiDn9oNI94vhoiRy2GdWHk0IBfZZv/rOzcAkuJNoz/UWm6V8e1Q ODApTzOT50z6qYjm6g2QlKiwrbDBxOlw2xRZTXjyWySJNuSSZRRPsc7NQWPdqUNa777/ Q04QtvYfJKm45gUB7sh9diJqPx2wa8QnhooREJEbGvU89WYR8UC4XFKu2HmIPpd0pW0W OEPC6v85/kXSCTe51KHBa8V3ZdRT/+iYDpuL3Ttm6euEiT76WIz3Jd6N9+iQ8a1vSEta XY7bdNtib/iHW+4wc4MqH2iwnAOitE3owO8VOZG3lAysO3Ec1PBD6DN6qPyNi3Dzeg8p 045g== X-Gm-Message-State: AO0yUKVW9rkeWjY+z7celJ13UzsYjTDst/V4WHESpElhHTiAI8hU8yZF H7Yetm5noGEl/B4Bsa3+SsYgWSawb2U8lQ== X-Google-Smtp-Source: AK7set+FeSYIVjZJmZH4dLRGWJBKPdhRvgyVdgv73gwLLftU8xKiRWPgqVpe81zD856tC+iCZ50CIQ== X-Received: by 2002:a2e:8e89:0:b0:293:153b:1c74 with SMTP id z9-20020a2e8e89000000b00293153b1c74mr1545297ljk.29.1676752654537; Sat, 18 Feb 2023 12:37:34 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:34 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 2/9] hurd: Use proper integer types Date: Sat, 18 Feb 2023 23:37:10 +0300 Message-Id: <20230218203717.373211-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Fix a few more cases of build errors caused by mismatched types. This is a continuation of f4315054b46d5e58b44a709a51943fb73f846afb. Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 6 +++--- sysdeps/mach/hurd/getpriority.c | 6 +++--- sysdeps/mach/hurd/if_index.c | 2 +- sysdeps/mach/hurd/ifreq.c | 2 +- sysdeps/mach/hurd/readdir64.c | 4 +++- sysdeps/mach/hurd/readdir64_r.c | 4 +++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 56e8e614..ea79ffb5 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -430,8 +430,8 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread, receive completes immediately or aborts. */ abort_thread (ss, state, reply); - if (state->basic.PC >= (natural_t) &_hurd_intr_rpc_msg_about_to - && state->basic.PC < (natural_t) &_hurd_intr_rpc_msg_in_trap) + if (state->basic.PC >= (uintptr_t) &_hurd_intr_rpc_msg_about_to + && state->basic.PC < (uintptr_t) &_hurd_intr_rpc_msg_in_trap) { /* The thread is about to do the RPC, but hasn't yet entered mach_msg. Mutate the thread's state so it knows not to try @@ -442,7 +442,7 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread, state->basic.SYSRETURN = MACH_SEND_INTERRUPTED; *state_change = 1; } - else if (state->basic.PC == (natural_t) &_hurd_intr_rpc_msg_in_trap + else if (state->basic.PC == (uintptr_t) &_hurd_intr_rpc_msg_in_trap /* The thread was blocked in the system call. After thread_abort, the return value register indicates what state the RPC was in when interrupted. */ diff --git a/sysdeps/mach/hurd/getpriority.c b/sysdeps/mach/hurd/getpriority.c index 9869c2f5..45b32215 100644 --- a/sysdeps/mach/hurd/getpriority.c +++ b/sysdeps/mach/hurd/getpriority.c @@ -30,7 +30,7 @@ __getpriority (enum __priority_which which, id_t who) int maxpri = INT_MIN; struct procinfo *pip; /* Just for sizeof. */ int pibuf[sizeof *pip + 2 * sizeof (pip->threadinfos[0])], *pi = pibuf; - size_t pisize = sizeof pibuf / sizeof pibuf[0]; + mach_msg_type_number_t pisize = sizeof pibuf / sizeof pibuf[0]; error_t getonepriority (pid_t pid, struct procinfo *pip) { @@ -39,9 +39,9 @@ __getpriority (enum __priority_which which, id_t who) else { int *oldpi = pi; - size_t oldpisize = pisize; + mach_msg_type_number_t oldpisize = pisize; char *tw = 0; - size_t twsz = 0; + mach_msg_type_number_t twsz = 0; int flags = PI_FETCH_TASKINFO; onerr = __USEPORT (PROC, __proc_getprocinfo (port, pid, &flags, &pi, &pisize, diff --git a/sysdeps/mach/hurd/if_index.c b/sysdeps/mach/hurd/if_index.c index a4472269..c8ad7e72 100644 --- a/sysdeps/mach/hurd/if_index.c +++ b/sysdeps/mach/hurd/if_index.c @@ -99,7 +99,7 @@ __if_nameindex (void) nifs = 0; else { - size_t len = sizeof data; + mach_msg_type_number_t len = sizeof data; err = __pfinet_siocgifconf (server, -1, &ifc.ifc_buf, &len); if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED) { diff --git a/sysdeps/mach/hurd/ifreq.c b/sysdeps/mach/hurd/ifreq.c index ef210c32..394d020c 100644 --- a/sysdeps/mach/hurd/ifreq.c +++ b/sysdeps/mach/hurd/ifreq.c @@ -37,7 +37,7 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd) else { char *data = NULL; - size_t len = 0; + mach_msg_type_number_t len = 0; error_t err = __pfinet_siocgifconf (server, -1, &data, &len); if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED) { diff --git a/sysdeps/mach/hurd/readdir64.c b/sysdeps/mach/hurd/readdir64.c index 47829d9e..cf98bbb1 100644 --- a/sysdeps/mach/hurd/readdir64.c +++ b/sysdeps/mach/hurd/readdir64.c @@ -43,12 +43,13 @@ __readdir64 (DIR *dirp) /* We've emptied out our buffer. Refill it. */ char *data = dirp->__data; + mach_msg_type_number_t data_size = dirp->__size; int nentries; error_t err; if (err = HURD_FD_PORT_USE (dirp->__fd, __dir_readdir (port, - &data, &dirp->__size, + &data, &data_size, dirp->__entry_ptr, -1, 0, &nentries))) { @@ -57,6 +58,7 @@ __readdir64 (DIR *dirp) break; } + dirp->__size = data_size; /* DATA now corresponds to entry index DIRP->__entry_ptr. */ dirp->__entry_data = dirp->__entry_ptr; diff --git a/sysdeps/mach/hurd/readdir64_r.c b/sysdeps/mach/hurd/readdir64_r.c index 7e438aaf..4f4252c2 100644 --- a/sysdeps/mach/hurd/readdir64_r.c +++ b/sysdeps/mach/hurd/readdir64_r.c @@ -45,11 +45,12 @@ __readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result) /* We've emptied out our buffer. Refill it. */ char *data = dirp->__data; + mach_msg_type_number_t data_size = dirp->__size; int nentries; if (err = HURD_FD_PORT_USE (dirp->__fd, __dir_readdir (port, - &data, &dirp->__size, + &data, &data_size, dirp->__entry_ptr, -1, 0, &nentries))) { @@ -58,6 +59,7 @@ __readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result) break; } + dirp->__size = data_size; /* DATA now corresponds to entry index DIRP->__entry_ptr. */ dirp->__entry_data = dirp->__entry_ptr; From patchwork Sat Feb 18 20:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65219 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1589C3881D0B for ; Sat, 18 Feb 2023 20:38:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1589C3881D0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752688; bh=zzKFMDhwlQY0ot1PZjl4B1IWgo/TsIFdvWREdCaiktM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=KsEQou4RdATainrz2lwWaoazESReqnKgsxSTuJ7MPlIbkDOK4ux/G3K8xAz8Obvbs /qsdFy90D0JMbHcGUIMy3LaW8z6d8DMqkqAL0SBtZ06F2jWy4DQapERpQdSgi3mGC1 bG7IVqVyL1up+8cF854QeLtpmo/d9CN0KN2oL/PM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 20B35385841E for ; Sat, 18 Feb 2023 20:37:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20B35385841E Received: by mail-lj1-x22d.google.com with SMTP id z10so1348376ljc.1 for ; Sat, 18 Feb 2023 12:37:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zzKFMDhwlQY0ot1PZjl4B1IWgo/TsIFdvWREdCaiktM=; b=cfm1PgBnRETFVhbSqHaw42mYWGfmOJAzLr4kIg0kcmbpcLFv5Lh9d2GDPd3Oz3X/0k 7WxBfMmfXb3Au2XUVGHnvL10tMBZoJ+52xyrWZJvovvoYVWkdfept5ihfSUPphfwuchV ylLfaM7iNkrnqqNfNhcQtZ62mqEyzRqLWyKEiRYeSATSdlSa8nNl2w3yGcdxkW0D7zps XQ2ne4bGsi8zHLpn4CZvjbtMMOu7Ooqi4aySiyobFqjGNs5zcFnz/j1zmDSldLb8Gi/A YKrAS9ALqMVcMfN18cNl1lYx0SG7sCLfBmS3Hnww5EWL84P+j1kr+uw0Jjgz1/lRreao Y1nw== X-Gm-Message-State: AO0yUKWdpnShA2ZlrtVj45mXpovsNZjvDxKGlh+GEOoQGyX1iP3uXSX+ JGA1A2IoVqyqH6E8306QT0Y= X-Google-Smtp-Source: AK7set/PK5eZcEEZ0+S8WtO1sHd9XrO9ItfSETytUy/IQOn/3wKY5mAQPRyA+Ukq2BYAtjO3SA4JBw== X-Received: by 2002:a2e:7005:0:b0:295:5305:855f with SMTP id l5-20020a2e7005000000b002955305855fmr1177009ljc.53.1676752656600; Sat, 18 Feb 2023 12:37:36 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:36 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 3/9] hurd: Fix xattr function return type Date: Sat, 18 Feb 2023 23:37:11 +0300 Message-Id: <20230218203717.373211-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" They all return int, not size_t. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/fsetxattr.c | 2 +- sysdeps/mach/hurd/lremovexattr.c | 2 +- sysdeps/mach/hurd/lsetxattr.c | 2 +- sysdeps/mach/hurd/removexattr.c | 2 +- sysdeps/mach/hurd/setxattr.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sysdeps/mach/hurd/fsetxattr.c b/sysdeps/mach/hurd/fsetxattr.c index 71ee7599..dcc48fa0 100644 --- a/sysdeps/mach/hurd/fsetxattr.c +++ b/sysdeps/mach/hurd/fsetxattr.c @@ -22,7 +22,7 @@ #include #include -ssize_t +int fsetxattr (int fd, const char *name, const void *value, size_t size, int flags) { error_t err; diff --git a/sysdeps/mach/hurd/lremovexattr.c b/sysdeps/mach/hurd/lremovexattr.c index 1d761e2d..cb6a1f8f 100644 --- a/sysdeps/mach/hurd/lremovexattr.c +++ b/sysdeps/mach/hurd/lremovexattr.c @@ -22,7 +22,7 @@ #include #include -ssize_t +int lremovexattr (const char *path, const char *name) { error_t err; diff --git a/sysdeps/mach/hurd/lsetxattr.c b/sysdeps/mach/hurd/lsetxattr.c index 56c138dc..4e1e2de2 100644 --- a/sysdeps/mach/hurd/lsetxattr.c +++ b/sysdeps/mach/hurd/lsetxattr.c @@ -22,7 +22,7 @@ #include #include -ssize_t +int lsetxattr (const char *path, const char *name, const void *value, size_t size, int flags) { diff --git a/sysdeps/mach/hurd/removexattr.c b/sysdeps/mach/hurd/removexattr.c index 128d0e01..fedc5370 100644 --- a/sysdeps/mach/hurd/removexattr.c +++ b/sysdeps/mach/hurd/removexattr.c @@ -21,7 +21,7 @@ #include #include -ssize_t +int removexattr (const char *path, const char *name) { error_t err; diff --git a/sysdeps/mach/hurd/setxattr.c b/sysdeps/mach/hurd/setxattr.c index be3b172b..ba6047cd 100644 --- a/sysdeps/mach/hurd/setxattr.c +++ b/sysdeps/mach/hurd/setxattr.c @@ -21,7 +21,7 @@ #include #include -ssize_t +int setxattr (const char *path, const char *name, const void *value, size_t size, int flags) { From patchwork Sat Feb 18 20:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65222 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69640388B694 for ; Sat, 18 Feb 2023 20:38:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69640388B694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752730; bh=7ZydTjn134Q8ZRBebYPHK1Ynbrg85B7593+qnrbUMh0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GLSDDxz9gBptADdG/kivMeBF6SsIvurPxurQ+j1x+ybzHuQ21SScIdc3uIu34LWfK gtdYtbXhsBWY38aRQbgwOeruitsaJRm6bEEgSYruvigaFuEQZR7zcKQ4AlVOD+ak8g SO9FV1BRq6cfio3J55huVVClsgEd1wr3hrIfZFWU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id EE9D13857BB2 for ; Sat, 18 Feb 2023 20:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE9D13857BB2 Received: by mail-lj1-x22b.google.com with SMTP id h23so1349583ljb.4 for ; Sat, 18 Feb 2023 12:37:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7ZydTjn134Q8ZRBebYPHK1Ynbrg85B7593+qnrbUMh0=; b=KsiivXb74OArhg7dQB7cu3oWDv1ujbxb8ApzO+Osdnfp6NlBBj4iSzYHm80cre9z1Q /9Ef1UuN5v03MxpDcGSqmh3lSJ5rLgx5gdIOopYfSw81aSIDxEam2NuKJZhHALo40WX+ xC5D8o+W7DX+UcqgR9v0mRB6nRGF5H4+1TYBtTDPhfcAJgoFdPKRIXtenVq5NdgQtOqZ RBHpQnlJmTdMMfF0gzJz+P2RSyaCC/xtamgnceC5rVFyFFP6MlMaW3qCw+gnWOtV0i/Q zBk7JXnSt3X2bGgQdzUyAbbsooct0vSX2YfgDy4X6GzDV/IK8sRVpIV9Zm2m93D8ovR+ X9Aw== X-Gm-Message-State: AO0yUKUcr2b+Jy8LFUt9dogxykS1PRJsCmDxpdMK2mOU6MNYb+hP5ItU E6zmVlPV7JTui8SocmAjVrc= X-Google-Smtp-Source: AK7set/IxR3x0wHm7yfoSId90/jvFyqt5wqI6nIY9C0/6szO71Xn3bjmB2vOLm9tRRApLPELDHaLSg== X-Received: by 2002:a2e:8e6f:0:b0:293:2159:751f with SMTP id t15-20020a2e8e6f000000b002932159751fmr1565524ljk.9.1676752657967; Sat, 18 Feb 2023 12:37:37 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:37 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 4/9] hurd: Make timer_t pointer-sized Date: Sat, 18 Feb 2023 23:37:12 +0300 Message-Id: <20230218203717.373211-5-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This ensures that a timer_t value can be cast to struct timer_node * and back. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/bits/typesizes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index 725a0cb1..7b95bb0b 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -54,7 +54,7 @@ #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE -#define __TIMER_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE __UWORD_TYPE #define __BLKSIZE_T_TYPE __SLONGWORD_TYPE #define __FSID_T_TYPE __UQUAD_TYPE #define __SSIZE_T_TYPE __SWORD_TYPE From patchwork Sat Feb 18 20:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65220 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9ADE6382E699 for ; Sat, 18 Feb 2023 20:38:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9ADE6382E699 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752696; bh=jlY8s5Momk93VyyBPAA+QkUCa9KqCf3ZVCnVTO9Uyq4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=m2o6uPCj7hkCexEysjZ4SQhBE7+duvs8WmU78/UT6ua4AOrkfWyAvcLgzVPeSoI7d 6n3PKkQ/KeFn4ajZvkxqyzwDdGhyl/2DNYhBMXV5SEn/IOnO+P0HCCwihVUahiK3zs fAhr41LACRaFFOawL3+aHZNZkesHvWWGMprvPcCc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 703363857835 for ; Sat, 18 Feb 2023 20:37:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 703363857835 Received: by mail-lj1-x232.google.com with SMTP id w17so1438497ljw.13 for ; Sat, 18 Feb 2023 12:37:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jlY8s5Momk93VyyBPAA+QkUCa9KqCf3ZVCnVTO9Uyq4=; b=bQmLwpp1MonWEi8bLJYqVRItQ8RtzfzjzDX36ovxdRiaj7GaEjWlXR3fzXkD5G9Sm+ 2SLhgOcgBQt+QQm/sdzwaITH/dHQXK+Hh8ADhIxK6Ti8lQIsLJvzJDxXgIW/GxBvFWmP XUlKPDok18RseIFIXynUPXUNYpwipP5yDeVKvLL/Wj1wGL6llMHUcoIFFBdI16u2zV2o FZF379jVMZw2F/Y7UtHCCAQESaMb+EXI/xFXFoDJdewU2PY6ohIuZp52t/vyMqPwGXTK 5YvgXVkSXyjVGZorrwySapHM+cZH3GSEyxPib4iUdjmkuaDxUd9jbfB4osZAWucOoeBS szHA== X-Gm-Message-State: AO0yUKWoNPrOZ+03pVv9L+IjP1IodxW6209jAAsAJnvv6cubPR7mt2yL YFgg8zPxU1WsL4fhXdqDwuo= X-Google-Smtp-Source: AK7set+tmOaMaIRtiA7TNRBHv7NIbTv9tslI8JgETh8dR+EnANWZVicBSnIMBfCvkgOoyuf6vb93qg== X-Received: by 2002:a2e:a238:0:b0:294:70b7:fd65 with SMTP id i24-20020a2ea238000000b0029470b7fd65mr1988768ljm.30.1676752659047; Sat, 18 Feb 2023 12:37:39 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:38 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 5/9] hurd: Simplify init-first.c a bit Date: Sat, 18 Feb 2023 23:37:13 +0300 Message-Id: <20230218203717.373211-6-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" And make it a bit more 64-bit ready. This is in preparation to moving this file into x86/ Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/i386/init-first.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index 94c94651..a558da16 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -195,7 +195,7 @@ init (int *data) /* Call `init1' (above) with the user code as the return address, and the argument data immediately above that on the stack. */ - int usercode; + void *usercode, **ret_address; void call_init1 (void); @@ -206,10 +206,11 @@ init (int *data) recognize that this read operation may alias the following write operation, and thus is free to reorder the two, clobbering the original return address. */ - usercode = *((int *) __builtin_frame_address (0) + 1); + ret_address = (void **) __builtin_frame_address (0) + 1; + usercode = *ret_address; /* GCC 4.4.6 also wants us to force loading USERCODE already here. */ asm volatile ("# %0" : : "X" (usercode)); - *((void **) __builtin_frame_address (0) + 1) = &call_init1; + *ret_address = &call_init1; /* Force USERCODE into %eax and &init1 into %ecx, which are not restored by function return. */ asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1)); @@ -223,19 +224,9 @@ init (int *data) /* The return address of `init' above, was redirected to here, so at this point our stack is unwound and callers' registers restored. Only %ecx and %eax are call-clobbered and thus still have the - values we set just above. Fetch from there the new stack pointer - we will run on, and jmp to the run-time address of `init1'; when it - returns, it will run the user code with the argument data at the - top of the stack. */ -asm ("switch_stacks:\n" - " movl %eax, %esp\n" - " jmp *%ecx"); - -/* As in the stack-switching case, at this point our stack is unwound - and callers' registers restored, and only %ecx and %eax communicate - values from the lines above. In this case we have stashed in %eax - the user code return address. Push it on the top of the stack so - it acts as init1's return address, and then jump there. */ + values we set just above. We have stashed in %eax the user code + return address. Push it on the top of the stack so it acts as + init1's return address, and then jump there. */ asm ("call_init1:\n" " push %eax\n" " jmp *%ecx\n"); From patchwork Sat Feb 18 20:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65221 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4CC53889E23 for ; Sat, 18 Feb 2023 20:38:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4CC53889E23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752727; bh=PZBvDveOgz89+9l6nW/zV0+NWazzuo38cjCulrm1nz4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=eP1FGfuiQiwGfDgfWfWKL5w6JAkIjqw+auC9lTxH52eSWttf/zkyAC6yM1K/ZOTL4 oxrxVo9NIdokgnBjpWRTQCbr2pI6UXd9upUkEPPx98j85m98+RUTMfjBxb8G26TMAu SfUbwiSuyYNVYTk+vsYr1Ue8DBVoS59Ah0AM1fyo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 35176385781F for ; Sat, 18 Feb 2023 20:37:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35176385781F Received: by mail-lj1-x22c.google.com with SMTP id r10so1439921ljd.11 for ; Sat, 18 Feb 2023 12:37:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PZBvDveOgz89+9l6nW/zV0+NWazzuo38cjCulrm1nz4=; b=7QnWT82PMMo/4ARzsdmKI52auuQbL4yhICUIkutRCieLOKIM29KHtJCG73NrimIaLb MAc1od8I4PcPrIFPIqvvWIjlNVG/ggDAYYV4wlMEP7rRDHsq1qsdc117ub0VoDTlYHHx adHPmy/VVGhbyk7rLLcdu4ibz2kPVMKLiP2A5jdA85O0gZakfxPQ6c3f5KnuDcVMMQPi u27cYafMKIjrhhrFxjF/UoZOnj7QHugEedZbfBnUwsNyt2Yi1G3Md2JoTOyxhShiU/Qb E/QN8FQ26dZ0XBtubE1wBlYbIjEOS+DjebBQkQPa2/8nfiENlejpx5QI4Wg+LbdkGe6a Xs5w== X-Gm-Message-State: AO0yUKVkpoSd2vQuTHfAVnQD20DJ4ECAPVs0SrZ95kuWnsU9n7UnYhlw sfMNVKk7J2U4xJRq8A95Lf0frDaAV2KNVQ== X-Google-Smtp-Source: AK7set9TpRzh56TJ2NkMXp4xxKxyX+0snHbpT8wK0spxiAN4yXZhpGVs/L3dhQ4VEpodWFojj48+Kg== X-Received: by 2002:a2e:b557:0:b0:293:4ffa:a697 with SMTP id a23-20020a2eb557000000b002934ffaa697mr1195452ljn.16.1676752660776; Sat, 18 Feb 2023 12:37:40 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:39 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 6/9] mach: Use PAGE_SIZE Date: Sat, 18 Feb 2023 23:37:14 +0300 Message-Id: <20230218203717.373211-7-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The PAGE_SIZE from the Mach headers statically defines the machine's page size. There's no need to query it dynamically; furthermore, the implementation of the vm_statistics () RPC unconditionally fills in pagesize = PAGE_SIZE; Not doing the extra RPC shaves off 2 RPCs from the start-up of every process! Signed-off-by: Sergey Bugaev --- mach/mach_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mach/mach_init.c b/mach/mach_init.c index a0d9f7f5..42b9cacf 100644 --- a/mach/mach_init.c +++ b/mach/mach_init.c @@ -17,6 +17,7 @@ #include #include +#include #include mach_port_t __mach_task_self_; @@ -38,7 +39,10 @@ __mach_init (void) __mach_host_self_ = (__mach_host_self) (); __mig_init (0); -#ifdef HAVE_HOST_PAGE_SIZE +#ifdef PAGE_SIZE + __vm_page_size = PAGE_SIZE; + (void) err; +#elif defined (HAVE_HOST_PAGE_SIZE) if (err = __host_page_size (__mach_host_self (), &__vm_page_size)) _exit (err); #else From patchwork Sat Feb 18 20:37:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65223 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEA5A383FB8D for ; Sat, 18 Feb 2023 20:39:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEA5A383FB8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752763; bh=tr3GiOLSPHhnoS46QIfw1VZNQ/rESRBBVBRMhvWQec0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=oPzzTCR+0rgM3Qbq7cGPBmAucbolWy9Puyphyp7Xtc714y5nCX/H3JodN0A2mRx/e R9ixIRNWsT6CvT6ZUkusdLSFmS4mCrnTrf1Knc2IVAV+yWrJqorcZpbtnIOVuIZCdS wIS5TH/prpmY/Ww01HO1L2PMyc++tGHgwnQZtX6M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 83D393858D38 for ; Sat, 18 Feb 2023 20:37:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83D393858D38 Received: by mail-lj1-x233.google.com with SMTP id j3so1396485lji.7 for ; Sat, 18 Feb 2023 12:37:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tr3GiOLSPHhnoS46QIfw1VZNQ/rESRBBVBRMhvWQec0=; b=p+yomVv407ESV3dkg0XouyELBWR6129BSYRc/itA2Uu7iAgPwrTg8nTpjjHBryF6Jq Lfny4buUf4+KkJ35zoCtT9LsW5mfcq4JWX6q03R3K6+iBQi2bMhd1wIAo/MtLp1szOEO 8A/l7cke49rVkOOhzURUN/FyxD6sjMQv+TSYsDVuSu14BS5RdZaauurzoRk9np2mc6Gn EYZ5px0HJOyiD2Y/MdXDTM/23HHCARbcf5HpKcYoI7wUbju8WGH3NNDtQnKh28RPxaWn st6NwguOZ0f8nGHEj6PDgou0Twue8uNVA+fMf9z86raPrFHPxjDpjcr3NPl8St3YoN6p mLZQ== X-Gm-Message-State: AO0yUKWtrkmtyl4tkXG2RwN3RHGtAG16PxuPmOGpmHEotNu5eiJgCzdj haILaUGYMUS1keXMlztPruLFpqpzQ2ik5A== X-Google-Smtp-Source: AK7set9TBGDDiNG+iIFj98nnw7yEnqGVocCYy4uejD7C5tVtFo9ilVKDRr1zSkuoOiwI8U82CxoCzw== X-Received: by 2002:a2e:b5d8:0:b0:290:6a6f:48d1 with SMTP id g24-20020a2eb5d8000000b002906a6f48d1mr1503402ljn.43.1676752662073; Sat, 18 Feb 2023 12:37:42 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:41 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 Date: Sat, 18 Feb 2023 23:37:15 +0300 Message-Id: <20230218203717.373211-8-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.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 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/{i386 => x86}/init-first.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename sysdeps/mach/hurd/{i386 => x86}/init-first.c (96%) diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/x86/init-first.c similarity index 96% rename from sysdeps/mach/hurd/i386/init-first.c rename to sysdeps/mach/hurd/x86/init-first.c index a558da16..75ac1ff2 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/x86/init-first.c @@ -227,10 +227,15 @@ init (int *data) values we set just above. We have stashed in %eax the user code return address. Push it on the top of the stack so it acts as init1's return address, and then jump there. */ +#ifdef __x86_64__ +asm ("call_init1:\n" + " push %rax\n" + " jmp *%rcx\n"); +#else asm ("call_init1:\n" " push %eax\n" " jmp *%ecx\n"); - +#endif /* Do the first essential initializations that must precede all else. */ static inline void @@ -242,7 +247,7 @@ first_init (void) #ifndef SHARED /* In the static case, we need to set up TLS early so that the stack protection guard can be read at gs:0x14 by the gcc-generated snippets. */ - _hurd_tls_init(&__init1_tcbhead); + _hurd_tls_init (&__init1_tcbhead); asm ("movw %%gs,%w0" : "=m" (__init1_desc)); #endif @@ -300,7 +305,7 @@ _hurd_stack_setup (void) { /* If we use ``__builtin_frame_address (0) + 2'' here, GCC gets confused. */ - init ((int *) &argc); + init (&argc); } /* Push the user return address after the argument data, and then @@ -308,9 +313,15 @@ _hurd_stack_setup (void) caller had called `doinit1' with the argument data already on the stack. */ *--data = caller; +# ifdef __x86_64__ + asm volatile ("movq %0, %%rsp\n" /* Switch to new outermost stack. */ + "movq $0, %%rbp\n" /* Clear outermost frame pointer. */ + "jmp *%1" : : "r" (data), "r" (&doinit1)); +# else asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ "jmp *%1" : : "r" (data), "r" (&doinit1)); +# endif /* NOTREACHED */ } From patchwork Sat Feb 18 20:37:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65225 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E8A13855580 for ; Sat, 18 Feb 2023 20:39:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E8A13855580 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752772; bh=M8hSFKdBo/+nGNkBf/kSELCVlqKEZwymUBpT1y3S6Rg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Iu3k+dk7Gj+VG1dk0z61An9BAULfZpQWL8xQbNxI4ZtWOE/6WOtZOh2Dt+cRH+P6+ LjLwodnREnwO1wKuPiNObTNKo7NAMOP42O4XqF9+TU+Iq4Pe3Ka4mQUVdaMep4kjqg Tub8m+xY9j7a1CMUWyQrT00uSQJhTfYUcAbPH0tU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id CC531385B51D for ; Sat, 18 Feb 2023 20:37:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC531385B51D Received: by mail-lj1-x22d.google.com with SMTP id z10so1348490ljc.1 for ; Sat, 18 Feb 2023 12:37:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M8hSFKdBo/+nGNkBf/kSELCVlqKEZwymUBpT1y3S6Rg=; b=bqP9vY3iiFp+JpgLBr/c0I78WhhuVyQ+XXDBO5OfA30/ZsZDrJLLJMMoKbMFHPUwsY 0zwsvjIvXB40amrNb8llaXcF+0x6p9xPo7ukWiEu1yciAq7iOXBJ43TbohiN8uCZeLBc Rdw85CgaFEC0PQ6ZNqNJTGSQhWiCRyUxI+GWk7vcKx04IgDMrkIt+9ZE7+E1bd6hrJgd FWQHFeyyzaAOgvPgjJRL2iLRCn3Vi+dKOqDuhCm++glvLtuFF+GcsBe3IplCmpINkkFi 37a5OLxBSWsMqMJjgkWx/ndhKVd6iRAFvbqlV2SW+l9IkhqxpckWs7A6uFARGI+oxTqD jw9A== X-Gm-Message-State: AO0yUKXIruMcCf9WYC5zJrHBkzGKSO/bd1xBGupIB67jHtZBaYiQ0h9M /w2iG0/8TdDyaF4dVHxs7IM= X-Google-Smtp-Source: AK7set/9dQgRCdb4YfpZvFqmWJ62a390RMhrGSxHkj6gkERwzlVnfLeMx5BB08TRRBEYTOl+mPTJNw== X-Received: by 2002:a2e:b88b:0:b0:294:5a6c:5221 with SMTP id r11-20020a2eb88b000000b002945a6c5221mr3329529ljp.19.1676752663381; Sat, 18 Feb 2023 12:37:43 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:42 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 8/9 gnumach] Add i386_fsgs_base_state Date: Sat, 18 Feb 2023 23:37:16 +0300 Message-Id: <20230218203717.373211-9-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- i386/include/mach/i386/thread_status.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/i386/include/mach/i386/thread_status.h b/i386/include/mach/i386/thread_status.h index 3de22ff3..32e40686 100644 --- a/i386/include/mach/i386/thread_status.h +++ b/i386/include/mach/i386/thread_status.h @@ -57,6 +57,7 @@ #define i386_V86_ASSIST_STATE 4 #define i386_REGS_SEGS_STATE 5 #define i386_DEBUG_STATE 6 +#define i386_FSGS_BASE_STATE 7 /* * This structure is used for both @@ -179,4 +180,11 @@ struct i386_debug_state { #define i386_DEBUG_STATE_COUNT \ (sizeof(struct i386_debug_state)/sizeof(unsigned int)) +struct i386_fsgs_base_state { + unsigned long fs_base; + unsigned long gs_base; +}; +#define i386_FSGS_BASE_STATE_COUNT \ + (sizeof(struct i386_fsgs_base_state)/sizeof(unsigned int)) + #endif /* _MACH_I386_THREAD_STATUS_H_ */ From patchwork Sat Feb 18 20:37:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65224 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07D543888C7C for ; Sat, 18 Feb 2023 20:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07D543888C7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676752770; bh=87A600v7GDrduEQWMkCtpkQOQF9mlg4+ESrinobReN0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=UiZeQuEjB84bXgmj791Kn7KfwnT3TCDlDJpAXAon8Vky5ZEQOkt1TyPhgN48ZIIOk pbEs+CbxDGQ9KZyqhDh10Si0m2caIQnxwl3eKQeEmR5AKaSZpMaBacqen3YHN5Mlsf yn5WkxnJc54x7rvgERxrRBlujzjV4eN2iqOoMzvk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 46F1F385841A for ; Sat, 18 Feb 2023 20:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46F1F385841A Received: by mail-lf1-x129.google.com with SMTP id k20so574868lfv.10 for ; Sat, 18 Feb 2023 12:37:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=87A600v7GDrduEQWMkCtpkQOQF9mlg4+ESrinobReN0=; b=U8vZ4vda0OtRVMoX5T5Qf5Mj/L0Qluy2YwDw0Us1K1JU232jI1wKhFaObDj5eDeGmv jYj+nF7LWPFm+QOYpCmyh+ZBR2tx0Rf3u+3VdrEGp4mma4WYrlLfFIybDEfSZEkxsQBt GLqoe1Kb5IsDOoEgRp5Aq2nLdFmNe5npF3KHw941um0hYFBr5+3HKUz4MXmJfVkOzwlj dcRzivBTyaalQ4GY9pxw0XQHOVovTesxcmTQ1S0MlEMikJL8J8VOG2MVPo1s3/feCP3C 9fuvR/T838oYMAUOdN0BoyBzCXw0Re56b/BTQOCgpmIAhHtlla1M0mpS0W2Dxs3HP5CF qusg== X-Gm-Message-State: AO0yUKUuhTOxn2GJODB2AM/wEgVotBK0DERB7gRfdsZQb2G4dqSHDpS5 gbLyNJ2DqI6DQmZNDxTREYqLLx4f+zFs0A== X-Google-Smtp-Source: AK7set+0pvq0bja0lg7nev0OfkZCot6Ojug4VtpAdRi3rwG1gDBk8Uc5EqUZgpt8Vt+cZIdY+PJVyg== X-Received: by 2002:a19:ad04:0:b0:4d8:56f2:6054 with SMTP id t4-20020a19ad04000000b004d856f26054mr778134lfc.41.1676752664599; Sat, 18 Feb 2023 12:37:44 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:44 -0800 (PST) To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?utf-8?q?Fl=C3=A1vio_Cruz?= , Sergey Bugaev Subject: [RFC PATCH 9/9] hurd, htl: Add some more x86_64-specific code Date: Sat, 18 Feb 2023 23:37:17 +0300 Message-Id: <20230218203717.373211-10-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86/init-first.c | 14 +- sysdeps/mach/hurd/x86_64/tls.h | 257 ++++++++++++++++++++ sysdeps/mach/x86_64/thread_state.h | 51 ++++ sysdeps/x86_64/htl/bits/pthreadtypes-arch.h | 36 +++ sysdeps/x86_64/htl/pt-machdep.h | 28 +++ 5 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 sysdeps/mach/hurd/x86_64/tls.h create mode 100644 sysdeps/mach/x86_64/thread_state.h create mode 100644 sysdeps/x86_64/htl/bits/pthreadtypes-arch.h create mode 100644 sysdeps/x86_64/htl/pt-machdep.h diff --git a/sysdeps/mach/hurd/x86/init-first.c b/sysdeps/mach/hurd/x86/init-first.c index 75ac1ff2..d4e6a4d6 100644 --- a/sysdeps/mach/hurd/x86/init-first.c +++ b/sysdeps/mach/hurd/x86/init-first.c @@ -43,8 +43,14 @@ extern char **__libc_argv attribute_hidden; extern char **_dl_argv; #ifndef SHARED -unsigned short __init1_desc; static tcbhead_t __init1_tcbhead; +# ifndef __x86_64__ +unsigned short __init1_desc; +# endif +#endif + +#ifdef __x86_64__ +unsigned char __libc_tls_initialized; #endif /* Things that want to be run before _hurd_init or much anything else. @@ -248,7 +254,13 @@ first_init (void) /* In the static case, we need to set up TLS early so that the stack protection guard can be read at gs:0x14 by the gcc-generated snippets. */ _hurd_tls_init (&__init1_tcbhead); + + /* Make sure __LIBC_NO_TLS () keeps evaluating to 1. */ +# ifdef __x86_64__ + __libc_tls_initialized = 0; +# else asm ("movw %%gs,%w0" : "=m" (__init1_desc)); +# endif #endif RUN_RELHOOK (_hurd_preinit_hook, ()); diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h new file mode 100644 index 00000000..644dcb1a --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/tls.h @@ -0,0 +1,257 @@ +/* Definitions for thread-local data handling. Hurd/x86_64 version. + Copyright (C) 2003-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _X86_64_TLS_H +#define _X86_64_TLS_H + + +/* Some things really need not be machine-dependent. */ +#include + + +#ifndef __ASSEMBLER__ +# include +# include +# include +# include + +/* Type of the TCB. */ +typedef struct +{ + void *tcb; /* Points to this structure. */ + dtv_t *dtv; /* Vector of pointers to TLS data. */ + thread_t self; /* This thread's control port. */ + int __glibc_padding1; + int multiple_threads; + int gscope_flag; + uintptr_t sysinfo; + uintptr_t stack_guard; + uintptr_t pointer_guard; + long __glibc_padding2[2]; + int private_futex; + int __glibc_padding3; + /* Reservation of some values for the TM ABI. */ + void *__private_tm[4]; + /* GCC split stack support. */ + void *__private_ss; + /* The lowest address of shadow stack. */ + unsigned long long int ssp_base; + + /* Keep these fields last, so offsets of fields above can continue being + compatible with the x86_64 NPTL version. */ + mach_port_t reply_port; /* This thread's reply port. */ + struct hurd_sigstate *_hurd_sigstate; + + /* Used by the exception handling implementation in the dynamic loader. */ + struct rtld_catch *rtld_catch; +} tcbhead_t; + +/* GCC generates %fs:0x28 to access the stack guard. */ +_Static_assert (offsetof (tcbhead_t, stack_guard) == 0x28, + "stack guard offset"); +/* libgcc uses %fs:0x70 to access the split stack pointer. */ +_Static_assert (offsetof (tcbhead_t, __private_ss) == 0x70, + "split stack pointer offset"); + +extern unsigned char __libc_tls_initialized; +# define __LIBC_NO_TLS() __builtin_expect (!__libc_tls_initialized, 0) + +/* The TCB can have any size and the memory following the address the + thread pointer points to is unspecified. Allocate the TCB there. */ +# define TLS_TCB_AT_TP 1 +# define TLS_DTV_AT_TP 0 + +# define TCB_ALIGNMENT 64 + + +# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr)) + +# if __GNUC_PREREQ (6, 0) + +# define THREAD_SELF \ + (*(tcbhead_t * __seg_fs *) offsetof (tcbhead_t, tcb)) +# define THREAD_GETMEM(descr, member) \ + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member)) +# define THREAD_SETMEM(descr, member, value) \ + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member) = value) + +# else + +# define THREAD_SELF \ + ({ tcbhead_t *__tcb; \ + asm ("movq %%fs:%c1,%0" : "=r" (__tcb) \ + : "i" (offsetof (tcbhead_t, tcb))); \ + __tcb; }) + +/* Read member of the thread descriptor directly. */ +# define THREAD_GETMEM(descr, member) \ + ({ __typeof (descr->member) __value; \ + _Static_assert (sizeof (__value) == 1 \ + || sizeof (__value) == 4 \ + || sizeof (__value) == 8, \ + "size of per-thread data"); \ + if (sizeof (__value) == 1) \ + asm volatile ("movb %%fs:%P2,%b0" \ + : "=q" (__value) \ + : "0" (0), "i" (offsetof (tcbhead_t, member))); \ + else if (sizeof (__value) == 4) \ + asm volatile ("movl %%fs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (tcbhead_t, member))); \ + else /* 8 */ \ + asm volatile ("movq %%fs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (tcbhead_t, member))); \ + __value; }) + +/* Write member of the thread descriptor directly. */ +# define THREAD_SETMEM(descr, member, value) \ + ({ \ + _Static_assert (sizeof (descr->member) == 1 \ + || sizeof (descr->member) == 4 \ + || sizeof (descr->member) == 8, \ + "size of per-thread data"); \ + if (sizeof (descr->member) == 1) \ + asm volatile ("movb %b0,%%fs:%P1" : \ + : "iq" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + else if (sizeof (descr->member) == 4) \ + asm volatile ("movl %0,%%fs:%P1" : \ + : "ir" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + else /* 8 */ \ + asm volatile ("movq %0,%%fs:%P1" : \ + : "ir" (value), \ + "i" (offsetof (tcbhead_t, member))); \ + }) +# endif /* __GNUC_PREREQ (6, 0) */ + +/* Return the TCB address of a thread given its state. + Note: this is expensive. */ +static inline tcbhead_t * __attribute__ ((unused)) +THREAD_TCB (thread_t thread, + const void *all_state __attribute__ ((unused))) +{ + error_t err; + /* Fetch the target thread's state. */ + struct i386_fsgs_base_state state; + mach_msg_type_number_t state_count = i386_FSGS_BASE_STATE_COUNT; + err = __thread_get_state (thread, i386_FSGS_BASE_STATE, + (thread_state_t) &state, + &state_count); + assert_perror (err); + assert (state_count == i386_FSGS_BASE_STATE_COUNT); + return (tcbhead_t *) state.fs_base; +} + +/* Set the stack guard field in TCB head. */ +# define THREAD_SET_STACK_GUARD(value) \ + THREAD_SETMEM (THREAD_SELF, stack_guard, value) +# define THREAD_COPY_STACK_GUARD(descr) \ + ((descr)->stack_guard \ + = THREAD_GETMEM (THREAD_SELF, stack_guard)) + +/* Set the pointer guard field in the TCB head. */ +# define THREAD_SET_POINTER_GUARD(value) \ + THREAD_SETMEM (THREAD_SELF, pointer_guard, value) +# define THREAD_COPY_POINTER_GUARD(descr) \ + ((descr)->pointer_guard \ + = THREAD_GETMEM (THREAD_SELF, pointer_guard)) + +/* Install new dtv for current thread. */ +# define INSTALL_NEW_DTV(dtvp) THREAD_SETMEM (THREAD_SELF, dtv, dtvp) + +/* Return the address of the dtv for the current thread. */ +# define THREAD_DTV() THREAD_GETMEM (THREAD_SELF, dtv) + +/* Set up TLS in the new thread of a fork child, copying from the original. */ +static inline kern_return_t __attribute__ ((unused)) +_hurd_tls_fork (thread_t child, thread_t orig, + void *machine_state __attribute__ ((unused))) +{ + error_t err; + struct i386_fsgs_base_state state; + mach_msg_type_number_t state_count = i386_FSGS_BASE_STATE_COUNT; + err = __thread_get_state (orig, i386_FSGS_BASE_STATE, + (thread_state_t) &state, + &state_count); + if (err) + return err; + assert (state_count == i386_FSGS_BASE_STATE_COUNT); + + return __thread_set_state (child, i386_FSGS_BASE_STATE, + (thread_state_t) &state, + state_count); +} + +static inline kern_return_t __attribute__ ((unused)) +_hurd_tls_new (thread_t child, tcbhead_t *tcb) +{ + struct i386_fsgs_base_state state; + + tcb->tcb = tcb; + tcb->self = child; + + /* Install the TCB address into FS base. */ + state.fs_base = (uintptr_t) tcb; + state.gs_base = 0; + return __thread_set_state (child, i386_FSGS_BASE_STATE, + (thread_state_t) &state, + i386_FSGS_BASE_STATE_COUNT); +} + +static inline bool __attribute__ ((unused)) +_hurd_tls_init (tcbhead_t *tcb) +{ + error_t err; + thread_t self = __mach_thread_self (); + + /* We always at least start the sigthread anyway. */ + tcb->multiple_threads = 1; + + err = _hurd_tls_new (self, tcb); + __mach_port_deallocate (__mach_task_self (), self); + __libc_tls_initialized = 1; + return err == 0; +} + + +/* Global scope switch support. */ +# define THREAD_GSCOPE_FLAG_UNUSED 0 +# define THREAD_GSCOPE_FLAG_USED 1 +# define THREAD_GSCOPE_FLAG_WAIT 2 + +# define THREAD_GSCOPE_SET_FLAG() \ + THREAD_SETMEM (THREAD_SELF, gscope_flag, THREAD_GSCOPE_FLAG_USED) + +# define THREAD_GSCOPE_RESET_FLAG() \ + ({ \ + int __flag; \ + asm volatile ("xchgl %0, %%fs:%P1" \ + : "=r" (__flag) \ + : "i" (offsetof (tcbhead_t, gscope_flag)), \ + "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ + if (__flag == THREAD_GSCOPE_FLAG_WAIT) \ + lll_wake (THREAD_SELF->gscope_flag, LLL_PRIVATE); \ + }) + + + +#endif /* __ASSEMBLER__ */ +#endif /* x86_64/tls.h */ diff --git a/sysdeps/mach/x86_64/thread_state.h b/sysdeps/mach/x86_64/thread_state.h new file mode 100644 index 00000000..d8c8889f --- /dev/null +++ b/sysdeps/mach/x86_64/thread_state.h @@ -0,0 +1,51 @@ +/* Mach thread state definitions for machine-independent code. x86_64 version. + Copyright (C) 1994-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MACH_X86_64_THREAD_STATE_H +#define _MACH_X86_64_THREAD_STATE_H 1 + +#include + +#define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE +#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT + +#define machine_thread_state i386_thread_state + +#define PC rip +#define SP ursp +#define SYSRETURN rax + +#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \ + asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \ + asm ("mov %%ds, %w0" : "=q" ((ts)->ds)); \ + asm ("mov %%es, %w0" : "=q" ((ts)->es)); \ + asm ("mov %%fs, %w0" : "=q" ((ts)->fs)); \ + asm ("mov %%gs, %w0" : "=q" ((ts)->gs)); \ +} while(0) + +struct machine_thread_all_state + { + int set; /* Mask of bits (1 << FLAVOR). */ + struct i386_thread_state basic; + struct i386_float_state fpu; + }; + +#include + +#endif /* mach/x86_64/thread_state.h */ diff --git a/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h b/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h new file mode 100644 index 00000000..1d402cc6 --- /dev/null +++ b/sysdeps/x86_64/htl/bits/pthreadtypes-arch.h @@ -0,0 +1,36 @@ +/* Machine-specific pthread type layouts. Hurd x86_64 version. + Copyright (C) 2002-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_PTHREADTYPES_ARCH_H +#define _BITS_PTHREADTYPES_ARCH_H 1 + +#define __SIZEOF_PTHREAD_MUTEX_T 32 +#define __SIZEOF_PTHREAD_ATTR_T 48 +#define __SIZEOF_PTHREAD_RWLOCK_T 48 +#define __SIZEOF_PTHREAD_BARRIER_T 40 +#define __SIZEOF_PTHREAD_MUTEXATTR_T 16 +#define __SIZEOF_PTHREAD_COND_T 40 +#define __SIZEOF_PTHREAD_CONDATTR_T 8 +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 4 +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +#define __SIZEOF_PTHREAD_ONCE_T 8 + +#define __LOCK_ALIGNMENT +#define __ONCE_ALIGNMENT + +#endif /* bits/pthreadtypes.h */ diff --git a/sysdeps/x86_64/htl/pt-machdep.h b/sysdeps/x86_64/htl/pt-machdep.h new file mode 100644 index 00000000..2e2846fa --- /dev/null +++ b/sysdeps/x86_64/htl/pt-machdep.h @@ -0,0 +1,28 @@ +/* Machine dependent pthreads internal defenitions. x86_64 version. + Copyright (C) 2000-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _PT_MACHDEP_H +#define _PT_MACHDEP_H 1 + +struct pthread_mcontext +{ + void *pc; + void *sp; +}; + +#endif /* pt-machdep.h */