From patchwork Mon May 17 18:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 440212 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1350936jac; Mon, 17 May 2021 11:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHSR0KfMbGxh9sAt+bTXSbMmLeXQNtMlbITuYqiJmQAV46zD5WNfft6buAqoeSGqyZ5n6U X-Received: by 2002:a05:6e02:1a07:: with SMTP id s7mr912213ild.251.1621277437751; Mon, 17 May 2021 11:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621277437; cv=none; d=google.com; s=arc-20160816; b=heD4+7lE8ixxMyGyJUJrufgLgULGd9k9hs9e6m5Io9ZhhHR8Nfc79kBfJgXh0ViPw4 6EfKqvM8Fc7CjtlWeLV7dNjldj5OEvwprPPTrwK8ATcJaJC2o7BvpdZhSIE7QQJdmt2y pI19WyL7z8guNprBEZSlQUgApal7J9uHEiSuaWD+09IzfLE3fq2EjeOOeBulvVLGNfk2 4kSRepuyOH/0Zomu179V242YICRVJ/xpy60+5kn76C9qjCY/QC1DF5INusROKZXRVSic 4M7wCF2/x6VHqUvDzRzgMcLxkpH/DqkY1Ph1nvh6L04c26wjSPz3MQVchxt1samLVvFt 3A6w== 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; bh=fjU0QaOwhlfOwCDWXKYMd5ILKcmprMipYdWURQqx3Kw=; b=ZdRadbJXf8sna3QRqyk0QaKv5DOwA0DzBFnD1r+AMn9czkCqEcj4Z8CtVe4ogXdBem Q0sgEOZbsJjetXGRGRQzrXvlAE1d/kURVd9ugmHWIZ26OPBiTP5qD+bybx/+FtYqRF87 aSWxEdaMob5iZ1HWUGNmNazgZxH2twzj7zFevbKqoX10tT0QDUkET3OpaLpp25W9+e9J lUrlPlNKS5SZtqOg8eli0g5jBJ5eI7OlJ/reXYqtqcFxoff+KgrpAHi0E3kZeqxg7Les QnBObpqFEbPZDjzf+NyAiMf5xUmgEnUBq3I42GqsjcfqXUsv6rrh3O5C8Pn919RdslzS yK9w== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q3si22219119ilu.88.2021.05.17.11.50.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 May 2021 11:50:37 -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; 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" Received: from localhost ([::1]:40162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liiK5-0006ul-5J for patch@linaro.org; Mon, 17 May 2021 14:50:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihlj-0006m4-Tf for qemu-devel@nongnu.org; Mon, 17 May 2021 14:15:17 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:59951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihlZ-0004Z2-9b for qemu-devel@nongnu.org; Mon, 17 May 2021 14:15:07 -0400 Received: from quad ([82.142.31.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MPaQU-1m4Cee1caA-00MdiF; Mon, 17 May 2021 20:14:50 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 46/59] linux-user/s390x: Clean up signal.c Date: Mon, 17 May 2021 20:14:11 +0200 Message-Id: <20210517181424.8093-47-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517181424.8093-1-laurent@vivier.eu> References: <20210517181424.8093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:HVBt4BQ80O7tbhyiWe6Y04tifcA3ZgB4LCPnE/7eNcbqtC4glHc e9jhTYakGc+6ec04L5gasNdchvLVP3jFmWx1qceSwIdiPF/X/qu0v6u+hXlJ2cbCLHrI3t9 VYMeFT+ZhbHemGAq4PDK7yzQpTjCj+pwqCa8LrWTGNm/nvH1EaEkohUSHqnZ+zr3CUFiQVo R8037PJfCK/+2Liop+Wxg== X-UI-Out-Filterresults: notjunk:1; V03:K0:rynPxZnuPXg=:0ao8TcilgcMD4mTl7Ls8Jz vbpBHPTlwwW23pr4G8KO8lG6HDq7xe5liht6n8hY8oIWGZxYrQ+mBNbixlx/4KsoOEq5AInHm QfSxjVx9vlNlqTuJuvAlnDeAWfJF+N7ed1rT8cjEfGH+xowGnKzLTy8nhqvk+nTf1kBcVGHYu /ScyKCoj5B66sjHJ67vi4AYMdyKVfFRXdzXQ8kkZh3FTVbkGKDaokWJE7TKk+d4NDHI8vaBfy 6VOnGVvqkP/VHyX5B/Aneo5OvVuNjkUgmFJrXcN5xGn+el26uB6fMnaYt+brBJ+5WgjJYonxB xkA/+wCfuRA7opwDgHxZld3+45CiW7lK4jP/Yj5/9k5/MrfcYYvCGgypbUeQAk44V2SMRiIpH D2of6EYAsHgndPUa0KSZdoLA+1EtBh1N/qwAlcXeyGfeLZWjNuLT5Ea6n1ZnSsfOuBoZoemTC f9izbUiAxQe0s28unThj8rnoD03Z3B6vNTk4UfHefDn7Es9weuoYgxDzyzv/KEbFLlOl5qckI koobZ+yl0AyHlSb+21BYaM= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: Richard Henderson , Laurent Vivier , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reorder the function bodies to correspond to the kernel source. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand Message-Id: <20210428193408.233706-15-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/s390x/signal.c | 63 ++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) -- 2.31.1 diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 839a7ae4b3d6..9d470e4ca069 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -133,6 +133,7 @@ void setup_frame(int sig, struct target_sigaction *ka, { sigframe *frame; abi_ulong frame_addr; + abi_ulong restorer; frame_addr = get_sigframe(ka, env, sizeof(*frame)); trace_user_setup_frame(env, frame_addr); @@ -141,28 +142,39 @@ void setup_frame(int sig, struct target_sigaction *ka, return; } + /* Set up backchain. */ + __put_user(env->regs[15], (abi_ulong *) frame); + + /* Create struct sigcontext on the signal stack. */ /* Make sure that we're initializing all of oldmask. */ QEMU_BUILD_BUG_ON(ARRAY_SIZE(frame->sc.oldmask) != 1); __put_user(set->sig[0], &frame->sc.oldmask[0]); + __put_user(frame_addr + offsetof(sigframe, sregs), &frame->sc.sregs); + /* Create _sigregs on the signal stack */ save_sigregs(env, &frame->sregs); - __put_user(frame_addr + offsetof(sigframe, sregs), &frame->sc.sregs); + /* + * ??? The kernel uses regs->gprs[2] here, which is not yet the signo. + * Moreover the comment talks about allowing backtrace, which is really + * done by the r15 copy above. + */ + __put_user(sig, &frame->signo); - /* Set up to return from userspace. If provided, use a stub - already in userspace. */ + /* + * Set up to return from userspace. + * If provided, use a stub already in userspace. + */ if (ka->sa_flags & TARGET_SA_RESTORER) { - env->regs[14] = ka->sa_restorer; + restorer = ka->sa_restorer; } else { - env->regs[14] = frame_addr + offsetof(sigframe, retcode); + restorer = frame_addr + offsetof(sigframe, retcode); __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &frame->retcode); } - /* Set up backchain. */ - __put_user(env->regs[15], (abi_ulong *) frame); - /* Set up registers for signal handler */ + env->regs[14] = restorer; env->regs[15] = frame_addr; /* Force default amode and default user address space control. */ env->psw.mask = PSW_MASK_64 | PSW_MASK_32 | PSW_ASC_PRIMARY @@ -180,8 +192,6 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[5] = 0; /* FIXME: regs->int_parm_long */ env->regs[6] = 0; /* FIXME: current->thread.last_break */ - /* Place signal number on stack to allow backtrace from handler. */ - __put_user(env->regs[2], &frame->signo); unlock_user_struct(frame, frame_addr, 1); } @@ -191,6 +201,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { rt_sigframe *frame; abi_ulong frame_addr; + abi_ulong restorer; frame_addr = get_sigframe(ka, env, sizeof *frame); trace_user_setup_rt_frame(env, frame_addr); @@ -199,29 +210,33 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, return; } - tswap_siginfo(&frame->info, info); - - /* Create the ucontext. */ - __put_user(0, &frame->uc.tuc_flags); - __put_user((abi_ulong)0, (abi_ulong *)&frame->uc.tuc_link); - target_save_altstack(&frame->uc.tuc_stack, env); - save_sigregs(env, &frame->uc.tuc_mcontext); - tswap_sigset(&frame->uc.tuc_sigmask, set); + /* Set up backchain. */ + __put_user(env->regs[15], (abi_ulong *) frame); - /* Set up to return from userspace. If provided, use a stub - already in userspace. */ + /* + * Set up to return from userspace. + * If provided, use a stub already in userspace. + */ if (ka->sa_flags & TARGET_SA_RESTORER) { - env->regs[14] = ka->sa_restorer; + restorer = ka->sa_restorer; } else { - env->regs[14] = frame_addr + offsetof(typeof(*frame), retcode); + restorer = frame_addr + offsetof(typeof(*frame), retcode); __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &frame->retcode); } - /* Set up backchain. */ - __put_user(env->regs[15], (abi_ulong *) frame); + /* Create siginfo on the signal stack. */ + tswap_siginfo(&frame->info, info); + + /* Create ucontext on the signal stack. */ + __put_user(0, &frame->uc.tuc_flags); + __put_user(0, &frame->uc.tuc_link); + target_save_altstack(&frame->uc.tuc_stack, env); + save_sigregs(env, &frame->uc.tuc_mcontext); + tswap_sigset(&frame->uc.tuc_sigmask, set); /* Set up registers for signal handler */ + env->regs[14] = restorer; env->regs[15] = frame_addr; /* Force default amode and default user address space control. */ env->psw.mask = PSW_MASK_64 | PSW_MASK_32 | PSW_ASC_PRIMARY