From patchwork Wed Sep 29 13:05:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514836 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:4087:0:0:0:0 with SMTP id m7csp15511jam; Wed, 29 Sep 2021 06:17:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+PFQEzDBmUaIuQlid19/K4ezp7ARqOgikBk1TBHul299VTgbsmHwowrA1a2bLFNnih+++ X-Received: by 2002:a17:907:9703:: with SMTP id jg3mr13977909ejc.449.1632921421214; Wed, 29 Sep 2021 06:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632921421; cv=none; d=google.com; s=arc-20160816; b=U9uZjcv9nDFhl0/Nk714FUxnyU5fSD3FUpgtPpqebC6uQMJUiYBI52Hd47K1cVmESU SyEWvr0ZdgZBiEAyhbqHhnq81UjFjpZySPet4xfCPNi9eopiA7yPxbsoTEojGYOJHaQE K7zhDrGl9pElXFg8JgoNG5II+ftqMfQtIS5TFLLOl6ADYNgC4kewJMW1lrTER8JpBW7P gOW2AsxFbJFpr8Xz2LpFS/JS7+/KAeQN7DZBn5qN/MT6lXmUt+V7YYUaLp+4ml/P46Lv ahSGrrr0XkEi7wAZ9oy8NJK45JyxDh6yktvkgdkfIG157FNcWydRET/+iXZd3E0LXlY7 RHDg== 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=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=BWjCHce7QydNj+Hun+ROBXkOYcrpjDr+a3EnlFVsYXvT1WHXd63nJ/OXvxDiix8l/2 WJOF5ulkc5BU+BCbz/jj6eQ+YnR5V5V+CE21pcaxJzufxPyygQLCnBTh/mvczOudm4cP 2qHnJnYBVtMtfce+mUV/JczdBkC4W6MTfjrMI1CgS9UMAWzdBiC8uU8yb3slrb5bsUFe YrX3J5xSup5tqk/BEf2rWEYOscT1NAZByAPa1Xm3cJWCnV6PsKiMH0BreME2KQBAnZDW /AW6+wlboPrna8B45mlu14lBT6rMfSVsI7Ga7uysF8LF385/R0OnDCbBnhnIvh9KG/Dr dTYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tuAHU8Y8; 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 n7si2824081ejl.237.2021.09.29.06.17.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Sep 2021 06:17:01 -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=tuAHU8Y8; 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]:52362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVZSG-0003sk-5q for patch@linaro.org; Wed, 29 Sep 2021 09:17:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVZHt-0006Rx-Th for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:17 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]:35573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVZHr-00068U-QO for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:17 -0400 Received: by mail-ot1-x330.google.com with SMTP id 77-20020a9d0ed3000000b00546e10e6699so2768920otj.2 for ; Wed, 29 Sep 2021 06:06:15 -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=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=tuAHU8Y8jFPwSKMFL94UOY8tJclHW50/+CblAqou+4w9yhbRWrUfML/Idu4vqbEM/F UYeDFUmMHbfjatDz4K56P8PWFeAuADV0ByAxNcTikuZZf5xsa8iZZeFTRUOFl+mKFCah iiFf61+STLR37pf7QYtiQgU/TtXm52QtKWj11xvV6DByJKRaodULkcesyi7QFALWHVMo tbSlxjhtfALqR7eBC+wQ5DpqatGqNrg1V+EF46eOrMdEIKlUcBrWP2vUMvSI8qwnxJvJ FwtaOfQF+aMBtkbnn+qIXWmSkOIcEtNBRhkGVWgcsIlIo6HH3ZJfOkqyhRRLqg9h131p 7kdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=deY+Y5vD4Cc7OYVYn0dnYPMAy8xwSX5d9ZgyZ0MpZJYxUV4+9iCj1mMOMGgCv+bxEB 3ZGX5a5TD4lFhYUkJBOenbW9B6CDNeidYP36bRARzCUe58J5RIM8x+RIv8gmd4nwhmsj frseipH+kAIrEUlXSbHHH3nnf6H5wc2mU2+Y4totGr+5tHE89R8elaD+yv1OIKnfpxjo a6RKEWlgkDF/SsHRteFT5Mcz9pfgIlCebkOZcn2hX1JCddk2CvlrK3ATU5n+6ikpacVR kibfaOZNal5oYbe2izT62ftMvOPEA5YEQNchQzLDwS9Dp8IyoS2l/KoHh5eF4GfOpOSX ixnQ== X-Gm-Message-State: AOAM530LW5ekOf43XR28uDSAraiQCza/+VNSObrM/9cRje3y6Py7JzRs 13mJmNoUWU47iWOENIz4kaEiQfk+paMKYw== X-Received: by 2002:a9d:6396:: with SMTP id w22mr10176866otk.26.1632920774754; Wed, 29 Sep 2021 06:06:14 -0700 (PDT) Received: from localhost.localdomain ([172.58.171.248]) by smtp.gmail.com with ESMTPSA id w1sm442823ote.41.2021.09.29.06.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:06:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 07/26] linux-user/cris: Implement setup_sigtramp Date: Wed, 29 Sep 2021 09:05:34 -0400 Message-Id: <20210929130553.121567-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210929130553.121567-1-richard.henderson@linaro.org> References: <20210929130553.121567-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x330.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: "Edgar E . Iglesias" , alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out setup_sigreturn so that we can continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/cris/target_signal.h | 2 ++ linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.h index 495a142896..83a5155507 100644 --- a/linux-user/cris/target_signal.h +++ b/linux-user/cris/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* CRIS_TARGET_SIGNAL_H */ diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c index 2c39bdf727..7f6aca934e 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -97,6 +97,14 @@ static abi_ulong get_sigframe(CPUCRISState *env, int framesize) return sp - framesize; } +static void setup_sigreturn(uint16_t *retcode) +{ + /* This is movu.w __NR_sigreturn, r9; break 13; */ + __put_user(0x9c5f, retcode + 0); + __put_user(TARGET_NR_sigreturn, retcode + 1); + __put_user(0xe93d, retcode + 2); +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUCRISState *env) { @@ -112,14 +120,8 @@ void setup_frame(int sig, struct target_sigaction *ka, /* * The CRIS signal return trampoline. A real linux/CRIS kernel doesn't * use this trampoline anymore but it sets it up for GDB. - * In QEMU, using the trampoline simplifies things a bit so we use it. - * - * This is movu.w __NR_sigreturn, r9; break 13; */ - __put_user(0x9c5f, frame->retcode+0); - __put_user(TARGET_NR_sigreturn, - frame->retcode + 1); - __put_user(0xe93d, frame->retcode + 2); + setup_sigreturn(frame->retcode); /* Save the mask. */ __put_user(set->sig[0], &frame->sc.oldmask); @@ -135,7 +137,7 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[10] = sig; env->pc = (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] = default_sigreturn; unlock_user_struct(frame, frame_addr, 1); return; @@ -187,3 +189,14 @@ long do_rt_sigreturn(CPUCRISState *env) qemu_log_mask(LOG_UNIMP, "do_rt_sigreturn: not implemented\n"); return -TARGET_ENOSYS; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 6); +}