From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id D202A38515E4 for ; Sun, 19 Mar 2023 15:11:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D202A38515E4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x12f.google.com with SMTP id y20so12036802lfj.2 for ; Sun, 19 Mar 2023 08:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679238677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PuNTEMo+upG57twKXDyN8ZRSb+xP1T3ItPyWXtT3Rus=; b=cmWcsMlPujmWmWTo4sKh09mCYsYutStwKSeL+aXfvUzXvdwzhMx5z/1OJ1spNvfkMw KyLvyGD2CCtGm/n3svwnqWycIu1kx8GIljyEDoZHcJyLtqVGOEDcn4Xua+7V94H6UmoE h9+1WQ9VvcCjYW6phKKXJKVd/ZjCdFArMwY18IlXRJVtb68bpyzKPFLEuRV9vqqGFi5R ttECVFu9sm32ClxGsBMWH47MXstOzfdLNPBG5xCknqzwgzHJPSPYoNv/DfdjnnGqpQ6P MSdBTujTOnQZ2HKZCLFWsYiHhc0+2JY6CamBgJA74lzjH+KX8AdcyPupkExzLU3x0uyz ehlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679238677; 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=PuNTEMo+upG57twKXDyN8ZRSb+xP1T3ItPyWXtT3Rus=; b=Ts3EJx5OeZ5ZIxlejMmSu1zGe/isHeyMeCZhfRr/IquIYryro1+7wW/Jk826wvP8nu GjQO0IM+42L96llj/MItylmqlR7eccAbNssv3zMYta+nNcGU/gczJIx6bhFtPGazT4PZ 14TsXuoio4v+PNXyWnJdKvVU57WmEQgbQvXTbfJg2O34xBKbeAPUNJdJmpDJpemRrlhR nFsnpwWhpc23/9tjFs1SQAji3QlKVz4HmWMNKG4/XD9ManowjcJEaf1Jpd5x08c8u7WX Q2mC2oDSiH0NhILqQ06uyNfoR6T4kfK1O0k3fPkUuhkQrNTKNvLW0M4D7zmRzf8HXy/p xbMA== X-Gm-Message-State: AO0yUKWg8yoEAbC0GI6pF4pYqWvHYUpXfgkPYbeireMm4EWitC0q4eJ+ TXpo9wM6TNxrYdE2o5oQKI2L8+e50s46TA== X-Google-Smtp-Source: AK7set+ypsyBla4QepJxtXkZ0rJ5Ekopx7mTNaAFVS5N9Z30OgFfw9Dd4LnnZmDr61/iW6XmDfWKvw== X-Received: by 2002:ac2:5623:0:b0:4db:38a2:e985 with SMTP id b3-20020ac25623000000b004db38a2e985mr5901340lff.62.1679238677241; Sun, 19 Mar 2023 08:11:17 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:577a:76f4:df43:5e66]) by smtp.gmail.com with ESMTPSA id m19-20020ac24253000000b004e90dee5469sm1274089lfl.157.2023.03.19.08.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 08:11:16 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault , Sergey Bugaev Subject: [RFC PATCH glibc 22/34] htl: Implement thread_set_pcsptp for x86_64 Date: Sun, 19 Mar 2023 18:10:05 +0300 Message-Id: <20230319151017.531737-23-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319151017.531737-1-bugaevc@gmail.com> References: <20230319151017.531737-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,KAM_NUMSUBJECT,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 List-Id: Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/htl/pt-machdep.c | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/htl/pt-machdep.c diff --git a/sysdeps/mach/hurd/x86_64/htl/pt-machdep.c b/sysdeps/mach/hurd/x86_64/htl/pt-machdep.c new file mode 100644 index 00000000..69094d3b --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/htl/pt-machdep.c @@ -0,0 +1,73 @@ +/* Machine dependent pthreads code. Hurd/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 + . */ + +#include +#include + +#include +#include +#include +#include +#include + +int +__thread_set_pcsptp (thread_t thread, + int set_ip, void *ip, + int set_sp, void *sp, + int set_tp, void *tp) +{ + error_t err; + struct i386_thread_state state; + struct i386_fsgs_base_state fsgs_state; + mach_msg_type_number_t state_count; + + state_count = i386_THREAD_STATE_COUNT; + + err = __thread_get_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, &state_count); + if (err) + return err; + assert (state_count == i386_THREAD_STATE_COUNT); + + if (set_sp) + state.ursp = (uintptr_t) sp; + if (set_ip) + state.rip = (uintptr_t) ip; + + err = __thread_set_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, i386_THREAD_STATE_COUNT); + if (err) + return err; + + if (set_tp) + { + state_count = i386_FSGS_BASE_STATE_COUNT; + err = __thread_get_state (thread, i386_FSGS_BASE_STATE, + (thread_state_t) &fsgs_state, &state_count); + if (err) + return err; + assert (state_count == i386_FSGS_BASE_STATE_COUNT); + fsgs_state.fs_base = (uintptr_t) tp; + err = __thread_set_state (thread, i386_FSGS_BASE_STATE, + (thread_state_t) &fsgs_state, state_count); + if (err) + return err; + } + + return 0; +} -- 2.39.2