From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922733; cv=none; d=zohomail.com; s=zohoarc; b=a0krtD2ZmsFJ8sLIEAzL1GjYbvyaPPd7fghKZGb9WpL5XRh7OImweoKX8Y1L1vAPdOIIjHBkJISBNmmqomnHie+WGUaPlXBZdJ/2C6n1l9lnt2D6hpcu9G3o689J/x+t8EgRtkCGNYYIBNemLlx0XiazRRtapmpEkX+AoqOMw/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922733; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=lJNt3/ihgiA7wrTRpTmrsWfi9v5xQ9uDbiaHQsILxco=; b=YBRTlupjG8Md7g/puIKO8KmpUTtxQiakZsUq92f0ATtwlOcrbOW95AA4jQQrI96TXg05E2963e93czIzQyp3iXyxIpXK8tD4x3uuCh3KqlamlEpJWGiBSfXAgQn+B6feV/Fydd3kYXX7eIJzuLvAzuQlTuldhNjFw33u0576vCQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179492273368299.05847897239971; Tue, 17 Nov 2026 05:38:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNp-0006YD-2W; Tue, 17 Nov 2026 08:38:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNn-0006Xo-Lc for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:37:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNm-00035k-5F for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:37:59 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655--1Tnb-M0Oy-Cf-rNVequrA-1; Tue, 17 Nov 2026 08:37:54 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A117219560BA for ; Tue, 17 Nov 2026 13:37:53 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3440428 for ; Tue, 17 Nov 2026 13:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lJNt3/ihgiA7wrTRpTmrsWfi9v5xQ9uDbiaHQsILxco=; b=dkqq2eEPjUXKkRtzBD/vJNIxweAOLkd8+ytVjj5TGPERPQ9NZlSpOMS1Abp5ZAmY86fxo9 umZlHqIm8mjHaMM0z3TNT43l4B0bYHdCE2kB/5ligruaVqNZYUwLJ2OyT5wNGuUpgtG42/ KD/elQNhSewqCathFhP0uLY5vHVSEgA= X-MC-Unique: -1Tnb-M0Oy-Cf-rNVequrA-1 X-Mimecast-MFC-AGG-ID: -1Tnb-M0Oy-Cf-rNVequrA_1794922673 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/15] target/i386/tcg: fix CPUID checks for TZCNT and LZCNT Date: Tue, 17 Nov 2026 14:37:36 +0100 Message-ID: <20261117133750.322253-2-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922735770158500 Content-Type: text/plain; charset="utf-8" decode_0FBC() decodes F3 0F BC as TZCNT only if the CPU has ABM, and decode_0FBD() decodes F3 0F BD as LZCNT only if the CPU has BMI1. The features are the other way round: TZCNT is part of BMI1, and LZCNT is part of ABM. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index aa22014786f..b51b2f1ae9d 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -688,7 +688,7 @@ static void decode_0FBC(DisasContext *s, CPUX86State *e= nv, X86OpEntry *entry, ui X86_OP_ENTRYwr(TZCNT, G,v, E,v, zextT0), /* 0xf3 */ X86_OP_ENTRY2(BSF, G,v, E,v, zextT1), /* 0xf2 */ }; - if (!(s->cpuid_ext3_features & CPUID_EXT3_ABM)) { + if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) { *entry =3D opcodes_0FBC[0]; } else { *entry =3D *decode_by_prefix(s, opcodes_0FBC); @@ -703,7 +703,7 @@ static void decode_0FBD(DisasContext *s, CPUX86State *e= nv, X86OpEntry *entry, ui X86_OP_ENTRYwr(LZCNT, G,v, E,v, zextT0), /* 0xf3 */ X86_OP_ENTRY2(BSR, G,v, E,v, zextT1), /* 0xf2 */ }; - if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) { + if (!(s->cpuid_ext3_features & CPUID_EXT3_ABM)) { *entry =3D opcodes_0FBD[0]; } else { *entry =3D *decode_by_prefix(s, opcodes_0FBD); --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922696; cv=none; d=zohomail.com; s=zohoarc; b=VTAOKPi8FpYnTnIDF4dFd5oilbKoCAWcZ/q417INeM1tsRRnI2aQhmyrKuxXL6Wfpgck36vyLo1Nxit1sLDoJmhBchzcaMd7K+jWRSW3usfqSN5WY00SbG7BewOgq2tzSY18XlpnF88DajB4ADu1MapFyJtYGJMdJmVgB98UzZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922696; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=YcuvNukDivAPcZf+pZTHmQNWOj+py513l8Uj9h0xvq0=; b=LSKGypAi64IFK21+eXNvp4LICc+toHt8pivdTaGhG8Mh/4/HNmGKX3IRKn0SlIADxlfWYFTKMicr4VqWRLwb6e70TUTgk1Qes20UlvmTiHmH1Fncrc14ZzhwK4gNfLLOl76MT+rgXQ1+wxe0CKUs1R0SxVEx+411e0vS9CxXatk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922696722758.1180380152948; Tue, 17 Nov 2026 05:38:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNp-0006Yl-TO; Tue, 17 Nov 2026 08:38:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNn-0006Xx-Uc for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:37:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNm-00035w-5p for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:37:59 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-NKQKDmLqNQCMkEvdpdv64w-1; Tue, 17 Nov 2026 08:37:55 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B3921195605F for ; Tue, 17 Nov 2026 13:37:54 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0DA3441F for ; Tue, 17 Nov 2026 13:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YcuvNukDivAPcZf+pZTHmQNWOj+py513l8Uj9h0xvq0=; b=KJvdoAhJsPLFJJQj3kOIxJPJMfWIejvZiScuxfVi08zhQpxXHiM25yrB5gx0wMOuotMKYG 61ybma40Nei0RftTk6P9IH3sYyPNDPsioWkhfU9B0Lu0XP03qVNqMmiwGtYe+5Lo5jwJIa 7wIlWUbt9zHJoiF4xGCfaX9LROgdgko= X-MC-Unique: NKQKDmLqNQCMkEvdpdv64w-1 X-Mimecast-MFC-AGG-ID: NKQKDmLqNQCMkEvdpdv64w_1794922674 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/15] target/i386/tcg: reject VEX encodings of PBLENDVB, BLENDVPS and BLENDVPD Date: Tue, 17 Nov 2026 14:37:37 +0100 Message-ID: <20261117133750.322253-3-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922699472158501 Content-Type: text/plain; charset="utf-8" The opcodes 66 0F 38 10, 14 and 15 (PBLENDVB, BLENDVPS and BLENDVPD) have vex_class 4, which allows both the legacy and the VEX encoding, so VEX.66.0F38 10, 14 and 15 were decoded as the same instructions. The VEX forms of these instructions are VPBLENDVB, VBLENDVPS and VBLENDVPD, which have four operands and are in map 0F 3A, so the VEX opcodes in map 0F 38 should raise #UD. Keep vex_class 4, which provides the legacy SSE checks, and add a new vex_special that raises #UD if the VEX or EVEX prefix is present. This is borderline disgusting, but an effective solution to x86's opcode sprawl will have to wait for a new AI policy... Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 3 ++ tests/tcg/i386/test-i386-blendv.c | 51 +++++++++++++++++++++++++++++++ target/i386/tcg/decode-new.c.inc | 16 +++++++--- tests/tcg/i386/meson.build | 1 + tests/tcg/x86_64/meson.build | 1 + 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 tests/tcg/i386/test-i386-blendv.c diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index b40c75fa222..7f7ed3b6cf4 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -257,6 +257,9 @@ typedef enum X86InsnSpecial { typedef enum X86VEXSpecial { X86_VEX_None, =20 + /* SSE and AVX instructions use different encoding */ + X86_VEX_SSEOnly, + /* Legacy SSE instructions that allow unaligned operands */ X86_VEX_SSEUnaligned, =20 diff --git a/tests/tcg/i386/test-i386-blendv.c b/tests/tcg/i386/test-i386-b= lendv.c new file mode 100644 index 00000000000..4f111fa4745 --- /dev/null +++ b/tests/tcg/i386/test-i386-blendv.c @@ -0,0 +1,51 @@ +/* + * Check that the legacy BLENDVPS, BLENDVPD and PBLENDVB exist, while the + * VEX encodings in the same opcodes do not (VBLENDVPS and the others are = in + * map 0F 3A as they add *two* register operands, and the second is encoded + * in an immediate byte). + */ +#include +#include +#include +#include + +static sigjmp_buf jmp_env; + +static void sigill_handler(int sig) +{ + siglongjmp(jmp_env, 1); +} + +/* 66 0F 38 xx with modrm =3D 11 001 001 (xmm1, xmm1 operands). */ +#define SSE_INSN(op) asm volatile(".byte 0x66, 0x0f, 0x38, " #op ", 0xc9" \ + : : : "xmm0", "xmm1") + +/* Same but encoded with a VEX3 prefix: RXB=3D111b, mmmmm=3D2 (0F38), w=3D= 0, + * VVVV=3D1111b (forced because QEMU does not list an Hx operand), + * l=3D0 (128-bit), pp=3D1 (66h). */ +#define VEX_INSN(op) asm volatile(".byte 0xc4, 0xe2, 0x79, " #op ", 0xc9") + +#define CHECK_VEX_ILLEGAL(op) \ + do { \ + if (sigsetjmp(jmp_env, 1) =3D=3D 0) { \ + VEX_INSN(op); \ + printf("VEX " #op " did not fault\n"); \ + exit(1); \ + } \ + } while (0) + +int main(void) +{ + struct sigaction act =3D { .sa_handler =3D sigill_handler }; + + sigaction(SIGILL, &act, NULL); + + SSE_INSN(0x10); + SSE_INSN(0x14); + SSE_INSN(0x15); + + CHECK_VEX_ILLEGAL(0x10); + CHECK_VEX_ILLEGAL(0x14); + CHECK_VEX_ILLEGAL(0x15); + return 0; +} diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index b51b2f1ae9d..5b3d772d999 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -120,7 +120,8 @@ * * (*) AMD lists VPBLENDVB as related to SSE4.1 PBLENDVB, which may * explain why it is considered exception class 4. However, - * Intel says that VEX-only instructions should be in class 6... + * the two have different encodings (in 0F38 for SSE, in 0F3A + * for AVX). * * (+) Not found in Intel's table 2-16 * @@ -250,6 +251,7 @@ #define vex2_rep3 .vex_class =3D 2, .vex_special =3D X86_VEX_REPScalar, #define vex3 .vex_class =3D 3, #define vex4 .vex_class =3D 4, +#define sse4 .vex_class =3D 4, .vex_special =3D X86_VEX_SSEOnly, #define vex4_unal .vex_class =3D 4, .vex_special =3D X86_VEX_SSEUnaligned, #define vex4_rep5 .vex_class =3D 4, .vex_special =3D X86_VEX_REPScalar, #define vex5 .vex_class =3D 5, @@ -732,10 +734,10 @@ static const X86OpEntry opcodes_0F38_00toEF[240] =3D { [0x06] =3D X86_OP_ENTRY3(PHSUBD, V,x, H,x, W,x, vex4 cpuid(SSSE= 3) mmx avx2_256 p_00_66), [0x07] =3D X86_OP_ENTRY3(PHSUBSW, V,x, H,x, W,x, vex4 cpuid(SSSE= 3) mmx avx2_256 p_00_66), =20 - [0x10] =3D X86_OP_ENTRY2(PBLENDVB, V,x, W,x, vex4 cpuid(SSE4= 1) avx2_256 p_66), + [0x10] =3D X86_OP_ENTRY2(PBLENDVB, V,x, W,x, sse4 cpuid(SSE4= 1) p_66), [0x13] =3D X86_OP_ENTRY2(VCVTPH2PS, V,x, W,xh, vex11 chk(W0) c= puid(F16C) p_66), - [0x14] =3D X86_OP_ENTRY2(BLENDVPS, V,x, W,x, vex4 cpuid(SSE4= 1) p_66), - [0x15] =3D X86_OP_ENTRY2(BLENDVPD, V,x, W,x, vex4 cpuid(SSE4= 1) p_66), + [0x14] =3D X86_OP_ENTRY2(BLENDVPS, V,x, W,x, sse4 cpuid(SSE4= 1) p_66), + [0x15] =3D X86_OP_ENTRY2(BLENDVPD, V,x, W,x, sse4 cpuid(SSE4= 1) p_66), /* Listed incorrectly as type 4 */ [0x16] =3D X86_OP_ENTRY3(VPERMD, V,qq, H,qq, W,qq, vex6 chk(W= 0) cpuid(AVX2) p_66), /* vpermps */ [0x17] =3D X86_OP_ENTRY3(VPTEST, None,None, V,x, W,x, vex4 cpuid= (SSE41) p_66), @@ -3114,6 +3116,12 @@ static bool validate_vex(DisasContext *s, X86Decoded= Insn *decode) } break; =20 + case X86_VEX_SSEOnly: + if (s->prefix & PREFIX_VEX) { + goto illegal; + } + break; + case X86_VEX_SSEUnaligned: /* handled in sse_needs_alignment. */ break; diff --git a/tests/tcg/i386/meson.build b/tests/tcg/i386/meson.build index 648b516582e..c912f37fab7 100644 --- a/tests/tcg/i386/meson.build +++ b/tests/tcg/i386/meson.build @@ -10,6 +10,7 @@ tests +=3D { }, 'test-aes.c': {'cflags': ['-O1', '-msse2', '-maes']}, 'test-i386-adcox.c': {'cflags': ['-O2']}, + 'test-i386-blendv.c': {}, 'test-i386-bmi2.c': {'cflags': ['-O2', '-fwrapv']}, 'test-i386-f2xm1.c': {}, 'test-i386-fbstp.c': {}, diff --git a/tests/tcg/x86_64/meson.build b/tests/tcg/x86_64/meson.build index fc7f48e98eb..9738d04220b 100644 --- a/tests/tcg/x86_64/meson.build +++ b/tests/tcg/x86_64/meson.build @@ -47,6 +47,7 @@ tests +=3D { 'exe_name': 'test-x86_64' }, '../i386/test-i386-adcox.c': {'cflags': ['-O2']}, + '../i386/test-i386-blendv.c': {}, '../i386/test-i386-bmi2.c': {'cflags': ['-O2', '-fwrapv']}, '../i386/test-idiv-overflow.c': {}, } --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922918; cv=none; d=zohomail.com; s=zohoarc; b=Q2MvCYibetaOIMWLU+vRSPjFrKfyrJYHT7lLDdv/fordXiJXtE35awOo7XffJZ+3T38qWCTexacviZc5sByXw3fVwnNr+GAPmuYquIMeLzhnyWivUGfX8PcTI/rlFp/BNXz4zyUi6XXNxA5r9hxMNF7eiKH9+NdNi1eoF4uC+HU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922918; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=m4t6VyO/l/uAQGoH822rv/6kOmEcDv36bSjYNhXgTi4=; b=YEtxqRN8QTKgglW7GsTqnf5radMu975VTGfbLmBZ0RojYS++vVBet5l8zL8OGbYEcLqZjqP9RyxMvPOslkZOJmUo84eHEwZ20ksNmuLWp2fAcNVHDcXNNlHH74275Bvt8fPNJHQLookRcvg0icz9vxvEjKZXP/FCH8ntAbXuL04= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922918591715.1614916021607; Tue, 17 Nov 2026 05:41:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNq-0006Yt-DI; Tue, 17 Nov 2026 08:38:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNo-0006Y7-Ru for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNn-000369-2Y for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:00 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-7u8VpsLsMwmQB5_qHj10wA-1; Tue, 17 Nov 2026 08:37:56 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C78D41800551 for ; Tue, 17 Nov 2026 13:37:55 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 21D0341F for ; Tue, 17 Nov 2026 13:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m4t6VyO/l/uAQGoH822rv/6kOmEcDv36bSjYNhXgTi4=; b=IhEfx2TfQlG/LRBXtL4ZMzYhOmDwegEyOwyLcfaIkPTuSe0oXfE8gV/Jn1YQNqVoS6soXk vFQvxAP2tzgHAzeaU3lJIx7DST+SLyWXyk9psdR2rdWtXqf93EScldUsqJshnmiFNu1Qv9 aY4hwgKmwFc09mScfLM0wTA/qoXyzTg= X-MC-Unique: 7u8VpsLsMwmQB5_qHj10wA-1 X-Mimecast-MFC-AGG-ID: 7u8VpsLsMwmQB5_qHj10wA_1794922675 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/15] target/i386/tcg: fix SETCC(zu) optimization Date: Tue, 17 Nov 2026 14:37:38 +0100 Message-ID: <20261117133750.322253-4-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794922919558158500 Content-Type: text/plain; charset="utf-8" With EVEX.ND=3D1, SETcc zero extends its result to the whole register, which validate_evex_apx() requests with EXT_Unsigned. QEMU is trying to avoid the extension by changing the size of the operand, but it sets a field of the row that is unused, because op1 is None. Do it in gen_SETcc() instead. The result of setcc is 0 or 1, so writing the whole register has the same effect as the zero extension, and gen_writeback() skips the extension. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 3 --- target/i386/tcg/emit.c.inc | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 5b3d772d999..e985b128893 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2109,9 +2109,6 @@ static void decode_EVEX4cc(DisasContext *s, CPUX86Sta= te *env, X86OpEntry *entry, =20 if (s->prefix & PREFIX_REPNZ) { *entry =3D setcc; - if (EVEX_APX_ND(s)) { - entry->s1 =3D X86_SIZE_q; /* optimization for zu */ - } } else { *entry =3D (EVEX_APX_ND(s) ? cfcmov_nd1 : cfcmov_nd0)[EVEX_APX_NF(= s)][mod =3D=3D 3]; } diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index b3029f6fbbe..49d33223f41 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -4136,6 +4136,14 @@ static void gen_SCAS(DisasContext *s, X86DecodedInsn= *decode) static void gen_SETcc(DisasContext *s, X86DecodedInsn *decode) { gen_setcc(s, decode->b & 0xf, s->T0); + + /* + * With APX ZU, the written value requests zero extension. Since T0 is + * 0 or 1, writing the whole register is the same and saves the extens= ion. + */ + if (decode->op[0].ext =3D=3D X86_EXT_Unsigned && !decode->op[0].has_ea= ) { + decode->op[0].ot =3D MO_TL; + } } =20 static void gen_SFENCE(DisasContext *s, X86DecodedInsn *decode) --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922695; cv=none; d=zohomail.com; s=zohoarc; b=SMuAEvSjTSvL7IeLLpsegV0SrliMAELB4hB+rh3+/npkAaP6MT8wBK9S8oOqlYJmy2EqoDKRg3QZAmpd4XVl9GKrGBxkzsrrz4u7sW+a/h3wI2Pq8sjhiM9xvraC91JYloaDUnH9f1samMxIgYwSvwPPYYC/Jt7KnzxYsU5UbAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922695; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PAqdlDBUK3KF7IPQrCnLZnJHYSzmn5xulUU2OWyh1gE=; b=enM6qDwi4knhGLhfQpNdt0LSx/SE1UkfiC5i7s7tVpYneTNfBU4XHbNp2jNj1sXVTU5t1rHUcVDQtMJ/y3PbyH83KrTqaQsC8+GWqBpXTeQhPiAY/P23tetQLAVjWIDE/hRXMnGkJIOeWWg6OpCuDbwTvOoMhSIoRWAWpPXts+g= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922695465568.9614704622088; Tue, 17 Nov 2026 05:38:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNu-0006bW-Vf; Tue, 17 Nov 2026 08:38:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNs-0006Zm-CB for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNq-00036z-Qw for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:04 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-Gy9hgFDgNlW92Qq_XgYlxg-1; Tue, 17 Nov 2026 08:37:58 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 799711800546; Tue, 17 Nov 2026 13:37:57 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 362E841F; Tue, 17 Nov 2026 13:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PAqdlDBUK3KF7IPQrCnLZnJHYSzmn5xulUU2OWyh1gE=; b=JmUbtudKoStFfBHOajwe8z+aRgFWlK0XRckd8SXYpg/RjjwdyDAqUc5wL5riDjmHxjrJkp cLCL94Bjb+AUBT3q7wELFkOJC/xSJ8WZpDpSdtzZVL8ys9hs8EXTgGwTvYoMgiMdd9+R3l 3Pz3lhTgPvYmImqGRVAlUrYx5QSMKMo= X-MC-Unique: Gy9hgFDgNlW92Qq_XgYlxg-1 X-Mimecast-MFC-AGG-ID: Gy9hgFDgNlW92Qq_XgYlxg_1794922678 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Denis V. Lunev" , qemu-stable@nongnu.org Subject: [PULL 04/15] target/i386/kvm: fix latched INIT lost in kvm_put_vcpu_events() Date: Tue, 17 Nov 2026 14:37:39 +0100 Message-ID: <20261117133750.322253-5-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1794922697550158500 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" CPU_INTERRUPT_INIT is 0x0400, while kvm_vcpu_events.smi.latched_init is a __u8. The assignment truncates the masked value to 0, so every KVM_SET_VCPU_EVENTS tells KVM to clear an INIT it has latched for a vCPU in SMM. smi.pending survives only because CPU_INTERRUPT_SMI is 0x0040; normalize both with !! like the neighbouring fields. Fixes: fc12d72e1082 ("target-i386: add support for SMBASE MSR and SMIs") Cc: qemu-stable@nongnu.org Signed-off-by: Denis V. Lunev Link: https://lore.kernel.org/r/20261103181702.832779-1-den@openvz.org Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e29ecaba575..2d533d4262b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5514,8 +5514,9 @@ static int kvm_put_vcpu_events(X86CPU *cpu, KvmPutSta= te level) /* As soon as these are moved to the kernel, remove them * from cs->interrupt_request. */ - events.smi.pending =3D cs->interrupt_request & CPU_INTERRUPT_S= MI; - events.smi.latched_init =3D cs->interrupt_request & CPU_INTERR= UPT_INIT; + events.smi.pending =3D !!(cs->interrupt_request & CPU_INTERRUP= T_SMI); + events.smi.latched_init =3D + !!(cs->interrupt_request & CPU_INTERRUPT_INIT); cpu_reset_interrupt(cs, CPU_INTERRUPT_INIT | CPU_INTERRUPT_SMI= ); } else { /* Keep these in cs->interrupt_request. */ --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922835; cv=none; d=zohomail.com; s=zohoarc; b=Zg9daVEaiuNV0Rhvz47mtwWeqWMfC/n6F2SNsTrOV2KqylT+udXnBu8T/KvXQanJjtE5dTCmZs3ejm1E60qIoTTkrgiU9MEObDbQ+0OXjkUzSE2UWKJByeg+8zSAUpNut2ib/fJipsQMYPwenBa/EAkoaZE1qnXTX673DvCsK9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922835; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LTwhbN2nqT3khoZUJPypm+ot7xzNDpu1k7s2VFipAQU=; b=U9fYUhh6cJwQ5tMXwitWknzFW+SjQUK//To+eBiOwMa4oehBZ8wzBHvU5cw2Yipo795Zbv/hRyBFyp8mht3zH6yDFOKrJIPvG7ZdO+N4KbC3GPNhnPnOA7k5qRoIXzIR61w2x2tgEaLWDNdeVORFLEFGSRGjsmPN7D1F2O2isOk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922835215170.60338165938958; Tue, 17 Nov 2026 05:40:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNs-0006Zw-Rj; Tue, 17 Nov 2026 08:38:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNr-0006ZE-Jt for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNp-00036b-TC for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:03 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-LzFL9IlqOFuMuljlhdWQGA-1; Tue, 17 Nov 2026 08:37:59 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E2D951800367; Tue, 17 Nov 2026 13:37:58 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 08BA941F; Tue, 17 Nov 2026 13:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LTwhbN2nqT3khoZUJPypm+ot7xzNDpu1k7s2VFipAQU=; b=G48ud81kHTmn07PG4Mk4x8k016w8RMX4Z0Aks1uqx7DezWBdjVM1qA/PYy/oMpNN/a4hP+ 3ROKF30Dns+ITlp5+Pc7atLTExieoc/G0f+HcXboWrSU6czl08u132vHX2mZ+5ASwnaBBZ N7cqcLRkeca8Og8qbtjLzJ8vFA+5owQ= X-MC-Unique: LzFL9IlqOFuMuljlhdWQGA-1 X-Mimecast-MFC-AGG-ID: LzFL9IlqOFuMuljlhdWQGA_1794922679 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Dongli Zhang Subject: [PULL 05/15] target/i386/kvm: set VM ioctl KVM_SET_TSC_KHZ to maintain TSC synchronization Date: Tue, 17 Nov 2026 14:37:40 +0100 Message-ID: <20261117133750.322253-6-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794922836893158500 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang When the guest and host use different TSC frequencies - specifically when "tsc-frequency" is configured - the guest TSC becomes unsynchronized after additional vCPUs are added. Suppose the host TSC frequency is 2596.102 MHz. Here are steps to reproduce: Create the QEMU instance with a different TSC frequency 2596.100 MHz. -cpu host,tsc-frequency=3D2596100000 \ -smp 2,maxcpus=3D8 \ After the guest VM has booted, add two additional vCPUs. (qemu) device_add host-x86_64-cpu,id=3Dcore2,socket-id=3D0,core-id=3D2,thre= ad-id=3D0 (qemu) device_add host-x86_64-cpu,id=3Dcore3,socket-id=3D0,core-id=3D3,thre= ad-id=3D0 The guest TSC becomes unsynchronized. The vCPUs end up with different TSC offsets. host# cat /sys/kernel/debug/kvm/167789-11/vcpu0/tsc-offset -345550695701016 host# cat /sys/kernel/debug/kvm/167789-11/vcpu1/tsc-offset -345550695701016 host# cat /sys/kernel/debug/kvm/167789-11/vcpu2/tsc-offset -345700146347894 host# cat /sys/kernel/debug/kvm/167789-11/vcpu3/tsc-offset -345700945993728 This issue occurs because KVM synchronizes the guest TSC twice for each newly added vCPU. In other words, kvm_synchronize_tsc() is invoked twice per vCPU by KVM. During the first synchronization, kvm->arch.default_tsc_khz is used. During the second synchronization, the TSC frequency configured by QEMU is used. Because different TSC frequencies are used during these two synchronization steps, the guest TSC becomes unsynchronized in KVM. Linux kernel commit ffbb61d09fc5 ("KVM: x86: Accept KVM_[GS]ET_TSC_KHZ as a VM ioctl.") introduced support in KVM to help mitigate this issue. QEMU should add corresponding support to address the problem on its side. Always issue the VM ioctl KVM_SET_TSC_KHZ before creating any vCPUs, so that the default TSC frequency is set correctly for all subsequently created vCPUs. Signed-off-by: Dongli Zhang Link: https://lore.kernel.org/r/20260210202041.153736-1-dongli.zhang@oracle= .com Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2d533d4262b..76528f1123f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2064,6 +2064,9 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **e= rrp) int ret; =20 if (first) { + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + first =3D false; =20 /* @@ -2085,6 +2088,17 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **= errp) return ret; } } + + if (!is_tdx_vm() && env->tsc_khz && + kvm_check_extension(kvm_state, KVM_CAP_VM_TSC_CONTROL)) { + ret =3D kvm_vm_ioctl(kvm_state, KVM_SET_TSC_KHZ, env->tsc_khz); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Unable to set TSC frequency to %"PRId64" kHz", + env->tsc_khz); + return ret; + } + } } =20 if (is_tdx_vm()) { --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922963; cv=none; d=zohomail.com; s=zohoarc; b=Vu76d/O9iTAcLc1t2RB7WDRVgOS+Tzt2wSey0iGT4+6QGrX9SDX258mK/Dee4PhgLP8Z2OGQecaNc6kDvEsG35QlW/m5L6SEtWSAYmON6z9BFT8esHRV4CNX9VFWFNVea/M3qfjJxCtSVdFRVc/6ME81QlUeH+Uns5zvSSUzdNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922963; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jdxw55erMUxd1wmjliFartPOyoUNynfcFZXGkpu034Y=; b=dIzdCNpX9/Lb65+XcAc58IoFXxo63xa0yJuPY0LIB0bcJxl/GjkBsBKufJKAmQfIr+ipQtiYD+d3uRepcp4AKb+UhYYDKTH5hoeJ3CTg1ZIg9pY1O9L/KwaS4o4c22is3RH4bDrUoqTHLLSxfVPnyVDlrMcAP1LP0bCMXKvfleg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179492296344538.30106289103446; Tue, 17 Nov 2026 05:42:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNv-0006bo-RE; Tue, 17 Nov 2026 08:38:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNt-0006aa-5E for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNr-00037b-JG for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:04 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-CzyEMZSlMsWmWVG5d5ICmw-1; Tue, 17 Nov 2026 08:38:01 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6D4EA1800540; Tue, 17 Nov 2026 13:38:00 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 51B49588; Tue, 17 Nov 2026 13:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jdxw55erMUxd1wmjliFartPOyoUNynfcFZXGkpu034Y=; b=I/vTLFjvg1SEPUt8r4eVgNd0NE12prPu+U8rZC5R9rgoCX3usWznmrKToQ5Y3wcuI0dBKa sqowhGetJYsCojHP/o9gQ8ILz5t6y3Zo40HSPrL1qBg9B1penXoJLQeSSc8YrMBV0IGgft MH0Jr05j5ohTThusXd84RQV1yjrR1uo= X-MC-Unique: CzyEMZSlMsWmWVG5d5ICmw-1 X-Mimecast-MFC-AGG-ID: CzyEMZSlMsWmWVG5d5ICmw_1794922680 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Richard Henderson Subject: [PULL 06/15] target/i386/tcg: fix lea address calculation for CS register Date: Tue, 17 Nov 2026 14:37:41 +0100 Message-ID: <20261117133750.322253-7-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794922963944158500 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland When the effective address calculation was simplified in commit 55a15eb3504 ("target/i386/tcg: simplify effective address calculation") the refactoring accidentally introduced the ADDSEG() macro into the CS base address inclusi= on test. Fix the logic in gen_lea_v_seg_dest() to use CODE64() instead of ADDSEG() f= or the CS base address inclusion test, and at the same time split it into a sw= itch statement to make the logic easier to follow. Fixes: 55a15eb3504 ("target/i386/tcg: simplify effective address calculatio= n") Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20260927123807.492352-1-mark.cave-ayland@il= ande.co.uk Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index b715921c379..d4ccddc33fd 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -625,7 +625,25 @@ static void gen_lea_v_seg_dest(DisasContext *s, MemOp = aflag, TCGv dest, TCGv a0, ovr_seg =3D def_seg; } =20 - has_base =3D ovr_seg >=3D R_FS || (ovr_seg >=3D 0 && ADDSEG(s)); + switch (ovr_seg) { + case R_DS: + case R_ES: + case R_SS: + has_base =3D ADDSEG(s); + break; + case R_CS: + has_base =3D !CODE64(s); + break; + case R_FS: + case R_GS: + has_base =3D true; + break; + default: + assert(ovr_seg < 0); + has_base =3D false; + break; + } + easize =3D CODE64(s) ? MO_64 : MO_32; =20 if (has_base) { --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922968; cv=none; d=zohomail.com; s=zohoarc; b=D060X+soZuBF2tFUNnOBgHI4s7w1QuLCOnGXU9HwcIKcAD5GpF5X3q7Dg6lKlJ3oK7eHTs/l9LJOdZU5o07GhOS1IJGbc/SbWIxxb0ZHX7hZzq23793suOOQmEouZsnbWy9WIp7rOPDrkWNR5mdMPxJzDa4rPiC4kp1yhestch0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922968; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QbPiqP84f1nbCjNsl5vAImTMLUhILof6aSiyTbFVTBM=; b=kWagyPW8dopTyLFGrb5mIRIceqykokY/un8vGMl378uW4azvodHw/s4logW/G5eCXNEouZ44uzybu8HwodD/94df/N1r0dU0Wc+3W1kgW9QdDxxQ2OTSN6QcGurqGHR1i7HpavtBwFHVM16tNl64MCULhKx1P22lB3jhPYrrpCI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922968754350.7898221217598; Tue, 17 Nov 2026 05:42:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNx-0006cC-D7; Tue, 17 Nov 2026 08:38:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNw-0006br-AG for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNu-00039h-MC for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:08 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-emoUE3hQNBe5O6FtKwfY5A-1; Tue, 17 Nov 2026 08:38:02 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B357D18002C0; Tue, 17 Nov 2026 13:38:01 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D143241F; Tue, 17 Nov 2026 13:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QbPiqP84f1nbCjNsl5vAImTMLUhILof6aSiyTbFVTBM=; b=U1ifBrLGT1+BOSTaPxUaP5+zILrnNb5ATBpfAzgvUlBS5zwzOKV55i3pEO1NZvXVFFNH5U pMRIKjXTOcV0WHSwtey1IMlwbzMXGu0K+62y4O4zg9tScOrKr1K5Jgk0sPtpCyeemGvZzu bEEX8NJvo7D9Vkhe40hmCym2YVDNpuc= X-MC-Unique: emoUE3hQNBe5O6FtKwfY5A-1 X-Mimecast-MFC-AGG-ID: emoUE3hQNBe5O6FtKwfY5A_1794922681 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 07/15] tests/tcg: fix load/restore for test-avx and test-mmx Date: Tue, 17 Nov 2026 14:37:42 +0100 Message-ID: <20261117133750.322253-8-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794922970002158500 Content-Type: text/plain; charset="utf-8" If "r"(&result) uses %rsp, which GCC16 seems eager to do, the comparison fails because run_test()'s assembly block moves %rsp below the red zone. Use fixed registers instead. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- tests/tcg/i386/test-avx.c | 22 ++++++++++++---------- tests/tcg/i386/test-mmx.c | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/tcg/i386/test-avx.c b/tests/tcg/i386/test-avx.c index 80fe363cfc2..bb37f7953d0 100644 --- a/tests/tcg/i386/test-avx.c +++ b/tests/tcg/i386/test-avx.c @@ -150,9 +150,10 @@ static void run_test(const TestDef *t) "push rbx\n\t" "push rcx\n\t" "push rdx\n\t" - "push %1\n\t" - "push %2\n\t" - "mov rax, %0\n\t" + "push rsi\n\t" + "push rdi\n\t" + "push rsi\n\t" // result + "push rdi\n\t" // fn "pushf\n\t" "pop rbx\n\t" "shr rbx, 8\n\t" @@ -165,19 +166,21 @@ static void run_test(const TestDef *t) REG(LOADREG) "mov rax, 0x240[rax]\n\t" "call [rsp]\n\t" - "mov [rsp], rax\n\t" - "mov rax, 8[rsp]\n\t" + "mov [rsp], rax\n\t" // save rax + "mov rax, 8[rsp]\n\t" // get back result REG(STOREREG) "mov rbx, [rsp]\n\t" - "mov 0x240[rax], rbx\n\t" + "mov 0x240[rax], rbx\n\t" // rax "mov rbx, 0\n\t" - "mov 0x270[rax], rbx\n\t" - "mov 0x278[rax], rbx\n\t" + "mov 0x270[rax], rbx\n\t" // rsp + "mov 0x278[rax], rbx\n\t" // rbp "pushf\n\t" "pop rbx\n\t" "and rbx, 0xff\n\t" "mov 0x2c0[rax], rbx\n\t" "add rsp, 16\n\t" + "pop rdi\n\t" + "pop rsi\n\t" "pop rdx\n\t" "pop rcx\n\t" "pop rbx\n\t" @@ -185,9 +188,8 @@ static void run_test(const TestDef *t) "add rsp, 128\n\t" MMREG(STOREMM) YMMREG(STOREYMM) - : : "r"(init), "r"(&result), "r"(t->fn) + : : "a"(init), "S"(&result), "D"(t->fn) : "memory", "cc", - "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", diff --git a/tests/tcg/i386/test-mmx.c b/tests/tcg/i386/test-mmx.c index 09e5d583ffd..1a640f8bbbf 100644 --- a/tests/tcg/i386/test-mmx.c +++ b/tests/tcg/i386/test-mmx.c @@ -154,9 +154,10 @@ static void run_test(const TestDef *t) "push rbx\n\t" "push rcx\n\t" "push rdx\n\t" - "push %1\n\t" - "push %2\n\t" - "mov rax, %0\n\t" + "push rsi\n\t" + "push rdi\n\t" + "push rsi\n\t" // result + "push rdi\n\t" // fn "pushf\n\t" "pop rbx\n\t" "shr rbx, 8\n\t" @@ -169,19 +170,21 @@ static void run_test(const TestDef *t) REG(LOADREG) "mov rax, 0xc0[rax]\n\t" "call [rsp]\n\t" - "mov [rsp], rax\n\t" - "mov rax, 8[rsp]\n\t" + "mov [rsp], rax\n\t" // save rax + "mov rax, 8[rsp]\n\t" // get back result REG(STOREREG) "mov rbx, [rsp]\n\t" - "mov 0xc0[rax], rbx\n\t" + "mov 0xc0[rax], rbx\n\t" // rax "mov rbx, 0\n\t" - "mov 0xf0[rax], rbx\n\t" - "mov 0xf8[rax], rbx\n\t" + "mov 0xf0[rax], rbx\n\t" // rsp + "mov 0xf8[rax], rbx\n\t" // rbp "pushf\n\t" "pop rbx\n\t" "and rbx, 0xff\n\t" "mov 0x140[rax], rbx\n\t" "add rsp, 16\n\t" + "pop rdi\n\t" + "pop rsi\n\t" "pop rdx\n\t" "pop rcx\n\t" "pop rbx\n\t" @@ -190,9 +193,8 @@ static void run_test(const TestDef *t) MMREG(STOREMM) EMMS "\n\t" XMMREG(STOREXMM) - : : "r"(init), "r"(&result), "r"(t->fn) + : : "a"(init), "S"(&result), "D"(t->fn) : "memory", "cc", - "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922700; cv=none; d=zohomail.com; s=zohoarc; b=m+Pc5geHVI3/kV+E/pnz7ccC5wu3E8mQLa/+JIKQnMNQrzLzZ1yVzWSCMKJWLPpJHL+9XmYa7343wS8tWwmZE0D90PTifOb7xAipJ0L+3pUwRxZ5m42PandZEidGsTgGAi7t0XuxzVU4L+YHDV/8SNuG62bIidwoyQugIfdrgNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922700; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+2gaaMxgG4mjw0pyjAnd/TnUbLRUfQoPFqZhgO2YvNY=; b=MTp1lAkeW9G7uCZ+zDoZZGXrPLA8WgPc2OQv95UUnddj805rjzbFtS8Yl+S48FRU04pA2k3ptZUGRBKQe/8go7FgT3jLD933FHzXbT72eHKtRK3n/tf7pxIWrwv5vJ748XYZh8fS7aTs2J45xFzoKLjfYsYS052ChpF00+lMT+c= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922700992442.42831089401864; Tue, 17 Nov 2026 05:38:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJNw-0006cB-Vy; Tue, 17 Nov 2026 08:38:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNw-0006bp-1O for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNu-00039W-CG for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:07 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-hVZrsnwePRuKILhXfH7jfQ-1; Tue, 17 Nov 2026 08:38:04 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3577E1956062; Tue, 17 Nov 2026 13:38:03 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 53DB841F; Tue, 17 Nov 2026 13:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+2gaaMxgG4mjw0pyjAnd/TnUbLRUfQoPFqZhgO2YvNY=; b=PjP2e81A+Z5zvCnvQCsnpta7dzDnl6sGmkNlxbrz8vsJONgggAbY9clh2ssL6YDrRoPGkx ZNiQdCvw8LoMnrppOS6YFP0Lk/97yWn5/1MfIxFGQJbMG5UFSCWv95+ah29kbyku3pAXsN TjzTBXEP6HxEfkoYZSMQrbO1A6NvNo4= X-MC-Unique: hVZrsnwePRuKILhXfH7jfQ-1 X-Mimecast-MFC-AGG-ID: hVZrsnwePRuKILhXfH7jfQ_1794922683 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: NickSampanis Subject: [PULL 08/15] target/i386/tcg: Fix 64-bit RSP truncation on retf in 64-bit mode Date: Tue, 17 Nov 2026 14:37:43 +0100 Message-ID: <20261117133750.322253-9-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922703304158500 Content-Type: text/plain; charset="utf-8" From: NickSampanis When executing retf in 64-bit mode with a 16- or 32-bit operand size, `helper_ret_protected()` is invoked with a shift of 0 or 1. However, in 64-bit mode, operand size should only govern the number of bytes that are popped, not how wide the stack pointer is because in 64-bit mode the SS attributes are ignored. By falling back to `get_sp_mask(SS.flags)`, QEMU applied a 16-bit mask (`0xffff`) with `SS.B` clear, and a 32-bit mask (`0xffffffff`) with `SS.B` set. As a result, a 64-bit RSP pointing above 4 GiB was truncated. As observed in testing, the truncated stack pop read the wrong address, loading corrupted values for the new CS and RIP which resulted in a `#GP` fault and then a triple fault. Fix this by ensuring that `helper_ret_protected()` uses the full 64-bit stack pointer with no mask applied whenever the active code segment (CS) is running in 64-bit mode. Signed-off-by: NickSampanis Link: https://lore.kernel.org/r/20261025231803.870-2-nicksampanis@gmail.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 45bffcd7380..af18aec694d 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -2056,7 +2056,7 @@ static inline void helper_ret_protected(CPUX86State *= env, int shift, sa.mmu_index =3D x86_mmu_index_pl(env, cpl); =20 #ifdef TARGET_X86_64 - if (shift =3D=3D 2) { + if (shift =3D=3D 2 || (env->hflags & HF_CS64_MASK)) { sa.sp_mask =3D -1; } else #endif --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922710; cv=none; d=zohomail.com; s=zohoarc; b=kd203ydMbqzuYJ9PgitgtG5+KfAoTbj6FW9GEgtYlmi9+NJh53b2rcBW4zPHRMsS81WrIb6kX9ZUAN+uJGDyM5hArXM+6qmtbZ5om7I/GG2/WS1UethlUmpIOnyf/Mib3w3gNIfkMcHgLqOcgqaf+2v5PNm1tKIR52geIK38Vkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922710; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r/lV2HI3oXu/R+bez1SA07wyhn//30xiUEMcZuvmDFY=; b=R1Z84WHgHDpXwvseFCTV3DTe1MxefyBQELxadjWpGcaV4kIQsUHqbhm0vrf7kNVZW1/azxpprKFUmThb6RuVGG7YDfI2tF2RtF6K/mIlRQtBiYJQEw4as7/XF+1qUtPsAnrN+PSDDenDHEWMu9fLVbmlRq5OXsk1uGSeTX5t6Bc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922710962634.9159700194052; Tue, 17 Nov 2026 05:38:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO0-0006d1-EA; Tue, 17 Nov 2026 08:38:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNy-0006cr-Rl for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNx-0003AP-A3 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:10 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-0YDUs5lBNUewuMuDc0xiqQ-1; Tue, 17 Nov 2026 08:38:05 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7C55E1800547; Tue, 17 Nov 2026 13:38:04 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97AA441F; Tue, 17 Nov 2026 13:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r/lV2HI3oXu/R+bez1SA07wyhn//30xiUEMcZuvmDFY=; b=WpKuYtTG/S76FVzFRwpNJOOiqjPQUtqHucWflYIFF9BxwaCcvY9wN4HE/11pBcX/cwnSdM +muHVxRBpynGG/Ld3XYiSRYqGA4dNnuj7oRZnEuddz1w/J+tYV2mJ0fqIDt9CI+Cd+WotD HaZQYUWUPn+gUNwFBRmJJLZZUuVfo88= X-MC-Unique: 0YDUs5lBNUewuMuDc0xiqQ-1 X-Mimecast-MFC-AGG-ID: 0YDUs5lBNUewuMuDc0xiqQ_1794922684 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: NickSampanis Subject: [PULL 09/15] target/i386/tcg: Fix 64-bit RSP truncation on far call in 64-bit mode Date: Tue, 17 Nov 2026 14:37:44 +0100 Message-ID: <20261117133750.322253-10-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794922713433158500 Content-Type: text/plain; charset="utf-8" From: NickSampanis When executing a direct far call to a code segment (no call gate involved) in 64-bit mode with a 16- or 32-bit operand size, `lcall_protected` falls back to `get_sp_mask(SS.flags)`. This gives a 16- or 32-bit mask, but in 64-bit mode the stack always uses the full RSP and the attributes are ignored. As a result, the pushes of the return address and the stack pointer update (`SET_ESP`) truncate RSP. This is the same bug fixed for retf in the previous patch. Use the full stack pointer, with no mask, for a direct far call when CS is 64-bit. Signed-off-by: NickSampanis Link: https://lore.kernel.org/r/20261025231803.870-3-nicksampanis@gmail.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index af18aec694d..87492a2f64f 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -1731,7 +1731,11 @@ void HELPER(lcall_protected)(CPUX86State *env, int n= ew_cs, target_ulong new_eip, #endif { sa.sp =3D env->regs[R_ESP]; - sa.sp_mask =3D get_sp_mask(env->segs[R_SS].flags); + if (env->hflags & HF_CS64_MASK) { + sa.sp_mask =3D -1; + } else { + sa.sp_mask =3D get_sp_mask(env->segs[R_SS].flags); + } sa.ss_base =3D env->segs[R_SS].base; if (shift) { pushl(&sa, env->segs[R_CS].selector); --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922805; cv=none; d=zohomail.com; s=zohoarc; b=OOSzpGmdXWBMGFE2i3GkBdojZyTzKJrbN54G0c1sl9j4i8voZAP5IXRKMIh7qYHPDbT33P4u6BvrGegxK5vPdzgkXRYQtIubm60W8YIxzDyNkK7DUODfLYG5Mdj1mvrrjjvGG6sGnG8Eupo4+SqitaMjsC+7xa1JyHqeWEJI75Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922805; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SOR4fixVLEAnOrMSkVWO8E2u7sFX548dHXwyhYHmR34=; b=Z2A9sF1XNpNC3rJ2/o4AXIf657i6sC8lxxLFUR0euLHU/NDUc+QgfaF2E8KwKvtU4o3puhEHvuuOimHw9dOv4U6uH1y2ZqnvUY9grCF/IF8DZG+JUOC8wkmWrtaVNJ4lbA/SSfIVohDmKu8pTamwsD3kGCIwcZsJ8V2U1dh407M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922805689684.9350208114992; Tue, 17 Nov 2026 05:40:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO1-0006df-Tg; Tue, 17 Nov 2026 08:38:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO0-0006d3-Gw for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNy-0003Af-Qh for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:12 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-ngMqS5ryPu6asKXjoqkWJQ-1; Tue, 17 Nov 2026 08:38:06 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF325195608E; Tue, 17 Nov 2026 13:38:05 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E07E741F; Tue, 17 Nov 2026 13:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SOR4fixVLEAnOrMSkVWO8E2u7sFX548dHXwyhYHmR34=; b=f4FTWDDHm9ynkx+VfOdAwBBduAee/kUir1NzJ/xwSqD9i2JNyvQj5xjHuKcQjXFLBbQGpo x7iqMzD+eoyzGAfyaIHqNSCcAaWcrFYg1i70rMJ0Ou/pI7Axh47ykosCtlFTKYaPPt7fcS UEUwGT8hSVll6NSJkroWAgxasABCpOM= X-MC-Unique: ngMqS5ryPu6asKXjoqkWJQ-1 X-Mimecast-MFC-AGG-ID: ngMqS5ryPu6asKXjoqkWJQ_1794922685 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: NickSampanis Subject: [PULL 10/15] target/i386/tcg: Fix 64-bit RSP truncation on far call through a call gate Date: Tue, 17 Nov 2026 14:37:45 +0100 Message-ID: <20261117133750.322253-11-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922806431158500 Content-Type: text/plain; charset="utf-8" From: NickSampanis In long mode, a call gate is 16 bytes and always has a 64-bit target. For a same-privilege call through a call gate, which can also be reached by a compatibility-mode caller, lcall_protected uses get_sp_mask(SS.flags) even though the pushes are 8 bytes. Consequently, the pushes and the stack pointer update (SET_ESP) truncate RSP. This is the same bug as in the previous two patches. Use the full stack pointer when shift =3D=3D 2, the same as the inner-privilege branch. This condition tests the gate's own size rather than the caller's mode, which is why it checks shift =3D=3D 2 instead of HF_CS64_MASK. Signed-off-by: NickSampanis Link: https://lore.kernel.org/r/20261025231803.870-4-nicksampanis@gmail.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 87492a2f64f..f11b55d136d 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -1925,7 +1925,12 @@ void HELPER(lcall_protected)(CPUX86State *env, int n= ew_cs, target_ulong new_eip, /* to same privilege */ sa.mmu_index =3D x86_mmu_index_pl(env, cpl); sa.sp =3D env->regs[R_ESP]; - sa.sp_mask =3D get_sp_mask(env->segs[R_SS].flags); +#ifdef TARGET_X86_64 + if (shift =3D=3D 2) { + sa.sp_mask =3D -1; + } else +#endif + sa.sp_mask =3D get_sp_mask(env->segs[R_SS].flags); sa.ss_base =3D env->segs[R_SS].base; /* push_size =3D (4 << shift); */ new_stack =3D 0; --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922954; cv=none; d=zohomail.com; s=zohoarc; b=DjnsjQ/ZuLMq4ElAU2Y37y8uM+wn+HWW2cOOkaUl2ZLea8766r4QkSA9Q+fm1xEQQyUji4iTKq8vtCtuxNMsPCZlAgZ0qcIA25+azQ/ygO6U0dituyXFeDoGIxbbraZEnxq2nve4oe87qNIe5Jst+w8ehB96TnYGdAaZ4VDIXO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922954; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=94HKhgd63UC2recRlNVLfdia338WUYdrqACerrLQ8tM=; b=dIN0ZC1gSBmVMuAmQCiLdIzG+1/La0iJOkEyOFG+xduBfhR/OGZgTOHqbl/70hqwy5rjcVUMS7zErzd7lsf/OKaM2Zc5t9hy5Af2tcxg/UwFZpHup+6RSIQ2w3caCWdF7adIAn/4eStkgtlte2ZItMKtWDjWjNztqFBq5j4KCS0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179492295401272.19827990860153; Tue, 17 Nov 2026 05:42:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO5-0006jb-9A; Tue, 17 Nov 2026 08:38:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO1-0006dg-Ss for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNz-0003B5-Tg for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:13 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-Bo5FO020Nd-L2yGqlKa9kw-1; Tue, 17 Nov 2026 08:38:07 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1198C19560BB; Tue, 17 Nov 2026 13:38:07 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2DBBE428; Tue, 17 Nov 2026 13:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94HKhgd63UC2recRlNVLfdia338WUYdrqACerrLQ8tM=; b=UN/ZsJG+AWGvHrmb5rCp/M+oGnK4lvhja0foAFGMDNg675dV2qVYWKSy+z8kZRbqhXRezh hxw8WxUQyIDzvNoLueFYqf0rmZGa5ER7hIWUjDX7sL+EQgWrEnen0fEJ2R/x4RAPTtfADw c9rfzwBDBp8ZfyCWqArBWjbmm8gV5C0= X-MC-Unique: Bo5FO020Nd-L2yGqlKa9kw-1 X-Mimecast-MFC-AGG-ID: Bo5FO020Nd-L2yGqlKa9kw_1794922687 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Andrey Polivoda Subject: [PULL 11/15] target/i386/tcg: all scalar instructions should be LIG Date: Tue, 17 Nov 2026 14:37:46 +0100 Message-ID: <20261117133750.322253-12-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922956246158500 Content-Type: text/plain; charset="utf-8" Add the vex_lig modifier to other scalar instructions, both defined via REPScalar and those listed as separate rows. The current edition of the manual lists them this way, but QEMU was either ignoring VEX.L but not resetting it, or raising #UD on VEX.L=3D1. Cc: Andrey Polivoda Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 48 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index e985b128893..b91e3718cb5 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -834,31 +834,31 @@ static const X86OpEntry opcodes_0F38_00toEF[240] =3D { =20 /* Should be exception type 2 or 3 but they do not have legacy SSE equ= ivalents? */ [0x98] =3D X86_OP_ENTRY3(VFMADD132Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0x99] =3D X86_OP_ENTRY3(VFMADD132Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0x99] =3D X86_OP_ENTRY3(VFMADD132Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0x9a] =3D X86_OP_ENTRY3(VFMSUB132Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0x9b] =3D X86_OP_ENTRY3(VFMSUB132Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0x9b] =3D X86_OP_ENTRY3(VFMSUB132Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0x9c] =3D X86_OP_ENTRY3(VFNMADD132Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0x9d] =3D X86_OP_ENTRY3(VFNMADD132Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0x9d] =3D X86_OP_ENTRY3(VFNMADD132Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0x9e] =3D X86_OP_ENTRY3(VFNMSUB132Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0x9f] =3D X86_OP_ENTRY3(VFNMSUB132Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0x9f] =3D X86_OP_ENTRY3(VFNMSUB132Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), =20 [0xa8] =3D X86_OP_ENTRY3(VFMADD213Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xa9] =3D X86_OP_ENTRY3(VFMADD213Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xa9] =3D X86_OP_ENTRY3(VFMADD213Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xaa] =3D X86_OP_ENTRY3(VFMSUB213Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xab] =3D X86_OP_ENTRY3(VFMSUB213Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xab] =3D X86_OP_ENTRY3(VFMSUB213Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xac] =3D X86_OP_ENTRY3(VFNMADD213Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xad] =3D X86_OP_ENTRY3(VFNMADD213Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xad] =3D X86_OP_ENTRY3(VFNMADD213Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xae] =3D X86_OP_ENTRY3(VFNMSUB213Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xaf] =3D X86_OP_ENTRY3(VFNMSUB213Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xaf] =3D X86_OP_ENTRY3(VFNMSUB213Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), =20 [0xb8] =3D X86_OP_ENTRY3(VFMADD231Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xb9] =3D X86_OP_ENTRY3(VFMADD231Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xb9] =3D X86_OP_ENTRY3(VFMADD231Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xba] =3D X86_OP_ENTRY3(VFMSUB231Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xbb] =3D X86_OP_ENTRY3(VFMSUB231Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xbb] =3D X86_OP_ENTRY3(VFMSUB231Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xbc] =3D X86_OP_ENTRY3(VFNMADD231Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xbd] =3D X86_OP_ENTRY3(VFNMADD231Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xbd] =3D X86_OP_ENTRY3(VFNMADD231Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), [0xbe] =3D X86_OP_ENTRY3(VFNMSUB231Px, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), - [0xbf] =3D X86_OP_ENTRY3(VFNMSUB231Sx, V,x, H,x, W,x, vex6 cpuid(FMA= ) p_66), + [0xbf] =3D X86_OP_ENTRY3(VFNMSUB231Sx, V,x, H,x, W,x, vex6 vex_lig c= puid(FMA) p_66), =20 [0xc8] =3D X86_OP_ENTRY2(SHA1NEXTE, V,dq, W,dq, cpuid(SHA_NI)), [0xc9] =3D X86_OP_ENTRY2(SHA1MSG1, V,dq, W,dq, cpuid(SHA_NI)), @@ -1064,7 +1064,7 @@ static void decode_0F10(DisasContext *s, CPUX86State = *env, X86OpEntry *entry, ui static const X86OpEntry opcodes_0F10_reg[4] =3D { X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPS= */ X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPD= */ - X86_OP_ENTRY3(VMOVSS, V,x, H,x, W,x, vex5), + X86_OP_ENTRY3(VMOVSS, V,x, H,x, W,x, vex5 vex_lig), X86_OP_ENTRY3(VMOVLPx, V,x, H,x, W,x, vex5), /* MOVSD */ }; =20 @@ -1087,7 +1087,7 @@ static void decode_0F11(DisasContext *s, CPUX86State = *env, X86OpEntry *entry, ui static const X86OpEntry opcodes_0F11_reg[4] =3D { X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPS= */ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPD= */ - X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex5), + X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex5 vex_lig), X86_OP_ENTRY3(VMOVLPx, W,x, H,x, V,q, vex5), /* MOVSD */ }; =20 @@ -1166,8 +1166,8 @@ static void decode_0F2A(DisasContext *s, CPUX86State = *env, X86OpEntry *entry, ui static const X86OpEntry opcodes_0F2A[4] =3D { X86_OP_ENTRY3(CVTPI2Px, V,x, None,None, Q,q), X86_OP_ENTRY3(CVTPI2Px, V,x, None,None, Q,q), - X86_OP_ENTRY3(VCVTSI2Sx, V,x, H,x, E,y, vex3), - X86_OP_ENTRY3(VCVTSI2Sx, V,x, H,x, E,y, vex3), + X86_OP_ENTRY3(VCVTSI2Sx, V,x, H,x, E,y, vex3 vex_lig), + X86_OP_ENTRY3(VCVTSI2Sx, V,x, H,x, E,y, vex3 vex_lig), }; *entry =3D *decode_by_prefix(s, opcodes_0F2A); } @@ -1191,8 +1191,8 @@ static void decode_0F2C(DisasContext *s, CPUX86State = *env, X86OpEntry *entry, ui /* Listed as ps/pd in the manual, but CVTTPS2PI only reads 64-bit.= */ X86_OP_ENTRY3(CVTTPx2PI, P,q, None,None, W,q), X86_OP_ENTRY3(CVTTPx2PI, P,q, None,None, W,dq), - X86_OP_ENTRY3(VCVTTSx2SI, G,y, None,None, W,ss, vex3), - X86_OP_ENTRY3(VCVTTSx2SI, G,y, None,None, W,sd, vex3), + X86_OP_ENTRY3(VCVTTSx2SI, G,y, None,None, W,ss, vex3 vex_lig), + X86_OP_ENTRY3(VCVTTSx2SI, G,y, None,None, W,sd, vex3 vex_lig), }; *entry =3D *decode_by_prefix(s, opcodes_0F2C); } @@ -1203,8 +1203,8 @@ static void decode_0F2D(DisasContext *s, CPUX86State = *env, X86OpEntry *entry, ui /* Listed as ps/pd in the manual, but CVTPS2PI only reads 64-bit. = */ X86_OP_ENTRY3(CVTPx2PI, P,q, None,None, W,q), X86_OP_ENTRY3(CVTPx2PI, P,q, None,None, W,dq), - X86_OP_ENTRY3(VCVTSx2SI, G,y, None,None, W,ss, vex3), - X86_OP_ENTRY3(VCVTSx2SI, G,y, None,None, W,sd, vex3), + X86_OP_ENTRY3(VCVTSx2SI, G,y, None,None, W,ss, vex3 vex_lig), + X86_OP_ENTRY3(VCVTSx2SI, G,y, None,None, W,sd, vex3 vex_lig), }; *entry =3D *decode_by_prefix(s, opcodes_0F2D); } @@ -1452,8 +1452,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0x2B] =3D X86_OP_GROUP0(0F2B), [0x2C] =3D X86_OP_GROUP0(0F2C), [0x2D] =3D X86_OP_GROUP0(0F2D), - [0x2E] =3D X86_OP_GROUP3(VxCOMISx, None,None, V,x, W,x, vex3 p_00_6= 6), /* VUCOMISS/SD */ - [0x2F] =3D X86_OP_GROUP3(VxCOMISx, None,None, V,x, W,x, vex3 p_00_6= 6), /* VCOMISS/SD */ + [0x2E] =3D X86_OP_GROUP3(VxCOMISx, None,None, V,x, W,x, vex3 vex_li= g p_00_66), /* VUCOMISS/SD */ + [0x2F] =3D X86_OP_GROUP3(VxCOMISx, None,None, V,x, W,x, vex3 vex_li= g p_00_66), /* VCOMISS/SD */ =20 [0x38] =3D X86_OP_GROUP0(0F38), [0x3a] =3D X86_OP_GROUP0(0F3A), @@ -3103,9 +3103,7 @@ static bool validate_vex(DisasContext *s, X86DecodedI= nsn *decode) assert(e->vex_class =3D=3D 1 || e->vex_class =3D=3D 2 || e->vex_cl= ass =3D=3D 4); if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { e->vex_class =3D e->vex_class < 4 ? 3 : 5; - if (s->vex_l) { - goto illegal; - } + s->vex_l =3D 0; assert(e->op2 =3D=3D X86_TYPE_W && e->s2 =3D=3D X86_SIZE_x); if ((s->modrm >> 6) !=3D 3) { e->s2 =3D s->prefix & PREFIX_REPNZ ? X86_SIZE_sd : X86_SIZ= E_ss; --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922801; cv=none; d=zohomail.com; s=zohoarc; b=M3rzrTOvwWkzkoKMMpVuEO8xZq5+5a6sxeBpTMpJgI6wlUsZ0AOa95usIj/EhkCwuVXu+zXqsKnKNyMCThbOeWn+lKglfRxXnMjVbYmEBl9jJCjTCwC8DQcKroHz0wMBVYhpcYTBzBFIb7W++XPOIbKmD5DhzX4lHSHY98Y/mrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922801; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=wbQZCmu6JaGqvwZYgLtD26u/hOVspcWKGWmvGtrIhGg=; b=Bsj2VtIqJbdrQU2c2i2mfNZbIJA+0NgQI3aA0p+6Vj/WSnqJvasECWujddwc9vElolTHiqlLRePcX2E41BIIS+ic6+kr3dATpKqvubhTVWjRQJoM38XbmOj6vR6TiTa30MiXeBUmBGEB5rVUud2kFIt8sxazZaC62jxUi0ZIuog= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922801633729.2457404782728; Tue, 17 Nov 2026 05:40:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO2-0006fo-MG; Tue, 17 Nov 2026 08:38:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO0-0006d2-Ea for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJNy-0003Al-W6 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:12 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-WYRQadlyPVaR4BxVo-RlAA-1; Tue, 17 Nov 2026 08:38:09 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2F54B195608A for ; Tue, 17 Nov 2026 13:38:08 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 72E0641F for ; Tue, 17 Nov 2026 13:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbQZCmu6JaGqvwZYgLtD26u/hOVspcWKGWmvGtrIhGg=; b=fQdzgYf7XYzO20Tw/7WIB0RgR+p4IDSd/X8KEGyBcTGa6mBU8rOtT3KFpvtOJZ1ONkC2KM m0/zTW1+cQdFFZ5aNMGQqw1C0fyCMd7MNMOU4E/4GpjlsnUIan9RDBeizxD7ba33S6B6gq 6dMn9EJ8kIXOudlmtCU+OJcYlyM+QYw= X-MC-Unique: WYRQadlyPVaR4BxVo-RlAA-1 X-Mimecast-MFC-AGG-ID: WYRQadlyPVaR4BxVo-RlAA_1794922688 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/15] target/i386/tcg: remove unused argument of decode_ops Date: Tue, 17 Nov 2026 14:37:47 +0100 Message-ID: <20261117133750.322253-13-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922802591158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index b91e3718cb5..731434ff50b 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2827,8 +2827,7 @@ static bool extract_evex_params(DisasContext *s, X86D= ecodedInsn *decode) } =20 =20 -static bool decode_ops(DisasContext *s, CPUX86State *env, X86DecodeFunc de= code_func, - X86DecodedInsn *decode) +static bool decode_ops(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) { X86OpEntry *e =3D &decode->e; =20 @@ -3608,7 +3607,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) } } =20 - if (!decode_ops(s, env, decode_func, &decode)) { + if (!decode_ops(s, env, &decode)) { goto illegal_op; } if (!validate_cr0_exceptions(s, &decode)) { --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922829; cv=none; d=zohomail.com; s=zohoarc; b=YP4pCZ6x76cZFQMHnN5C52GBVgWAJCyfZ1bgCjkr6pji16QIxuyrhze1tol/12+PaIv09EIQxoU+v7yOVx+KUGD4Vm5WAcI2J/QPvIiYwHkVLD0nl/6r7+c7ycujotxQvwyt07nk84QOz8/kSiq6OnFuVGTMciGtuwmQl4heGSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922829; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=/hNje6YUHdnu3aRo8fA0Fhrbju+nZwVH0sRanEkzr14=; b=iCt7q4S8TRClQKXL5gRs5RKE08iqSclFgM8iKsLNJd/w76zdw8n5IQhI+4+S2ym85WGqBlxj/Tgnk07BWnH831Yq9JqvWnOE2sbkOj7ccuCKb4XYMCACxijR+zU1ssiLiG/OavhYrZMjUilzejdkC4iXvWyVruFQsKgVz2HjUxM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922829816899.1184427404937; Tue, 17 Nov 2026 05:40:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO4-0006iM-GM; Tue, 17 Nov 2026 08:38:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO1-0006dd-Q3 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO0-0003B9-7i for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:13 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-gmed5SfyN0u7n52lrbg07w-1; Tue, 17 Nov 2026 08:38:10 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DFBD1954B2C for ; Tue, 17 Nov 2026 13:38:09 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FF30428 for ; Tue, 17 Nov 2026 13:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hNje6YUHdnu3aRo8fA0Fhrbju+nZwVH0sRanEkzr14=; b=bjitvu9b/ZP/VPkoRNcxw5J7A1hTWlQ0Frh5WOuwy0e4bKztlB0eIAX8VH2GvYZn403LeG BJ8HnHkqd1BgKUxjRGgqVKSyea7XDHB/DETI/gZ3FJjYtQ6dQzKxlYsoBeSnccNUMe4l53 3UUqKNgneIU7z/CXkmf99xp7VZHWgJs= X-MC-Unique: gmed5SfyN0u7n52lrbg07w-1 X-Mimecast-MFC-AGG-ID: gmed5SfyN0u7n52lrbg07w_1794922689 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/15] target/i386/tcg: remove unused operand sizes Date: Tue, 17 Nov 2026 14:37:48 +0100 Message-ID: <20261117133750.322253-14-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922830844158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 4 ---- target/i386/tcg/decode-new.c.inc | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 7f7ed3b6cf4..72ab6473e4a 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -73,15 +73,11 @@ typedef enum X86OpSize { X86_SIZE_d, /* 32-bit */ X86_SIZE_dq, /* SSE/AVX 128-bit */ X86_SIZE_p, /* Far pointer */ - X86_SIZE_pd, /* SSE/AVX packed double precision */ - X86_SIZE_pi, /* MMX */ - X86_SIZE_ps, /* SSE/AVX packed single precision */ X86_SIZE_q, /* 64-bit */ X86_SIZE_qq, /* AVX 256-bit */ X86_SIZE_s, /* Descriptor */ X86_SIZE_sd, /* SSE/AVX scalar double precision */ X86_SIZE_ss, /* SSE/AVX scalar single precision */ - X86_SIZE_si, /* 32-bit GPR */ X86_SIZE_v, /* 16/32/64-bit, based on operand size */ X86_SIZE_w, /* 16-bit */ X86_SIZE_x, /* 128/256-bit, based on operand size */ diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 731434ff50b..19c76a12009 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -73,8 +73,8 @@ * the V/U/H/W types to P/N/P/Q if there is no prefix, as well as changing * "x" to "q" if there is no prefix. * - * In addition, the ss/ps/sd/pd types are sometimes mushed together as "x" - * if the difference is expressed via prefixes. Individual instructions + * In addition, the ss/sd types are sometimes mushed together as "x" + * if the difference is expressed via prefixes; individual instructions * are separated by prefix in the generator functions. * * There is a custom size "xh" used to address half of a SSE/AVX operand. @@ -82,6 +82,8 @@ * for 256-bit AVX operands, etc. It is used for conversion operations * such as VCVTPH2PS or VCVTSS2SD. * + * pi/ps/pd are simply written as "q" or "x". + * * There are a couple cases in which instructions (e.g. MOVD) write the * whole XMM or MM register but are established incorrectly in the manual * as "d" or "q". These have to be fixed for the decoder to work correctl= y. @@ -2448,7 +2450,6 @@ static bool decode_op_size(DisasContext *s, X86OpEntr= y *e, X86OpSize size, MemOp *ot =3D s->dflag; return true; =20 - case X86_SIZE_pi: /* MMX */ case X86_SIZE_q: /* 64-bit */ case X86_SIZE_sd: /* SSE/AVX scalar double precision */ *ot =3D MO_64; @@ -2497,9 +2498,6 @@ static bool decode_op_size(DisasContext *s, X86OpEntr= y *e, X86OpSize size, MemOp *ot =3D MO_64; return true; } - /* fall through */ - case X86_SIZE_ps: /* SSE/AVX packed single precision */ - case X86_SIZE_pd: /* SSE/AVX packed double precision */ *ot =3D s->vex_l ? MO_256 : MO_128; return true; =20 --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922786; cv=none; d=zohomail.com; s=zohoarc; b=CLejicm4lEpzhMyt63xfRB+8+CkkP/LRIpQebi272R4/OJMZZ2KruzQayzA1DZ8q2n7uTRv3m6rHs1lirJhqi701khzgv4j3aerwVeO0tgDgVkLF/DocJ9iLVmE+RxzMw/Zq4wvtmNiMLBapq7u8/uS0mwbTzoSzeuBwBiVxS30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922786; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K1RqVy/lLvgOs++VfFlXNCBjmc7C28B5+SCIskKK164=; b=IygCUW5ddD4YY/1xKSJpfIZTdHyE8atUn4n61EGg8XC7YD7AFKVhnMAJE+4YnyhCypWFN3GRDqJ8GlCRvxuBdMwD0ANVu0aal1Mz0+xdM+JJtxt2w3mvCee2V2gBME2TEcROaOT3+PKlL1G8eI3z41Oy9IGMGw77UY1iKXm8h0M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922786112802.8460374855133; Tue, 17 Nov 2026 05:39:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO6-0006kE-IS; Tue, 17 Nov 2026 08:38:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO3-0006iG-Tk for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO1-0003BR-Pb for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:15 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-OJ5SyH0qMiit-Hln5ZhaEQ-1; Tue, 17 Nov 2026 08:38:11 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 81C2B195607C; Tue, 17 Nov 2026 13:38:10 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A02FC428; Tue, 17 Nov 2026 13:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K1RqVy/lLvgOs++VfFlXNCBjmc7C28B5+SCIskKK164=; b=Fdm50biuhKjAMJH1/YOrl32tv55DQXg+ctZLJQHK/rCIB0SuDkNp38MDNgZDDCW9+5xGt2 89wsKHJbplFLsJMy89/3njTFJwysaQMt9JIkvUII/8vPu1iY723J1FhmAdCp/W+HE1oPzr uVzQFzS6TRK9k95OcvJzWi3MQSCink0= X-MC-Unique: OJ5SyH0qMiit-Hln5ZhaEQ-1 X-Mimecast-MFC-AGG-ID: OJ5SyH0qMiit-Hln5ZhaEQ_1794922690 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: z Y Subject: [PULL 14/15] target/i386/tcg: treat ENTER's size operand as unsigned Date: Tue, 17 Nov 2026 14:37:49 +0100 Message-ID: <20261117133750.322253-15-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922788282158500 Content-Type: text/plain; charset="utf-8" From: z Y The first immediate operand of ENTER is the size of the dynamic storage area and is unsigned. Decoding it as a signed immediate sign-extends values with bit 15 set, moving the stack pointer in the wrong direction. Decode it with I_unsigned and add a regression test covering 32-bit and 64-bit guests. Tested with a minimal x86_64-linux-user build; the new test fails before the change and passes after it. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4643 Signed-off-by: Zixin Wang Link: https://lore.kernel.org/r/CABG6VKODisrETOuH5thhimg_DtJLH+1wmARKL5OsoN= D5Qse_TA@mail.gmail.com Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 +- tests/tcg/i386/test-i386-enter.c | 42 ++++++++++++++++++++++++++++++++ target/i386/tcg/decode-new.c.inc | 2 +- tests/tcg/i386/meson.build | 1 + tests/tcg/x86_64/meson.build | 1 + 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/i386/test-i386-enter.c diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index d4ccddc33fd..719771032ff 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1989,7 +1989,7 @@ static void gen_popa(DisasContext *s) gen_stack_update(s, 8 * size); } =20 -static void gen_enter(DisasContext *s, int esp_addend, int level) +static void gen_enter(DisasContext *s, uint16_t esp_addend, int level) { MemOp d_ot =3D mo_pushpop(s, s->dflag); MemOp a_ot =3D mo_stacksize(s); diff --git a/tests/tcg/i386/test-i386-enter.c b/tests/tcg/i386/test-i386-en= ter.c new file mode 100644 index 00000000000..509740d88c9 --- /dev/null +++ b/tests/tcg/i386/test-i386-enter.c @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * ENTER's 16-bit size operand is unsigned. If the decoder sign-extends + * it, the stack pointer moves in the wrong direction. + */ +#include + +static int check_enter(void) +{ + unsigned long before, after; + +#ifdef __x86_64__ + __asm__ volatile( + "movq %%rsp, %0\n\t" + "enter $0x8000, $0\n\t" + "movq %%rsp, %1\n\t" + "leave\n\t" + : "=3Dr"(before), "=3Dr"(after) + : + : "memory"); + return (before - after) =3D=3D 0x8008 ? 0 : 1; +#else + __asm__ volatile( + "movl %%esp, %0\n\t" + "enter $0x8000, $0\n\t" + "movl %%esp, %1\n\t" + "leave\n\t" + : "=3Dr"(before), "=3Dr"(after) + : + : "memory"); + return (before - after) =3D=3D 0x8004 ? 0 : 1; +#endif +} + +int main(void) +{ + if (check_enter()) { + printf("FAIL: ENTER treated the 16-bit size operand as signed\n"); + return 1; + } + return 0; +} diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 19c76a12009..bd9a94b3162 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1972,7 +1972,7 @@ static const X86OpEntry opcodes_root[256] =3D { [0xBE] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), [0xBF] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), =20 - [0xC8] =3D X86_OP_ENTRYrr(ENTER, I,w, I,b), + [0xC8] =3D X86_OP_ENTRYrr(ENTER, I_unsigned, w, I, b), [0xC9] =3D X86_OP_ENTRY0(LEAVE), [0xCA] =3D X86_OP_ENTRYr(RETF, I,w), [0xCB] =3D X86_OP_ENTRY0(RETF), diff --git a/tests/tcg/i386/meson.build b/tests/tcg/i386/meson.build index c912f37fab7..d2ba8410413 100644 --- a/tests/tcg/i386/meson.build +++ b/tests/tcg/i386/meson.build @@ -37,6 +37,7 @@ tests +=3D { '-lm', '-fno-pie', '-Wl,--no-warn-rwx-segments'], }, 'test-idiv-overflow.c': {}, + 'test-i386-enter.c': {'cflags': ['-O2', '-fomit-frame-pointer']}, '../multiarch/sha512.c': { 'exe_name': 'sha512-sse', 'cflags': ['-msse4.1', '-O3'], diff --git a/tests/tcg/x86_64/meson.build b/tests/tcg/x86_64/meson.build index 9738d04220b..1efb35cf2eb 100644 --- a/tests/tcg/x86_64/meson.build +++ b/tests/tcg/x86_64/meson.build @@ -50,6 +50,7 @@ tests +=3D { '../i386/test-i386-blendv.c': {}, '../i386/test-i386-bmi2.c': {'cflags': ['-O2', '-fwrapv']}, '../i386/test-idiv-overflow.c': {}, + '../i386/test-i386-enter.c': {'cflags': ['-O2', '-fomit-frame-pointer']}, } =20 tests +=3D { --=20 2.56.0 From nobody Mon Nov 23 04:28:02 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794922714; cv=none; d=zohomail.com; s=zohoarc; b=Md8fCzzhxgp4LHcmsNybBCJ8/jpEJEJtEDkaG34H9fXuMMp7zoPIuh71bAcJ8xhreJnx5RfNWeQVnRqod0y1u8uF6wJ8g4iX0Y8Kw/MWUAgMy3q+QTsxrl3JUSyMVlJbJjNL6IwDAj2vLK0ZYVwRDmp6PzmG9YJjo6Gwda27XCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922714; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a3pHyXjdino8hK1/vyczWqrs3EtG1X4oXkpO/L6Z4dM=; b=D1pcjM796T/ukm9xttwSk5EEigNg0DjOxsGkeDsT+gQNdeTUg7C3RNB0EAJOuxJbaVBBpGgqGhao668uLTIfhh25rgDWZKqlGDE86e3DGUoi2xEYqjkAamPs1vmr66trpSG8JR4UQ0yjT2RaKkdIgCNt9SkAR4sfafILYJSH8PE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179492271480342.52525169308262; Tue, 17 Nov 2026 05:38:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJO9-0006ni-J0; Tue, 17 Nov 2026 08:38:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO5-0006jy-MC for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJO3-0003Bo-T9 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:38:17 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-yTKIU2kpMimrgpayxpjc-Q-1; Tue, 17 Nov 2026 08:38:13 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F7AD19560A6; Tue, 17 Nov 2026 13:38:12 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2DA6436; Tue, 17 Nov 2026 13:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794922695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a3pHyXjdino8hK1/vyczWqrs3EtG1X4oXkpO/L6Z4dM=; b=MAZOnx3YlvNz7SDV8Usvt2Fs2vEN74LUctPTNEi5t4ccNaaoS+ERBvgIpgiK6TOQalGrdA guU0xbjdmNVLGbIcSMtGZbiceR1usKL+LDym+VAUdC9D1CeGXaHOq0aqlH93gScX1tiPyZ ow96Ny6rJcqqm29aJlQY59oLOfuDBQQ= X-MC-Unique: yTKIU2kpMimrgpayxpjc-Q-1 X-Mimecast-MFC-AGG-ID: yTKIU2kpMimrgpayxpjc-Q_1794922692 From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Samuel Tardieu Subject: [PULL 15/15] rust/common: rename IntegerExt::bit() to single_bit() Date: Tue, 17 Nov 2026 14:37:50 +0100 Message-ID: <20261117133750.322253-16-pbonzini@redhat.com> In-Reply-To: <20261117133750.322253-1-pbonzini@redhat.com> References: <20261117133750.322253-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794922717913158500 Content-Type: text/plain; charset="utf-8" From: Samuel Tardieu An experimental Rust nightly feature `get_set_bit` introduces a `bit()` method on integer types which checks whether a specific bit is set. This clashes with QEMU's `IntegerExt::bit()` associated function which returns an integer with one particular bit set. While the `get_set_bit` feature has no planned stabilization date yet, this is reported as a `unstable_name_collisions` warning when compiling with the `strict_rust_lints` option, and warnings are turned into errors. Renaming `IntegerExt::bit()` to `IntegerExt::single_bit()` prevents this. Signed-off-by: Samuel Tardieu Link: https://lore.kernel.org/r/20261114-rust-single-bit-v1-1-da0172820f84@= rfc1149.net Signed-off-by: Paolo Bonzini --- rust/common/src/bitops.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/common/src/bitops.rs b/rust/common/src/bitops.rs index 06c78c3b8a7..a0aff75d763 100644 --- a/rust/common/src/bitops.rs +++ b/rust/common/src/bitops.rs @@ -34,7 +34,7 @@ pub trait IntegerExt: =20 #[inline] #[must_use] - fn bit(start: u32) -> Self + fn single_bit(start: u32) -> Self { debug_assert!(start < Self::BITS); =20 @@ -105,9 +105,9 @@ fn test_extract() { } =20 #[test] - fn test_bit() { - assert_eq!(u8::bit(7), 128); - assert_eq!(u32::bit(16), 0x10000); + fn test_single_bit() { + assert_eq!(u8::single_bit(7), 128); + assert_eq!(u32::single_bit(16), 0x10000); } =20 #[test] --=20 2.56.0