From patchwork Wed Jun 16 01:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461310 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp96615jae; Tue, 15 Jun 2021 18:14:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykV2QR9fbUdbOPRSKgFA4Zg3tjuMDOlJfKj2m+uYEbh0nWM2tBCs+9bzZRhIDoXwOtmhvn X-Received: by 2002:a05:622a:10e:: with SMTP id u14mr2534675qtw.85.1623806076958; Tue, 15 Jun 2021 18:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806076; cv=none; d=google.com; s=arc-20160816; b=Ps1G45ahWu3zJFaBJv6a/Si93IFci+lzJVn9YIxUImhW/f7kDFtaBVoUjyAXO3pHSY 3nB5PTLCHxj1WteqTMBr/6w4anHTazZSaTcDhuDBT5H4LVZ7dvqyF/qesHwj7Dl3Q3XL ybYljvyufthGOGgCdPytHWUmsl/tyJGwR8h7sdesbtdgDAtFCl/0oFDchy+VF/dBWN/2 99MQpe5aAJMF59K/5G4a5AVh3sS4uhgjHdQgifkMVgxKZJSXICxamr1s/KZmF9iy9cWB HTP5eSTWc3owpBHLnb79v2lhxcP5xmAoScbByjaZa+Pp0wUS/l5uGvI1tmJXTUvr0Amp 9RoQ== 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=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=EGROXlsULfM7sUfWvr23dxkiEoQ0hQKvNPNhQt3+pqTjC5GyXj+1l7AMZDwbmir3yR HibqW2tjZnD/Dr/ShVTAguFbIeNm+Ab2QWwR7Ohj5lVDmceHmygLi/e7JJiVkWqjZN7I adCujLOGWO+zN+4naa3erdOvoz/el6+54BYGoo085j54dfhtuawpd5O8X6B4kUt3T0ps 6uF/1eFl+3Othtz6iLFz9XHbmVWw2nSNOjuf5bQg1oGHRZl4DCmB6e6cA/A8ZtUHqdF+ fRI6COx3F9HaZI5RXByPV28v/epCk5wc9XugAIIopbZJjFUiMzSbNJTeT4tvVDtuy+yD oAcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cop90s9p; 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 o1si547248qkp.24.2021.06.15.18.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:14:36 -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=Cop90s9p; 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]:38308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltK8a-0000EG-Di for patch@linaro.org; Tue, 15 Jun 2021 21:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0005BF-Ms for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:15 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:46874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6H-0008Kw-3p for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:15 -0400 Received: by mail-pg1-x533.google.com with SMTP id n12so550380pgs.13 for ; Tue, 15 Jun 2021 18:12:12 -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=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=Cop90s9pWYpPLPVIBKugKe96uw6O0INI6O5CcP/EL2iTFNKsBstuetvJG4dR1F73gu P9vVyf47OGlWh35TZBk9/TRzOtmGCMFbw6wLsMUl50/hNRGCZZ5RdNWtkuz0S3MJxzPK PeAfdwOsbrNJ6sDsk/3xiJA2wtVcmylFVQKSfxM3KHJz1jipMDMayX4qvad58ThzWYXR poKRmOheb5gC3LdjCZq/nutiv6uGIeJjKdpWeSXT0NcFodWw5/6PWznK/3GLOek6CDRn gzjAvtEFrL5u3zYzzAYw/3JDGVkCRGno4R0k96V/k/80fLI9tzU65I5gpgfZYW8s2zr2 sKdQ== 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=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=TL+/YN3uqopAVMv5GnYUBEmffIkY94aFXOrIMNfDxQ+HlTXDJw7zsY5/HH69OL7fbG UGXYc/pGSpqv2ec3mixELQSaeJbzAxHuEgxXxJxZs4wvZgOWu44atly5lBjGxowqhllx k7GaF6X95qiCwOQxIlEPLIYS0B9UJ45dLh1aQkT35HSGe7QkJn20lfM/FuU0W0P/YVRU 7CRQud2UdHHYA7rXnQ9zfo+pu+2ncfoCQ/94JuLeDHd12oZA2cJ7uAFdWM+oPS3XXd1h rUne0W1pCkj27MsVfCRpGVn4dGxhYt0zn9ybQ4zhDRL8uTnVbjHydFfCGx8wUuT2MlE/ Ri6w== X-Gm-Message-State: AOAM530FvSvhj2rPMTbTFmxvcX4JMSGhX1xsoC0N3lmakCQpAMdx3/sw JVntDeraECF0tjNkPdThrbRIeOc6paB1fQ== X-Received: by 2002:a62:e307:0:b029:2f8:d49:7b65 with SMTP id g7-20020a62e3070000b02902f80d497b65mr6998165pfh.48.1623805931806; Tue, 15 Jun 2021 18:12:11 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 02/21] linux-user/aarch64: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:50 -0700 Message-Id: <20210616011209.1446045-3-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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=ham 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-arm@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 rt signal trampoline. Use it when the guest does not use SA_RESTORER. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h index 18013e1b23..7580d99403 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -25,4 +25,6 @@ typedef struct target_sigaltstack { #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* AARCH64_TARGET_SIGNAL_H */ diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 662bcd1c4e..65b84eb04e 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -108,7 +108,6 @@ struct target_rt_sigframe { struct target_rt_frame_record { uint64_t fp; uint64_t lr; - uint32_t tramp[2]; }; static void target_setup_general_frame(struct target_rt_sigframe *sf, @@ -495,15 +494,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { return_addr = ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endian - * regardless of target default or current CPU endianness. - */ - __put_user_e(0xd2801168, &fr->tramp[0], le); - __put_user_e(0xd4000001, &fr->tramp[1], le); - return_addr = frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr = default_rt_sigreturn; } env->xregs[0] = usig; env->xregs[29] = frame_addr + fr_ofs; @@ -576,3 +567,20 @@ long do_sigreturn(CPUARMState *env) { return do_rt_sigreturn(env); } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * mov x8,#__NR_rt_sigreturn; svc #0 + * Since these are instructions they need to be put as little-endian + * regardless of target default or current CPU endianness. + */ + __put_user_e(0xd2801168, &tramp[0], le); + __put_user_e(0xd4000001, &tramp[1], le); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +}