From nobody Sun Apr 12 07:21:21 2026 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1771075123; cv=none; d=zohomail.com; s=zohoarc; b=NSRZ/oq8zyN7Y70Wbh32eQQVQgHErIR6yWskJSdA/AtI2hw9ftzeQCRX3Mw/A7OIjrdzhf0/gkLYA1SdfSkDlLTA9qrrKdkPUJ8HDCBpTJFpS3rns4a7pgQm8HEl1q9tJH+L5kAJkFlOPuN4RwGmg2v67j9d7aI/WuOKZKg6qWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771075123; 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=uz2Q2r2Kx3bjbyNSueRh5MEBau+EbL1eCrXfzJbXPkc=; b=iOvWbXJhG9dMo189VNdm1iC9XM0iohq0cDRTmxNKFjy0LzSrnHeox9rJbl4dhni81XjHfCiB2cuflqHd7NwTiCcay/RFgiitQ0Jj6oVFLdGSuFrWTiaahkumUDcoqJDpAIDHXw/2V2qOF0Mgx24djg2C6ZlyU0JQ7tqjvYoO42U= 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 1771075123483724.5614050813807; Sat, 14 Feb 2026 05:18:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrFWt-0005Wc-GI; Sat, 14 Feb 2026 08:17:49 -0500 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 1vrFWX-0005UC-CX for qemu-devel@nongnu.org; Sat, 14 Feb 2026 08:17:26 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vrFWV-0007y4-Th for qemu-devel@nongnu.org; Sat, 14 Feb 2026 08:17:25 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-435f177a8f7so1907353f8f.1 for ; Sat, 14 Feb 2026 05:17:23 -0800 (PST) Received: from archlinux (dynamic-092-224-176-164.92.224.pool.telefonica.de. [92.224.176.164]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac800esm13340471f8f.27.2026.02.14.05.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Feb 2026 05:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771075042; x=1771679842; 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=uz2Q2r2Kx3bjbyNSueRh5MEBau+EbL1eCrXfzJbXPkc=; b=Smchuys8tzugLYRJJvtFvGNYbjGYPkFgPjAGxDfEHh7QiBGbLGJ0Rcktm8iEcZhmbm lAnwP8va8J0jRcyXMkT/XM50BNcHn0PQQ/SzWS3kzTyUMyPK7cbjoXgRdfO9ALM42khU 6cw5QmD92r/CgC0QbUs87jAi3bOaeOZZYegxSXE4We2JZmBMDJYo9PJx6EsDtbccDohQ PN55BlT7J7TlKadDeUmSs9NN0zj+1czZimK1wClx3qdxX0krHbd3prCT4G9SbmU8sTPm OoFBjkw5gZtPTE3G+446Fr3xaFNSJ/6rAHEgODvli0FvikpsVqAgcEGWy5ib/W3HHzly n/IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771075042; x=1771679842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uz2Q2r2Kx3bjbyNSueRh5MEBau+EbL1eCrXfzJbXPkc=; b=qITWwQlhcKPZMkS5jzpUA/Bxhtg2Ik0ces4RrXBFInpe0BuSHR8pOt5BxUWrID4By7 8l7mfajNOrghP68eGZnTHPfAEriqw4E9ebqNIT82f1UmMzu3LxwKtxHa3WBVH+oTfGWa aY7XbVZotAMyarl1N6k+BlCcrhF4P3ty1rUA/k7rRE9dGpaD3YP/QhT5QM/3ktuHQcDF jRFpWNNLYAd2beJpvQOwQriwmED4aTJN5qyRQeF6apEv6/V77JRie+R1KvMjO4zOioeP gluypZUXaaaDivRzfUs3XiLC5XbJ2MLSGTCC72/V/ZCQug8W3xu3vF39W+aXR04pQ6Ql AWeg== X-Gm-Message-State: AOJu0YxJw3uLS/o9vWGbpiX5ifcaDxpUb4VfgTObkP8oclI0tQx6mQ8t YCK89X7PI4ACaHmfVuQ4GK5qfUUl5BoQadqAEsbE3AtAkFrIEU9riPv0hhAskgOb X-Gm-Gg: AZuq6aJeM3/0r983ipxdXhyAsVY1YQ4N1Fx2/UpCLkV2OnBtwaUEgHG6t5laIPuLsin raFJjHBSHqmL9Q4YTB8BWuypvrnOTclCBrn0C0/ekmh4sr7i9jk+jjl/Gz/qNfMfqSCqtmP512g wWa1WAtvA4wc5vYzvj76CHC7VP0pSpqluG6smfBRIAbhX1bGw+40VvhuImQdDt9+woa2ZC/pcLp OgJ3G4Lb81P2Ouv4kCWkOUwNWrj/CLgKEmpdiUG3PvE1xmXtDGtI9ESehzkNpDhbH19uQRKSvT4 5WFMfgDt83plcosb62EuK1PeH6Nk2w6YD5aWac1+YpV0d3zHpSucqa6HnYA7e8WtbHOHEcGZCFo DhNEGpNABuVdE+aMWXhIZqiwY6YZoh+TjFJKfziTFwkF6LL17XKozZ5Fx+memuu9Ap44mG+l+Xt Xi6Y1ehkFM4Qrd4nqb+1Nw7SlxsiPdpqW8IzEKIEHMBNY248rPJUKGvIipHUZo6kWaVAFvP93OQ Dv0t17PqXj9LnVM X-Received: by 2002:a05:6000:2387:b0:435:9a50:bbb4 with SMTP id ffacd0b85a97d-4379dbae64dmr3963260f8f.59.1771075041860; Sat, 14 Feb 2026 05:17:21 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Cameron Esfahani , Magnus Kulke , Roman Bolshakov , Phil Dennis-Jordan , Wei Liu , Mohamed Mediouni , Bernhard Beschow Subject: [PATCH 3/3] target/i386/emulate/x86_decode: Actually use stream in decode_instruction_stream() Date: Sat, 14 Feb 2026 14:16:59 +0100 Message-ID: <20260214131659.31378-4-shentey@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260214131659.31378-1-shentey@gmail.com> References: <20260214131659.31378-1-shentey@gmail.com> 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=2a00:1450:4864:20::431; envelope-from=shentey@gmail.com; helo=mail-wr1-x431.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, FREEMAIL_FROM=0.001, 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: qemu development 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 @gmail.com) X-ZM-MESSAGEID: 1771075125010158500 Content-Type: text/plain; charset="utf-8" Compared to decode_instruction(), decode_instruction_stream() has an additi= onal stream parameter which avoids some guest memory accesses during instruction decoding. Both functions defer the actual work to decode_opcode() which wou= ld set the stream pointer to zero such that decode_instruction_stream() essent= ially behaved like decode_instruction(). Given that all callers of decode_instruction_stream() properly zero-initialize the decode parameter, = the memset() call can be moved into decode_instruction() which is the only other user of decode_opcode(). This preserves the non-zero stream pointer which avoids extra guest memory accesses. Fixes: 1e25327b244a ("target/i386/emulate: Allow instruction decoding from = stream") cc: qemu-stable Signed-off-by: Bernhard Beschow --- target/i386/emulate/x86_decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_dec= ode.c index 6ad03b71b0..7bbcd2a9a2 100644 --- a/target/i386/emulate/x86_decode.c +++ b/target/i386/emulate/x86_decode.c @@ -2088,8 +2088,6 @@ static void decode_opcodes(CPUX86State *env, struct x= 86_decode *decode) =20 static uint32_t decode_opcode(CPUX86State *env, struct x86_decode *decode) { - memset(decode, 0, sizeof(*decode)); - decode_prefix(env, decode); set_addressing_size(env, decode); set_operand_size(env, decode); @@ -2101,6 +2099,8 @@ static uint32_t decode_opcode(CPUX86State *env, struc= t x86_decode *decode) =20 uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode) { + memset(decode, 0, sizeof(*decode)); + return decode_opcode(env, decode); } =20 --=20 2.53.0