From patchwork Tue Jul 23 16:25:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 813958 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2399353wro; Tue, 23 Jul 2024 09:26:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUs93WE9gTXnasDT24vgTwJAkwqPRL4HRvFaQHS7ydWuD0zA23Ghtd/oYMExinxOC5fZ8chivXNI18U8tiCTvT4 X-Google-Smtp-Source: AGHT+IEwW67QZP4MCHEeKFCtEz5c34xHzdAY0+FYOggYZ1/OkU2jqx5NetIKiCQ5TCwVYZCQ749A X-Received: by 2002:a5d:6e03:0:b0:368:31c7:19d9 with SMTP id ffacd0b85a97d-369debf8ce1mr2212772f8f.12.1721751996369; Tue, 23 Jul 2024 09:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721751996; cv=none; d=google.com; s=arc-20160816; b=ysS52pikAWBepx8a0fSBKltFYsyJ3b//iN3to9D2ApVrCk7dGN3HM2sOhUgCWDJJ1K FHlY/GG8RepGzGkq+fBXKIOfYDANKlEN30/YbeTk3QklK6kKOep5LkLAccwyTyOiku3u uNGVk/X/lBq+abllmhWMi6TOaFUYwmg50Bjg+7A/ZbIoW7/Zax+DOWfPKu1W1WlpgNTw hu5glBwRirjLOmrlTKKHSTCQjdY6t5+kdTHYCsqaBQ8faTaiLqjfAxHQvVDyOEyeJDkn SQNWvVulfzWP0lh8A2P3CSaTYqI/uUjvXVnq+0EPkpJw2mkun30FKHKIFbSdP0IzIfa4 K1iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=ZUqqESPN3rURYwrIrQ9xb/I9TaQXbTrIwdP6WuJ8a/A=; fh=gFYQbQhcR0R4R/txGAMCxVm3hG6COJ6ZCud7Dy3qkHI=; b=ncUPxcksTZwvpLbq+K4XiD786s5yBSeZzilxMm3mn4IRbar5hBwPX2sgsoBHvDjdlc 63WuOX052bUdof+5txZEOVlTw4U/y1am9Y2RSt8ZO/g6fIqU8wsqTr9N0NX84upznx63 g3qyUP1FxtwLxc8Wi6yHorTG/uIm4G3WcL5sCCPIiZPWaxagFV4kOJGCnJziqJoYnJdt WQ/MzI8CUhMXGPYL91coiqkzEfS+Qq1m1r8IyoQHTQpXlNTZ0tsjY88XuP4EJmec9vk1 Hd7rYPCQdgEmD7Tnxgkfu+eswNPNRrfdXAEvVslmz3YpWSUMvXVRzafGRM1pVJpfhFXH KKUg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xIcUd5Nu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5b1f17b1804b1-427d69029aasi44804385e9.77.2024.07.23.09.26.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 09:26: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=pass header.i=@linaro.org header.s=google header.b=xIcUd5Nu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWIKR-0005lM-TV; Tue, 23 Jul 2024 12:25:31 -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 1sWIKQ-0005kd-AQ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 12:25:30 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWIKO-00077k-K6 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 12:25:30 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3684bea9728so3360999f8f.3 for ; Tue, 23 Jul 2024 09:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721751926; x=1722356726; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZUqqESPN3rURYwrIrQ9xb/I9TaQXbTrIwdP6WuJ8a/A=; b=xIcUd5NujFo4h4NiAcVzevt8CaJVlB9YWQhsVXsRa0Qm02uV0odIih44XUjw7yA0SY Tk81fzdwcdO3xh+8TC5bb+hG9nS2l0X0NPJse6uaRpE54k6jw4+I0eyTgBNepHq3E4kF qfHxNnI+wMm3/4T/NDFT7zOjadsA1v6Sq37/02zxrO6jxpMgIgHmh3RfY+n8VD8K5N/c Te72DFcXRaDss67iiLezNR7H80b3AiKaVrMvAvdgqHBbw/F+QPVWOBkmXBHICqzWC9dr +GtUROYL+NM1L0tnsDkGBiGSpLfcJ8i7qSTmOho4+znCZQHjKKtGkuLucx18StcSJgLr bs9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721751926; x=1722356726; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZUqqESPN3rURYwrIrQ9xb/I9TaQXbTrIwdP6WuJ8a/A=; b=QJvMtLYns9NoqQ4W0CYDwEZyq83t7SjEaWxjXFCLHTD56OWd8fh5LtrQKLSb28YjY1 xCcdZujU4DuQUWe41wK/mz61lZDly6MQkkaCX3LTVY+5zcKuPnu4ko1CwcYefBZcwuBh 5iEmhMIkaEKiVmx5ZjuLuobi7UGZicpJxSaVysc5iedPIFlr0QI4rqSScYWWDqwT1SEh A/xPfW75xaFYc/UeFgrFxPbi0mw53ebfnn8b/mMRqtO+q7RM2W99D2GnIfEkknBQUUGK f8vR1e3rmv1EsI0iTwejTb0iFGmIaEj0PbaiFQyVm053VClzPtY09xjtC8kleNOGbHpb HdfQ== X-Gm-Message-State: AOJu0YwTY4tHSxX5jy8h1oWDZVWhPQoftoiOlGzdRsCL0HjzsVAmLJda yaNtkrOy9liWUUJYxFIEIPPPwLyyLmUbrgq9zIYkmb4ZONpCyoNMnt1LwcUzD8o5mRNyoc+HOor + X-Received: by 2002:adf:ead2:0:b0:366:eb45:6d55 with SMTP id ffacd0b85a97d-369dee43e96mr2407569f8f.49.1721751926528; Tue, 23 Jul 2024 09:25:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68f789csm180936945e9.6.2024.07.23.09.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 09:25:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PATCH] target/i386: Remove dead assignment to ss in do_interrupt64() Date: Tue, 23 Jul 2024 17:25:25 +0100 Message-Id: <20240723162525.1585743-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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.29 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 Coverity points out that in do_interrupt64() in the "to inner privilege" codepath we set "ss = 0", but because we also set "new_stack = 1" there, later in the function we will always override that value of ss with "ss = 0 | dpl". Remove the unnecessary initialization of ss, which allows us to reduce the scope of the variable to only where it is used. Borrow a comment from helper_lcall_protected() that explains what "0 | dpl" means here. Resolves: Coverity CID 1527395 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/i386/tcg/seg_helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index aac092a356b..bab552cd535 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -926,7 +926,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int, target_ulong ptr; int type, dpl, selector, cpl, ist; int has_error_code, new_stack; - uint32_t e1, e2, e3, ss, eflags; + uint32_t e1, e2, e3, eflags; target_ulong old_eip, offset; bool set_rf; StackAccess sa; @@ -1007,7 +1007,6 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int, /* to inner privilege */ new_stack = 1; sa.sp = get_rsp_from_tss(env, ist != 0 ? ist + 3 : dpl); - ss = 0; } else { /* to same privilege */ if (env->eflags & VM_MASK) { @@ -1040,7 +1039,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int, env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK); if (new_stack) { - ss = 0 | dpl; + uint32_t ss = 0 | dpl; /* SS = NULL selector with RPL = new CPL */ cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, dpl << DESC_DPL_SHIFT); } env->regs[R_ESP] = sa.sp;