From patchwork Wed Jun 16 01:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461328 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp106774jae; Tue, 15 Jun 2021 18:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8+yftEKYXl9yDEiotoGVOdvvVHptTDc/MnnOLhj7HX2NZ4CwU6LgZjVUM37pffXGLax0e X-Received: by 2002:a37:9c88:: with SMTP id f130mr2634013qke.368.1623807159266; Tue, 15 Jun 2021 18:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623807159; cv=none; d=google.com; s=arc-20160816; b=tSaSGKyp7t+b1UANtQ1+yD7n+vJTWIr+14La936ErR6VHvuhnEPZois5ATtnCtXfkm xNRO/ZnST+0UkceG333Rnyve9bgt4tryTjwUvooiDJK/Z2Fs1mQziORTnjADZkLMoTq2 ly4nVpujp3S9iXZXmCfLA4QPW6DQ3xA2/WsRlFqJSBMkp3Yyspsqg/fqS0x2bGk/om+Y eIICN82QpeO2R8M+NnsL0UM4Xb7+9PvPMkP2n/Zo7q8/TG5w3yz+xk4ABu1MG8RZv11Y syg3Nsz8P4hvpJnDsxc4M6QIbV0HyHWi3OKD3fV4KEzrVBwdxPbRBaCNGteP+pkxPPRl B9Fw== 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=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=QBJfLFL2Ax43TxswUxc92GzQsOE0JkXHr/8fXHHNYK6crECaFVz5InZvSQg/PK5OSu 4C9b5oG6NysMl42LEWuf/qFdFegSKT6027SX97oPUIdNuK2uhtASn5c8xBpEXKuAKq4Q +LdH4tQNrmHuLgspXROqaquQ1rR8CnVp+bqSbVYxaYO5eWgir7TnVdhMp0YwWLah4ioe Iu6ox1LYxRWQIMIhgA6zd10yCnSnGxVET7wLWPDzS4ooJqGq/dyUuvJO2iKZDf91dqLE aS8pJeRO+Sa0E2U5T4qYjZzy06a9mQTFpllzKoaQvGtWyUmByIyaiEqYtOe8x+1+gh66 XrFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="qD7/36kF"; 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 p207si448737qke.143.2021.06.15.18.32.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:32:39 -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="qD7/36kF"; 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]:40380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKQ2-0006gt-Mb for patch@linaro.org; Tue, 15 Jun 2021 21:32:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6h-0005hH-UC for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:39 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:40738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6S-0008VC-EZ for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:39 -0400 Received: by mail-pj1-x1029.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so2573754pjb.5 for ; Tue, 15 Jun 2021 18:12:24 -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=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=qD7/36kFVmvwhUT7pFuHSEzVsphnUjzB8+KlfN7GwYW+PoDmk0NuN+doPjauZa5+2E tMbBGqi9duoqV+NsMNdkHMHK/vbNEfSxuT1cl4253++DoAPcg4wHOJxOEgGinqZkXMP8 fkJK3I06POcVj1xa6UYhluQDsHeETYgOBj3XUHnaobJv6TxoVC4DukQj1l9Z5muKifC0 dYmT5q8lHXtLi0jIIs/LF4lKkI5o6ZP7MDxgrDy/tsL9vOPkonMTLUwCEp41Zyzkl/kE I/GuxJB95HXKjVDux+LKZOtGx64IWc2j2T5ACDm02Ly0vRttWG1i8eqIlYoWSTcgIi0A zMtQ== 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=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=cMJjvih0BSJK2mivOMsXW/hmRG/NlBzJxBPqoknvVDfrlgzcjQsvVxWmuMvAhgysip j9pmH9Kf9e+99IU40dUvRvxtIKGKxozyGth5Kdo8/iY+Zxo/PO+OC/LrbvCz7NkkfVne iF19tGk/qKuHfioTVi5Fv2qUu1YXLhYs4P7RCnyCtzj9TwgyUt3+g0YHVWkX7PodHLDn DepXNGyImJqSZ9twz87M7GsTxXa461X6YVT3vKW3ADvxx9869lpHq/RkQxt9jfgM2oB/ BkeFgVBd74PEOuWBLxMsEjAPi3YI+W4vz0hKjhT2c39grHSq3CBGa8QqF7INkeYrfVW6 //Ng== X-Gm-Message-State: AOAM532lsw53Amc9xkbxL7x+Tey592MkEM0UDJcre7OOkXZnMk2G1b3a vovYgz9E84270AGfrfAs/bRq/XQmzqBngw== X-Received: by 2002:a17:90a:e2d4:: with SMTP id fr20mr8036923pjb.92.1623805943265; Tue, 15 Jun 2021 18:12:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 20/21] linux-user/xtensa: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:08 -0700 Message-Id: <20210616011209.1446045-21-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: Max Filippov , 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: Max Filippov Signed-off-by: Richard Henderson --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 50 ++++++++++++++++++------------- 2 files changed, 32 insertions(+), 20 deletions(-) -- 2.25.1 Reviewed-by: Max Filippov diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.h index c60bf656f6..1c7ee73154 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -20,4 +20,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 72771e1294..fd57481bf5 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -163,26 +163,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { ra = ka->sa_restorer; } else { - ra = frame_addr + offsetof(struct target_rt_sigframe, retcode); -#ifdef TARGET_WORDS_BIGENDIAN - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0x0a, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x05, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#else - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0xa0, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x50, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#endif + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = ka->_sa_handler; @@ -263,3 +244,32 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint8_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + +#ifdef TARGET_WORDS_BIGENDIAN + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0x0a, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x05, &tramp[4]); + __put_user(0x00, &tramp[5]); +#else + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0xa0, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x50, &tramp[4]); + __put_user(0x00, &tramp[5]); +#endif + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 6); +}