From patchwork Sun Mar 19 15:10: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: 66597 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 B9118384B803 for ; Sun, 19 Mar 2023 15:14:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9118384B803 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679238844; bh=qbEat5LJ2mUp6bhK1jdbPJm+yAdnReTesvMhGVXU4bs=; 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=t+xDLp4f7lvMC+0OjJu8OWcMabS87WQH7wjuZgd74act4mpEzAPwFNHGaizEfJ+xo wQ4jxukLyT289rHNsQhByhr3AabKvXnNfjMPbm8ILYzYf+FpH4KIc2FkKjs15UXMcQ 6jkYORsFWcuYGXhzCypRCGn+uy4pXFgtPoh2QQ8c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 0B5D93850849 for ; Sun, 19 Mar 2023 15:11:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B5D93850849 Received: by mail-lf1-x130.google.com with SMTP id h25so355664lfv.6 for ; Sun, 19 Mar 2023 08:11:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679238683; 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=qbEat5LJ2mUp6bhK1jdbPJm+yAdnReTesvMhGVXU4bs=; b=TJ8vrpPejEHQ6QapNmcasJo77PqJAqWz46ycXXiHwwaAsEbUfFFxIh9dQhJZPrbYbt oquetJVCoUmnAV7QQP8jRuvcsASbs0QM/+m08MD9yyRH2ORtqQktAA7DBlmEi6ld3L7H ZUjLCPwsBta1kxXleuMBdxOyC2C3iNmeCUs5eTqUvngKiZIu4D4J1nXCFtG/S0aszdtr Jt7oLMqZ9gSJlBLLbeoKoQajmpbDHcKfhCF3pWa8aBldXON1iS7FKFvHuCeJjriit46j mbTJzvtt7DSBwhAHxzsjKMhzZoSlHNtaCk+GR4/NCEJFTY3kn5vLPscewMhsQWQ/ll2t fHiA== X-Gm-Message-State: AO0yUKXEszlMaMEDw6CwbPv4cgRO5RyRP+EphVu064Y86m11R6poIDfJ xIX/SuogPU0BX11F0PcTMGar9hYsUvREew== X-Google-Smtp-Source: AK7set+bKIWdLvpd84wFUQ/kKys6UpBH3Q5GhYaMSLYaG27JFCKmGwMud44U0ybIuIkQVx4eft0cJQ== X-Received: by 2002:a05:6512:25a:b0:4e9:609f:256d with SMTP id b26-20020a056512025a00b004e9609f256dmr2762211lfo.13.1679238683325; Sun, 19 Mar 2023 08:11:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 08:11:22 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault , Sergey Bugaev Subject: [RFC PATCH glibc 28/34] hurd: Implement _hurd_longjmp_thread_state for x86_64 Date: Sun, 19 Mar 2023 18:10:11 +0300 Message-Id: <20230319151017.531737-29-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 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_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 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_64/longjmp-ts.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/longjmp-ts.c diff --git a/sysdeps/mach/hurd/x86_64/longjmp-ts.c b/sysdeps/mach/hurd/x86_64/longjmp-ts.c new file mode 100644 index 00000000..2c57d26a --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/longjmp-ts.c @@ -0,0 +1,41 @@ +/* Perform a `longjmp' on a Mach thread_state. x86_64 version. + Copyright (C) 1991-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 + + +/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */ + +void +_hurd_longjmp_thread_state (void *state, jmp_buf env, int val) +{ + struct i386_thread_state *ts = state; + + ts->rbx = env[0].__jmpbuf[JB_RBX]; + ts->rbp = env[0].__jmpbuf[JB_RBP]; + ts->r12 = env[0].__jmpbuf[JB_R12]; + ts->r13 = env[0].__jmpbuf[JB_R13]; + ts->r14 = env[0].__jmpbuf[JB_R14]; + ts->r15 = env[0].__jmpbuf[JB_R15]; + ts->ursp = env[0].__jmpbuf[JB_RSP]; + ts->rip = env[0].__jmpbuf[JB_PC]; + ts->rax = val ?: 1; +}