From patchwork Fri Jun 6 09:46:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 31479 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0CAF203C3 for ; Fri, 6 Jun 2014 10:34:39 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf11400107iec.0 for ; Fri, 06 Jun 2014 03:34:39 -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:cc: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=RggQbi1iGTPv++0s+Qz8CVhd9LJlh0ehopCydt88EXU=; b=cB01qGiH1uDXRsOliepFt9PzBY4isw0hJjitNCuTq80yvmqYQqRUQFBzlWmPI57fLj Tsqtv+jQwOAeSUT/wbQ/wuJiEF+w00p+JtN7/+VP9+1bpoRvQoGxjt2ppr1rNT/bdMG7 QaEQFKU4fVYso4odUMmy+nhaWAIdpKSKsZu2U+nFsA+oRJ7yOcvOpTdynO4c+KMXPXYm k9D+L+egCuv7rA57l2wVKGIgB1auno2E5l+8SQ8kYAFJiEL0uRSnRJIspvzHN1Yendgf p8ZntEBk99IJpZtPjPtXoBVn79UvL/64NQjAR/T02Gxh1V0vlU5UFZZvTNvVGxmZNaHX kuJQ== X-Gm-Message-State: ALoCoQlLOHIt3gWvp9/QqH9TNwKXtxg4dVhQhqjllO7EY1V9FTV8PYNNpS0EybrGpUDAiB38OHVo X-Received: by 10.50.55.35 with SMTP id o3mr1932221igp.6.1402050879152; Fri, 06 Jun 2014 03:34:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.87 with SMTP id v81ls634056qge.0.gmail; Fri, 06 Jun 2014 03:34:39 -0700 (PDT) X-Received: by 10.58.29.198 with SMTP id m6mr3642491veh.15.1402050879043; Fri, 06 Jun 2014 03:34:39 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id fl16si5836299vec.81.2014.06.06.03.34.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 03:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id hy4so2750058vcb.9 for ; Fri, 06 Jun 2014 03:34:39 -0700 (PDT) X-Received: by 10.52.25.130 with SMTP id c2mr3110243vdg.27.1402050878921; Fri, 06 Jun 2014 03:34:38 -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.221.54.6 with SMTP id vs6csp86993vcb; Fri, 6 Jun 2014 03:34:38 -0700 (PDT) X-Received: by 10.224.16.199 with SMTP id p7mr7183363qaa.76.1402050878496; Fri, 06 Jun 2014 03:34:38 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id lc5si12036574qcb.23.2014.06.06.03.34.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 06 Jun 2014 03:34:38 -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]:46213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsqoN-0005WM-PH for patch@linaro.org; Fri, 06 Jun 2014 05:51:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsqjv-0006Gq-1w for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wsqjm-0001XH-GZ for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:47:10 -0400 Received: from afflict.kos.to ([92.243.29.197]:38373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsqjm-0001WK-4l for qemu-devel@nongnu.org; Fri, 06 Jun 2014 05:47:02 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id CC93F26560; Fri, 6 Jun 2014 11:46:59 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 6 Jun 2014 12:46:54 +0300 Message-Id: <1402048017-30604-11-git-send-email-riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Riku Voipio , Alexander Graf Subject: [Qemu-devel] [PATCH v2 10/13] signal/ppc/{save, restore}_user_regs remove __put/get error 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) 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 As __get_user and __put_user do not return errors, remove the if checks from around them. This allows making the save/restore functions void. Signed-off-by: Riku Voipio Cc: Alexander Graf --- linux-user/signal.c | 126 +++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 85 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index f97ed58..052c03a 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -4473,7 +4473,7 @@ static target_ulong get_sigframe(struct target_sigaction *ka, return newsp; } -static int save_user_regs(CPUPPCState *env, struct target_mcontext *frame, +static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame, int sigret) { target_ulong msr = env->msr; @@ -4486,21 +4486,17 @@ static int save_user_regs(CPUPPCState *env, struct target_mcontext *frame, /* Save general registers. */ for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { - if (__put_user(env->gpr[i], &frame->mc_gregs[i])) { - return 1; - } + __put_user(env->gpr[i], &frame->mc_gregs[i]); } - if (__put_user(env->nip, &frame->mc_gregs[TARGET_PT_NIP]) - || __put_user(env->ctr, &frame->mc_gregs[TARGET_PT_CTR]) - || __put_user(env->lr, &frame->mc_gregs[TARGET_PT_LNK]) - || __put_user(env->xer, &frame->mc_gregs[TARGET_PT_XER])) - return 1; + __put_user(env->nip, &frame->mc_gregs[TARGET_PT_NIP]); + __put_user(env->ctr, &frame->mc_gregs[TARGET_PT_CTR]); + __put_user(env->lr, &frame->mc_gregs[TARGET_PT_LNK]); + __put_user(env->xer, &frame->mc_gregs[TARGET_PT_XER]); for (i = 0; i < ARRAY_SIZE(env->crf); i++) { ccr |= env->crf[i] << (32 - ((i + 1) * 4)); } - if (__put_user(ccr, &frame->mc_gregs[TARGET_PT_CCR])) - return 1; + __put_user(ccr, &frame->mc_gregs[TARGET_PT_CCR]); /* Save Altivec registers if necessary. */ if (env->insns_flags & PPC_ALTIVEC) { @@ -4508,69 +4504,53 @@ static int save_user_regs(CPUPPCState *env, struct target_mcontext *frame, ppc_avr_t *avr = &env->avr[i]; ppc_avr_t *vreg = &frame->mc_vregs.altivec[i]; - if (__put_user(avr->u64[0], &vreg->u64[0]) || - __put_user(avr->u64[1], &vreg->u64[1])) { - return 1; - } + __put_user(avr->u64[0], &vreg->u64[0]); + __put_user(avr->u64[1], &vreg->u64[1]); } /* Set MSR_VR in the saved MSR value to indicate that frame->mc_vregs contains valid data. */ msr |= MSR_VR; - if (__put_user((uint32_t)env->spr[SPR_VRSAVE], - &frame->mc_vregs.altivec[32].u32[3])) - return 1; + __put_user((uint32_t)env->spr[SPR_VRSAVE], + &frame->mc_vregs.altivec[32].u32[3]); } /* Save floating point registers. */ if (env->insns_flags & PPC_FLOAT) { for (i = 0; i < ARRAY_SIZE(env->fpr); i++) { - if (__put_user(env->fpr[i], &frame->mc_fregs[i])) { - return 1; - } + __put_user(env->fpr[i], &frame->mc_fregs[i]); } - if (__put_user((uint64_t) env->fpscr, &frame->mc_fregs[32])) - return 1; + __put_user((uint64_t) env->fpscr, &frame->mc_fregs[32]); } /* Save SPE registers. The kernel only saves the high half. */ if (env->insns_flags & PPC_SPE) { #if defined(TARGET_PPC64) for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { - if (__put_user(env->gpr[i] >> 32, &frame->mc_vregs.spe[i])) { - return 1; - } + __put_user(env->gpr[i] >> 32, &frame->mc_vregs.spe[i]); } #else for (i = 0; i < ARRAY_SIZE(env->gprh); i++) { - if (__put_user(env->gprh[i], &frame->mc_vregs.spe[i])) { - return 1; - } + __put_user(env->gprh[i], &frame->mc_vregs.spe[i]); } #endif /* Set MSR_SPE in the saved MSR value to indicate that frame->mc_vregs contains valid data. */ msr |= MSR_SPE; - if (__put_user(env->spe_fscr, &frame->mc_vregs.spe[32])) - return 1; + __put_user(env->spe_fscr, &frame->mc_vregs.spe[32]); } /* Store MSR. */ - if (__put_user(msr, &frame->mc_gregs[TARGET_PT_MSR])) - return 1; + __put_user(msr, &frame->mc_gregs[TARGET_PT_MSR]); /* Set up the sigreturn trampoline: li r0,sigret; sc. */ if (sigret) { - if (__put_user(0x38000000UL | sigret, &frame->tramp[0]) || - __put_user(0x44000002UL, &frame->tramp[1])) { - return 1; - } + __put_user(0x38000000UL | sigret, &frame->tramp[0]); + __put_user(0x44000002UL, &frame->tramp[1]); } - - return 0; } -static int restore_user_regs(CPUPPCState *env, - struct target_mcontext *frame, int sig) +static void restore_user_regs(CPUPPCState *env, + struct target_mcontext *frame, int sig) { target_ulong save_r2 = 0; target_ulong msr; @@ -4584,17 +4564,13 @@ static int restore_user_regs(CPUPPCState *env, /* Restore general registers. */ for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { - if (__get_user(env->gpr[i], &frame->mc_gregs[i])) { - return 1; - } + __get_user(env->gpr[i], &frame->mc_gregs[i]); } - if (__get_user(env->nip, &frame->mc_gregs[TARGET_PT_NIP]) - || __get_user(env->ctr, &frame->mc_gregs[TARGET_PT_CTR]) - || __get_user(env->lr, &frame->mc_gregs[TARGET_PT_LNK]) - || __get_user(env->xer, &frame->mc_gregs[TARGET_PT_XER])) - return 1; - if (__get_user(ccr, &frame->mc_gregs[TARGET_PT_CCR])) - return 1; + __get_user(env->nip, &frame->mc_gregs[TARGET_PT_NIP]); + __get_user(env->ctr, &frame->mc_gregs[TARGET_PT_CTR]); + __get_user(env->lr, &frame->mc_gregs[TARGET_PT_LNK]); + __get_user(env->xer, &frame->mc_gregs[TARGET_PT_XER]); + __get_user(ccr, &frame->mc_gregs[TARGET_PT_CCR]); for (i = 0; i < ARRAY_SIZE(env->crf); i++) { env->crf[i] = (ccr >> (32 - ((i + 1) * 4))) & 0xf; @@ -4604,8 +4580,7 @@ static int restore_user_regs(CPUPPCState *env, env->gpr[2] = save_r2; } /* Restore MSR. */ - if (__get_user(msr, &frame->mc_gregs[TARGET_PT_MSR])) - return 1; + __get_user(msr, &frame->mc_gregs[TARGET_PT_MSR]); /* If doing signal return, restore the previous little-endian mode. */ if (sig) @@ -4617,28 +4592,22 @@ static int restore_user_regs(CPUPPCState *env, ppc_avr_t *avr = &env->avr[i]; ppc_avr_t *vreg = &frame->mc_vregs.altivec[i]; - if (__get_user(avr->u64[0], &vreg->u64[0]) || - __get_user(avr->u64[1], &vreg->u64[1])) { - return 1; - } + __get_user(avr->u64[0], &vreg->u64[0]); + __get_user(avr->u64[1], &vreg->u64[1]); } /* Set MSR_VEC in the saved MSR value to indicate that frame->mc_vregs contains valid data. */ - if (__get_user(env->spr[SPR_VRSAVE], - (target_ulong *)(&frame->mc_vregs.altivec[32].u32[3]))) - return 1; + __get_user(env->spr[SPR_VRSAVE], + (target_ulong *)(&frame->mc_vregs.altivec[32].u32[3])); } /* Restore floating point registers. */ if (env->insns_flags & PPC_FLOAT) { uint64_t fpscr; for (i = 0; i < ARRAY_SIZE(env->fpr); i++) { - if (__get_user(env->fpr[i], &frame->mc_fregs[i])) { - return 1; - } + __get_user(env->fpr[i], &frame->mc_fregs[i]); } - if (__get_user(fpscr, &frame->mc_fregs[32])) - return 1; + __get_user(fpscr, &frame->mc_fregs[32]); env->fpscr = (uint32_t) fpscr; } @@ -4648,23 +4617,16 @@ static int restore_user_regs(CPUPPCState *env, for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { uint32_t hi; - if (__get_user(hi, &frame->mc_vregs.spe[i])) { - return 1; - } + __get_user(hi, &frame->mc_vregs.spe[i]); env->gpr[i] = ((uint64_t)hi << 32) | ((uint32_t) env->gpr[i]); } #else for (i = 0; i < ARRAY_SIZE(env->gprh); i++) { - if (__get_user(env->gprh[i], &frame->mc_vregs.spe[i])) { - return 1; - } + __get_user(env->gprh[i], &frame->mc_vregs.spe[i]); } #endif - if (__get_user(env->spe_fscr, &frame->mc_vregs.spe[32])) - return 1; + __get_user(env->spe_fscr, &frame->mc_vregs.spe[32]); } - - return 0; } static void setup_frame(int sig, struct target_sigaction *ka, @@ -4694,7 +4656,7 @@ static void setup_frame(int sig, struct target_sigaction *ka, __put_user(sig, &sc->signal); /* Save user regs. */ - err |= save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn); + save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn); /* The kernel checks for the presence of a VDSO here. We don't emulate a vdso, so use a sigreturn system call. */ @@ -4760,7 +4722,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, } frame = &rt_sf->uc.tuc_mcontext; - err |= save_user_regs(env, frame, TARGET_NR_rt_sigreturn); + save_user_regs(env, frame, TARGET_NR_rt_sigreturn); /* The kernel checks for the presence of a VDSO here. We don't emulate a vdso, so use a sigreturn system call. */ @@ -4820,8 +4782,7 @@ long do_sigreturn(CPUPPCState *env) __get_user(sr_addr, &sc->regs); if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1)) goto sigsegv; - if (restore_user_regs(env, sr, 1)) - goto sigsegv; + restore_user_regs(env, sr, 1); unlock_user_struct(sr, sr_addr, 1); unlock_user_struct(sc, sc_addr, 1); @@ -4859,15 +4820,10 @@ static int do_setcontext(struct target_ucontext *ucp, CPUPPCState *env, int sig) target_to_host_sigset_internal(&blocked, &set); do_sigprocmask(SIG_SETMASK, &blocked, NULL); - if (restore_user_regs(env, mcp, sig)) - goto sigsegv; + restore_user_regs(env, mcp, sig); unlock_user_struct(mcp, mcp_addr, 1); return 0; - -sigsegv: - unlock_user_struct(mcp, mcp_addr, 1); - return 1; #endif }