render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0001-target-i386-do-not-re-compute-new-pc-with-CF_PCREL.patch

b7ea00
From nobody Fri Jan 12 11:43:01 2024
b7ea00
Delivered-To: importer@patchew.org
b7ea00
Authentication-Results: mx.zohomail.com;
b7ea00
	dkim=pass;
b7ea00
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
b7ea00
 permitted sender)
b7ea00
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
b7ea00
	dmarc=pass(p=none dis=none)  header.from=linaro.org
b7ea00
ARC-Seal: i=1; a=rsa-sha256; t=1704150435; cv=none;
b7ea00
	d=zohomail.com; s=zohoarc;
b7ea00
	b=WuuXzKFWal2lWtDkRW1hyD3JeOc+SWN52QHBHapuNgK1+I2+cPYMj5+cN4Zjw5A7mvf00GT1vtuKEVQlfbQSdQAabRvUm1IApyvu/IScVt/y4bgJZtJkcM5aIIBT037PWrprtRBiC9NpSYfZNMYJYHp5uvh2KAr4S98QWMlhafM=
b7ea00
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
b7ea00
 s=zohoarc;
b7ea00
	t=1704150435;
b7ea00
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
b7ea00
	bh=Fc7w6qm1lcKkOSX/aWlQDZG20+2gOdT5iAy2c8bZOd8=;
b7ea00
	b=QMgOfOfOQAWcCWBO+IO/NBDK5btCFlibal5JOy2X4uS9kOBwvViipo6SvZjrO2SptH2Bi+pLPhRpPU1O+ubVU7cY0GoFzzM0Wawd0XkZ9kzDzY/fvhog49o5nYI6cX46rt18qOXLWvvY702wGVdiMHoKrhRrIaJJE75z3jI9Bj4=
b7ea00
ARC-Authentication-Results: i=1; mx.zohomail.com;
b7ea00
	dkim=pass;
b7ea00
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
b7ea00
 permitted sender)
b7ea00
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
b7ea00
	dmarc=pass header.from=<richard.henderson@linaro.org> (p=none dis=none)
b7ea00
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
b7ea00
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
b7ea00
 mx.zohomail.com
b7ea00
	with SMTPS id 1704150435302898.4215703047593;
b7ea00
 Mon, 1 Jan 2024 15:07:15 -0800 (PST)
b7ea00
Received: from localhost ([::1] helo=lists1p.gnu.org)
b7ea00
	by lists.gnu.org with esmtp (Exim 4.90_1)
b7ea00
	(envelope-from <qemu-devel-bounces@nongnu.org>)
b7ea00
	id 1rKRMd-0001OI-9C; Mon, 01 Jan 2024 18:06:31 -0500
b7ea00
Received: from eggs.gnu.org ([2001:470:142:3::10])
b7ea00
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
b7ea00
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
b7ea00
 id 1rKRMa-0001NR-Rr
b7ea00
 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 18:06:28 -0500
b7ea00
Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f])
b7ea00
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
b7ea00
 (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)
b7ea00
 id 1rKRMZ-0000Uc-9F
b7ea00
 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 18:06:28 -0500
b7ea00
Received: by mail-pg1-x52f.google.com with SMTP id
b7ea00
 41be03b00d2f7-53fbf2c42bfso6436343a12.3
b7ea00
 for <qemu-devel@nongnu.org>; Mon, 01 Jan 2024 15:06:26 -0800 (PST)
b7ea00
Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207])
b7ea00
 by smtp.gmail.com with ESMTPSA id
b7ea00
 h12-20020a63df4c000000b005bd2b3a03eesm19672386pgj.6.2024.01.01.15.06.21
b7ea00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
b7ea00
 Mon, 01 Jan 2024 15:06:24 -0800 (PST)
b7ea00
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
b7ea00
 d=linaro.org; s=google; t=1704150385; x=1704755185; darn=nongnu.org;
b7ea00
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
b7ea00
 :to:from:from:to:cc:subject:date:message-id:reply-to;
b7ea00
 bh=Fc7w6qm1lcKkOSX/aWlQDZG20+2gOdT5iAy2c8bZOd8=;
b7ea00
 b=dNkcO41+f8tEqtfO4CNEK3dzzuYmU72bWdyd57epmAhewzLeLt7RHz7f8a67QcEMtj
b7ea00
 ogk6TnzY9C5YB3hC95BjYoWhfUSIRC+4LS6Z0RwjdR/VKwliPovopIgOnnCJgr11M6gq
b7ea00
 x0Oo7AV6+ydX2/CJ/vi7CdysfcZZNdnlX5DkwVtTI296PMIfJhRN/SIHiqDfABCFrw8B
b7ea00
 Nf+VpbYc91syKadTGBPzmOtamcAqx3MD7ndkVEI1eFkiejeGu9jawdqrAxz+jrFJJMby
b7ea00
 3/j4e+hqiQjlRVHVrpiQEM6ip7BsHqaMXlc6glQyIRph/u6yRDewnRTojoIGcUN84nFm
b7ea00
 mbCg==
b7ea00
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
b7ea00
 d=1e100.net; s=20230601; t=1704150385; x=1704755185;
b7ea00
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
b7ea00
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
b7ea00
 :reply-to;
b7ea00
 bh=Fc7w6qm1lcKkOSX/aWlQDZG20+2gOdT5iAy2c8bZOd8=;
b7ea00
 b=hZafAFg/VkyIycwdF4otV76XBU2LSrOJf6IQXXrHMfYC6VpDcmh6U6unnnNrhV1rJc
b7ea00
 Frk0If2lK+nqHlo6ygJZVRdtRCln267V28VDpSD/lTZPO9vgZZYtmILeAjt4/L6mtPUf
