From patchwork Fri Sep 24 16:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514587 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1676968jao; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0OebAnBz8jnVcUW1ZXdfxFmsq6pVfRP0g9PLEp1oeDtGvmvS6hvNKnme9YwdEWwQNvCGn X-Received: by 2002:a37:754:: with SMTP id 81mr11469569qkh.260.1632503076744; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503076; cv=none; d=google.com; s=arc-20160816; b=r3jxVGj8czgqla7CLXcdSifsG8xhE9DidGdrCuPKaAnzB7dTf+4GMciRsm9H9H2Tp+ +ZZjv2s1UqIicKd6+JumSRNNG5lEgPdhXOQ3WokDDz4SKcI49w15uTM6rf2CC8BQ0EI0 XQG0vX5Uy50hmvhUHWMWHgANQd/z4lR30UWVQt4sOwctgVhh9DQzH27oE0oSKnsDmeuC 2uK9C7TM8JVbPt4FU4pqsjFr+ccBFLwTg6fvo8MOi4BHXIf/cWGKXSTSNrFUrIX1XYOJ Fs7AtOvycoaNWYoggvDiEKVqJ/SzaIxj1Ncp6M8sqJY7QuzR8ELLaApZ9Q1EHYMKWxUw NYHQ== 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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=S7N5bWD4i9g9/hMJ0RVt/aGbfhySW2xet6EXvUiOvmawbmvUARwQnF62OVkZ5ld71x F/iAbmK/aNSqTJ1VSti6H/cX/SLZjIvztkQS7eO+X5yGx15bDytLviLf05qaA0oQ/2ze 1ptc7BIzQefT8qUbR5Evaw056pFUu9PegKYu0GrCXobdC2JbNsD1q11D9oJ5g4Ff9yn6 s6vWlu8Vz5JIo0e6bxPcg6lUxsWACCCBtxcOBEU407IM/Qnkn0mBOX6YM60D9xz8xjts kGY5NQtgWGCAJ1bCGGGeaGLmNdHNeEldT3qaSIrEznznCREnnMR7YHbok/ueBUn90xzb ojwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UBgNzb4w; 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 d7si1935781qkn.80.2021.09.24.10.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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=UBgNzb4w; 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]:35412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTocm-0000TO-6o for patch@linaro.org; Fri, 24 Sep 2021 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXv-0002dc-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:39553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXs-0006sq-UE for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: by mail-qv1-xf32.google.com with SMTP id a14so6648536qvb.6 for ; Fri, 24 Sep 2021 09:59:31 -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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=UBgNzb4w1rN/7zgVQMVmhj2RZkMfo45LY8uLiZPciaA7Dvtjy6dDPslJkzDYpDahOg /wLd0GkJx3tmT0wwhmMEgKfceNKnXAHroaeZqOduySHxK9y3C2/llHCwMN9Gux85B7L7 1yph/8ZXm20ZsdE3RRxT6Ev7PyKyKZEQh7JMhpBp8jRCpQKdW4mdQc59mlFdbc2takNe B8q1ihXqjgME6Wu0RaO8luPT3ofxvwW0hIGiacfqT9RP+julZt9hD4InNQ8eZ47fJLj9 lo4kIKOf+j+UhEl0PkQuBkDsyHn6M4/LzBXQ9SP/gWQ1g3LbYU6bGzfXDGY2kjTNPpdj T9AA== 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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=MK5oh8uhgiqIQpneXQFt3Lrtry7rVC8GC5dVA03k7vFQQqkugrHDvMGEQOUatc2lRj it8cX12U/sRfQ1iTtWuXQPitRfGBsVLsaBxpEsHFCGWGRV1EDBeh17oOFJdy8rZ/AoCW nQ/1i8sER6hu0FChSWpDALWEbQdthmPbNg1qg9m4f+nIxrvYe4I5WY+Rdbgy5oX5BuUw J0Hi4o9p3z0H0eIUn3plhapYU37bbzVbmsniOazdrQhv3QRxvLPGDkHgQcx9CzSXfRMn lyrrTjg3krK8LogQjatA58vdtaQmGxWFIvDGHe7mOtJDLD6cgA52Aa7FEgRUVc5AGuHu 2T2w== X-Gm-Message-State: AOAM5306gOeqHriYxmI638JajwzB3YWYEwF4xeFycoe80xT8dYUCMpRf zj9Hk7+9Dimz3iScBNJdu+Ni9Q9zm9vCDg== X-Received: by 2002:a0c:cc84:: with SMTP id f4mr2268295qvl.14.1632502770503; Fri, 24 Sep 2021 09:59:30 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/27] linux-user/arm: Drop v1 signal frames Date: Fri, 24 Sep 2021 12:59:02 -0400 Message-Id: <20210924165926.752809-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.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: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Version 2 signal frames are used from 2.6.12 and since cbc14e6f286, we have set UNAME_MINIMUM_RELEASE to 2.6.32. Suggested-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 220 +--------------------------------------- 1 file changed, 4 insertions(+), 216 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed144f9455..d0940bab47 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,14 +46,6 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v1 { - abi_ulong tuc_flags; - abi_ulong tuc_link; - target_stack_t tuc_stack; - struct target_sigcontext tuc_mcontext; - target_sigset_t tuc_sigmask; /* mask last for extensibility */ -}; - struct target_ucontext_v2 { abi_ulong tuc_flags; abi_ulong tuc_link; @@ -98,28 +90,12 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v1 -{ - struct target_sigcontext sc; - abi_ulong extramask[TARGET_NSIG_WORDS-1]; - abi_ulong retcode[4]; -}; - struct sigframe_v2 { struct target_ucontext_v2 uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v1 -{ - abi_ulong pinfo; - abi_ulong puc; - struct target_siginfo info; - struct target_ucontext_v1 uc; - abi_ulong retcode[4]; -}; - struct rt_sigframe_v2 { struct target_siginfo info; @@ -363,37 +339,6 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -/* compare linux/arch/arm/kernel/signal.c:setup_frame() */ -static void setup_frame_v1(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - struct sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); - int i; - - trace_user_setup_frame(regs, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - setup_sigcontext(&frame->sc, regs, set->sig[0]); - - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->extramask[i - 1]); - } - - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { - goto sigsegv; - } - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - static void setup_frame_v2(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { @@ -422,60 +367,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { - setup_frame_v2(usig, ka, set, regs); - } else { - setup_frame_v1(usig, ka, set, regs); - } -} - -/* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */ -static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - struct target_sigaltstack stack; - int i; - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info); - __put_user(info_addr, &frame->pinfo); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v1, uc); - __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); - - /* Clear all the bits of the ucontext we don't use. */ - memset(&frame->uc, 0, offsetof(struct target_ucontext_v1, tuc_mcontext)); - - memset(&stack, 0, sizeof(stack)); - target_save_altstack(&stack, env); - memcpy(&frame->uc.tuc_stack, &stack, sizeof(stack)); - - setup_sigcontext(&frame->uc.tuc_mcontext, env, set->sig[0]); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); - } - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); + setup_frame_v2(usig, ka, set, regs); } static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, @@ -516,11 +408,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - if (get_osversion() >= 0x020612) { - setup_rt_frame_v2(usig, ka, info, set, env); - } else { - setup_rt_frame_v1(usig, ka, info, set, env); - } + setup_rt_frame_v2(usig, ka, info, set, env); } static int @@ -553,54 +441,6 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static long do_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct sigframe_v1 *frame = NULL; - target_sigset_t set; - sigset_t host_set; - int i; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - __get_user(set.sig[0], &frame->sc.oldmask); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __get_user(set.sig[i], &frame->extramask[i - 1]); - } - - target_to_host_sigset_internal(&host_set, &set); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->sc)) { - goto badframe; - } - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; -} - static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) { int i; @@ -733,55 +573,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_sigreturn_v2(env); - } else { - return do_sigreturn_v1(env); - } -} - -static long do_rt_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct rt_sigframe_v1 *frame = NULL; - sigset_t host_set; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_rt_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { - goto badframe; - } - - target_restore_altstack(&frame->uc.tuc_stack, env); - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - unlock_user_struct(frame, frame_addr, 0); - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; + return do_sigreturn_v2(env); } static long do_rt_sigreturn_v2(CPUARMState *env) @@ -822,9 +614,5 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_rt_sigreturn_v2(env); - } else { - return do_rt_sigreturn_v1(env); - } + return do_rt_sigreturn_v2(env); }