From patchwork Wed Jun 16 01:12:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461325 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp103838jae; Tue, 15 Jun 2021 18:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxftbho28TPCnYAv2KKkkLbPZA5HPUqr6L2h2Ss04Y5CCPn5GirGa/i4u6rqxTIp6Hwdpdo X-Received: by 2002:ac8:5d87:: with SMTP id d7mr2546669qtx.172.1623806843347; Tue, 15 Jun 2021 18:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806843; cv=none; d=google.com; s=arc-20160816; b=gbB5s6zul9v74wxHg7zOKmQiKGf5GQCwsquQ6iE+qkSi//l2ylsN2KlqSpELbgx207 NdOWRkpcdpXQW8BKK7CeAuSlhlfFn9mjXfbOxJmsJ0jdNwYq/thDPmwyqZWXRSJM9NUD vNsJjML8dhV3HsXPYCSSBKK8Ne+/Qjitob6e14HlWTDinVKDgbFhM4pyvnKQYSrgF6SE 1y15/Z+im5RfhxjzvpxiJY83pYus/wbHbB5WkuTVQ/2HpJTWyuGEoqOCDL1aKBuYWKip zigsp3xqUTzfXO1v/aa1anYoXM4nQAbFOk+uoYZRM6BW6LpLNZpKMYTczbLhTGk4asyr TOfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=mFu/uIzyvFQ5jHVd4Ks/dMMZ58vFrWCFd0AYPO8b8wDqUU7ggisknLJpfz3z0EzCFI Q6FASxYyXdkKuGW8KNbagikRkw2uOTXfvlD3noEK9MZyFrQ6s54FnVKPnPu73yy5HHzu T+hTI3CPDN5QYQpKNSub9EXWgJRYrqDunhBlWivFbnLV3r4dxq+a5egrgf9FFJmHgWTU NhNzfVCzNWezz/5IpJUUjvCtpax0FMddQXaB9Z3/BQnzfE8H8iQ0ztJOgmVz57OhC3fX tWnYpdoshjn+30Z+s4MC8Gq1K5FxPVNZpa7mFt6yLBQXHXPcLWipOI2qT3TGPMbkN9te mdbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIho14J9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q7si533873qtr.101.2021.06.15.18.27.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIho14J9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKKw-0004W4-Oz for patch@linaro.org; Tue, 15 Jun 2021 21:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6Y-0005eY-MH for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:31 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:56178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0008Tw-Tu for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:28 -0400 Received: by mail-pj1-x1031.google.com with SMTP id k7so708770pjf.5 for ; Tue, 15 Jun 2021 18:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=xIho14J9VZccF0xdHT0ReBhRINvgIEW8gbG06REgcdgBcmlXtBECTT/OvCS56DsKvT xlFC3Nlrh3rxB70ojUTr1m9mcNXEqKFNIRUeeUZfyriIPv9BkS5BgWcYHUmDwSF0y6mV 3m1iHnhlH1Dz0S7ThASFke1yb+KLKMOzSb1HqTKqaDzbVRO12MpCWuFwgBp3s+3Pxd+4 cnTlhgvccA4bgzsz+SrHgcIrgf+YAsJBR3HFPtJkd3TN8K4fmEj5NtPZa5VcB/Ygr5UV JOuYqfRJW+UwNswS0tev6W3kITjkNA54HNf/5L+8MTIFdRN9uZWzh86HK7Xa0ixP5S7O cwhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=uadCWGheuJ8IXubte+h2hxzvQDF1zgX9JTt2nGygrrQYmuOwgd1okLBCbuObsiix69 /SWAGy3ElxhM6l9YS4OmUCGqN/vCnUT1X505uO/lJf80KGXKv7idIqQJuyALFgJIUncF CLKfXpevSaVY+Ojmt6MgoIoqPdNJ7oOKDjQfgBTRCXOYslv6/oCftA6y6KnubuAbgztI ECPa8G0Hhylg+Qycr8AJDq4zmtwp5H/9Q47M63Q2xQUTCJzfQiMkbpUeYpil/HSYfNE8 VCNhlwLjUwYJ1p5p7IL4UgLvJlkJeZeu9YqVyQhg5JymDinomllk0X7BZrG+PBqBWy/Z r3EA== X-Gm-Message-State: AOAM530EWDyFZ/WH+DeYOKBIiXAoiDQtK+4cmWYnwso1d94qcsJ5khpr B2Y7b8pFeFXfH+GRFAn55BJtbDavGtxDRA== X-Received: by 2002:a17:90b:305:: with SMTP id ay5mr7819478pjb.0.1623805941588; Tue, 15 Jun 2021 18:12:21 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 17/21] linux-user/s390x: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:05 -0700 Message-Id: <20210616011209.1446045-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: qemu-s390x@nongnu.org Signed-off-by: Richard Henderson --- linux-user/s390x/target_signal.h | 2 ++ linux-user/s390x/signal.c | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index bbfc464d44..64f5f42201 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -19,4 +19,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* S390X_TARGET_SIGNAL_H */ diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index ef136dae33..806c09f921 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -67,7 +67,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; #define TARGET_UC_VXRS 2 @@ -84,7 +83,6 @@ struct target_ucontext { typedef struct { uint8_t callee_used_stack[__SIGNAL_FRAMESIZE]; - uint16_t retcode; struct target_siginfo info; struct target_ucontext uc; } rt_sigframe; @@ -200,9 +198,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer = default_sigreturn; } /* Set up registers for signal handler */ @@ -253,9 +249,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer = default_rt_sigreturn; } /* Create siginfo on the signal stack. */ @@ -377,3 +371,17 @@ long do_rt_sigreturn(CPUS390XState *env) unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn = sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 4); +}