b7ea00
 43iW7kR8zjBT8Uf80ld5qRodyuJS5bo86Asuzg/WgRfMGqBs9Im+w+MqwqKrTxSjPAvs
b7ea00
 Psix/WKTNvKR6XHuyVDA17fTVJiGIsDUQp1InHF1ExsF2gG4wPI3hVMjTj+F2hs0SeY6
b7ea00
 Ivqs1RMAKbe9i581Wo6tIM2Jw/MHxL8fKN1SVC7klk4HpF516HBS8u/gQQE9vunYup05
b7ea00
 ccyQ==
b7ea00
X-Gm-Message-State: AOJu0Yy5sdlKUW0PNOmXX9aF7N5+gfVMCk21pUVv8dRCuvQamjzIYvYj
b7ea00
 bSbNjV179B0oOyVl1t2lm1MwjDSpugfXsoz2rrpo8m8NOcc=
b7ea00
X-Google-Smtp-Source: 
b7ea00
 AGHT+IEE8RrF8uJO+68mSKODXu7giWx4EOgGGw+lT4v5lrdoFoZHlM0SU92PKHZ7B7CK5Dh1q82oRg==
b7ea00
X-Received: by 2002:a05:6a20:111f:b0:194:9578:9ba8 with SMTP id
b7ea00
 x31-20020a056a20111f00b0019495789ba8mr14471419pze.16.1704150384447;
b7ea00
 Mon, 01 Jan 2024 15:06:24 -0800 (PST)
b7ea00
From: Richard Henderson <richard.henderson@linaro.org>
b7ea00
To: qemu-devel@nongnu.org
b7ea00
Cc: pbonzini@redhat.com, qemu-stable@nongnu.org,
b7ea00
 Michael Tokarev <mjt@tls.msk.ru>
b7ea00
Subject: [PATCH] target/i386: Do not re-compute new pc with CF_PCREL
b7ea00
Date: Tue,  2 Jan 2024 10:06:17 +1100
b7ea00
Message-Id: <20240101230617.129349-1-richard.henderson@linaro.org>
b7ea00
X-Mailer: git-send-email 2.34.1
b7ea00
MIME-Version: 1.0
b7ea00
Content-Transfer-Encoding: quoted-printable
b7ea00
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
b7ea00
 as permitted sender) client-ip=209.51.188.17;
b7ea00
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
b7ea00
 helo=lists.gnu.org;
b7ea00
Received-SPF: pass client-ip=2607:f8b0:4864:20::52f;
b7ea00
 envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com
b7ea00
X-Spam_score_int: -20
b7ea00
X-Spam_score: -2.1
b7ea00
X-Spam_bar: --
b7ea00
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
b7ea00
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
b7ea00
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
b7ea00
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no
b7ea00
X-Spam_action: no action
b7ea00
X-BeenThere: qemu-devel@nongnu.org
b7ea00
X-Mailman-Version: 2.1.29
b7ea00
Precedence: list
b7ea00
List-Id: <qemu-devel.nongnu.org>
b7ea00
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
b7ea00
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
b7ea00
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
b7ea00
List-Post: <mailto:qemu-devel@nongnu.org>
b7ea00
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
b7ea00
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
b7ea00
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
b7ea00
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
b7ea00
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
b7ea00
X-ZohoMail-DKIM: pass (identity @linaro.org)
b7ea00
X-ZM-MESSAGEID: 1704150436325100001
b7ea00
Content-Type: text/plain; charset="utf-8"
b7ea00
b7ea00
With PCREL, we have a page-relative view of EIP, and an
b7ea00
approximation of PC =3D EIP+CSBASE that is good enough to
b7ea00
detect page crossings.  If we try to recompute PC after
b7ea00
masking EIP, we will mess up that approximation and write
b7ea00
a corrupt value to EIP.
b7ea00
b7ea00
We already handled masking properly for PCREL, so the
b7ea00
fix in b5e0d5d2 was only needed for the !PCREL path.
b7ea00
b7ea00
Cc: qemu-stable@nongnu.org
b7ea00
Fixes: b5e0d5d22fbf ("target/i386: Fix 32-bit wrapping of pc/eip computatio=
b7ea00
n")
b7ea00
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
b7ea00
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
b7ea00
---
b7ea00
 target/i386/tcg/translate.c | 6 ++----
b7ea00
 1 file changed, 2 insertions(+), 4 deletions(-)
b7ea00
b7ea00
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
b7ea00
index 037bc47e7c..e68375b19d 100644
b7ea00
--- a/target/i386/tcg/translate.c
b7ea00
+++ b/target/i386/tcg/translate.c
b7ea00
@@ -2845,10 +2845,6 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, i=
b7ea00
nt diff, int tb_num)
b7ea00
         }
b7ea00
     }
b7ea00
     new_eip &=3D mask;
b7ea00
-    new_pc =3D new_eip + s->cs_base;
b7ea00
-    if (!CODE64(s)) {
b7ea00
-        new_pc =3D (uint32_t)new_pc;
b7ea00
-    }
b7ea00
=20
b7ea00
     gen_update_cc_op(s);
b7ea00
     set_cc_op(s, CC_OP_DYNAMIC);
b7ea00
@@ -2864,6 +2860,8 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, in=
b7ea00
t diff, int tb_num)
b7ea00
             tcg_gen_andi_tl(cpu_eip, cpu_eip, mask);
b7ea00
             use_goto_tb =3D false;
b7ea00
         }
b7ea00
+    } else if (!CODE64(s)) {
b7ea00
+        new_pc =3D (uint32_t)(new_eip + s->cs_base);
b7ea00
     }
b7ea00
=20
b7ea00
     if (use_goto_tb && translator_use_goto_tb(&s->base, new_pc)) {
b7ea00
--=20
b7ea00
2.34.1