From nobody Mon Nov 25 09:55:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1716771251; cv=none; d=zohomail.com; s=zohoarc; b=h/Ny+FKDGYGADiFJeSGnElRJk482kqt+aaiXdOalEM4AZE3lL1cyGCWRk1+LyT9L30xMI1bxSLD3+bCc/bRpiRm1sla0T6EE4hlpMIyz9Wf0BhGywECmNN8X/Cl0gKI9A8Ix7nRiVGEhqCwbOXHA5B0K8gd027fPHskxZxh3GGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716771251; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A/3mRVbjkwDF9eBMMUHlCcFHLaNSo0keoR5CYS7AGJ4=; b=C3yKMDydVkRGZiYJJilbx2LWlU/CXQHo+7axJQBfDNTXnf7/YA3aVw7Nz+rWyYF8HCAqyusNBwbA83hKqlaDHEFEc5JQ+vMTkEhTyzMCcLCicC/aiBllHUr+R7G6Fwaw0TLGF/z/oei3v6NDF4yQ4gCxdB8FmmvAphs6PxNFjXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716771251380789.980726215896; Sun, 26 May 2024 17:54:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBOZM-0007HH-I8; Sun, 26 May 2024 20:50:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBOZJ-0007Cq-94 for qemu-devel@nongnu.org; Sun, 26 May 2024 20:50:29 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBOZA-0003ga-Im for qemu-devel@nongnu.org; Sun, 26 May 2024 20:50:24 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-24ca21014ccso1196450fac.1 for ; Sun, 26 May 2024 17:50:19 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fd6d7598sm3942958b3a.220.2024.05.26.17.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 17:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716771018; x=1717375818; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A/3mRVbjkwDF9eBMMUHlCcFHLaNSo0keoR5CYS7AGJ4=; b=b4tx9VX2ipo3QWJaCnvPeV8jHd8yj1SiW2CVowcTU/pl05dR1wZRAxJ4b0A1aoz78s Qx/8U4UVQJI4uuFO0Tse14J3qSIbBN3rdBnJbIL+zw1aAVxjBfsxCkz/km3W+/+rwFSe OKT2CUUM5N/py7AuR1uE63mlxnYcpDwh4AIma4D1GAblyPcrEVg7AD7nm05hCrddMVH8 jqBrXEGQSuR3EyB6SWnMlJ/A3Pzjrwp7kvdrztiJxGfbxFJxeyHbqhubldZNXQImY7zp k+1zofvqLl4Vu/vNQtb6I1DKFFnjLRSWp1Q14ZzK17COZVFBJbG5yn25NQ6/ItrXhDGA sZ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716771018; x=1717375818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A/3mRVbjkwDF9eBMMUHlCcFHLaNSo0keoR5CYS7AGJ4=; b=UsO1NYG6zmEr+RLLSSEBpBbHqG19etmpyx00tB2VAtzJdZGtGS/7Wu/4aiiNkBxFnn nD2lWsePvwJd6dhYn7h0wfNqaoDS517lqX0mQ/SpWSRYBmo8cwxZ1H283eNk5/B7rSyj QNSNZzQuVw7jvzkwlxrcRFjaIDUhny4fHjD0aFEgxgvqYxTer3mrBIu5jFFK5AD6eb9U btJEC27S+xO9CAT7yo3UAa7zk4sqvLwsAiuWVcVgyamaGaGnn3bMSJEx/EehmPjAk6Pi dAOcj8qWvHfKMfLZqOAomcrBoXowfIGp1I2jv2CVsICo/uhKbu2AV+4eKfGWBJPfaBtB GZ9A== X-Gm-Message-State: AOJu0Yx9OLcOdEpULJP9qO9iOmMtu4dAWwPy5D6XEapOmHQWsFDu0VNm O0u+NTt8lNiCxfc5G9ZcxqZ55StgguctACyRDmSdMlKb2wVacEX59dT+14xnnzStehuzFljOPEt H X-Google-Smtp-Source: AGHT+IFA2iVpuarcuYSqSufpVwNrRJR1oc/ymReMRy4jXMKIE+b98HZvw+ZA5QwO7USzbFcaK6mcyg== X-Received: by 2002:a05:6870:e256:b0:24f:ef6b:353e with SMTP id 586e51a60fabf-24fef6b7416mr2348778fac.36.1716771018523; Sun, 26 May 2024 17:50:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PULL 20/28] linux-user/i386: Return boolean success from restore_sigcontext Date: Sun, 26 May 2024 17:49:53 -0700 Message-Id: <20240527005001.642825-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527005001.642825-1-richard.henderson@linaro.org> References: <20240527005001.642825-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::30; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x30.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1716771251987100001 Content-Type: text/plain; charset="utf-8" Invert the sense of the return value and use bool. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 51 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 6763b4bda8..9e6d883ea1 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -564,12 +564,12 @@ static int xrstor_sigcontext(CPUX86State *env, X86Leg= acyXSaveArea *fxsave, return 0; } =20 -static int -restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) +static bool restore_sigcontext(CPUX86State *env, struct target_sigcontext = *sc) { - int err =3D 1; abi_ulong fpstate_addr; unsigned int tmpflags; + struct target_fpstate *fpstate; + bool ok; =20 #ifndef TARGET_X86_64 cpu_x86_load_seg(env, R_GS, tswap16(sc->gs)); @@ -617,29 +617,27 @@ restore_sigcontext(CPUX86State *env, struct target_si= gcontext *sc) // regs->orig_eax =3D -1; /* disable syscall check= s */ =20 fpstate_addr =3D tswapl(sc->fpstate); - if (fpstate_addr !=3D 0) { - struct target_fpstate *fpstate; - if (!lock_user_struct(VERIFY_READ, fpstate, fpstate_addr, - sizeof(struct target_fpstate))) { - return err; - } -#ifndef TARGET_X86_64 - if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { - cpu_x86_frstor(env, fpstate_addr, 1); - err =3D 0; - } else { - err =3D xrstor_sigcontext(env, &fpstate->fxstate, - fpstate_addr + TARGET_FPSTATE_FXSAVE_O= FFSET); - } -#else - err =3D xrstor_sigcontext(env, fpstate, fpstate_addr); -#endif - unlock_user_struct(fpstate, fpstate_addr, 0); - } else { - err =3D 0; + if (fpstate_addr =3D=3D 0) { + return true; } + if (!lock_user_struct(VERIFY_READ, fpstate, fpstate_addr, + sizeof(struct target_fpstate))) { + return false; + } +#ifndef TARGET_X86_64 + if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { + cpu_x86_frstor(env, fpstate_addr, 1); + ok =3D true; + } else { + ok =3D !xrstor_sigcontext(env, &fpstate->fxstate, + fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSE= T); + } +#else + ok =3D !xrstor_sigcontext(env, fpstate, fpstate_addr); +#endif + unlock_user_struct(fpstate, fpstate_addr, 0); =20 - return err; + return ok; } =20 /* Note: there is no sigreturn on x86_64, there is only rt_sigreturn */ @@ -665,8 +663,9 @@ long do_sigreturn(CPUX86State *env) set_sigmask(&set); =20 /* restore registers */ - if (restore_sigcontext(env, &frame->sc)) + if (!restore_sigcontext(env, &frame->sc)) { goto badframe; + } unlock_user_struct(frame, frame_addr, 0); return -QEMU_ESIGRETURN; =20 @@ -690,7 +689,7 @@ long do_rt_sigreturn(CPUX86State *env) target_to_host_sigset(&set, &frame->uc.tuc_sigmask); set_sigmask(&set); =20 - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { + if (!restore_sigcontext(env, &frame->uc.tuc_mcontext)) { goto badframe; } =20 --=20 2.34.1