From patchwork Wed Apr 23 13:12:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 28884 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 31EB720534 for ; Wed, 23 Apr 2014 13:14:44 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp4sf5544368obc.0 for ; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=ihAnMQ9i5Y2W+2kZp4cMM+PsCDpfYYGQYuLgnJ7p9sY=; b=ePTglrewF2rbzcdTH7m9bcAC1ePX9rvs9HzTkDDzplWSUsZ5SCfUPTpabeGiQfCA2s nQ8b7r2WyesMi6z/Beb/cRgNnzP0AnGEWDGv8FLme4hzNCFNGPwihoDWO9A//rVtS8s2 CoT5fTRtG6DBPJRKPmRVbtkxPhc7SfHA0bRP7Uvi/asSoamxx4Kixn4RjkWUgUJIfUIN sJBDtC+CJ+W1ek7fhhIHjBUsIiM1Dq5vjEMufFoijWXzc3SaHjne8Rg/xL3WY/2Z9JFu HnuDrF8pwzD3H0sb3l0H/EyyolRV5fdrDG+aZc1zWlouwEnEFZNJddYOvAGVw5JjBEz6 iYIg== X-Gm-Message-State: ALoCoQncnunD0qMDKIFH6tEv+DFjPV0ZO4VJlhPEAQAEaBGOrGFXcA2Zg9bIqsY585SIEESSAFId X-Received: by 10.50.39.80 with SMTP id n16mr1216604igk.2.1398258883548; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.114 with SMTP id m105ls631024qgd.87.gmail; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) X-Received: by 10.58.77.238 with SMTP id v14mr20707vew.27.1398258883388; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id sq9si156293vdc.143.2014.04.23.06.14.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 06:14:43 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lh14so1103779vcb.20 for ; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) X-Received: by 10.220.105.130 with SMTP id t2mr5571819vco.18.1398258883293; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp103057vcb; Wed, 23 Apr 2014 06:14:42 -0700 (PDT) X-Received: by 10.224.129.66 with SMTP id n2mr20104035qas.55.1398258882784; Wed, 23 Apr 2014 06:14:42 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x7si412865qaj.232.2014.04.23.06.14.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Apr 2014 06:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:60881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcx0c-0000bj-7b for patch@linaro.org; Wed, 23 Apr 2014 09:14:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcwyE-0001kp-TY for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wcwy8-0001Js-Pi for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:14 -0400 Received: from afflict.kos.to ([92.243.29.197]:42805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcwy8-0001It-E7 for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:08 -0400 Received: from localhost.localdomain (afflict [92.243.29.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 1B8BD264D7 for ; Wed, 23 Apr 2014 15:12:06 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 23 Apr 2014 16:12:00 +0300 Message-Id: <541b6c6f58693ee11c23a5e4f5c25ae92379f56f.1398257165.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Subject: [Qemu-devel] [PATCH 09/13] signal.c: setup_frame remove __put_user checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio Remove "if(__put_user" checks and their related error paths for all architecture's setup_frame, setup_rt_frame and similar. Remove the unlock_user_struct when the only way to end up there is from failed lock_user_struct. Remove err variable if there are no users for it in the function anymore. --- linux-user/signal.c | 97 ++++++++++++++--------------------------------------- 1 file changed, 25 insertions(+), 72 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 2c717b8..c3e5545 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -971,7 +971,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, { abi_ulong frame_addr, addr; struct rt_sigframe *frame; - int i, err = 0; + int i; frame_addr = get_sigframe(ka, env, sizeof(*frame)); @@ -996,10 +996,9 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) - goto give_sigsegv; - } + for(i = 0; i < TARGET_NSIG_WORDS; i++) { + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); + } /* Set up to return from userspace. If provided, use a stub already in userspace. */ @@ -1016,9 +1015,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(val16, (uint16_t *)(frame->retcode+5)); } - if (err) - goto give_sigsegv; - /* Set up registers for signal handler */ env->regs[R_ESP] = frame_addr; env->eip = ka->_sa_handler; @@ -1034,7 +1030,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, return; give_sigsegv: - unlock_user_struct(frame, frame_addr, 1); if (sig == TARGET_SIGSEGV) ka->_sa_handler = TARGET_SIG_DFL; force_sig(TARGET_SIGSEGV /* , current */); @@ -1593,7 +1588,7 @@ get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize) return (sp - framesize) & ~7; } -static int +static void setup_return(CPUARMState *env, struct target_sigaction *ka, abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr) { @@ -1617,8 +1612,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_SIGINFO) idx += 2; - if (__put_user(retcodes[idx], rc)) - return 1; + __put_user(retcodes[idx], rc); retcode = rc_addr + thumb; } @@ -1628,8 +1622,6 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, env->regs[14] = retcode; env->regs[15] = handler & (thumb ? ~1 : ~3); cpsr_write(env, cpsr, 0xffffffff); - - return 0; } static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) @@ -1716,15 +1708,13 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, regs, set->sig[0]); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->extramask[i - 1])) - goto end; - } + for(i = 1; i < TARGET_NSIG_WORDS; i++) { + __put_user(set->sig[i], &frame->extramask[i - 1]); + } setup_return(regs, ka, &frame->retcode, frame_addr, usig, frame_addr + offsetof(struct sigframe_v1, retcode)); -end: unlock_user_struct(frame, frame_addr, 1); } @@ -1786,8 +1776,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, setup_sigcontext(&frame->uc.tuc_mcontext, env, set->sig[0]); for(i = 0; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) - goto end; + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } setup_return(env, ka, &frame->retcode, frame_addr, usig, @@ -1796,7 +1785,6 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, env->regs[1] = info_addr; env->regs[2] = uc_addr; -end: unlock_user_struct(frame, frame_addr, 1); } @@ -2952,8 +2940,7 @@ static void setup_frame(int sig, struct target_sigaction * ka, setup_sigcontext(regs, &frame->sf_sc); for(i = 0; i < TARGET_NSIG_WORDS; i++) { - if(__put_user(set->sig[i], &frame->sf_mask.sig[i])) - goto give_sigsegv; + __put_user(set->sig[i], &frame->sf_mask.sig[i]); } /* @@ -2980,7 +2967,6 @@ static void setup_frame(int sig, struct target_sigaction * ka, return; give_sigsegv: - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV/*, current*/); } @@ -3560,7 +3546,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, { struct target_signal_frame *frame; abi_ulong frame_addr; - int err = 0; int i; frame_addr = get_sigframe(ka, env, sizeof *frame); @@ -3569,12 +3554,9 @@ static void setup_frame(int sig, struct target_sigaction *ka, /* Save the mask. */ __put_user(set->sig[0], &frame->uc.tuc_mcontext.oldmask); - if (err) - goto badframe; for(i = 1; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->extramask[i - 1])) - goto badframe; + __put_user(set->sig[i], &frame->extramask[i - 1]); } setup_sigcontext(&frame->uc.tuc_mcontext, env); @@ -3599,9 +3581,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, env->regs[15] = ((unsigned long)frame->tramp) - 8; } - if (err) - goto badframe; - /* Set up registers for signal handler */ env->regs[1] = frame_addr; /* Signal handler args: */ @@ -3616,7 +3595,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, unlock_user_struct(frame, frame_addr, 1); return; badframe: - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); } @@ -3747,7 +3725,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, { struct target_signal_frame *frame; abi_ulong frame_addr; - int err = 0; int i; frame_addr = get_sigframe(env, sizeof *frame); @@ -3768,13 +3745,10 @@ static void setup_frame(int sig, struct target_sigaction *ka, /* Save the mask. */ __put_user(set->sig[0], &frame->sc.oldmask); - if (err) - goto badframe; - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->extramask[i - 1])) - goto badframe; - } + for(i = 1; i < TARGET_NSIG_WORDS; i++) { + __put_user(set->sig[i], &frame->extramask[i - 1]); + } setup_sigcontext(&frame->sc, env); @@ -3788,7 +3762,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, unlock_user_struct(frame, frame_addr, 1); return; badframe: - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); } @@ -4177,9 +4150,7 @@ static void setup_frame(int sig, struct target_sigaction *ka, } qemu_log("%s: 1\n", __FUNCTION__); - if (__put_user(set->sig[0], &frame->sc.oldmask[0])) { - goto give_sigsegv; - } + __put_user(set->sig[0], &frame->sc.oldmask[0]); save_sigregs(env, &frame->sregs); @@ -4194,15 +4165,12 @@ static void setup_frame(int sig, struct target_sigaction *ka, } else { env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE; - if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - (uint16_t *)(frame->retcode))) - goto give_sigsegv; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, + (uint16_t *)(frame->retcode)); } /* Set up backchain. */ - if (__put_user(env->regs[15], (abi_ulong *) frame)) { - goto give_sigsegv; - } + __put_user(env->regs[15], (abi_ulong *) frame); /* Set up registers for signal handler */ env->regs[15] = frame_addr; @@ -4217,15 +4185,12 @@ static void setup_frame(int sig, struct target_sigaction *ka, env->regs[5] = 0; // FIXME: no clue... current->thread.prot_addr; /* Place signal number on stack to allow backtrace from handler. */ - if (__put_user(env->regs[2], (int *) &frame->signo)) { - goto give_sigsegv; - } + __put_user(env->regs[2], (int *) &frame->signo); unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: qemu_log("%s: give_sigsegv\n", __FUNCTION__); - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); } @@ -4266,16 +4231,12 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE; } else { env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE; - if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - (uint16_t *)(frame->retcode))) { - goto give_sigsegv; - } + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, + (uint16_t *)(frame->retcode)); } /* Set up backchain. */ - if (__put_user(env->regs[15], (abi_ulong *) frame)) { - goto give_sigsegv; - } + __put_user(env->regs[15], (abi_ulong *) frame); /* Set up registers for signal handler */ env->regs[15] = frame_addr; @@ -4288,7 +4249,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, give_sigsegv: qemu_log("%s: give_sigsegv\n", __FUNCTION__); - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); } @@ -5086,7 +5046,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, abi_ulong frame_addr; abi_ulong retcode_addr; abi_ulong sc_addr; - int err = 0; int i; frame_addr = get_sigframe(ka, env, sizeof *frame); @@ -5101,8 +5060,7 @@ static void setup_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, env, set->sig[0]); for(i = 1; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->extramask[i - 1])) - goto give_sigsegv; + __put_user(set->sig[i], &frame->extramask[i - 1]); } /* Set up to return from userspace. */ @@ -5115,9 +5073,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (long *)(frame->retcode)); - if (err) - goto give_sigsegv; - /* Set up to return from userspace */ env->aregs[7] = frame_addr; @@ -5127,7 +5082,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, return; give_sigsegv: - unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); } @@ -5241,8 +5195,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; for(i = 0; i < TARGET_NSIG_WORDS; i++) { - if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) - goto give_sigsegv; + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } /* Set up to return from userspace. */