From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665484796; cv=none; d=zohomail.com; s=zohoarc; b=PcC6uBCpDUX49voB2gg53lgYhq7aJBIHap2qzpT2B+EmhFo1PF6LxrUUy3JDir+fsYiWYImV6n9hwdzkNOzFAMfBIuSAKmcq8KkrNIjOm5P/BKMYG1yATZ2m9etZ05gjLiZozr3jd9aVepCQByJh9nv060M1hfF5P1o9rd6Gv9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665484796; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cuphIr+mFW20bUhhqmhIieGdN2By5F1MAq8fBtfFWvI=; b=cNmYuXCh/SZRZZZ8Gm45qIxKGfl/TG6P43QdHvOfAM1KNbHNzNFN665n0gVEaAfm9DmiI9pGX01MpHCDm9JXyBskrLT4H0p/D6kYZ5G/13d3EZ39lA3MV2IgPR8BaGBXX6ShWf8TuoeTujCQHYfFTdf2oJzC9COv5/6ks9mkoqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665484796916718.1097759211731; Tue, 11 Oct 2022 03:39:56 -0700 (PDT) Received: from localhost ([::1]:60712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCfz-0001iH-Hl for importer@patchew.org; Tue, 11 Oct 2022 06:39:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTh-0001fn-ND for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTe-0004FS-Cx for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:12 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-407-Lm6_Oqt0Pb6-FNM6_krNBA-1; Tue, 11 Oct 2022 06:27:08 -0400 Received: by mail-ed1-f72.google.com with SMTP id dz21-20020a0564021d5500b004599f697666so10794793edb.18 for ; Tue, 11 Oct 2022 03:27:08 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id kx1-20020a170907774100b00738467f743dsm6746650ejc.5.2022.10.11.03.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cuphIr+mFW20bUhhqmhIieGdN2By5F1MAq8fBtfFWvI=; b=icGIHlbU7cQdqTqtR9jr0+95LHbThCWqOSQ+LKh55QHxV9saV49vRbC7vDspWh9cx2xGjs Dz8YuDNIZu4wJtzA1wbGNy+pkZzhaWqLnjYG/7LcBt+8lTVA3/39Z0qi+jk1Y5gkF2MPrr EBuOEc26y+NDGL0z9bypIPaCm8Fd7cE= X-MC-Unique: Lm6_Oqt0Pb6-FNM6_krNBA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cuphIr+mFW20bUhhqmhIieGdN2By5F1MAq8fBtfFWvI=; b=jAG+dMuBdiCrbpKVOkPcJ7a/lujOSUmh5pypTgJGWfsmuPjezRVetWrhG3vt2GYIN6 al0w7S+siFH07YQN45coF1At7vyEbzicv9/G4nHvixhU9l3nHJaL5iaIu/d4bbAagZe6 +ixvku8tv5p0NzYwpzPrDkQVvFqv1BYDXoAHBOajYQq7EpHqaH9AAQGBhvqCgp6z/0+I xQvbcW4bazT6sklb/AcETE9xrV3CR5X1K7sWIOiUN+LxziRlMaY7/r4lFvoqqHbG4GLy Cv10LPObB7Gdv5zRXczIxQkHh6ETJa9/1G6JSarG8F59VEXqHAbkeG+OksnNeV+Vcp08 FVrQ== X-Gm-Message-State: ACrzQf1471ZE3qLIhVAg/M3hY7wnhFfPwgkkqYE4Kmube2i8WIHkjEdl CMLBbSYdclf1FipgyTARuiC0pas69O+Iq09s1qY7DtY31iSK+pHhMrkf2iSH/2QqAcy4I2NofwU qMDTO5EfsGS6hRQkczjIv3dqdaLVl25GaWltbjtqd73IjnW189lUXrnU41/edw4GfK/k= X-Received: by 2002:a17:907:94c6:b0:787:9157:a87a with SMTP id dn6-20020a17090794c600b007879157a87amr18111987ejc.5.1665484026617; Tue, 11 Oct 2022 03:27:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VAMPYQvYLAYgsUPHpF5B/xA8YY/QVWBp3cuHkBOnWnV2UW40TP5d8ui1yNFGmy8GRNFS/Mg== X-Received: by 2002:a17:907:94c6:b0:787:9157:a87a with SMTP id dn6-20020a17090794c600b007879157a87amr18111980ejc.5.1665484026396; Tue, 11 Oct 2022 03:27:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: John Millikin Subject: [PULL 01/37] scsi-disk: support setting CD-ROM block size via device options Date: Tue, 11 Oct 2022 12:26:24 +0200 Message-Id: <20221011102700.319178-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665484798936100001 Content-Type: text/plain; charset="utf-8" From: John Millikin SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048. When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size. Signed-off-by: John Millikin Message-Id: <20220804122950.1577012-1-john@john-millikin.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 399e1787ea..e493c28814 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2544,6 +2544,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **= errp) SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); AioContext *ctx; int ret; + uint32_t blocksize =3D 2048; =20 if (!dev->conf.blk) { /* Anonymous BlockBackend for an empty drive. As we put it into @@ -2553,9 +2554,13 @@ static void scsi_cd_realize(SCSIDevice *dev, Error *= *errp) assert(ret =3D=3D 0); } =20 + if (dev->conf.physical_block_size !=3D 0) { + blocksize =3D dev->conf.physical_block_size; + } + ctx =3D blk_get_aio_context(dev->conf.blk); aio_context_acquire(ctx); - s->qdev.blocksize =3D 2048; + s->qdev.blocksize =3D blocksize; s->qdev.type =3D TYPE_ROM; s->features |=3D 1 << SCSI_DISK_F_REMOVABLE; if (!s->product) { --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485262; cv=none; d=zohomail.com; s=zohoarc; b=ObdERQQPhQgGKeqINFQ6O/IqJYJr4QCiHQ7AfL0fw4fARp8hQsq9rtRCYEO7UPYs0ce6gom9fiQ7d407vuYkzGp8Pk4JwNwPLzDIR1eAA6GwnmtNhxEcb3rZJ6aYCkC5W5BVdIcYJjshZJkzr1aW3fGBp0v+0UBuKjJtK3DOTSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485262; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iyPQGYZ1c7/e+tS0H3PukCSxg5MkFBP2Gn19GXnF6jI=; b=XonDSuMS4y1XVDqSXBltTnTvG1ZZQntIsnn2dAMArKlFJCUpOauOHCFFSUV1h/k4HnIsLcuufMou5/SkW+7Xt48HOkmJQ/+MGon2HB1zBxI8qntMldRjo3p5X+9ZsJCU9Fbh/uzJqhEpnyQ9VxLbORmPJcS1oKgi25vdndjT1/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485262399255.94143032803015; Tue, 11 Oct 2022 03:47:42 -0700 (PDT) Received: from localhost ([::1]:34388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCnV-0008Q3-AV for importer@patchew.org; Tue, 11 Oct 2022 06:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTi-0001jY-Op for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTg-0004Hn-RN for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:14 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-153-3hHRaapJOWax5f4zVws1wQ-1; Tue, 11 Oct 2022 06:27:11 -0400 Received: by mail-ed1-f71.google.com with SMTP id v4-20020a056402348400b0045bd50cb9adso5610410edc.0 for ; Tue, 11 Oct 2022 03:27:10 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id g12-20020a170906394c00b0078d61c5db0asm6400190eje.49.2022.10.11.03.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iyPQGYZ1c7/e+tS0H3PukCSxg5MkFBP2Gn19GXnF6jI=; b=fSWIk1OTlNxtJBDqiTEeujuZUv/v27Re9Y4R9DarTPUI9YmZt+2QwkU8u+wYwym1gf/Qc3 oSOsWKNpWiUaJg5+ryTRNLmO7HiyzlCx0xgf5uvMpj5Qroru1t6DsMh6Hcm6i7v31gwaxC p+f94DEQ40bAhPdLlEmyp3B+nXO9ZUI= X-MC-Unique: 3hHRaapJOWax5f4zVws1wQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iyPQGYZ1c7/e+tS0H3PukCSxg5MkFBP2Gn19GXnF6jI=; b=LioVIwRQs7QdG3pITPuezpyk2aLtQtfADW44KAMqZw3vZQ+KgL/GPJwSvGVQ7W8KgL aOluWnMKHQOQJa/EFW2Fb8JzIfAhwXtb1aAnnSz3z6DqKNX7zPE9naWPkJNqdT23m3Y3 gBI1diDAovUUdl+u89jOUXuAYyrp2N+MFirOvMD+0Sr3grvi80hfdZ/ycjlMq3knc7Ym DJVwsp85JxbY5Qx70P2mKDn5XgNVwtH4n4RTmfIctM5CD56j+qaVAqxdIVRaCX1do+R+ v8zIGR8h9IhOe7nMpdJoHI/sbdxooe4Ah53uFQ8NkHEU1uSRzUjd0O6PgLa/TGB7pvwh PRnw== X-Gm-Message-State: ACrzQf31eYrL48xhCYilX2lmElohZF0MZynukKBRqc+pep62O1UqGvg/ LgycbpTxnR+Z5nZxAfLTa96pJocESIhuByejSO3oyjV9WSNuDn0pwHgiCbTiOW78Gdo70UgffP5 nv/aRVZGVMTdTL3WZVZVhpLV9pY4tnIJj285hupVmFUK1/v7aHvp4zkS6C7CZVth/WUQ= X-Received: by 2002:a17:906:fe45:b0:788:15a5:7495 with SMTP id wz5-20020a170906fe4500b0078815a57495mr18496914ejb.633.1665484029502; Tue, 11 Oct 2022 03:27:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FE5p3WsJQ7Sc8Bqwwz3nf1uclag1lEbmCRiSfV6zpJE8u3bj0dVmKXgWr4xVko2YfD8n9Ig== X-Received: by 2002:a17:906:fe45:b0:788:15a5:7495 with SMTP id wz5-20020a170906fe4500b0078815a57495mr18496896ejb.633.1665484029216; Tue, 11 Oct 2022 03:27:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Chenyi Qiang , Peter Xu Subject: [PULL 02/37] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault Date: Tue, 11 Oct 2022 12:26:25 +0200 Message-Id: <20221011102700.319178-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485262962100001 Content-Type: text/plain; charset="utf-8" From: Chenyi Qiang For the direct triple faults, i.e. hardware detected and KVM morphed to VM-Exit, KVM will never lose them. But for triple faults sythesized by KVM, e.g. the RSM path, if KVM exits to userspace before the request is serviced, userspace could migrate the VM and lose the triple fault. A new flag KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang Message-Id: <20220929072014.20705-2-chenyi.qiang@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 20 ++++++++++++++++++++ target/i386/machine.c | 20 ++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ad623d91e4..06884177fa 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6017,6 +6017,7 @@ static void x86_cpu_reset(DeviceState *dev) env->exception_has_payload =3D false; env->exception_payload =3D 0; env->nmi_injected =3D false; + env->triple_fault_pending =3D false; #if !defined(CONFIG_USER_ONLY) /* We hard-wire the BSP to the first CPU. */ apic_designate_bsp(cpu->apic_state, s->cpu_index =3D=3D 0); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 82004b65b9..d4124973ce 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1739,6 +1739,7 @@ typedef struct CPUArchState { uint8_t has_error_code; uint8_t exception_has_payload; uint64_t exception_payload; + uint8_t triple_fault_pending; uint32_t ins_len; uint32_t sipi_vector; bool tsc_valid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f2a96492ce..3ebe8b7f1f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -132,6 +132,7 @@ static int has_xcrs; static int has_pit_state2; static int has_sregs2; static int has_exception_payload; +static int has_triple_fault_event; =20 static bool has_msr_mcg_ext_ctl; =20 @@ -2479,6 +2480,16 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 + has_triple_fault_event =3D kvm_check_extension(s, KVM_CAP_X86_TRIPLE_F= AULT_EVENT); + if (has_triple_fault_event) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_TRIPLE_FAULT_EVENT, 0, tr= ue); + if (ret < 0) { + error_report("kvm: Failed to enable triple fault event cap: %s= ", + strerror(-ret)); + return ret; + } + } + ret =3D kvm_get_supported_msrs(s); if (ret < 0) { return ret; @@ -4295,6 +4306,11 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int leve= l) } } =20 + if (has_triple_fault_event) { + events.flags |=3D KVM_VCPUEVENT_VALID_TRIPLE_FAULT; + events.triple_fault.pending =3D env->triple_fault_pending; + } + return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events); } =20 @@ -4364,6 +4380,10 @@ static int kvm_get_vcpu_events(X86CPU *cpu) } } =20 + if (events.flags & KVM_VCPUEVENT_VALID_TRIPLE_FAULT) { + env->triple_fault_pending =3D events.triple_fault.pending; + } + env->sipi_vector =3D events.sipi_vector; =20 return 0; diff --git a/target/i386/machine.c b/target/i386/machine.c index cecd476e98..310b125235 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -1562,6 +1562,25 @@ static const VMStateDescription vmstate_arch_lbr =3D= { } }; =20 +static bool triple_fault_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + + return env->triple_fault_pending; +} + +static const VMStateDescription vmstate_triple_fault =3D { + .name =3D "cpu/triple_fault", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D triple_fault_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(env.triple_fault_pending, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_x86_cpu =3D { .name =3D "cpu", .version_id =3D 12, @@ -1706,6 +1725,7 @@ const VMStateDescription vmstate_x86_cpu =3D { &vmstate_amx_xtile, #endif &vmstate_arch_lbr, + &vmstate_triple_fault, NULL } }; --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665484673; cv=none; d=zohomail.com; s=zohoarc; b=EfaNwHTvMJnf9pYBdVQIiHxEcYA9EEo4qDDG6FvLzIGK+g5y743X/XnmDMD1tKAqYv6r96iS7DiA/8TkS+T30tKNFbZ/Z6oMf8P3GJPd6Yxx0f8UBO8b2GJiMR3O3pl+jHrQjYpX17Q4o5mrbfFc8VkuLYk/sM1/IEZeXl2hxZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665484673; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=14oJjmYHgvUa/MpVPKwUTUCEeQ4n4MsXaBY+cVDVYVA=; b=KaV+4djamASZjZBQ7+S1O06xcekqNST+1mIVsBSne2uL7hs2lEkOd0+X4+iIuc15NKwLpR8Td0BFCU8lxjumw2Wi2a9xvzLgqkQXZNHqeJsHTlsrQ1AQeSQi8dxS8Acj3MFXLXv16Ybfos/OVvdNb7b9yQuWVgz5LdpORkMLTZc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665484673103440.3204279926815; Tue, 11 Oct 2022 03:37:53 -0700 (PDT) Received: from localhost ([::1]:36986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCdv-0000Ji-4j for importer@patchew.org; Tue, 11 Oct 2022 06:37:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTs-0001mM-9Q for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTk-0004Ix-40 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:20 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-331-IDr60FpnOyCkDV2KCkb62A-1; Tue, 11 Oct 2022 06:27:13 -0400 Received: by mail-ed1-f70.google.com with SMTP id q17-20020a056402519100b00459a2e5adbcso10912205edd.16 for ; Tue, 11 Oct 2022 03:27:13 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id i16-20020a1709061e5000b0078d46aa3b82sm6702782ejj.21.2022.10.11.03.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=14oJjmYHgvUa/MpVPKwUTUCEeQ4n4MsXaBY+cVDVYVA=; b=ULHZkJgw/1GbsF5ThPOA1WmhV9iMLFgFT7rBA9xgMo7EAoSZrua1M0hm02LrOcI7oLiJgT m6uyz+oxiY280y5QQbJi3vVlixJ9IPcWx9q+bq1hqp2YoA7aDlA27DyCk6IkfIMk+L60U5 7jYSxG1CgGAiNHE599lihDxgmpbHt4w= X-MC-Unique: IDr60FpnOyCkDV2KCkb62A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=14oJjmYHgvUa/MpVPKwUTUCEeQ4n4MsXaBY+cVDVYVA=; b=tI1ikgUdVx4SKWCAboDxziSVkKGnRWL+cha7UQE30pg9VfE8oSjulSfyCAQCI2K5rw fjw9SNlyH2rNm6O8eOCySWTmtz9i5/Hq4Nz7cTSr3oworf0rPHFykXOCRY5ymeU7zRMX R1cMX7SwoAkJ4e/94dkQwjxktDoHQrlX4COsb5xaQQQtYGd2aXgYgrYiQ6OuTNomJXcK mWYup5GSXSxRUN/A7jXAJCfuTKZQit9NFpUmLMwHavEqmkh8DTOBz/WpT7W/V0z1Pb0O qSnFO8+whD7+5+Ofq6iLrdae5Axt0lc4w4PfzltlvPQb8qEm/pAscaySgGT6rxz1LYIb iL2g== X-Gm-Message-State: ACrzQf2vgXX6XUBafzLs92drWfHMIs31eMCLNmPgkl+M2NUEZmzhySvK pW85fO94zIwQE5JI1pzaBf8h8jPFpvWTwu3Jm2XL662cjGm1fXA1tL20lQk+oQjBav1CQbE9OJD 7oVfbqBsXl6eLbyN3C5OC9ejOubBlvuT08mmTEE48QcZSHnO6b8OQcxv0qeBwbLKzkY4= X-Received: by 2002:a05:6402:27d4:b0:459:b28f:1b62 with SMTP id c20-20020a05640227d400b00459b28f1b62mr22116884ede.217.1665484032489; Tue, 11 Oct 2022 03:27:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yuD4C2uscSW/EOI2Al6b+or5+2XE8b7OSayzs2gUAipnW9Vw/WoKjZk9p/D0BCepu+8CfxQ== X-Received: by 2002:a05:6402:27d4:b0:459:b28f:1b62 with SMTP id c20-20020a05640227d400b00459b28f1b62mr22116863ede.217.1665484032126; Tue, 11 Oct 2022 03:27:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/37] kvm: allow target-specific accelerator properties Date: Tue, 11 Oct 2022 12:26:26 +0200 Message-Id: <20221011102700.319178-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665484674144100001 Content-Type: text/plain; charset="utf-8" Several hypervisor capabilities in KVM are target-specific. When exposed to QEMU users as accelerator properties (i.e. -accel kvm,prop=3Dvalue), they should not be available for all targets. Add a hook for targets to add their own properties to -accel kvm, for now no such property is defined. Signed-off-by: Paolo Bonzini Message-Id: <20220929072014.20705-3-chenyi.qiang@intel.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 2 ++ include/sysemu/kvm.h | 2 ++ target/arm/kvm.c | 4 ++++ target/i386/kvm/kvm.c | 4 ++++ target/mips/kvm.c | 4 ++++ target/ppc/kvm.c | 4 ++++ target/riscv/kvm.c | 4 ++++ target/s390x/kvm/kvm.c | 4 ++++ 8 files changed, 28 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 423fb1936f..03a69cf053 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3731,6 +3731,8 @@ static void kvm_accel_class_init(ObjectClass *oc, voi= d *data) NULL, NULL); object_class_property_set_description(oc, "dirty-ring-size", "Size of KVM dirty page ring buffer (default: 0, i.e. use bitmap)"= ); + + kvm_arch_accel_class_init(oc); } =20 static const TypeInfo kvm_accel_type =3D { diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 790d35ef78..e9a97eda8c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -349,6 +349,8 @@ bool kvm_device_supported(int vmfd, uint64_t type); =20 extern const KVMCapabilityInfo kvm_arch_required_capabilities[]; =20 +void kvm_arch_accel_class_init(ObjectClass *oc); + void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run); =20 diff --git a/target/arm/kvm.c b/target/arm/kvm.c index e5c1bd50d2..d21603cf28 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1056,3 +1056,7 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 3ebe8b7f1f..f18d21413c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5468,3 +5468,7 @@ void kvm_request_xsave_components(X86CPU *cpu, uint64= _t mask) mask &=3D ~BIT_ULL(bit); } } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} diff --git a/target/mips/kvm.c b/target/mips/kvm.c index caf70decd2..bcb8e06b2c 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -1294,3 +1294,7 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 466d0d2f4c..7c25348b7b 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2966,3 +2966,7 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 70b4cff06f..30f21453d6 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -532,3 +532,7 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 6a8dbadf7e..508c24cfec 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2581,3 +2581,7 @@ int kvm_s390_get_zpci_op(void) { return cap_zpci_op; } + +void kvm_arch_accel_class_init(ObjectClass *oc) +{ +} --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665484947; cv=none; d=zohomail.com; s=zohoarc; b=lMFtWlEBoK1GNRykPphMWay4ivDuZoKb3fAL2E4S/bbQFbAWojQVqUDjoWmV2LvljK15EFX7HVQAC6eYr96jX+RhhDwkUHEo0v8ThEnN7AJzTrsEmPDRzq9Bvy7MQ8oS/Br/NQFWBdZ4mkjR+kkemXipMkETeCGHwR+k46UYbUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665484947; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xZusI1znOLcmgbAOaPKJgjMoffzX/bBvt01BsInxDwo=; b=UMYhj2fTFsaPBwe3TyS3AWJG5ChT0Nf61UWvG+JLoVyqL+WKRc99BWQdqgsTtTOTtqTwb+wmmWp0s/YCL8r8HvquqvaFfOOW4fnb66004ZU+buX/LA618KT13lrGAqhM6Qmuh7ILf0vGu2JP2voBYaiJGnsETRJdEVIOpk21kns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665484947609585.5045575140163; Tue, 11 Oct 2022 03:42:27 -0700 (PDT) Received: from localhost ([::1]:53558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCiQ-0003JL-D0 for importer@patchew.org; Tue, 11 Oct 2022 06:42:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTr-0001mO-C9 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTn-0004Jf-Ak for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:22 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-499-4jnRSv5eNVWGp2F6t9CkUQ-1; Tue, 11 Oct 2022 06:27:17 -0400 Received: by mail-ed1-f72.google.com with SMTP id b19-20020a056402351300b0045c129ed62cso4013503edd.6 for ; Tue, 11 Oct 2022 03:27:17 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id kw17-20020a170907771100b0077e6be40e4asm6799060ejc.175.2022.10.11.03.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZusI1znOLcmgbAOaPKJgjMoffzX/bBvt01BsInxDwo=; b=KdbCOaiekAW1EP4bqRXH4gHZGSoRntXHF8Iax8O+RZrcEn9R8TL83w/Kcq0anbpoYRAxA6 jUYKHLHr4aUdrUNam2w67iU80BnSUadoh1kzIWzsfOeCJHR3QbZ1S8zWlSEnfmLdVU+31t NLUkGQDn6bfXizUOsFc4sxxQq84+Sgw= X-MC-Unique: 4jnRSv5eNVWGp2F6t9CkUQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xZusI1znOLcmgbAOaPKJgjMoffzX/bBvt01BsInxDwo=; b=QPqGfGOMqb0LE+XcBt/ktZGbB2HYkvytnozM/LDsYeWKwLJq7f1hdwiEd8mo59lsCR BMTIum6PJaaLmgIewO5TyxPT6wqv3TjBJDNWS+GPMx04QtqMwOE5rSzZ6HwGSdLnI628 bgvwJGy2YWMCXdcr+xQCvtifjKBNwNKHVUK58RZrSw5hBfaN5MGw0VgYUz/hqwfDgFHB XgKc3vKFnXUInozmXyyTsgwbGGUbRPmdR9AstcMbkeoMh1vDFLdBV+ph4NsDr8ta6wb5 9FebRZjvIivlIO4qJSqjvHJsjhNNbBtLHArzNMzQF97d3eOB3+M8B3QRVmwR3hxsDUKy 7qfQ== X-Gm-Message-State: ACrzQf3fzzfwnPhZUss6XPkSAZXXMm80Ya+UAzMIAm3KubFZbxdC5Dr+ QZu6OWVBJYqUnjOeosSTST2x0B5+FCq0vDzwg0gAljKk0vZ9tBXHtTMYnq5M8yB/TW7VBKQjIIC XcPhNWP409JsUiTCy067AKwpRBqfWfda4DQT2IuvdrSAG9+bDuUm1HY1jwntTCe/QBMk= X-Received: by 2002:a17:907:e87:b0:783:98dd:4221 with SMTP id ho7-20020a1709070e8700b0078398dd4221mr19573768ejc.22.1665484035844; Tue, 11 Oct 2022 03:27:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Xuh75GsExw5Zy2ascM3vwZTMeWGK6VtUG32rlxElMXioB5cUhlW1qQ7e0kNfwTljM6hD5eA== X-Received: by 2002:a17:907:e87:b0:783:98dd:4221 with SMTP id ho7-20020a1709070e8700b0078398dd4221mr19573752ejc.22.1665484035570; Tue, 11 Oct 2022 03:27:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Chenyi Qiang Subject: [PULL 04/37] kvm: expose struct KVMState Date: Tue, 11 Oct 2022 12:26:27 +0200 Message-Id: <20221011102700.319178-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665484948419100001 Content-Type: text/plain; charset="utf-8" From: Chenyi Qiang Expose struct KVMState out of kvm-all.c so that the field of struct KVMState can be accessed when defining target-specific accelerator properties. Signed-off-by: Chenyi Qiang Message-Id: <20220929072014.20705-4-chenyi.qiang@intel.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 74 -------------------------------------- include/sysemu/kvm_int.h | 76 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 03a69cf053..fbfe948398 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -77,86 +77,12 @@ do { } while (0) #endif =20 -#define KVM_MSI_HASHTAB_SIZE 256 - struct KVMParkedVcpu { unsigned long vcpu_id; int kvm_fd; QLIST_ENTRY(KVMParkedVcpu) node; }; =20 -enum KVMDirtyRingReaperState { - KVM_DIRTY_RING_REAPER_NONE =3D 0, - /* The reaper is sleeping */ - KVM_DIRTY_RING_REAPER_WAIT, - /* The reaper is reaping for dirty pages */ - KVM_DIRTY_RING_REAPER_REAPING, -}; - -/* - * KVM reaper instance, responsible for collecting the KVM dirty bits - * via the dirty ring. - */ -struct KVMDirtyRingReaper { - /* The reaper thread */ - QemuThread reaper_thr; - volatile uint64_t reaper_iteration; /* iteration number of reaper thr = */ - volatile enum KVMDirtyRingReaperState reaper_state; /* reap thr state = */ -}; - -struct KVMState -{ - AccelState parent_obj; - - int nr_slots; - int fd; - int vmfd; - int coalesced_mmio; - int coalesced_pio; - struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; - bool coalesced_flush_in_progress; - int vcpu_events; - int robust_singlestep; - int debugregs; -#ifdef KVM_CAP_SET_GUEST_DEBUG - QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; -#endif - int max_nested_state_len; - int many_ioeventfds; - int intx_set_mask; - int kvm_shadow_mem; - bool kernel_irqchip_allowed; - bool kernel_irqchip_required; - OnOffAuto kernel_irqchip_split; - bool sync_mmu; - uint64_t manual_dirty_log_protect; - /* The man page (and posix) say ioctl numbers are signed int, but - * they're not. Linux, glibc and *BSD all treat ioctl numbers as - * unsigned, and treating them as signed here can break things */ - unsigned irq_set_ioctl; - unsigned int sigmask_len; - GHashTable *gsimap; -#ifdef KVM_CAP_IRQ_ROUTING - struct kvm_irq_routing *irq_routes; - int nr_allocated_irq_routes; - unsigned long *used_gsi_bitmap; - unsigned int gsi_count; - QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; -#endif - KVMMemoryListener memory_listener; - QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; - - /* For "info mtree -f" to tell if an MR is registered in KVM */ - int nr_as; - struct KVMAs { - KVMMemoryListener *ml; - AddressSpace *as; - } *as; - uint64_t kvm_dirty_ring_bytes; /* Size of the per-vcpu dirty ring */ - uint32_t kvm_dirty_ring_size; /* Number of dirty GFNs per ring */ - struct KVMDirtyRingReaper reaper; -}; - KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_split_irqchip; diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 1f5487d9b7..3b4adcdc10 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -10,6 +10,7 @@ #define QEMU_KVM_INT_H =20 #include "exec/memory.h" +#include "qapi/qapi-types-common.h" #include "qemu/accel.h" #include "sysemu/kvm.h" =20 @@ -36,6 +37,81 @@ typedef struct KVMMemoryListener { int as_id; } KVMMemoryListener; =20 +#define KVM_MSI_HASHTAB_SIZE 256 + +enum KVMDirtyRingReaperState { + KVM_DIRTY_RING_REAPER_NONE =3D 0, + /* The reaper is sleeping */ + KVM_DIRTY_RING_REAPER_WAIT, + /* The reaper is reaping for dirty pages */ + KVM_DIRTY_RING_REAPER_REAPING, +}; + +/* + * KVM reaper instance, responsible for collecting the KVM dirty bits + * via the dirty ring. + */ +struct KVMDirtyRingReaper { + /* The reaper thread */ + QemuThread reaper_thr; + volatile uint64_t reaper_iteration; /* iteration number of reaper thr = */ + volatile enum KVMDirtyRingReaperState reaper_state; /* reap thr state = */ +}; +struct KVMState +{ + AccelState parent_obj; + + int nr_slots; + int fd; + int vmfd; + int coalesced_mmio; + int coalesced_pio; + struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; + bool coalesced_flush_in_progress; + int vcpu_events; + int robust_singlestep; + int debugregs; +#ifdef KVM_CAP_SET_GUEST_DEBUG + QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; +#endif + int max_nested_state_len; + int many_ioeventfds; + int intx_set_mask; + int kvm_shadow_mem; + bool kernel_irqchip_allowed; + bool kernel_irqchip_required; + OnOffAuto kernel_irqchip_split; + bool sync_mmu; + uint64_t manual_dirty_log_protect; + /* The man page (and posix) say ioctl numbers are signed int, but + * they're not. Linux, glibc and *BSD all treat ioctl numbers as + * unsigned, and treating them as signed here can break things */ + unsigned irq_set_ioctl; + unsigned int sigmask_len; + GHashTable *gsimap; +#ifdef KVM_CAP_IRQ_ROUTING + struct kvm_irq_routing *irq_routes; + int nr_allocated_irq_routes; + unsigned long *used_gsi_bitmap; + unsigned int gsi_count; + QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; +#endif + KVMMemoryListener memory_listener; + QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; + + /* For "info mtree -f" to tell if an MR is registered in KVM */ + int nr_as; + struct KVMAs { + KVMMemoryListener *ml; + AddressSpace *as; + } *as; + uint64_t kvm_dirty_ring_bytes; /* Size of the per-vcpu dirty ring */ + uint32_t kvm_dirty_ring_size; /* Number of dirty GFNs per ring */ + struct KVMDirtyRingReaper reaper; + NotifyVmexitOption notify_vmexit; + uint32_t notify_window; +}; + void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id, const char = *name); =20 --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485217; cv=none; d=zohomail.com; s=zohoarc; b=MmTAt12rjCDTFSI19u/pFVFOaK57nJICAxEoGzF3dAstC/90E9nM2NrwKz3Shq12yOR49lrpkCh+aSnkjtArgy95ntIuRiL4488cBZfgc3t/2DJDT1TEpox1nKaHcSNT+FVj1IOnqT65i79pl+ovuU+u3I7lb6iFndOmrK3qmQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wHwt4wzgqW3P8bT1wnaCEw3RQuutu+NUFATpSfeagOI=; b=lvWDnquDm/RnEfS3uBxSa1c0luDVp7utcX2ituaU6E7VFL6bI7n5PXKKc5eSjXCpcbIZk9RBfCFMW5wGB3Hj6Me2EwvhWWbbK3OLf9h0VrEsgNvYuJGdZhZtmI5DEAxwKsuRDRN2RkPf6id9PbiJhKB48i/WeIi0csv1Try3ozc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485217849158.5185844187323; Tue, 11 Oct 2022 03:46:57 -0700 (PDT) Received: from localhost ([::1]:51622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCml-0006hV-8C for importer@patchew.org; Tue, 11 Oct 2022 06:46:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTt-0001mT-CK for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTr-0004Kt-4Y for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:24 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-284-op7F_mc0PF6a4lOok8nufg-1; Tue, 11 Oct 2022 06:27:21 -0400 Received: by mail-ej1-f72.google.com with SMTP id gn33-20020a1709070d2100b00787e6fbcb72so5673428ejc.3 for ; Tue, 11 Oct 2022 03:27:20 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id g3-20020a170906594300b007815c3e95f6sm6837422ejr.146.2022.10.11.03.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHwt4wzgqW3P8bT1wnaCEw3RQuutu+NUFATpSfeagOI=; b=MUr0gHrtvSA6LYMuLZW50qNkhbFS+FIrEuf5tVWy83eKcJtda/Xyp5fA/vLouSTSJABKAZ YYWEI+wb/xQcBjJYKTlp+zJxQCnf5h12opuC3ZYQgKOpYa+W5Z1asxc2J8EtoqjK8maC8C ufyMSd6UWNwP9QkhfMXtH86EJPMfIF8= X-MC-Unique: op7F_mc0PF6a4lOok8nufg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wHwt4wzgqW3P8bT1wnaCEw3RQuutu+NUFATpSfeagOI=; b=YX5EVYfemHL39hfBH5BVWN74nEmGlhxf7ENY+yjytXG6U9FgVGmDnb7tR3j4npQRuz s9Ghwr0hFlQPkgVAK9kdk+YUfuj5FbDJJQ68MsmMlmwUdP007GxrxPNOSe1jTAWLsqGq KXfK4NgtIOUYjAvc1Gc6FqBXeAZLXTd8yEgDZX60yMCQDnQa6/60vJh9qu+vR9j0GcZK JPnI2/Df+QG2B1LrmBw6TLftUBCkyIznCRNICXonJdNY30qBuzSxR62Wa7qGOp8onUWA fnOOYDXH1OhQOyT3W9as4bfMUS/BDzsg4WzDEHrJDKfKfSXh4+vBAnxCG7T5sfeI0esx 3PQg== X-Gm-Message-State: ACrzQf0kh58LpOn2d99EQPKZfJtwk8pnB0os1AJyvutNpbiZ4Alp0JG9 s+OSw8zQd1kECSJkr0UGkurQAq5GT4mM4iYW5of9ribADkA9F79ZCtIspG2xq8lX+tuDqU4w7ck RZ9LRGOFUssetNKwJW0dDs1EYSCASbGw3ha5FaQ4vs597ocwDhJ//SNlgxKR+TSq7X0c= X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr7005188eje.157.1665484038964; Tue, 11 Oct 2022 03:27:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7OeKPnNgIJ/b5oVA9TnkFGneaeTfhCmYnCfWhMQ8YnFh9LhQPpDN5OytRmQDWmRO6BRzy+OA== X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr7005169eje.157.1665484038588; Tue, 11 Oct 2022 03:27:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Chenyi Qiang , Peter Xu Subject: [PULL 05/37] i386: add notify VM exit support Date: Tue, 11 Oct 2022 12:26:28 +0200 Message-Id: <20221011102700.319178-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485218997100001 Content-Type: text/plain; charset="utf-8" From: Chenyi Qiang There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event window means no event (NMI, SMI and IRQ) can be delivered. It leads the CPU to be unavailable to host or other VMs. Notify VM exit is introduced to mitigate such kind of attacks, which will generate a VM exit if no event window occurs in VM non-root mode for a specified amount of time (notify window). A new KVM capability KVM_CAP_X86_NOTIFY_VMEXIT is exposed to user space so that the user can query the capability and set the expected notify window when creating VMs. The format of the argument when enabling this capability is as follows: Bit 63:32 - notify window specified in qemu command Bit 31:0 - some flags (e.g. KVM_X86_NOTIFY_VMEXIT_ENABLED is set to enable the feature.) Users can configure the feature by a new (x86 only) accel property: qemu -accel kvm,notify-vmexit=3Drun|internal-error|disable,notify-windo= w=3Dn The default option of notify-vmexit is run, which will enable the capability and do nothing if the exit happens. The internal-error option raises a KVM internal error if it happens. The disable option does not enable the capability. The default value of notify-window is 0. It is valid only when notify-vmexit is not disabled. The valid range of notify-window is non-negative. It is even safe to set it to zero since there's an internal hardware threshold to be added to ensure no false positive. Because a notify VM exit may happen with VM_CONTEXT_INVALID set in exit qualification (no cases are anticipated that would set this bit), which means VM context is corrupted. It would be reflected in the flags of KVM_EXIT_NOTIFY exit. If KVM_NOTIFY_CONTEXT_INVALID bit is set, raise a KVM internal error unconditionally. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang Message-Id: <20220929072014.20705-5-chenyi.qiang@intel.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 2 + qapi/run-state.json | 17 ++++++++ qemu-options.hx | 11 +++++ target/i386/kvm/kvm.c | 98 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fbfe948398..f99b0becd8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3618,6 +3618,8 @@ static void kvm_accel_instance_init(Object *obj) s->kernel_irqchip_split =3D ON_OFF_AUTO_AUTO; /* KVM dirty ring is by default off */ s->kvm_dirty_ring_size =3D 0; + s->notify_vmexit =3D NOTIFY_VMEXIT_OPTION_RUN; + s->notify_window =3D 0; } =20 /** diff --git a/qapi/run-state.json b/qapi/run-state.json index 9273ea6516..49989d30e6 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -643,3 +643,20 @@ { 'struct': 'MemoryFailureFlags', 'data': { 'action-required': 'bool', 'recursive': 'bool'} } + +## +# @NotifyVmexitOption: +# +# An enumeration of the options specified when enabling notify VM exit +# +# @run: enable the feature, do nothing and continue if the notify VM exit = happens. +# +# @internal-error: enable the feature, raise a internal error if the notify +# VM exit happens. +# +# @disable: disable the feature. +# +# Since: 7.2 +## +{ 'enum': 'NotifyVmexitOption', + 'data': [ 'run', 'internal-error', 'disable' ] } \ No newline at end of file diff --git a/qemu-options.hx b/qemu-options.hx index 95b998a13b..606d379186 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -191,6 +191,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, " split-wx=3Don|off (enable TCG split w^x mapping)\n" " tb-size=3Dn (TCG translation block cache size)\n" " dirty-ring-size=3Dn (KVM dirty ring GFN count, defaul= t 0)\n" + " notify-vmexit=3Drun|internal-error|disable,notify-win= dow=3Dn (enable notify VM exit and set notify window, x86 only)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) SRST ``-accel name[,prop=3Dvalue[,...]]`` @@ -242,6 +243,16 @@ SRST is disabled (dirty-ring-size=3D0). When enabled, KVM will instead record dirty pages in a bitmap. =20 + ``notify-vmexit=3Drun|internal-error|disable,notify-window=3Dn`` + Enables or disables notify VM exit support on x86 host and specify + the corresponding notify window to trigger the VM exit if enabled. + ``run`` option enables the feature. It does nothing and continue + if the exit happens. ``internal-error`` option enables the feature. + It raises a internal error. ``disable`` option doesn't enable the = feature. + This feature can mitigate the CPU stuck issue due to event windows= don't + open up for a specified of time (i.e. notify-window). + Default: notify-vmexit=3Drun,notify-window=3D0. + ERST =20 DEF("smp", HAS_ARG, QEMU_OPTION_smp, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f18d21413c..ec63b5eb10 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -15,6 +15,7 @@ #include "qemu/osdep.h" #include "qapi/qapi-events-run-state.h" #include "qapi/error.h" +#include "qapi/visitor.h" #include #include #include @@ -2595,6 +2596,21 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 + if (s->notify_vmexit !=3D NOTIFY_VMEXIT_OPTION_DISABLE && + kvm_check_extension(s, KVM_CAP_X86_NOTIFY_VMEXIT)) { + uint64_t notify_window_flags =3D + ((uint64_t)s->notify_window << 32) | + KVM_X86_NOTIFY_VMEXIT_ENABLED | + KVM_X86_NOTIFY_VMEXIT_USER; + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_NOTIFY_VMEXIT, 0, + notify_window_flags); + if (ret < 0) { + error_report("kvm: Failed to enable notify vmexit cap: %s", + strerror(-ret)); + return ret; + } + } + return 0; } =20 @@ -5137,6 +5153,9 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run= *run) X86CPU *cpu =3D X86_CPU(cs); uint64_t code; int ret; + bool ctx_invalid; + char str[256]; + KVMState *state; =20 switch (run->exit_reason) { case KVM_EXIT_HLT: @@ -5192,6 +5211,21 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_ru= n *run) /* already handled in kvm_arch_post_run */ ret =3D 0; break; + case KVM_EXIT_NOTIFY: + ctx_invalid =3D !!(run->notify.flags & KVM_NOTIFY_CONTEXT_INVALID); + state =3D KVM_STATE(current_accel()); + sprintf(str, "Encounter a notify exit with %svalid context in" + " guest. There can be possible misbehaves in guest." + " Please have a look.", ctx_invalid ? "in" : ""); + if (ctx_invalid || + state->notify_vmexit =3D=3D NOTIFY_VMEXIT_OPTION_INTERNAL_ERRO= R) { + warn_report("KVM internal error: %s", str); + ret =3D -1; + } else { + warn_report_once("KVM: %s", str); + ret =3D 0; + } + break; default: fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); ret =3D -1; @@ -5469,6 +5503,70 @@ void kvm_request_xsave_components(X86CPU *cpu, uint6= 4_t mask) } } =20 +static int kvm_arch_get_notify_vmexit(Object *obj, Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + return s->notify_vmexit; +} + +static void kvm_arch_set_notify_vmexit(Object *obj, int value, Error **err= p) +{ + KVMState *s =3D KVM_STATE(obj); + + if (s->fd !=3D -1) { + error_setg(errp, "Cannot set properties after the accelerator has = been initialized"); + return; + } + + s->notify_vmexit =3D value; +} + +static void kvm_arch_get_notify_window(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + uint32_t value =3D s->notify_window; + + visit_type_uint32(v, name, &value, errp); +} + +static void kvm_arch_set_notify_window(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + Error *error =3D NULL; + uint32_t value; + + if (s->fd !=3D -1) { + error_setg(errp, "Cannot set properties after the accelerator has = been initialized"); + return; + } + + visit_type_uint32(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + + s->notify_window =3D value; +} + void kvm_arch_accel_class_init(ObjectClass *oc) { + object_class_property_add_enum(oc, "notify-vmexit", "NotifyVMexitOptio= n", + &NotifyVmexitOption_lookup, + kvm_arch_get_notify_vmexit, + kvm_arch_set_notify_vmexit); + object_class_property_set_description(oc, "notify-vmexit", + "Enable notify VM exit"); + + object_class_property_add(oc, "notify-window", "uint32", + kvm_arch_get_notify_window, + kvm_arch_set_notify_window, + NULL, NULL); + object_class_property_set_description(oc, "notify-window", + "Clock cycles without an event w= indow " + "after which a notification VM e= xit occurs"); } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485615; cv=none; d=zohomail.com; s=zohoarc; b=en5dIXHfDLlTH1BtrFIqlI+mvldMrIo0AVHQaI6+XeKYGLOsL0jbbL1k1y07gdmmqH0PeOYns5d2FGYImOZzOCBVhxUC9lc93raBkO1x7ePHLCEcX60LPP86dg9gqj0lNIY38MmBfqBrFHeNqWqC0DYXhqyDixHyaKuh9PHKiy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485615; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SVip0KBxPg4z4BeuYr2Zar9WmRywPpxynwTVJk5vNl0=; b=TFRG/611slRQ+9TLBOnYAuekdQ3Z0oNPnsY/qf0QmpPRKc9JCs0t2LkBL6uBHWCOIPr21DE6aP1sj5fRLM5mKo7M0oWRGyialOjYoFeEB4pr7tXsubbCk+pFpPpohCIbhklas6Oh5QahgF1HwEdGhmjK3PqA57Cqy5uts3/kPcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485615960813.7648936000764; Tue, 11 Oct 2022 03:53:35 -0700 (PDT) Received: from localhost ([::1]:53974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCtB-0004hp-KA for importer@patchew.org; Tue, 11 Oct 2022 06:53:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTy-0001pU-Ly for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTw-0004NZ-8P for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:30 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-413-sHfGqZLpM62dl3PLq8Urgg-1; Tue, 11 Oct 2022 06:27:23 -0400 Received: by mail-ej1-f69.google.com with SMTP id sh33-20020a1709076ea100b0078d28567b70so5701534ejc.16 for ; Tue, 11 Oct 2022 03:27:23 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id p26-20020a05640210da00b004587c2b5048sm6566279edu.52.2022.10.11.03.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SVip0KBxPg4z4BeuYr2Zar9WmRywPpxynwTVJk5vNl0=; b=b0XPWw2hbv5iWrGHeD4P06iQAo3GHxVBn+0goSHyEUNgTG74HLoyhEwx7kYVp3nhJfNr6i p2evRzt8m7RN5jEPoos2HdHQ6JLSqQQd4ik3RsoOz/HOrHoU/U4pG6KBKrvfCEypzM+nQV 6e3XAxHF+cuZz5yOZJtdA6a0YRPWMoE= X-MC-Unique: sHfGqZLpM62dl3PLq8Urgg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SVip0KBxPg4z4BeuYr2Zar9WmRywPpxynwTVJk5vNl0=; b=Cyj2Oroifubp5mgyT68MoUBqXnyhPBWtrJzdC5j3apR9lkSr0K0vRg1ubNkjj2/ddU ikBLZbibIaSJA+DLtzW5dtcSpXwA4Pag/QUUEUUPgLDcLN9wqJVWUwsS0Of3bUiIA1VQ ddRsbK/yBdN/kbKm466EgquV/a7FubM0udhYAB7gZVP+l99BPJIKJE+dcYfkMXJ1yD9k vpzABRb5TqHvzC1IxbNqLltLGqBHS5WuyMQaI8T1QeU3TuQuxjLg4DQtZmDybvRCuwKS i0W69fViq1/vHCGzTMug1vzS/DsrU+m3A6e2iC5UMzuJ5SZNiftDPZGgXtj4yFvzQXCO sgQw== X-Gm-Message-State: ACrzQf1hFKYQP2AG5XbpCTCcEhOhdAeHDYQ9l8C3QwwzRbeL2HwXrc4E L6b3FDnd2P4FpdCE7YvWSlhBAxYX6JcNPddmGqukfC6uDgd4ON6LxRIlNfyvD1/mEwdjPEeBPTe W588uZ+it9Wdz0WNXRmTCF0kQPyoaCyLONIV4wqNTV++sGBqDoqFiSCyYdHL5So4oFFI= X-Received: by 2002:a05:6402:51c6:b0:45b:d0d7:4b41 with SMTP id r6-20020a05640251c600b0045bd0d74b41mr14994497edd.219.1665484042110; Tue, 11 Oct 2022 03:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CS4ztNgATfdLHsspX8KDhnlEg0mIKw4deZ1Xn8uYUvK4C6davP1NDflR4c3We8KCwasJmUw== X-Received: by 2002:a05:6402:51c6:b0:45b:d0d7:4b41 with SMTP id r6-20020a05640251c600b0045bd0d74b41mr14994477edd.219.1665484041698; Tue, 11 Oct 2022 03:27:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 06/37] target/i386: Remove pc_start Date: Tue, 11 Oct 2022 12:26:29 +0200 Message-Id: <20221011102700.319178-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485616784100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The DisasContext member and the disas_insn local variable of the same name are identical to DisasContextBase.pc_next. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-2-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 114 +++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 44af8c107f..16bf56dbc7 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -76,7 +76,6 @@ typedef struct DisasContext { DisasContextBase base; =20 target_ulong pc; /* pc =3D eip + cs_base */ - target_ulong pc_start; /* pc at TB entry */ target_ulong cs_base; /* base of CS segment */ =20 MemOp aflag; @@ -1345,13 +1344,13 @@ static void gen_exception(DisasContext *s, int trap= no, target_ulong cur_eip) the instruction is known, but it isn't allowed in the current cpu mode.= */ static void gen_illegal_opcode(DisasContext *s) { - gen_exception(s, EXCP06_ILLOP, s->pc_start - s->cs_base); + gen_exception(s, EXCP06_ILLOP, s->base.pc_next - s->cs_base); } =20 /* Generate #GP for the current instruction. */ static void gen_exception_gpf(DisasContext *s) { - gen_exception(s, EXCP0D_GPF, s->pc_start - s->cs_base); + gen_exception(s, EXCP0D_GPF, s->base.pc_next - s->cs_base); } =20 /* Check for cpl =3D=3D 0; if not, raise #GP and return false. */ @@ -2016,7 +2015,7 @@ static uint64_t advance_pc(CPUX86State *env, DisasCon= text *s, int num_bytes) } =20 s->pc +=3D num_bytes; - if (unlikely(s->pc - s->pc_start > X86_MAX_INSN_LENGTH)) { + if (unlikely(s->pc - s->base.pc_next > X86_MAX_INSN_LENGTH)) { /* If the instruction's 16th byte is on a different page than the = 1st, a * page fault on the second page wins over the general protection = fault * caused by the instruction being too long. @@ -2614,7 +2613,7 @@ static void gen_unknown_opcode(CPUX86State *env, Disa= sContext *s) if (qemu_loglevel_mask(LOG_UNIMP)) { FILE *logfile =3D qemu_log_trylock(); if (logfile) { - target_ulong pc =3D s->pc_start, end =3D s->pc; + target_ulong pc =3D s->base.pc_next, end =3D s->pc; =20 fprintf(logfile, "ILLOPC: " TARGET_FMT_lx ":", pc); for (; pc < end; ++pc) { @@ -3226,8 +3225,7 @@ static const struct SSEOpHelper_table7 sse_op_table7[= 256] =3D { goto illegal_op; \ } while (0) =20 -static void gen_sse(CPUX86State *env, DisasContext *s, int b, - target_ulong pc_start) +static void gen_sse(CPUX86State *env, DisasContext *s, int b) { int b1, op1_offset, op2_offset, is_xmm, val; int modrm, mod, rm, reg; @@ -3269,7 +3267,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s= , int b, } /* simple MMX/SSE operation */ if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base); return; } if (s->flags & HF_EM_MASK) { @@ -4717,11 +4715,10 @@ static target_ulong disas_insn(DisasContext *s, CPU= State *cpu) MemOp ot, aflag, dflag; int modrm, reg, rm, mod, op, opreg, val; target_ulong next_eip, tval; - target_ulong pc_start =3D s->base.pc_next; bool orig_cc_op_dirty =3D s->cc_op_dirty; CCOp orig_cc_op =3D s->cc_op; =20 - s->pc_start =3D s->pc =3D pc_start; + s->pc =3D s->base.pc_next; s->override =3D -1; #ifdef TARGET_X86_64 s->rex_w =3D false; @@ -4745,7 +4742,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) s->base.num_insns--; tcg_remove_ops_after(s->prev_insn_end); s->base.is_jmp =3D DISAS_TOO_MANY; - return pc_start; + return s->base.pc_next; default: g_assert_not_reached(); } @@ -6079,7 +6076,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) if (s->flags & (HF_EM_MASK | HF_TS_MASK)) { /* if CR0.EM or CR0.TS are set, generate an FPU exception = */ /* XXX: what to do if illegal op ? */ - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); break; } modrm =3D x86_ldub_code(env, s); @@ -6620,7 +6617,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) offsetof(CPUX86State, segs[R_CS].selector)); tcg_gen_st16_i32(s->tmp2_i32, cpu_env, offsetof(CPUX86State, fpcs)); - tcg_gen_st_tl(tcg_constant_tl(pc_start - s->cs_base), + tcg_gen_st_tl(tcg_constant_tl(s->base.pc_next - s->cs_base= ), cpu_env, offsetof(CPUX86State, fpip)); } } @@ -6632,7 +6629,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0xa5: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_movs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= ); + gen_repz_movs(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base); } else { gen_movs(s, ot); } @@ -6642,7 +6640,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0xab: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_stos(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= ); + gen_repz_stos(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base); } else { gen_stos(s, ot); } @@ -6651,7 +6650,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0xad: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_lods(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= ); + gen_repz_lods(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base); } else { gen_lods(s, ot); } @@ -6660,9 +6660,11 @@ static target_ulong disas_insn(DisasContext *s, CPUS= tate *cpu) case 0xaf: ot =3D mo_b_d(b, dflag); if (prefixes & PREFIX_REPNZ) { - gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= , 1); + gen_repz_scas(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base, 1); } else if (prefixes & PREFIX_REPZ) { - gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= , 0); + gen_repz_scas(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base, 0); } else { gen_scas(s, ot); } @@ -6672,9 +6674,11 @@ static target_ulong disas_insn(DisasContext *s, CPUS= tate *cpu) case 0xa7: ot =3D mo_b_d(b, dflag); if (prefixes & PREFIX_REPNZ) { - gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= , 1); + gen_repz_cmps(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base, 1); } else if (prefixes & PREFIX_REPZ) { - gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= , 0); + gen_repz_cmps(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base, 0); } else { gen_cmps(s, ot); } @@ -6692,7 +6696,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_io_start(); } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base); + gen_repz_ins(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base); /* jump generated by gen_repz_ins */ } else { gen_ins(s, ot); @@ -6713,7 +6718,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_io_start(); } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base= ); + gen_repz_outs(s, ot, s->base.pc_next - s->cs_base, + s->pc - s->cs_base); /* jump generated by gen_repz_outs */ } else { gen_outs(s, ot); @@ -6825,7 +6831,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) do_lret: if (PE(s) && !VM86(s)) { gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_lret_protected(cpu_env, tcg_const_i32(dflag - 1), tcg_const_i32(val)); } else { @@ -7295,7 +7301,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; val =3D x86_ldub_code(env, s); if (val =3D=3D 0) { - gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base); + gen_exception(s, EXCP00_DIVZ, s->base.pc_next - s->cs_base); } else { gen_helper_aam(cpu_env, tcg_const_i32(val)); set_cc_op(s, CC_OP_LOGICB); @@ -7321,34 +7327,34 @@ static target_ulong disas_insn(DisasContext *s, CPU= State *cpu) } if (prefixes & PREFIX_REPZ) { gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); - gen_helper_pause(cpu_env, tcg_const_i32(s->pc - pc_start)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_pause(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); s->base.is_jmp =3D DISAS_NORETURN; } break; case 0x9b: /* fwait */ if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) =3D=3D (HF_MP_MASK | HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base); } else { gen_helper_fwait(cpu_env); } break; case 0xcc: /* int3 */ - gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs= _base); + gen_interrupt(s, EXCP03_INT3, s->base.pc_next - s->cs_base, s->pc = - s->cs_base); break; case 0xcd: /* int N */ val =3D x86_ldub_code(env, s); if (check_vm86_iopl(s)) { - gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_bas= e); + gen_interrupt(s, val, s->base.pc_next - s->cs_base, s->pc - s-= >cs_base); } break; case 0xce: /* into */ if (CODE64(s)) goto illegal_op; gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); - gen_helper_into(cpu_env, tcg_const_i32(s->pc - pc_start)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_into(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)); break; #ifdef WANT_ICEBP case 0xf1: /* icebp (undocumented, exits to external debugger) */ @@ -7454,7 +7460,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0x132: /* rdmsr */ if (check_cpl0(s)) { gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); if (b & 2) { gen_helper_rdmsr(cpu_env); } else { @@ -7466,7 +7472,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; case 0x131: /* rdtsc */ gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -7477,7 +7483,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; case 0x133: /* rdpmc */ gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_rdpmc(cpu_env); s->base.is_jmp =3D DISAS_NORETURN; break; @@ -7507,8 +7513,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0x105: /* syscall */ /* XXX: is it usable in real mode ? */ gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); - gen_helper_syscall(cpu_env, tcg_const_i32(s->pc - pc_start)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_syscall(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); /* TF handling for the syscall insn is different. The TF bit is c= hecked after the syscall insn completes. This allows #DB to not be generated after one has entered CPL0 if TF is set in FMASK. */ @@ -7533,14 +7539,14 @@ static target_ulong disas_insn(DisasContext *s, CPU= State *cpu) #endif case 0x1a2: /* cpuid */ gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_cpuid(cpu_env); break; case 0xf4: /* hlt */ if (check_cpl0(s)) { gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); - gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - pc_start)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); s->base.is_jmp =3D DISAS_NORETURN; } break; @@ -7636,7 +7642,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); tcg_gen_mov_tl(s->A0, cpu_regs[R_EAX]); gen_extu(s->aflag, s->A0); gen_add_A0_ds_seg(s); @@ -7648,8 +7654,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); - gen_helper_mwait(cpu_env, tcg_const_i32(s->pc - pc_start)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_mwait(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); s->base.is_jmp =3D DISAS_NORETURN; break; =20 @@ -7726,9 +7732,9 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_vmrun(cpu_env, tcg_const_i32(s->aflag - 1), - tcg_const_i32(s->pc - pc_start)); + tcg_const_i32(s->pc - s->base.pc_next)); tcg_gen_exit_tb(NULL, 0); s->base.is_jmp =3D DISAS_NORETURN; break; @@ -7738,7 +7744,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_vmmcall(cpu_env); break; =20 @@ -7750,7 +7756,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_vmload(cpu_env, tcg_const_i32(s->aflag - 1)); break; =20 @@ -7762,7 +7768,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_vmsave(cpu_env, tcg_const_i32(s->aflag - 1)); break; =20 @@ -7788,7 +7794,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_clgi(cpu_env); break; =20 @@ -7934,7 +7940,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, pc_start - s->cs_base); + gen_jmp_im(s, s->base.pc_next - s->cs_base); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -8386,7 +8392,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); break; } gen_lea_modrm(env, s, modrm); @@ -8399,7 +8405,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); break; } gen_lea_modrm(env, s, modrm); @@ -8411,7 +8417,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); break; } gen_lea_modrm(env, s, modrm); @@ -8424,7 +8430,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) goto illegal_op; } if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); + gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); break; } gen_helper_update_mxcsr(cpu_env); @@ -8633,7 +8639,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 0x1c2: case 0x1c4 ... 0x1c6: case 0x1d0 ... 0x1fe: - gen_sse(env, s, b, pc_start); + gen_sse(env, s, b); break; default: goto unknown_op; --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485293; cv=none; d=zohomail.com; s=zohoarc; b=YmDJUXdHjvJbwOzkOIoJqbTGNVo5nHkEccKTwuY3QYQGd+Pjgaf0+ceuUggc//Qpfv+VCIKwbyvM8NF+LLElydNoe3Z9WKVTRU6Bd2Pg6IDIOa7uZkXMDbGhoQ7FFkKu2nhjbxdDWtnCH/xCS58JiEV7M5r92qFTuTztMsCIaCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485293; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4v10Kc9t6YsWGRDXH0zBX3cO3GWE7Kg1t8plFc8Disk=; b=nK66dAnPS4HEvyisG4oeCcem/3+hu0sjC0Uy8R1DeXibaWX1FnLczVNEFiRHHMMaTEpuXyPTb6LjbaZc7HBDR5FFmtm9+86BZ9q/Jnc2vminfc6F1VebXlYHRSS9sxzy7FFI3BMst6K3UlrpD8RU+XiPRyh7feHXGlh2NXXdWnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485293706796.8491401463604; Tue, 11 Oct 2022 03:48:13 -0700 (PDT) Received: from localhost ([::1]:33074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCo0-0000qP-I5 for importer@patchew.org; Tue, 11 Oct 2022 06:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTy-0001pT-1w for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTw-0004Nm-B9 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:29 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-599-IhwUbtE4MMeX9Cm1gO9Yew-1; Tue, 11 Oct 2022 06:27:26 -0400 Received: by mail-ej1-f69.google.com with SMTP id gn33-20020a1709070d2100b00787e6fbcb72so5673566ejc.3 for ; Tue, 11 Oct 2022 03:27:26 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id y2-20020a1709063da200b0073d83f80b05sm6755681ejh.94.2022.10.11.03.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4v10Kc9t6YsWGRDXH0zBX3cO3GWE7Kg1t8plFc8Disk=; b=aEy6wr7OrCE2pnVu7g6beeXXnV1fZN/NyNDkq9If4CDmndJ7vDxs+XwHsMyxcpqkBj0oue U7v0n7I0bNRtJ+jfT0so49mG2yQvdAUew2A6n/e1lKDb2cCHRP2WKqFpHbZbw+4g8h5LL2 EyHuvYYo4K/y8RJbvDM2PQ5JFJyHGHU= X-MC-Unique: IhwUbtE4MMeX9Cm1gO9Yew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4v10Kc9t6YsWGRDXH0zBX3cO3GWE7Kg1t8plFc8Disk=; b=j3JFdCLxYMQSjuXECwmW9onlAiHnCoj/IpbDuAATF26nKYHen3KBJPV7+5QRXRAjth B4elBuYv05qbgOGN4Tjpv/mXNbzIz5rQcZO3HX7OnT6NTs9lxgOq3gtbRmOWORwJrueY SY63rTz0jZZ+ai/37tvqPjqBuoysuu5PFB/hw5kigToYw+O7j6XT3p0X1zwAkTg592dN BGoWn/gxC0RZGfwKtgTyIXMLO54gCgqgLoOBx9cxrQ3gtyIzoWjqaspSncXg9loj4A0Z iOqOWMWxGec3+IiGjJ0ZfFNpryWScdIqdElMh8qSAE5/Y5p42YC3XCXn/XqHhIzrokDh WvCQ== X-Gm-Message-State: ACrzQf2wgkhGl3cKz46vJj/Nve6kL32A4HbhT10lACPg1J/ZR4Dg6wtx GEQHoPQE2j6pNW7ij8TkXqTxroBkMfgKRyam2MU6G3IJSMREPMGvJo7WrUjDaKAYdkkCYhbXUv3 zBGdLs6L5fATiQqWy/XXbqF21VFwoaDrAw2czXScz9kegH2w6geauChcRfLjJHPBsGJU= X-Received: by 2002:a05:6402:5202:b0:45c:9525:9bc4 with SMTP id s2-20020a056402520200b0045c95259bc4mr156034edd.380.1665484044800; Tue, 11 Oct 2022 03:27:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Vzy71edPNv1VrJnq5wV69QOismcJzjekCtWOrlrjb1iiuyZS5fNuRG9L+/ulR4jN+1rjuMQ== X-Received: by 2002:a05:6402:5202:b0:45c:9525:9bc4 with SMTP id s2-20020a056402520200b0045c95259bc4mr156013edd.380.1665484044538; Tue, 11 Oct 2022 03:27:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 07/37] target/i386: Return bool from disas_insn Date: Tue, 11 Oct 2022 12:26:30 +0200 Message-Id: <20221011102700.319178-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485295244100001 From: Richard Henderson Instead of returning the new pc, which is present in DisasContext, return true if an insn was translated. This is false when we detect a page crossing and must undo the insn under translation. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-3-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 16bf56dbc7..3f3e79c096 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -4707,7 +4707,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s= , int b) =20 /* convert one instruction. s->base.is_jmp is set if the translation must be stopped. Return the next pc value */ -static target_ulong disas_insn(DisasContext *s, CPUState *cpu) +static bool disas_insn(DisasContext *s, CPUState *cpu) { CPUX86State *env =3D cpu->env_ptr; int b, prefixes; @@ -4734,15 +4734,16 @@ static target_ulong disas_insn(DisasContext *s, CPU= State *cpu) break; case 1: gen_exception_gpf(s); - return s->pc; + return true; case 2: /* Restore state that may affect the next instruction. */ + s->pc =3D s->base.pc_next; s->cc_op_dirty =3D orig_cc_op_dirty; s->cc_op =3D orig_cc_op; s->base.num_insns--; tcg_remove_ops_after(s->prev_insn_end); s->base.is_jmp =3D DISAS_TOO_MANY; - return s->base.pc_next; + return false; default: g_assert_not_reached(); } @@ -8644,13 +8645,13 @@ static target_ulong disas_insn(DisasContext *s, CPU= State *cpu) default: goto unknown_op; } - return s->pc; + return true; illegal_op: gen_illegal_opcode(s); - return s->pc; + return true; unknown_op: gen_unknown_opcode(env, s); - return s->pc; + return true; } =20 void tcg_x86_init(void) @@ -8815,7 +8816,6 @@ static void i386_tr_insn_start(DisasContextBase *dcba= se, CPUState *cpu) static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); - target_ulong pc_next; =20 #ifdef TARGET_VSYSCALL_PAGE /* @@ -8828,21 +8828,23 @@ static void i386_tr_translate_insn(DisasContextBase= *dcbase, CPUState *cpu) } #endif =20 - pc_next =3D disas_insn(dc, cpu); - dc->base.pc_next =3D pc_next; + if (disas_insn(dc, cpu)) { + target_ulong pc_next =3D dc->pc; + dc->base.pc_next =3D pc_next; =20 - if (dc->base.is_jmp =3D=3D DISAS_NEXT) { - if (dc->flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK)) { - /* - * If single step mode, we generate only one instruction and - * generate an exception. - * If irq were inhibited with HF_INHIBIT_IRQ_MASK, we clear - * the flag and abort the translation to give the irqs a - * chance to happen. - */ - dc->base.is_jmp =3D DISAS_TOO_MANY; - } else if (!is_same_page(&dc->base, pc_next)) { - dc->base.is_jmp =3D DISAS_TOO_MANY; + if (dc->base.is_jmp =3D=3D DISAS_NEXT) { + if (dc->flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK)) { + /* + * If single step mode, we generate only one instruction a= nd + * generate an exception. + * If irq were inhibited with HF_INHIBIT_IRQ_MASK, we clear + * the flag and abort the translation to give the irqs a + * chance to happen. + */ + dc->base.is_jmp =3D DISAS_TOO_MANY; + } else if (!is_same_page(&dc->base, pc_next)) { + dc->base.is_jmp =3D DISAS_TOO_MANY; + } } } } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485952; cv=none; d=zohomail.com; s=zohoarc; b=kfLsD1xLBvZRSU9KFyd+ats+C7gQw6FuPmppzKi+oHg9Besq/Qf1bzuZyQVft0G6uyMDtYTKZBXDp/EQskg7nbuiXFnzo0DUcMcnjyafM5kWq39l/O/ra0kl+x3vbYmTT53mxs1K5/a7oOBVfX8i8KuijBphwdqbPQdbDM+AqAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485952; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cY1YtgpZbWRPCspprxt46+AxuqK8Gnzm3W5hRXACGYE=; b=AHWkF/OtL29TMOefrAH9ToLz5NK/Bem2UDsP+qH8T7w1rmr6Um4w0MYhuP1EyDuBe49k1Rif1F8Scvum5Wres6p7x12Hkpw0sjhGm477Fm6k4cLgUSNiie3fehMZF+Mb/4aCPBTaVaLfP6DOSWBlLDJuV4YKD+dGrB12n94GkcU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485952376124.61443031293561; Tue, 11 Oct 2022 03:59:12 -0700 (PDT) Received: from localhost ([::1]:38050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCyd-0002BB-9f for importer@patchew.org; Tue, 11 Oct 2022 06:59:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU0-0001px-Ch for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCTy-0004QJ-Qz for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:32 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-29-IWMJGjiLP0qQVrAeQQGVGw-1; Tue, 11 Oct 2022 06:27:29 -0400 Received: by mail-ed1-f71.google.com with SMTP id m10-20020a056402430a00b0045968bb0874so10819218edc.10 for ; Tue, 11 Oct 2022 03:27:28 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id d1-20020a170906304100b00788c622fa2csm6769589ejd.135.2022.10.11.03.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cY1YtgpZbWRPCspprxt46+AxuqK8Gnzm3W5hRXACGYE=; b=ON+9uZUG8PyIPsawST+6iHkX5NVBGW0YuEsgj1GgAeeB6SI+sJ+INrV9mwF8xUQ3jz/2ry eBLBVluSlVvv7bLAtor54/7h96HqHxFQj5aKdmkCRhZ4rd4lsxzo5cJHsEz9ttSk5KbB7F bUVmrjAVGhmVQDUkzSMQ7imwLQGtoGs= X-MC-Unique: IWMJGjiLP0qQVrAeQQGVGw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cY1YtgpZbWRPCspprxt46+AxuqK8Gnzm3W5hRXACGYE=; b=II08n1CK601JRTps2OMfvNHuRSYoCnMoVIxO1ERfADh4wnEiQNpwQp6/0D7hmFIaUq nvGBdkxA0bkQATg48k/8qMsOIgitbQG79jRiwO9wCQqtUFQcwTrIT5t7AuVIZjmgVS2d 2NUajoueM7OEDoALQ8RtoDcAPnoQEa9QUvmf1BBSO0nhIroUCMZRmGlhXXmBggeCYE3y h64ZeElmRqJJRr5Y0Jw40JHZyYrKATiyGAK5fFpfQQX2/C3vz2697bL1MBe12yIDM8lh YjIDbJVkq7oQzW8OktA3d7E5JqaPjd6iRto/noKduMoJF72ElPXV6CsPVGqOS0xhEaEc ujuw== X-Gm-Message-State: ACrzQf3H78oH+vNTX/ykR2UavbjFpM34jN2h1t0DCBxXwdW7vVipd9It aZQQqAdJyy7MuVb4Y0NLhDQiBwkQl5X/hJ06jLA7+fyPbMTz5b4wa5wF5AbtbutsIRGmcQSNDyt 3MIlMCKiDHnUo7vMAZ7xEgE9E9VF0JUhUu8OUPTFfL6KxNm+hPNbmDV8W540+AV7mkrs= X-Received: by 2002:a17:906:974f:b0:780:4a3c:d179 with SMTP id o15-20020a170906974f00b007804a3cd179mr18956094ejy.289.1665484047405; Tue, 11 Oct 2022 03:27:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40VBVLzMiApU7CgoBskD2Hu0J1PdNCVqT7vXZTk4eNGlA4pT55q9cI5dNA4hir/+qjnhI3YQ== X-Received: by 2002:a17:906:974f:b0:780:4a3c:d179 with SMTP id o15-20020a170906974f00b007804a3cd179mr18956073ejy.289.1665484047079; Tue, 11 Oct 2022 03:27:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 08/37] target/i386: Remove cur_eip argument to gen_exception Date: Tue, 11 Oct 2022 12:26:31 +0200 Message-Id: <20221011102700.319178-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485953796100001 From: Richard Henderson All callers pass s->base.pc_next - s->cs_base, which we can just as well compute within the function. Note the special case of EXCP_VSYSCALL in which s->cs_base wasn't subtracted, but cs_base is always zero in 64-bit mode, when vsyscall is used. Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-4-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 3f3e79c096..617832fcb0 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1332,10 +1332,10 @@ static void gen_helper_fp_arith_STN_ST0(int op, int= opreg) } } =20 -static void gen_exception(DisasContext *s, int trapno, target_ulong cur_ei= p) +static void gen_exception(DisasContext *s, int trapno) { gen_update_cc_op(s); - gen_jmp_im(s, cur_eip); + gen_jmp_im(s, s->base.pc_next - s->cs_base); gen_helper_raise_exception(cpu_env, tcg_const_i32(trapno)); s->base.is_jmp =3D DISAS_NORETURN; } @@ -1344,13 +1344,13 @@ static void gen_exception(DisasContext *s, int trap= no, target_ulong cur_eip) the instruction is known, but it isn't allowed in the current cpu mode.= */ static void gen_illegal_opcode(DisasContext *s) { - gen_exception(s, EXCP06_ILLOP, s->base.pc_next - s->cs_base); + gen_exception(s, EXCP06_ILLOP); } =20 /* Generate #GP for the current instruction. */ static void gen_exception_gpf(DisasContext *s) { - gen_exception(s, EXCP0D_GPF, s->base.pc_next - s->cs_base); + gen_exception(s, EXCP0D_GPF); } =20 /* Check for cpl =3D=3D 0; if not, raise #GP and return false. */ @@ -3267,7 +3267,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s= , int b) } /* simple MMX/SSE operation */ if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base); + gen_exception(s, EXCP07_PREX); return; } if (s->flags & HF_EM_MASK) { @@ -6077,7 +6077,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (s->flags & (HF_EM_MASK | HF_TS_MASK)) { /* if CR0.EM or CR0.TS are set, generate an FPU exception = */ /* XXX: what to do if illegal op ? */ - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); + gen_exception(s, EXCP07_PREX); break; } modrm =3D x86_ldub_code(env, s); @@ -7302,7 +7302,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; val =3D x86_ldub_code(env, s); if (val =3D=3D 0) { - gen_exception(s, EXCP00_DIVZ, s->base.pc_next - s->cs_base); + gen_exception(s, EXCP00_DIVZ); } else { gen_helper_aam(cpu_env, tcg_const_i32(val)); set_cc_op(s, CC_OP_LOGICB); @@ -7336,7 +7336,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x9b: /* fwait */ if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) =3D=3D (HF_MP_MASK | HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base); + gen_exception(s, EXCP07_PREX); } else { gen_helper_fwait(cpu_env); } @@ -8393,7 +8393,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); + gen_exception(s, EXCP07_PREX); break; } gen_lea_modrm(env, s, modrm); @@ -8406,7 +8406,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); + gen_exception(s, EXCP07_PREX); break; } gen_lea_modrm(env, s, modrm); @@ -8418,7 +8418,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); + gen_exception(s, EXCP07_PREX); break; } gen_lea_modrm(env, s, modrm); @@ -8431,7 +8431,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX, s->base.pc_next - s->cs_base= ); + gen_exception(s, EXCP07_PREX); break; } gen_helper_update_mxcsr(cpu_env); @@ -8822,7 +8822,7 @@ static void i386_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cpu) * Detect entry into the vsyscall page and invoke the syscall. */ if ((dc->base.pc_next & TARGET_PAGE_MASK) =3D=3D TARGET_VSYSCALL_PAGE)= { - gen_exception(dc, EXCP_VSYSCALL, dc->base.pc_next); + gen_exception(dc, EXCP_VSYSCALL); dc->base.pc_next =3D dc->pc + 1; return; } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665484921; cv=none; d=zohomail.com; s=zohoarc; b=lHAlzW/hm57Q59g4lMrXFZtTpl3KvS7W/rbxJncWDRVMvDbUJ9ZOAoIFiZOe+cd0H789VwjfLp44c8MTi7uaqzem5f4msqA65slXaKRu5PTm/aLEJiMrbso+FVSTcr5fJwh/YEcs5wzl6dxiVQra96tYNKu+x3mM1nEsKstojiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665484921; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C10XqGvscv2Z5J53N3vmn7co32YR0PJyvc5leSysMHY=; b=JUGUdHSdte+afkeDPNCCs7xgPla+nrGmTKXUkSaI3kIPF2pl5SFBELMzIoBDzaN2XAw6Vnxxi7/KJAA3xU669sRLlafmxuAutmHUUQpp6GpdrqJ4QTnZXvKVgmim3Q/3YZnZDzol1EahRRcOO9PzQbSXKdlrjFqoYDVerRW33bY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665484921885902.3489983543063; Tue, 11 Oct 2022 03:42:01 -0700 (PDT) Received: from localhost ([::1]:33456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiChz-0002iN-R8 for importer@patchew.org; Tue, 11 Oct 2022 06:41:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU3-0001qP-5t for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU1-0004RI-OH for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:34 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-111-4HII_IJ-O3idLUxjYsZ7zg-1; Tue, 11 Oct 2022 06:27:31 -0400 Received: by mail-ed1-f72.google.com with SMTP id b19-20020a056402351300b0045c129ed62cso4013963edd.6 for ; Tue, 11 Oct 2022 03:27:31 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id r23-20020aa7c157000000b0044e937ddcabsm8900445edp.77.2022.10.11.03.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C10XqGvscv2Z5J53N3vmn7co32YR0PJyvc5leSysMHY=; b=O5uzdNdH28HCoAA11oozuxi6zUlQa0m57voJQq6oVGeUQ2yaNv9eb7o9x6ntR4HJ83rpv+ Q0LTOyb2prdEf88drM417W5IbH6HA/B/v26Qqu4EEN/Z3IizxPcF5i8KZT1nc3wJwUrEcv w9gPEAhck981UIo0iUaR7yO8+rISzsA= X-MC-Unique: 4HII_IJ-O3idLUxjYsZ7zg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C10XqGvscv2Z5J53N3vmn7co32YR0PJyvc5leSysMHY=; b=MVyzmj6qXqmdG+2v/B7F6T0wTNPgy09Tvkwofat4D5MQ5ixICC5VcK4yCk+nVtOzVo BcpPOnT8/NVv2Wo9dHTH7bTSbMJfK6bgS+JbZ8OAx2NVhJTjNP05sCAUuOyYwstYHDTF tScaAewNqZ54/mBPZ5TUhf9TlOyVPUgGsCa/8Oaefw6PhKct5g3jiQHk0EhvdBj17rel xu9/UVVE5ffixgAR8wBWWC6lqUQXW2LurLMd+3M1OSz03YFt9sP47vtZ0RMykNoaK+JN mJ4TUmwrWwzZ1v0i4pfEeGMtuzuUTdirtrS6K65YLtejwiefYTRDioihSEDGYpMl4K7t HNLQ== X-Gm-Message-State: ACrzQf073lsn4caQ+Koh1kmqYU/XUI6UHtj/ikkBjw8cOR3SQnv5t9Io FuYepRhiql9FPN5uYnyIcPu/xRAKH8izHURspXS2t801rlOfKAvxd9HlEEl9bwEunl6bzkSjk+U aUXULsGuOswTJqIlUGxVDR4dYfVsNtiiRIN8l+o2VBP2OM1LTpkPlpj2RXJ3JiJC/w2g= X-Received: by 2002:a05:6402:27c6:b0:45c:1f1a:6b85 with SMTP id c6-20020a05640227c600b0045c1f1a6b85mr8806757ede.316.1665484050371; Tue, 11 Oct 2022 03:27:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GGRDTEly/vlHuMR0O+UOek59JVJEkELVG99ZPprJOPjvT6w/fGV3gZ/ya8iCSpFmIDKt9zg== X-Received: by 2002:a05:6402:27c6:b0:45c:1f1a:6b85 with SMTP id c6-20020a05640227c600b0045c1f1a6b85mr8806741ede.316.1665484050085; Tue, 11 Oct 2022 03:27:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 09/37] target/i386: Remove cur_eip, next_eip arguments to gen_interrupt Date: Tue, 11 Oct 2022 12:26:32 +0200 Message-Id: <20221011102700.319178-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665484922501100001 From: Richard Henderson All callers pass s->base.pc_next and s->pc, which we can just as well compute within the function. Adjust to use tcg_constant_i32 while we're at it. Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-5-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 617832fcb0..5a9c3b1e71 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2627,13 +2627,12 @@ static void gen_unknown_opcode(CPUX86State *env, Di= sasContext *s) =20 /* an interrupt is different from an exception because of the privilege checks */ -static void gen_interrupt(DisasContext *s, int intno, - target_ulong cur_eip, target_ulong next_eip) +static void gen_interrupt(DisasContext *s, int intno) { gen_update_cc_op(s); - gen_jmp_im(s, cur_eip); - gen_helper_raise_interrupt(cpu_env, tcg_const_i32(intno), - tcg_const_i32(next_eip - cur_eip)); + gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_helper_raise_interrupt(cpu_env, tcg_constant_i32(intno), + tcg_constant_i32(s->pc - s->base.pc_next)); s->base.is_jmp =3D DISAS_NORETURN; } =20 @@ -7342,12 +7341,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } break; case 0xcc: /* int3 */ - gen_interrupt(s, EXCP03_INT3, s->base.pc_next - s->cs_base, s->pc = - s->cs_base); + gen_interrupt(s, EXCP03_INT3); break; case 0xcd: /* int N */ val =3D x86_ldub_code(env, s); if (check_vm86_iopl(s)) { - gen_interrupt(s, val, s->base.pc_next - s->cs_base, s->pc - s-= >cs_base); + gen_interrupt(s, val); } break; case 0xce: /* into */ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485706; cv=none; d=zohomail.com; s=zohoarc; b=IVW0MroS64kEbvCcgE1k//kEkgQMOHtlt4PmWJgIwxZkixk7rhGT6Hd0jxI4ReSpsQYKk6TFFrkTxzlVNIryiotjTxGY6orxTyHA/yLtLZb5fpIzhIGCBDISKTXWwoFxrIFRzmgoetewLjSQ0xZBfIOJJZpm9dUfp0oRu5klQXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485706; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kfJZrHKhK90+vm7Oq61/X5IHIyexTd1oiv6ouy8QF0Q=; b=V5ihsutE+XTFrSQnuks/tyha/BrSURJ5xyIkKYJeZN9+Ghgzpyf95WaJ/fxhmyNynU0ztatEmSluySRz7rTVYLeDKRNsGDmz2QK2XrHcUHQOSgS+zQjAu0V0j163eOVP6zdKqYBtu6q2KZSX1oavpChhuoo6h2Ymnqp0kBDzir0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485706161406.3631001909763; Tue, 11 Oct 2022 03:55:06 -0700 (PDT) Received: from localhost ([::1]:39878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCue-0005k1-OZ for importer@patchew.org; Tue, 11 Oct 2022 06:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU6-0001so-Lr for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU4-0004S2-Jc for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:38 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-58-gzrGlQ0OOPihRKm8Ydqc1w-1; Tue, 11 Oct 2022 06:27:34 -0400 Received: by mail-ej1-f70.google.com with SMTP id gn33-20020a1709070d2100b00787e6fbcb72so5673721ejc.3 for ; Tue, 11 Oct 2022 03:27:34 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id d41-20020a056402402900b0045bef7cf489sm5112999eda.89.2022.10.11.03.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kfJZrHKhK90+vm7Oq61/X5IHIyexTd1oiv6ouy8QF0Q=; b=b4rhoPgeSczpQ7LHKYndtLjaywZJFuypDxFvh4ZijVT7f1i3bDr4+d/4TNlnheypV+HWZt HGfnxxcaZ6lEIp4KtCqzTO1M6gFSaDekDq+Zwp6JJkTDnUkRohUM3pgNDrL2uYnQbhO5LN 1HwvbILThp6CyTjIJyrD4I+ia3a0xjU= X-MC-Unique: gzrGlQ0OOPihRKm8Ydqc1w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kfJZrHKhK90+vm7Oq61/X5IHIyexTd1oiv6ouy8QF0Q=; b=h7fTYZdVS7OVRr2Ckq1IhKEOnfICa0AyzNO2qODJtQKrs8U0VIqur+4mYye1hHlIuh lTiZzN4MFYHLp8Is/u0nYInuAYTxnN955wFvs5FNj8KNO52UtxgS7n0HD65I2FR+a/2v xNd8hKgzueFXdibGwXlDV0kDVcmTyjQ0mGV/NJqlFqXGrQfHbrsj1nDGoBW1tFraReTl uelbrQStRL/EwQoY2i8vOts4vGFFfW0y4lsBMTLCWQtuFtXQ6BmkpL98Ux8cMA0IQ3Ok TYt1fa/CQvKbC2CWXi0OSu6i+ip1PRqhN289QvDAuU9Fm/X9r9MT5ThRNTxBp9bSSXbP qlOA== X-Gm-Message-State: ACrzQf3MLLm3ABRGhRnVvfosg08KO990aAeZB7z3c3FPqZzF8gpHYmxO yMRzia1pYqNv2HdhThA20EuWJfTYSLVCaNbXkC0pteWQQ9Z+Z5trxFy8vhts/OHrT4FCfFq7X9O JiI/yiyduiMZLqQ9sUkRBKMKGiRN3aU96Hjn9BDp0TcyCeqYTTudV/nITqP5mZiYVweQ= X-Received: by 2002:a17:906:8446:b0:78d:9f1a:9afc with SMTP id e6-20020a170906844600b0078d9f1a9afcmr11139916ejy.637.1665484053141; Tue, 11 Oct 2022 03:27:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DnW5tVICZuwZBopjKhQVSiTPSn+sQyJqVi6eZUQAMSzw+A5WHHLZWKq4dRADVs4mZoC1Y+A== X-Received: by 2002:a17:906:8446:b0:78d:9f1a:9afc with SMTP id e6-20020a170906844600b0078d9f1a9afcmr11139896ejy.637.1665484052823; Tue, 11 Oct 2022 03:27:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 10/37] target/i386: Create gen_update_eip_cur Date: Tue, 11 Oct 2022 12:26:33 +0200 Message-Id: <20221011102700.319178-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485707252100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Like gen_update_cc_op, sync EIP before doing something that could raise an exception. Replace all gen_jmp_im that use s->base.pc_next. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-6-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 52 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 5a9c3b1e71..85253e1e17 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -511,10 +511,14 @@ static inline void gen_op_st_rm_T0_A0(DisasContext *s= , int idx, int d) } } =20 -static inline void gen_jmp_im(DisasContext *s, target_ulong pc) +static void gen_jmp_im(DisasContext *s, target_ulong pc) { - tcg_gen_movi_tl(s->tmp0, pc); - gen_op_jmp_v(s->tmp0); + gen_op_jmp_v(tcg_constant_tl(pc)); +} + +static void gen_update_eip_cur(DisasContext *s) +{ + gen_jmp_im(s, s->base.pc_next - s->cs_base); } =20 /* Compute SEG:REG into A0. SEG is selected from the override segment @@ -703,7 +707,7 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCG= v_i32 port, target_ulong next_eip =3D s->pc - s->cs_base; =20 gen_update_cc_op(s); - gen_jmp_im(s, cur_eip); + gen_update_eip_cur(s); if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { svm_flags |=3D SVM_IOIO_REP_MASK; } @@ -1335,7 +1339,7 @@ static void gen_helper_fp_arith_STN_ST0(int op, int o= preg) static void gen_exception(DisasContext *s, int trapno) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_raise_exception(cpu_env, tcg_const_i32(trapno)); s->base.is_jmp =3D DISAS_NORETURN; } @@ -2630,7 +2634,7 @@ static void gen_unknown_opcode(CPUX86State *env, Disa= sContext *s) static void gen_interrupt(DisasContext *s, int intno) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_raise_interrupt(cpu_env, tcg_constant_i32(intno), tcg_constant_i32(s->pc - s->base.pc_next)); s->base.is_jmp =3D DISAS_NORETURN; @@ -6831,7 +6835,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) do_lret: if (PE(s) && !VM86(s)) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_lret_protected(cpu_env, tcg_const_i32(dflag - 1), tcg_const_i32(val)); } else { @@ -7327,7 +7331,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } if (prefixes & PREFIX_REPZ) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_pause(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); s->base.is_jmp =3D DISAS_NORETURN; } @@ -7353,7 +7357,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (CODE64(s)) goto illegal_op; gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_into(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)); break; #ifdef WANT_ICEBP @@ -7460,7 +7464,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x132: /* rdmsr */ if (check_cpl0(s)) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); if (b & 2) { gen_helper_rdmsr(cpu_env); } else { @@ -7472,7 +7476,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; case 0x131: /* rdtsc */ gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -7483,7 +7487,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; case 0x133: /* rdpmc */ gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_rdpmc(cpu_env); s->base.is_jmp =3D DISAS_NORETURN; break; @@ -7513,7 +7517,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x105: /* syscall */ /* XXX: is it usable in real mode ? */ gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_syscall(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); /* TF handling for the syscall insn is different. The TF bit is c= hecked after the syscall insn completes. This allows #DB to not be @@ -7539,13 +7543,13 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) #endif case 0x1a2: /* cpuid */ gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_cpuid(cpu_env); break; case 0xf4: /* hlt */ if (check_cpl0(s)) { gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); s->base.is_jmp =3D DISAS_NORETURN; } @@ -7642,7 +7646,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); tcg_gen_mov_tl(s->A0, cpu_regs[R_EAX]); gen_extu(s->aflag, s->A0); gen_add_A0_ds_seg(s); @@ -7654,7 +7658,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_mwait(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); s->base.is_jmp =3D DISAS_NORETURN; break; @@ -7732,7 +7736,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_vmrun(cpu_env, tcg_const_i32(s->aflag - 1), tcg_const_i32(s->pc - s->base.pc_next)); tcg_gen_exit_tb(NULL, 0); @@ -7744,7 +7748,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_vmmcall(cpu_env); break; =20 @@ -7756,7 +7760,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_vmload(cpu_env, tcg_const_i32(s->aflag - 1)); break; =20 @@ -7768,7 +7772,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_vmsave(cpu_env, tcg_const_i32(s->aflag - 1)); break; =20 @@ -7794,7 +7798,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); gen_helper_clgi(cpu_env); break; =20 @@ -7940,7 +7944,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_update_cc_op(s); - gen_jmp_im(s, s->base.pc_next - s->cs_base); + gen_update_eip_cur(s); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -8853,7 +8857,7 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase,= CPUState *cpu) DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 if (dc->base.is_jmp =3D=3D DISAS_TOO_MANY) { - gen_jmp_im(dc, dc->base.pc_next - dc->cs_base); + gen_update_eip_cur(dc); gen_eob(dc); } } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486576; cv=none; d=zohomail.com; s=zohoarc; b=ExGKgpxBl/Y9yf/mfeXdrA2ay1UtQ5l1lCHaZKl1lsg74VoXWN9dLBbFZAeaS4YN4s8dmcL1IpWU6115oBpXe5hAMkFcY2GTXl7l+g1IVlIEK4mlYJ2NJPw+4AaDUrNekCObVKOG96JawWrv61HMt+36fBEmEd4el5uIarfMw7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486576; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DCoSJb8oPvBjKKVe1L+9Wvu1MPX3YmO7JejJi5VhZpI=; b=FZ94mNXvLrB7sVXhziEGYY9gyKWGSV7RR3Ew73IzFpsfipBQZfw5CS9qAn7CSboXzt9zNtUwY/MpN4/+HgVfYTQqtSp/RrFvfe6yfW2sJZnyEWgqrgQ0BiNLoGDaN0brOvQdZjsJ6PlLcdroSXp7BI1saO9laU8eF5tcY1XQGUI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486576870562.0945818618173; Tue, 11 Oct 2022 04:09:36 -0700 (PDT) Received: from localhost ([::1]:39406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiD8h-0000NB-9H for importer@patchew.org; Tue, 11 Oct 2022 07:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU9-0001wX-PT for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCU7-0004TI-CK for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:41 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-100-P1eY3olTOiuFPkyxA0ZdKA-1; Tue, 11 Oct 2022 06:27:37 -0400 Received: by mail-ed1-f70.google.com with SMTP id y14-20020a056402440e00b0044301c7ccd9so10811417eda.19 for ; Tue, 11 Oct 2022 03:27:37 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id sb25-20020a1709076d9900b0077077b59085sm6743571ejc.184.2022.10.11.03.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DCoSJb8oPvBjKKVe1L+9Wvu1MPX3YmO7JejJi5VhZpI=; b=YxFlOvV0PMylXgzai+GrjQOpZ7Nn2d+awsvuu7r3sOeIdTNxj3AFvSmNqe9t1qUDDoseFq Dvs5c3KrlGuZMUjc8Ya5Sog87EbppouS7pOOfwqI7nHAkYcW2xj/To+qI/o4lSdm7i2JmE JlDT7o0fHK3VReAZfgybk/06DNHVs/s= X-MC-Unique: P1eY3olTOiuFPkyxA0ZdKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DCoSJb8oPvBjKKVe1L+9Wvu1MPX3YmO7JejJi5VhZpI=; b=gSQI56IWiEPQvV5CY+FhJKQEazEZrAyKhRbbf8fCy71hORFype05Nf32CsYXAbxjRd g1UV1YVlK7MzOFDI5gpu6OJzBHRmoqs5vSd33m2bOc9upgmn95jdschFWWKfIMtORYp8 ByuhWN7ia3R62YJhJFq6QMPdwCXwYJq8OiqpcOI+acX9pif3UMaS2/tY51mM+c5CXBBh IhDTNDRYPdk/uMvsG12PcYb8h88pJgKl8qwgPtcFF/GsbEeWMicKgcY62Bl+gQ8wW3d7 2tMpM4vKjHreScTkK/pdw1nRTOmiXnVOy7TTSv43EcUpqAxkhuT98LMGt48a304wl/Wo CgvQ== X-Gm-Message-State: ACrzQf3QnYbiCGV5tYBNSqo4PJ2m92IGgwnQzGjFc+k66e/kwX0W+54Y MTUepyiMLqbKtpguOQdA7TzXgDeFwBulue+O24VX331pM3478NxFWN2oh6Lr2Zqi3jRTmi3ae6D zGo9QaP7yeMuYXsynxqOyXNSQoj8MdIHUd5l3dR8u1Xwq4LkZjnbhTzYly3qz8+xIeas= X-Received: by 2002:a17:907:7b94:b0:731:1b11:c241 with SMTP id ne20-20020a1709077b9400b007311b11c241mr18980876ejc.676.1665484055918; Tue, 11 Oct 2022 03:27:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Cwn5JguBkq9B0iuvK6vberor2ZiZdVRFBVNBeIFVdQpPvDDGl5mqg6hDx7R38ceuSUv9JQQ== X-Received: by 2002:a17:907:7b94:b0:731:1b11:c241 with SMTP id ne20-20020a1709077b9400b007311b11c241mr18980855ejc.676.1665484055585; Tue, 11 Oct 2022 03:27:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 11/37] target/i386: Create gen_update_eip_next Date: Tue, 11 Oct 2022 12:26:34 +0200 Message-Id: <20221011102700.319178-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486577812100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Sync EIP before exiting a translation block. Replace all gen_jmp_im that use s->pc. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-7-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 85253e1e17..4c1548da8e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -521,6 +521,11 @@ static void gen_update_eip_cur(DisasContext *s) gen_jmp_im(s, s->base.pc_next - s->cs_base); } =20 +static void gen_update_eip_next(DisasContext *s) +{ + gen_jmp_im(s, s->pc - s->cs_base); +} + /* Compute SEG:REG into A0. SEG is selected from the override segment (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to indicate no override. */ @@ -5719,7 +5724,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_pop_update(s, ot); /* Note that reg =3D=3D R_SS in gen_movl_seg_T0 always sets is_jmp= . */ if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); if (reg =3D=3D R_SS) { s->flags &=3D ~HF_TF_MASK; gen_eob_inhibit_irq(s, true); @@ -5734,7 +5739,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_movl_seg_T0(s, (b >> 3) & 7); gen_pop_update(s, ot); if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -5785,7 +5790,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_movl_seg_T0(s, reg); /* Note that reg =3D=3D R_SS in gen_movl_seg_T0 always sets is_jmp= . */ if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); if (reg =3D=3D R_SS) { s->flags &=3D ~HF_TF_MASK; gen_eob_inhibit_irq(s, true); @@ -5983,7 +5988,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* then put the data */ gen_op_mov_reg_v(s, ot, reg, s->T1); if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -7039,7 +7044,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_pop_update(s, ot); set_cc_op(s, CC_OP_EFLAGS); /* abort translation because TF/AC flag may change */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -7375,7 +7380,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (check_iopl(s)) { gen_helper_sti(cpu_env); /* interruptions are enabled only the first insn after sti */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob_inhibit_irq(s, true); } break; @@ -7451,7 +7456,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } =20 gen_set_label(l3); - gen_jmp_im(s, next_eip); + gen_update_eip_next(s); tcg_gen_br(l2); =20 gen_set_label(l1); @@ -7469,7 +7474,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_helper_rdmsr(cpu_env); } else { gen_helper_wrmsr(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } } @@ -7669,7 +7674,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_clac(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7679,7 +7684,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_stac(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7724,7 +7729,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_trunc_tl_i32(s->tmp2_i32, cpu_regs[R_ECX]); gen_helper_xsetbv(cpu_env, s->tmp2_i32, s->tmp1_i64); /* End TB because translation flags may change. */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7786,7 +7791,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_update_cc_op(s); gen_helper_stgi(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7825,7 +7830,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_ext32u_tl(s->A0, cpu_regs[R_EAX]); } gen_helper_flush_page(cpu_env, s->A0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7909,7 +7914,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_andi_tl(s->T1, s->T1, ~0xe); tcg_gen_or_tl(s->T0, s->T0, s->T1); gen_helper_write_crN(cpu_env, tcg_constant_i32(0), s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -7920,7 +7925,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_INVLPG); gen_lea_modrm(env, s, modrm); gen_helper_flush_page(cpu_env, s->A0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -8320,7 +8325,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0 + reg); gen_op_mov_v_reg(s, ot, s->T0, rm); gen_helper_write_crN(cpu_env, tcg_constant_i32(reg), s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } else { gen_svm_check_intercept(s, SVM_EXIT_READ_CR0 + reg); @@ -8355,7 +8360,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_op_mov_v_reg(s, ot, s->T0, rm); tcg_gen_movi_i32(s->tmp2_i32, reg); gen_helper_set_dr(cpu_env, s->tmp2_i32, s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } else { gen_svm_check_intercept(s, SVM_EXIT_READ_DR0 + reg); @@ -8370,7 +8375,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); gen_helper_clts(cpu_env); /* abort block because static cpu state changed */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -8468,7 +8473,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* XRSTOR is how MPX is enabled, which changes how we translate. Thus we need to end the TB. */ gen_update_cc_op(s); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; =20 @@ -8602,7 +8607,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) g_assert_not_reached(); #else gen_update_cc_op(s); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_helper_rsm(cpu_env); #endif /* CONFIG_USER_ONLY */ gen_eob(s); --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486746; cv=none; d=zohomail.com; s=zohoarc; b=lbyPJWP/wlTpVvV26vhb3CUmON9XtL4XP89ESQ7CjgrKdU8LlI+gUV2kmcEuR82D46C/RMm+WCcuse/FN4mLIKJX9WbN3GlN3+7DPCQGuxvSKcc8IIQk5GEBwX38NyfAGRy1TmtHJtHbn8tff6PGQk0AfzFsQBBAidQq6wWEsR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486746; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Cr4HwV5vgUKgE+3UKuM8EcKp4MKuhG+a+4lxA7aTRqI=; b=jnRrBizF1hb2BbLxEzRHTmAC0rWJjZBM5Gjl5nhR6dL8tY4VgJcWA8Gamn+xMPEQDDKjW6/r2WjfsGnIGdojCNEgh6mjqD9tEuHaA/kMkAtYtvm3O51Fp0ZeOvpBJfllpFRIiA/Ti0zElXTFA9rFTKbgdNrRVL2fmVsHj/D+Ki4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486746352577.3601084902301; Tue, 11 Oct 2022 04:12:26 -0700 (PDT) Received: from localhost ([::1]:44084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDBQ-00020i-4s for importer@patchew.org; Tue, 11 Oct 2022 07:12:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUL-0002AZ-OG for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUK-0004W7-00 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:53 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-127--M4Q5CpAN5CEE9N9cA4Gpg-1; Tue, 11 Oct 2022 06:27:50 -0400 Received: by mail-ed1-f69.google.com with SMTP id w13-20020a05640234cd00b0045bd246f73bso5713435edc.8 for ; Tue, 11 Oct 2022 03:27:50 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id mh19-20020a170906eb9300b00781be3e7badsm6746554ejb.53.2022.10.11.03.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cr4HwV5vgUKgE+3UKuM8EcKp4MKuhG+a+4lxA7aTRqI=; b=DH6/6bnv7f3YaafvosBdeIdPpMi7vh1+MXfN07aqOgPNM03P+Rw377GTJ4pwtljUuJquHF egRCytEMgTBK57hdr8sE57/gnmqCgy6eMaLjejYwzfddNcQ4qTLbbnWfz7xggbls8yQemH NcBgo7hxeodJIrye3yR+YMAkN3gKfyU= X-MC-Unique: -M4Q5CpAN5CEE9N9cA4Gpg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cr4HwV5vgUKgE+3UKuM8EcKp4MKuhG+a+4lxA7aTRqI=; b=qU0e1qYHokt0V2tRtNsnlaE8SvSgLAhXtnDtQGqlZJ0bkmQWt35NJWHreGBs83sU1d dqslOrLyXZXN+0uM9wgXow2lJvsL6C7fqJHvh/JPMSF0PzC0dYTI3/4yY062W2guOS16 fv4+yOJhetr4T8clHiBrCa+wgiwMDidZPp4XYROfeJMRVvEK+H6N5QIrlkGtsWBoUHdI x0BR6RiE8WmUnoeONJR4Pg/0zml5qNN5j5J1IruaEMREuLr+c7ixbOC7Kv2W6esna46A d6EvZOEzzGx3g2EraL1UFEHbH5ajat8BWrm5tkFbIK0bG0weOEHrDQfLN6N3/zWN0HNY Ovuw== X-Gm-Message-State: ACrzQf2uPTQ4An09Yc/oKFzFXi2ckpEJuaTXaHDdekdqE4tWgGkGRn3F F7dU6nntbw5jkgp7cf//qGtyr891RqzwcI+7cxh72k2tLK+epvEVFpeQgwPi7aAqjJ4kh78xG7x RRJVGMxcJy/RhpPNdUGKsCLYZANGpU+ld6lob5dmpyV8HZ1FA3Cj7BURnwI/b9Gmsyto= X-Received: by 2002:a17:907:25cc:b0:77b:a6c7:6d2b with SMTP id ae12-20020a17090725cc00b0077ba6c76d2bmr18648983ejc.148.1665484058597; Tue, 11 Oct 2022 03:27:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KHB86atCJOMpZLGJGikaQ686k0rXFEuq2IBWpK/MpZWx3GLeMEH9fNk4ozL3IpLG+Hc+l2w== X-Received: by 2002:a17:907:25cc:b0:77b:a6c7:6d2b with SMTP id ae12-20020a17090725cc00b0077ba6c76d2bmr18648964ejc.148.1665484058255; Tue, 11 Oct 2022 03:27:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 12/37] target/i386: Introduce DISAS_EOB* Date: Tue, 11 Oct 2022 12:26:35 +0200 Message-Id: <20221011102700.319178-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486747617100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Add a few DISAS_TARGET_* aliases to reduce the number of calls to gen_eob() and gen_eob_inhibit_irq(). So far, only update i386_tr_translate_insn for exiting the block because of single-step or previous inhibit irq. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-8-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 4c1548da8e..caa22af5a7 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -132,6 +132,10 @@ typedef struct DisasContext { TCGOp *prev_insn_end; } DisasContext; =20 +#define DISAS_EOB_ONLY DISAS_TARGET_0 +#define DISAS_EOB_NEXT DISAS_TARGET_1 +#define DISAS_EOB_INHIBIT_IRQ DISAS_TARGET_2 + /* The environment in which user-only runs is constrained. */ #ifdef CONFIG_USER_ONLY #define PE(S) true @@ -8849,7 +8853,7 @@ static void i386_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cpu) * the flag and abort the translation to give the irqs a * chance to happen. */ - dc->base.is_jmp =3D DISAS_TOO_MANY; + dc->base.is_jmp =3D DISAS_EOB_NEXT; } else if (!is_same_page(&dc->base, pc_next)) { dc->base.is_jmp =3D DISAS_TOO_MANY; } @@ -8861,9 +8865,24 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase= , CPUState *cpu) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 - if (dc->base.is_jmp =3D=3D DISAS_TOO_MANY) { + switch (dc->base.is_jmp) { + case DISAS_NORETURN: + break; + case DISAS_TOO_MANY: + case DISAS_EOB_NEXT: + gen_update_cc_op(dc); gen_update_eip_cur(dc); + /* fall through */ + case DISAS_EOB_ONLY: gen_eob(dc); + break; + case DISAS_EOB_INHIBIT_IRQ: + gen_update_cc_op(dc); + gen_update_eip_cur(dc); + gen_eob_inhibit_irq(dc, true); + break; + default: + g_assert_not_reached(); } } =20 --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487028; cv=none; d=zohomail.com; s=zohoarc; b=i+ZW2lFxqRiRRax4TeF/1+tluq4ndKeBJTuqTTFUGes0hLqiDmNLZocQHvGOoZd3C8XOCC1lbzp+a/wGynTh2d8UpK11D25DdNpIoEfxfoKhU9zeqIJkpSBLvI5HCgM7uu8GMX7a7y0Ljyw+x/3hZdzIbDM1OVB3Xp3oa6xyhWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487028; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/K5lDjsNFkB2O7N5fFE1PmGPOVDI/Bu0WvplKA586RI=; b=QN0wL88kCZE1p3ir5UxySwDeDKVUB0lBZEJ4TV30k+DJVI3pBKsFjI1ygrdTh6cvyLnkC4WywpOW9Xa9di9TRyosKutKdVVH5hgNqLOypg7G3bzDQ8yb1h4fbA6V6Ot/fLPdPMzPJD2vPQFbVEDioEUMIoZVDfvRP6CNVQ9GFo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16654870280201003.4772722424012; Tue, 11 Oct 2022 04:17:08 -0700 (PDT) Received: from localhost ([::1]:56714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDFy-0007Jf-2E for importer@patchew.org; Tue, 11 Oct 2022 07:17:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUI-00029O-1o for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUF-0004UN-DD for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:49 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-518-xv1_APz2O2G9AKkRMKymQg-1; Tue, 11 Oct 2022 06:27:42 -0400 Received: by mail-ej1-f72.google.com with SMTP id ho8-20020a1709070e8800b0078db5e53032so1960215ejc.9 for ; Tue, 11 Oct 2022 03:27:42 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id dy4-20020a05640231e400b00457618d3409sm8719710edb.68.2022.10.11.03.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/K5lDjsNFkB2O7N5fFE1PmGPOVDI/Bu0WvplKA586RI=; b=NDHsgt9zsc+Ne4jcaFstal34PxarChLiY+QG9Bre6YqCaU0czV+3LUORfdGSiyz4Fbg46o IPi82JFA8Ha4w+qEIUlb9J8YeUDexo47UJLPC7ed3xfy98TnG2iCh5TJOI8OmhQNwPkzDK buNLTJ8PUj/C0IVpjJvcvn24VMSp6Ds= X-MC-Unique: xv1_APz2O2G9AKkRMKymQg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/K5lDjsNFkB2O7N5fFE1PmGPOVDI/Bu0WvplKA586RI=; b=dy/VgoLzkMB4/meEKbtvmLo0v4zBUbFOzHuTvzy/JgVfsyf8YPTs68bMxgVKTO4B+Q dQ9LcfGY1+hsrja7jUcQpwi2IJitrfGnPo4M24Y7pg7C/fkINWum23IU7fncK+1h2ZL+ HwOGa8R5Trcv6WkR/Ey8gsaiDwCTAMtnZL2Te1XyaCyh4BZnRtzFbzWzEzl2KopFsPUB 2ZC/maVl0bR7kxGh+7nAm/Ugzq5yvCEJ3PBm7h13m20hsZn8/EMmgDPXCu0+9n8HD4EF NsRoP+cu7Yjqg8H2YIVjn6+JV3/v2p5b5gmTZwLNKFczlc/1jQKukyB9p2mfewhT5fsI mgHg== X-Gm-Message-State: ACrzQf0Ax3kJm6MDHnM9tcuDQ4SWNiknND0cA8Ht+KvIjOJuN5dGiFL9 IzV5/3KC8urTStz/Ln4Jm2YjuEAdMRmeUZkkJyDkq35CE85rafOoUF3W9LBs4tB3nI4oalQj3S9 /nHoZH2IPQzOiM/jubPcvA05HN8Bq354TnTDgCrFdUKbhnp+WIkiYi1P1C9rg2mDKsDk= X-Received: by 2002:a17:907:9625:b0:78d:bb06:9072 with SMTP id gb37-20020a170907962500b0078dbb069072mr6346315ejc.472.1665484061187; Tue, 11 Oct 2022 03:27:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qQQbmAKX712rNmBnhjFisIU8bc7woZs6HA0wgpRlxjCDnmhtFh2S/ySqOPpBzFJFXuAuIJw== X-Received: by 2002:a17:907:9625:b0:78d:bb06:9072 with SMTP id gb37-20020a170907962500b0078dbb069072mr6346298ejc.472.1665484060764; Tue, 11 Oct 2022 03:27:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 13/37] target/i386: Use DISAS_EOB* in gen_movl_seg_T0 Date: Tue, 11 Oct 2022 12:26:36 +0200 Message-Id: <20221011102700.319178-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487029087100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Set is_jmp properly in gen_movl_seg_T0, so that the callers need to nothing special. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-9-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index caa22af5a7..8c0ef0f212 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2457,13 +2457,15 @@ static void gen_movl_seg_T0(DisasContext *s, X86Seg= seg_reg) because ss32 may change. For R_SS, translation must always stop as a special handling must be done to disable hardware interrupts for the next instruction */ - if (seg_reg =3D=3D R_SS || (CODE32(s) && seg_reg < R_FS)) { - s->base.is_jmp =3D DISAS_TOO_MANY; + if (seg_reg =3D=3D R_SS) { + s->base.is_jmp =3D DISAS_EOB_INHIBIT_IRQ; + } else if (CODE32(s) && seg_reg < R_FS) { + s->base.is_jmp =3D DISAS_EOB_NEXT; } } else { gen_op_movl_seg_T0_vm(s, seg_reg); if (seg_reg =3D=3D R_SS) { - s->base.is_jmp =3D DISAS_TOO_MANY; + s->base.is_jmp =3D DISAS_EOB_INHIBIT_IRQ; } } } @@ -5726,26 +5728,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) ot =3D gen_pop_T0(s); gen_movl_seg_T0(s, reg); gen_pop_update(s, ot); - /* Note that reg =3D=3D R_SS in gen_movl_seg_T0 always sets is_jmp= . */ - if (s->base.is_jmp) { - gen_update_eip_next(s); - if (reg =3D=3D R_SS) { - s->flags &=3D ~HF_TF_MASK; - gen_eob_inhibit_irq(s, true); - } else { - gen_eob(s); - } - } break; case 0x1a1: /* pop fs */ case 0x1a9: /* pop gs */ ot =3D gen_pop_T0(s); gen_movl_seg_T0(s, (b >> 3) & 7); gen_pop_update(s, ot); - if (s->base.is_jmp) { - gen_update_eip_next(s); - gen_eob(s); - } break; =20 /**************************/ @@ -5792,16 +5780,6 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) goto illegal_op; gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 0); gen_movl_seg_T0(s, reg); - /* Note that reg =3D=3D R_SS in gen_movl_seg_T0 always sets is_jmp= . */ - if (s->base.is_jmp) { - gen_update_eip_next(s); - if (reg =3D=3D R_SS) { - s->flags &=3D ~HF_TF_MASK; - gen_eob_inhibit_irq(s, true); - } else { - gen_eob(s); - } - } break; case 0x8c: /* mov Gv, seg */ modrm =3D x86_ldub_code(env, s); @@ -5991,10 +5969,6 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) gen_movl_seg_T0(s, op); /* then put the data */ gen_op_mov_reg_v(s, ot, reg, s->T1); - if (s->base.is_jmp) { - gen_update_eip_next(s); - gen_eob(s); - } break; =20 /************************/ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485494; cv=none; d=zohomail.com; s=zohoarc; b=b2pEQnubIfkmvtgs6OXAiTeoJHHq2PwOypwrDsiILldCARMgc16AT6/NvjUiPN/a1NqV44XkfUfyTUdI5kM21F9bchz6BMNq2OhzJXSIxToKFb7PrVZV4lwIkHh9BR4XTG9F6MxkW5Dkwtxh1QUWJJWXFO6ZNJlGpt8gG8mEuZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YQrgVh5+WZj8NBxv9tJEB4/Q2aTJD2W6dvNkeWRMf7E=; b=C+SIDITt2y2B4G+iNc8brJfkX0VQhLTjQaGpsVD0PU7gvXDuhTF0DabWNmw/Td/6QctkY6zWd1Fq9AXFbBbarJUklXwlxmWsULJtBtzASwhPdq9z0wEBgt2IYSZZTXKzxlgdJ1fn+IIlPW9zJ4UyuyzCLoof/MntV1r9UsCnFmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485494470560.847302722752; Tue, 11 Oct 2022 03:51:34 -0700 (PDT) Received: from localhost ([::1]:34278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCrE-0003Jv-Dm for importer@patchew.org; Tue, 11 Oct 2022 06:51:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUI-00029W-Uu for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUG-0004UY-9Y for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:50 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-584-S4QAd99XP96S_4IiNUbVXA-1; Tue, 11 Oct 2022 06:27:45 -0400 Received: by mail-ed1-f70.google.com with SMTP id b19-20020a056402351300b0045c129ed62cso4014321edd.6 for ; Tue, 11 Oct 2022 03:27:45 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id g3-20020a170906594300b007815c3e95f6sm6838080ejr.146.2022.10.11.03.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YQrgVh5+WZj8NBxv9tJEB4/Q2aTJD2W6dvNkeWRMf7E=; b=ZVVA0DjNs6d23dszXFtCzv9AMBwLELjXIGRpqvgCuSshFry1KfpM5pdSf/dVijW82cnPpL tyzh1T6R9fB1ou9ZMF/R9OtLtqqy9U+nPMs/+M0yPVgmI5CynMM30k7E2n1rtcTYgLuzOO Wm5PpKZpzWzk2BBGNZ766FhiyE5ZiGs= X-MC-Unique: S4QAd99XP96S_4IiNUbVXA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YQrgVh5+WZj8NBxv9tJEB4/Q2aTJD2W6dvNkeWRMf7E=; b=dT8avyp1CIJgW/tXuMYkH3IE5VRtTQ/0wElFaLtor7kshrYazWwFRTBTv6HQql64aM Q0CZJsyY5IJJSgXxgT5/3ybs9j9eCadawa/zrslzypI3K2yctXNsqfcM8zA6qnP+0i+v Qu5SApvwUa7iaEJfs3uQJ6cedj73t97b7J/WjjfQo9XUrxeXDAkKm9nqcq4PaaBtSxTk 1ki6Muh3Whsz7bTFgJuqgRONp3h/Rlh/5mJCGjYjNtR0oCF6FDlB9mX+quB1wbYpAY5+ TJc+lSfqM7Jb0WYBs5i60mguxN6krgdFTbkdWlTnW4LarG8hamX1EXVat6TBIkn2AaRV 7ETw== X-Gm-Message-State: ACrzQf2kwlMo0ONJ9WtznXjU/E4AJEiWLSFx+0UTgLVDlePERVrR/Fgq CBj01NYLLKel/b2cImylySQCUnR+m2N7nGjX3X1vM7RIQfLZ9Xs4t7qUPTEUbmiIkMJPEWPTm+I p9NBIqjT27WlKvauyMJ1KMKGaMSUGIcAPDJeP5YZ79nha8ryQMNpjGlbGtjBZ6cmamCU= X-Received: by 2002:a17:907:3d8f:b0:78d:b46e:eadd with SMTP id he15-20020a1709073d8f00b0078db46eeaddmr8615552ejc.277.1665484063659; Tue, 11 Oct 2022 03:27:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7sagaDcLQ1Hcyl+1sLgULHKwD1xIuehtEg/9o7RA+DCXhhAvD2MqM6v3/7X65jRODhkuMmaw== X-Received: by 2002:a17:907:3d8f:b0:78d:b46e:eadd with SMTP id he15-20020a1709073d8f00b0078db46eeaddmr8615529ejc.277.1665484063354; Tue, 11 Oct 2022 03:27:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 14/37] target/i386: Use DISAS_EOB_NEXT Date: Tue, 11 Oct 2022 12:26:37 +0200 Message-Id: <20221011102700.319178-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485496303100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Replace sequences of gen_update_cc_op, gen_update_eip_next, and gen_eob with the new is_jmp enumerator. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-10-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 40 ++++++++++++------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 8c0ef0f212..717c978381 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -7022,8 +7022,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_pop_update(s, ot); set_cc_op(s, CC_OP_EFLAGS); /* abort translation because TF/AC flag may change */ - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; } break; case 0x9e: /* sahf */ @@ -7452,8 +7451,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_helper_rdmsr(cpu_env); } else { gen_helper_wrmsr(cpu_env); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; } } break; @@ -7652,8 +7650,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_clac(cpu_env); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 case 0xcb: /* stac */ @@ -7662,8 +7659,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_stac(cpu_env); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 CASE_MODRM_MEM_OP(1): /* sidt */ @@ -7707,8 +7703,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_trunc_tl_i32(s->tmp2_i32, cpu_regs[R_ECX]); gen_helper_xsetbv(cpu_env, s->tmp2_i32, s->tmp1_i64); /* End TB because translation flags may change. */ - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 case 0xd8: /* VMRUN */ @@ -7769,8 +7764,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_update_cc_op(s); gen_helper_stgi(cpu_env); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 case 0xdd: /* CLGI */ @@ -7808,8 +7802,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_ext32u_tl(s->A0, cpu_regs[R_EAX]); } gen_helper_flush_page(cpu_env, s->A0); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 CASE_MODRM_MEM_OP(2): /* lgdt */ @@ -7892,8 +7885,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_andi_tl(s->T1, s->T1, ~0xe); tcg_gen_or_tl(s->T0, s->T0, s->T1); gen_helper_write_crN(cpu_env, tcg_constant_i32(0), s->T0); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 CASE_MODRM_MEM_OP(7): /* invlpg */ @@ -7903,8 +7895,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_INVLPG); gen_lea_modrm(env, s, modrm); gen_helper_flush_page(cpu_env, s->A0); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 case 0xf8: /* swapgs */ @@ -8303,8 +8294,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0 + reg); gen_op_mov_v_reg(s, ot, s->T0, rm); gen_helper_write_crN(cpu_env, tcg_constant_i32(reg), s->T0); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; } else { gen_svm_check_intercept(s, SVM_EXIT_READ_CR0 + reg); gen_helper_read_crN(s->T0, cpu_env, tcg_constant_i32(reg)); @@ -8338,8 +8328,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_op_mov_v_reg(s, ot, s->T0, rm); tcg_gen_movi_i32(s->tmp2_i32, reg); gen_helper_set_dr(cpu_env, s->tmp2_i32, s->T0); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; } else { gen_svm_check_intercept(s, SVM_EXIT_READ_DR0 + reg); tcg_gen_movi_i32(s->tmp2_i32, reg); @@ -8353,8 +8342,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); gen_helper_clts(cpu_env); /* abort block because static cpu state changed */ - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; } break; /* MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4 support */ @@ -8450,9 +8438,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_helper_xrstor(cpu_env, s->A0, s->tmp1_i64); /* XRSTOR is how MPX is enabled, which changes how we translate. Thus we need to end the TB. */ - gen_update_cc_op(s); - gen_update_eip_next(s); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_NEXT; break; =20 CASE_MODRM_MEM_OP(6): /* xsaveopt / clwb */ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485993; cv=none; d=zohomail.com; s=zohoarc; b=LH3IHngZueiLd4ZTgw8IwgMzZ/yUwLu+fcWQU2fS2MhXFUCCS6nDFmP/Hiij75wbl6NoQrTsMPE8M15cwLO9/vSR09roagXM6jHFjtMiOktf+hgzAE0Lt/1YYSJ6oIBOFkzf9LmjESRNgtRGsEdFJx7G+8pW/9juVNoyrD7Jp5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485993; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QYjmEtsyz0HFuuReqcxOc4A+Fs5cqe4buhNy2Ov+D/o=; b=QrUi/N46kv5grdGfvD9Fu6U1vvAOQ4Qr7+hSOHAQ3hA/+ggYeEqx0woJL3mpBYrTDZeu+gBHomEJnm90H6zFA+YWpQ/Qou1g5krjLLb15XtPwBqJ36vzN1pdFje9tPE/MNN63fBueo5J2niE59Bm83HkYB9+bd1uW2c3cBV7+K4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485993854482.40933569365404; Tue, 11 Oct 2022 03:59:53 -0700 (PDT) Received: from localhost ([::1]:54592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCzI-0003VI-PJ for importer@patchew.org; Tue, 11 Oct 2022 06:59:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUJ-00029z-QL for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUH-0004Vj-PO for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:51 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-228-l84CIzK-PmKZMj1KI4VSrw-1; Tue, 11 Oct 2022 06:27:47 -0400 Received: by mail-ej1-f71.google.com with SMTP id ho8-20020a1709070e8800b0078db5e53032so1960359ejc.9 for ; Tue, 11 Oct 2022 03:27:47 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id m6-20020a170906258600b0078d261f9f44sm6657415ejb.224.2022.10.11.03.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QYjmEtsyz0HFuuReqcxOc4A+Fs5cqe4buhNy2Ov+D/o=; b=NauN/smjys/oCUnGYTWRg/uLh4o/c5yjEydMCsisX6Xx/288iIt7Vt6KUt5SZittwdCUff y8oMHgA532NINmakBapZEy00w5itKq87caDN/vWbq1mye4Pv3b1x1P9mwJzS0hWK2YBKku 3iS0HGmHJLoSot/kLYhvdIHg0O2IdfE= X-MC-Unique: l84CIzK-PmKZMj1KI4VSrw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QYjmEtsyz0HFuuReqcxOc4A+Fs5cqe4buhNy2Ov+D/o=; b=ZkWB1ZMSPCH3xz9bd0Dr48h17NkDj4PqIFgejymWUxJ62u5jS0RPTbY19n48dF20T8 MN6qsBYslELBJUoXGixrmgwTXO/6RTQR7cQZlQGna1VWcJ4DPNGOCUOzViq6wso/Evlo FEf+aTHh7D5GaL/bjeIyKv3MtI49JCeF/zBYbxXicG22MGmdddwy/kPegW1ICDpaDjL/ N3tDa0YbB4WvjL3i893QIRmjKQ8NcfSmyxX/szcJIscqSme+VT21QWfFXnwVeCjnyinv zJMA3Gpfdn4hhsUammbp59qeLXZ0ataSFTU4QgSrc7eRw0hSzGiSksWuFxrL6L28y07d Rdag== X-Gm-Message-State: ACrzQf08GaW3StvspQaAtTTV3URqiL63bJOC/Pofjj38NFT4KBYuT3gz 9/QCxAOrPBK8Rum7fY2YHk36xaMgrTHywhOfcv0OtHkkjwkvsJYD6vzRCgtS7bosjrB1iKJYjY7 n802wrP0a+RCdxJg85zw7kJQmgs+210VqSVK1YP80cQOu4853x38p/I1zdORCZdeJjb4= X-Received: by 2002:aa7:d28c:0:b0:459:3cc5:3cb8 with SMTP id w12-20020aa7d28c000000b004593cc53cb8mr22885305edq.261.1665484066372; Tue, 11 Oct 2022 03:27:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lKAIannluTRECE1orODrkZQ9L+iqM8UzqVEAdXqmsnR2wLGntErTGLaayZ4ZZ9xUu07OCZA== X-Received: by 2002:aa7:d28c:0:b0:459:3cc5:3cb8 with SMTP id w12-20020aa7d28c000000b004593cc53cb8mr22885290edq.261.1665484066105; Tue, 11 Oct 2022 03:27:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 15/37] target/i386: USe DISAS_EOB_ONLY Date: Tue, 11 Oct 2022 12:26:38 +0200 Message-Id: <20221011102700.319178-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485995945100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Replace lone calls to gen_eob() with the new enumerator. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-11-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 717c978381..6b16c0b62c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -6835,7 +6835,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* add stack offset */ gen_stack_update(s, val + (2 << dflag)); } - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; break; case 0xcb: /* lret */ val =3D 0; @@ -6853,7 +6853,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_const_i32(s->pc - s->cs_base)); } set_cc_op(s, CC_OP_EFLAGS); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; break; case 0xe8: /* call im */ { @@ -7439,7 +7439,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_set_label(l1); gen_jmp_im(s, tval); gen_set_label(l2); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; } break; case 0x130: /* wrmsr */ @@ -7480,7 +7480,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_exception_gpf(s); } else { gen_helper_sysenter(cpu_env); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; } break; case 0x135: /* sysexit */ @@ -7491,7 +7491,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_exception_gpf(s); } else { gen_helper_sysexit(cpu_env, tcg_const_i32(dflag - 1)); - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; } break; #ifdef TARGET_X86_64 @@ -8574,7 +8574,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_update_eip_next(s); gen_helper_rsm(cpu_env); #endif /* CONFIG_USER_ONLY */ - gen_eob(s); + s->base.is_jmp =3D DISAS_EOB_ONLY; break; case 0x1b8: /* SSE4.2 popcnt */ if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=3D --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485750; cv=none; d=zohomail.com; s=zohoarc; b=cp4G/o0/rJP5BWVIgejyKUK3ZEDfhQvN6hnA7QbR7jLicydIVdFu6JynGx8NV6g0Maoy9ykN6I/+QZ+KYENPBDYdOHuCLZEOtG6OB0MYxh88p0cpkBGNzVg9OnJSkRDdTsMLnGnRAylcpjp6tP2653JF3/G9ubCBUcwNhOatT9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485750; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HNWVHL6TMxYEEz+B7KNJ7vI5IU34kxSzh+4YMoD4+h0=; b=i/d4xn76NTgngkvfKlYqwIDEyO8Q25ivUE3iqhI8aFvtkZ37wgrHF8oe9ojJGSV7aM5DMijS+/8CJ11WwkuMvT7VMn0Ha/J+FaXoi7FqmvqzKRaewwysySpczPqIbOqSaIffvqvnwpJyT5h/NwtQzEFvY+pBI+uzcYW6pG7sf0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485750335597.8526832183767; Tue, 11 Oct 2022 03:55:50 -0700 (PDT) Received: from localhost ([::1]:45768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCvN-0006wi-4t for importer@patchew.org; Tue, 11 Oct 2022 06:55:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUN-0002Bj-U9 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUL-0004WS-9p for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:54 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-249-ZTDFiS31O5CDmWPNoHvGHg-1; Tue, 11 Oct 2022 06:27:50 -0400 Received: by mail-ej1-f70.google.com with SMTP id gn33-20020a1709070d2100b00787e6fbcb72so5674062ejc.3 for ; Tue, 11 Oct 2022 03:27:50 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id e15-20020a170906314f00b00734bfab4d59sm6792335eje.170.2022.10.11.03.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNWVHL6TMxYEEz+B7KNJ7vI5IU34kxSzh+4YMoD4+h0=; b=QlMCxOkvfVNAQUAZdWuB5M/snZb1oigSKhbDRgpy7x7x67h6I/2Bjv+/n/S3Fhbzi8OVY3 Q/gjDaQ/2wy/XuScUxIH2PV+PcM5aodla+h8aRmaCgpMel3vnaogLJ2uDryFMdIsIgyrlP HPzwg3yjt5Uxu6q8+e9/aBlXHB3DcGU= X-MC-Unique: ZTDFiS31O5CDmWPNoHvGHg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HNWVHL6TMxYEEz+B7KNJ7vI5IU34kxSzh+4YMoD4+h0=; b=pdnFToTyuWWiGBpaqijU5LNXSFvmm0mj3rRzfr8WmKx4ucI8MDHkSzxnMuBejf7Yp4 dMVj4UHltCJ5B5ci3jM5v7b3iYjwNqnXkhgYttbZgyTNutE+K1Z2l3FctbTxP6H22xnK TnZu8z2G6wGRaEY8pkxMS9htZAyFljcWJ4vZfsI1zG/JEbypbd/xGApIvSiXcaLCA+/5 Er0PZsJAwGUaJGd9/wTFMg7wEfr2+on2P9OD3B5I2zELKeIUb9NTCL9AM8K1ZxeBGWCq RZPTuqmhq/nSajRHSXJoWEztYkTKxvNuaE6MEDFmPm0/jtNpx88HbaI5JaCvALeQTb09 owhw== X-Gm-Message-State: ACrzQf3Y7+TN0RYRYVEPRl2mG1OPoxqv2GzCD1jmTGRLgK4nZ2Pg4Nnj rK9iIkH9zRSJJ7mR5++gGVre6xwsHwj+9VYC3A3LFgYPNzSYu6vr5Co9WoJe2GVi2TL+m30xeeZ y1Q+kJG5dOBxiQQ4vnLRvbdLRQml2f0HYmLn3An2ZbGdlmCGpe/IcN/VXg2XNVkjeZwM= X-Received: by 2002:a17:906:9bca:b0:78d:bc5a:9137 with SMTP id de10-20020a1709069bca00b0078dbc5a9137mr6660776ejc.25.1665484069108; Tue, 11 Oct 2022 03:27:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+PRyw5W144WvaJTEj/RAugm47U9Oi0msSwt7nQBHM5dD0/T8UT2ll9Mm5Lqda1DuvKo9kpg== X-Received: by 2002:a17:906:9bca:b0:78d:bc5a:9137 with SMTP id de10-20020a1709069bca00b0078dbc5a9137mr6660753ejc.25.1665484068800; Tue, 11 Oct 2022 03:27:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 16/37] target/i386: Create cur_insn_len, cur_insn_len_i32 Date: Tue, 11 Oct 2022 12:26:39 +0200 Message-Id: <20221011102700.319178-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485751520100001 From: Richard Henderson Create common routines for computing the length of the insn. Use tcg_constant_i32 in the new function, while we're at it. Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-12-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 6b16c0b62c..fe99c4361c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -530,6 +530,16 @@ static void gen_update_eip_next(DisasContext *s) gen_jmp_im(s, s->pc - s->cs_base); } =20 +static int cur_insn_len(DisasContext *s) +{ + return s->pc - s->base.pc_next; +} + +static TCGv_i32 cur_insn_len_i32(DisasContext *s) +{ + return tcg_constant_i32(cur_insn_len(s)); +} + /* Compute SEG:REG into A0. SEG is selected from the override segment (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to indicate no override. */ @@ -712,9 +722,6 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCG= v_i32 port, gen_helper_check_io(cpu_env, port, tcg_constant_i32(1 << ot)); } if (GUEST(s)) { - target_ulong cur_eip =3D s->base.pc_next - s->cs_base; - target_ulong next_eip =3D s->pc - s->cs_base; - gen_update_cc_op(s); gen_update_eip_cur(s); if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -723,7 +730,7 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCG= v_i32 port, svm_flags |=3D 1 << (SVM_IOIO_SIZE_SHIFT + ot); gen_helper_svm_check_io(cpu_env, port, tcg_constant_i32(svm_flags), - tcg_constant_i32(next_eip - cur_eip)); + cur_insn_len_i32(s)); } return true; #endif @@ -2028,7 +2035,7 @@ static uint64_t advance_pc(CPUX86State *env, DisasCon= text *s, int num_bytes) } =20 s->pc +=3D num_bytes; - if (unlikely(s->pc - s->base.pc_next > X86_MAX_INSN_LENGTH)) { + if (unlikely(cur_insn_len(s) > X86_MAX_INSN_LENGTH)) { /* If the instruction's 16th byte is on a different page than the = 1st, a * page fault on the second page wins over the general protection = fault * caused by the instruction being too long. @@ -2647,7 +2654,7 @@ static void gen_interrupt(DisasContext *s, int intno) gen_update_cc_op(s); gen_update_eip_cur(s); gen_helper_raise_interrupt(cpu_env, tcg_constant_i32(intno), - tcg_constant_i32(s->pc - s->base.pc_next)); + cur_insn_len_i32(s)); s->base.is_jmp =3D DISAS_NORETURN; } =20 @@ -7314,7 +7321,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (prefixes & PREFIX_REPZ) { gen_update_cc_op(s); gen_update_eip_cur(s); - gen_helper_pause(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); + gen_helper_pause(cpu_env, cur_insn_len_i32(s)); s->base.is_jmp =3D DISAS_NORETURN; } break; @@ -7340,7 +7347,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; gen_update_cc_op(s); gen_update_eip_cur(s); - gen_helper_into(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)); + gen_helper_into(cpu_env, cur_insn_len_i32(s)); break; #ifdef WANT_ICEBP case 0xf1: /* icebp (undocumented, exits to external debugger) */ @@ -7499,7 +7506,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* XXX: is it usable in real mode ? */ gen_update_cc_op(s); gen_update_eip_cur(s); - gen_helper_syscall(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); + gen_helper_syscall(cpu_env, cur_insn_len_i32(s)); /* TF handling for the syscall insn is different. The TF bit is c= hecked after the syscall insn completes. This allows #DB to not be generated after one has entered CPL0 if TF is set in FMASK. */ @@ -7531,7 +7538,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (check_cpl0(s)) { gen_update_cc_op(s); gen_update_eip_cur(s); - gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - s->base.pc_next)= ); + gen_helper_hlt(cpu_env, cur_insn_len_i32(s)); s->base.is_jmp =3D DISAS_NORETURN; } break; @@ -7640,7 +7647,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_update_cc_op(s); gen_update_eip_cur(s); - gen_helper_mwait(cpu_env, tcg_const_i32(s->pc - s->base.pc_nex= t)); + gen_helper_mwait(cpu_env, cur_insn_len_i32(s)); s->base.is_jmp =3D DISAS_NORETURN; break; =20 @@ -7716,7 +7723,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_update_cc_op(s); gen_update_eip_cur(s); gen_helper_vmrun(cpu_env, tcg_const_i32(s->aflag - 1), - tcg_const_i32(s->pc - s->base.pc_next)); + cur_insn_len_i32(s)); tcg_gen_exit_tb(NULL, 0); s->base.is_jmp =3D DISAS_NORETURN; break; --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486024; cv=none; d=zohomail.com; s=zohoarc; b=QHMbdmeuvv9e75jlLJT4nxMsEDnaHbE9PfgGYJb6ySW7rG0ZIK6D+w588DLVzsAGOYOs5Tvw7Vy0bOY+8KM4bCj6xayqeOlQSY8a4zq3UN9bkHwEgy/sc1c4jN77LehQudu28YYaORNrI1xi8/KbqlNOR9wy4OAKzECwJA0K7cA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486024; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q19lbNDEmiPwPnrz0hHNWPHofwAMVNqazrj/KXWd5rM=; b=WwjmD9B+fg4hwFlbdpkry22YiSGPjPiZ6TpUwGFXKzVnLDDMV5gLs/tgsCBUgFTTsmuo4jGqzzQ0opGjCgb/zj+scX7nAWxvNRXYUA74KmdLmqn35CzISvXVCIEoWPARQXqWmhZUWwwiTLM4lPl0XYlz0a/4RLfsD2dRHTBuNOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486024649526.6537788694818; Tue, 11 Oct 2022 04:00:24 -0700 (PDT) Received: from localhost ([::1]:45356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCzl-0004JF-Ex for importer@patchew.org; Tue, 11 Oct 2022 07:00:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUR-0002CN-2q for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUN-0004XP-Fx for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:27:58 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-417-YbW_09sCM2SLt7wGlVXSMw-1; Tue, 11 Oct 2022 06:27:53 -0400 Received: by mail-ej1-f70.google.com with SMTP id qf25-20020a1709077f1900b0078c02a23da3so5666823ejc.0 for ; Tue, 11 Oct 2022 03:27:53 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id i17-20020aa7c711000000b004575085bf18sm8880727edq.74.2022.10.11.03.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q19lbNDEmiPwPnrz0hHNWPHofwAMVNqazrj/KXWd5rM=; b=ZpD2ldSh479n/DvDGfxIDjewJQz62ud3Oijv77yYghpwpcRdZ+UqnKK1GJRH9iw3gGGXtj OqNiQ6PAPY5gTIlTOIiFLLeAhvyHrWbewGX2YEIubHqI29NJ5BnfO/WlK1WnCSxD5QU5Wc 4nnHY1d+6rve7qa7WC1ezMIRq9Pw2bI= X-MC-Unique: YbW_09sCM2SLt7wGlVXSMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q19lbNDEmiPwPnrz0hHNWPHofwAMVNqazrj/KXWd5rM=; b=NkeIt3THFWh09qTGFpmVTeDmzSBOnrzgfHGUX227uqQp1tGz1ox2GiLq4/HfHjf07N 159k9foyalivth20SazF9++Rm2/OHA/O+Bdng0/SbUS7BojtBehvG3uH8DaZSOWK2YZi xdD3cr5j1Lyp/GzPnOTDRyBMpCMI+7dNH03Zm3XnPmuvu81LPkhlOfrB7n+fw4T0nu43 BHFMpWqjdqsm20PEnYeAC/ilhnfT0UJ7O2FsxcVkUbUVR0hAQuLtCR3G+vmyRIf85wU1 nXPKQL3ixblfZnWRPJRQoR4x7amezdUjI6KCNLzqis3yiwW8YxSOF4GFRW0YE2qqNDO4 /qXQ== X-Gm-Message-State: ACrzQf2nWNC4tLhnXo+alzrrQGkI6iCkbj9roRQswXcfNtIl6Tqc0nuf HdMXU+EngvuWsKUQ+Idvb2q6Cidd90bJLkVhynIT5bozsbBmLotnJvgHVlq8pXdit6KTN/uC3zY 2pVqi9JAse/7YTxMOx4fNXQfY3LleP3ukMVmta31yKulLRDowIfCKhxR/nhqK5G7RF8A= X-Received: by 2002:a17:907:6d27:b0:78d:46f6:c59e with SMTP id sa39-20020a1709076d2700b0078d46f6c59emr18478683ejc.30.1665484071959; Tue, 11 Oct 2022 03:27:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/lymGIi03TX6IJT/R3xPkej+KHn8pQjjGqgf651KUoIfr6dyGItKwV3m4YdmGfASWkTDzqA== X-Received: by 2002:a17:907:6d27:b0:78d:46f6:c59e with SMTP id sa39-20020a1709076d2700b0078d46f6c59emr18478661ejc.30.1665484071584; Tue, 11 Oct 2022 03:27:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 17/37] target/i386: Remove cur_eip, next_eip arguments to gen_repz* Date: Tue, 11 Oct 2022 12:26:40 +0200 Message-Id: <20221011102700.319178-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486026247100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson All callers pass s->base.pc_next and s->pc, which we can just as well compute within the functions. Pull out common helpers and reduce the amount of code under macros. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-13-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 116 ++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index fe99c4361c..c8ef9f0356 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -736,7 +736,7 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCG= v_i32 port, #endif } =20 -static inline void gen_movs(DisasContext *s, MemOp ot) +static void gen_movs(DisasContext *s, MemOp ot) { gen_string_movl_A0_ESI(s); gen_op_ld_v(s, ot, s->T0, s->A0); @@ -1156,18 +1156,18 @@ static inline void gen_jcc1(DisasContext *s, int b,= TCGLabel *l1) =20 /* XXX: does not work with gdbstub "ice" single step - not a serious problem */ -static TCGLabel *gen_jz_ecx_string(DisasContext *s, target_ulong next_eip) +static TCGLabel *gen_jz_ecx_string(DisasContext *s) { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); gen_op_jnz_ecx(s, s->aflag, l1); gen_set_label(l2); - gen_jmp_tb(s, next_eip, 1); + gen_jmp_tb(s, s->pc - s->cs_base, 1); gen_set_label(l1); return l2; } =20 -static inline void gen_stos(DisasContext *s, MemOp ot) +static void gen_stos(DisasContext *s, MemOp ot) { gen_op_mov_v_reg(s, MO_32, s->T0, R_EAX); gen_string_movl_A0_EDI(s); @@ -1176,7 +1176,7 @@ static inline void gen_stos(DisasContext *s, MemOp ot) gen_op_add_reg_T0(s, s->aflag, R_EDI); } =20 -static inline void gen_lods(DisasContext *s, MemOp ot) +static void gen_lods(DisasContext *s, MemOp ot) { gen_string_movl_A0_ESI(s); gen_op_ld_v(s, ot, s->T0, s->A0); @@ -1185,7 +1185,7 @@ static inline void gen_lods(DisasContext *s, MemOp ot) gen_op_add_reg_T0(s, s->aflag, R_ESI); } =20 -static inline void gen_scas(DisasContext *s, MemOp ot) +static void gen_scas(DisasContext *s, MemOp ot) { gen_string_movl_A0_EDI(s); gen_op_ld_v(s, ot, s->T1, s->A0); @@ -1194,7 +1194,7 @@ static inline void gen_scas(DisasContext *s, MemOp ot) gen_op_add_reg_T0(s, s->aflag, R_EDI); } =20 -static inline void gen_cmps(DisasContext *s, MemOp ot) +static void gen_cmps(DisasContext *s, MemOp ot) { gen_string_movl_A0_EDI(s); gen_op_ld_v(s, ot, s->T1, s->A0); @@ -1222,7 +1222,7 @@ static void gen_bpt_io(DisasContext *s, TCGv_i32 t_po= rt, int ot) } } =20 -static inline void gen_ins(DisasContext *s, MemOp ot) +static void gen_ins(DisasContext *s, MemOp ot) { gen_string_movl_A0_EDI(s); /* Note: we must do this dummy write first to be restartable in @@ -1238,7 +1238,7 @@ static inline void gen_ins(DisasContext *s, MemOp ot) gen_bpt_io(s, s->tmp2_i32, ot); } =20 -static inline void gen_outs(DisasContext *s, MemOp ot) +static void gen_outs(DisasContext *s, MemOp ot) { gen_string_movl_A0_ESI(s); gen_op_ld_v(s, ot, s->T0, s->A0); @@ -1252,42 +1252,49 @@ static inline void gen_outs(DisasContext *s, MemOp = ot) gen_bpt_io(s, s->tmp2_i32, ot); } =20 -/* same method as Valgrind : we generate jumps to current or next - instruction */ -#define GEN_REPZ(op) = \ -static inline void gen_repz_ ## op(DisasContext *s, MemOp ot, = \ - target_ulong cur_eip, target_ulong next_e= ip) \ -{ = \ - TCGLabel *l2; = \ - gen_update_cc_op(s); = \ - l2 =3D gen_jz_ecx_string(s, next_eip); = \ - gen_ ## op(s, ot); = \ - gen_op_add_reg_im(s, s->aflag, R_ECX, -1); = \ - /* a loop would cause two single step exceptions if ECX =3D 1 = \ - before rep string_insn */ = \ - if (s->repz_opt) = \ - gen_op_jz_ecx(s, s->aflag, l2); = \ - gen_jmp(s, cur_eip); = \ +/* Generate jumps to current or next instruction */ +static void gen_repz(DisasContext *s, MemOp ot, + void (*fn)(DisasContext *s, MemOp ot)) +{ + TCGLabel *l2; + gen_update_cc_op(s); + l2 =3D gen_jz_ecx_string(s); + fn(s, ot); + gen_op_add_reg_im(s, s->aflag, R_ECX, -1); + /* + * A loop would cause two single step exceptions if ECX =3D 1 + * before rep string_insn + */ + if (s->repz_opt) { + gen_op_jz_ecx(s, s->aflag, l2); + } + gen_jmp(s, s->base.pc_next - s->cs_base); } =20 -#define GEN_REPZ2(op) = \ -static inline void gen_repz_ ## op(DisasContext *s, MemOp ot, = \ - target_ulong cur_eip, = \ - target_ulong next_eip, = \ - int nz) = \ -{ = \ - TCGLabel *l2; = \ - gen_update_cc_op(s); = \ - l2 =3D gen_jz_ecx_string(s, next_eip); = \ - gen_ ## op(s, ot); = \ - gen_op_add_reg_im(s, s->aflag, R_ECX, -1); = \ - gen_update_cc_op(s); = \ - gen_jcc1(s, (JCC_Z << 1) | (nz ^ 1), l2); = \ - if (s->repz_opt) = \ - gen_op_jz_ecx(s, s->aflag, l2); = \ - gen_jmp(s, cur_eip); = \ +#define GEN_REPZ(op) \ + static inline void gen_repz_ ## op(DisasContext *s, MemOp ot) \ + { gen_repz(s, ot, gen_##op); } + +static void gen_repz2(DisasContext *s, MemOp ot, int nz, + void (*fn)(DisasContext *s, MemOp ot)) +{ + TCGLabel *l2; + gen_update_cc_op(s); + l2 =3D gen_jz_ecx_string(s); + fn(s, ot); + gen_op_add_reg_im(s, s->aflag, R_ECX, -1); + gen_update_cc_op(s); + gen_jcc1(s, (JCC_Z << 1) | (nz ^ 1), l2); + if (s->repz_opt) { + gen_op_jz_ecx(s, s->aflag, l2); + } + gen_jmp(s, s->base.pc_next - s->cs_base); } =20 +#define GEN_REPZ2(op) \ + static inline void gen_repz_ ## op(DisasContext *s, MemOp ot, int nz) \ + { gen_repz2(s, ot, nz, gen_##op); } + GEN_REPZ(movs) GEN_REPZ(stos) GEN_REPZ(lods) @@ -6623,8 +6630,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0xa5: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_movs(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base); + gen_repz_movs(s, ot); } else { gen_movs(s, ot); } @@ -6634,8 +6640,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0xab: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_stos(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base); + gen_repz_stos(s, ot); } else { gen_stos(s, ot); } @@ -6644,8 +6649,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0xad: ot =3D mo_b_d(b, dflag); if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_lods(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base); + gen_repz_lods(s, ot); } else { gen_lods(s, ot); } @@ -6654,11 +6658,9 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) case 0xaf: ot =3D mo_b_d(b, dflag); if (prefixes & PREFIX_REPNZ) { - gen_repz_scas(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base, 1); + gen_repz_scas(s, ot, 1); } else if (prefixes & PREFIX_REPZ) { - gen_repz_scas(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base, 0); + gen_repz_scas(s, ot, 0); } else { gen_scas(s, ot); } @@ -6668,11 +6670,9 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) case 0xa7: ot =3D mo_b_d(b, dflag); if (prefixes & PREFIX_REPNZ) { - gen_repz_cmps(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base, 1); + gen_repz_cmps(s, ot, 1); } else if (prefixes & PREFIX_REPZ) { - gen_repz_cmps(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base, 0); + gen_repz_cmps(s, ot, 0); } else { gen_cmps(s, ot); } @@ -6690,8 +6690,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_io_start(); } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_ins(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base); + gen_repz_ins(s, ot); /* jump generated by gen_repz_ins */ } else { gen_ins(s, ot); @@ -6712,8 +6711,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_io_start(); } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { - gen_repz_outs(s, ot, s->base.pc_next - s->cs_base, - s->pc - s->cs_base); + gen_repz_outs(s, ot); /* jump generated by gen_repz_outs */ } else { gen_outs(s, ot); --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665485888; cv=none; d=zohomail.com; s=zohoarc; b=Js6NGy6qY1U9rFD/T3XBfFqnowfGgv7vcpSWWiiXGA6IIlQYBnh2IwEPPfkmTS7RoP5TT5Uflp8Dova4JezDlRxgItXX0LIVjNjYkUe23qtKo1vEx0UhElVAmpHpbPks8XMdNNHqmg4aA2lu7Xt6v8bkuQ1IDWrB2IUNh1nvwfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665485888; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=22TAl+o1Pln9HwWBNDRYRw1yfkBwlpL9jm+XULzxcxc=; b=IrNTe2DtK1/q2gsLJK2/je/bAV/hn8798CWDUt+jyWzW7qMOOMcqKQZw953aIievsjSJgRetOa++C3dY8xAtIJrEqZmRUG/5D7izIo1X3RQ8jmwt4DeqXwEKROIj2rjlhGRCeK3TnPHDmXzLFhlO+toTTjcPzburn7CTf68vzQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665485888330643.2859587973638; Tue, 11 Oct 2022 03:58:08 -0700 (PDT) Received: from localhost ([::1]:54354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiCxb-00013l-4W for importer@patchew.org; Tue, 11 Oct 2022 06:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUT-0002Cs-Fl for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31092) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUQ-0004Y0-4z for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:00 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-542-MeoIkkyqPZez9B1h76t3EQ-1; Tue, 11 Oct 2022 06:27:56 -0400 Received: by mail-ed1-f70.google.com with SMTP id s17-20020a056402521100b0045bfaaab697so4638571edd.1 for ; Tue, 11 Oct 2022 03:27:56 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id mb20-20020a170906eb1400b0078d85972524sm6170255ejb.157.2022.10.11.03.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=22TAl+o1Pln9HwWBNDRYRw1yfkBwlpL9jm+XULzxcxc=; b=T6AosCC37CBSid5GF903e3O0B7WtzDvpnRSeU8EK0/s8BM9ER9UuWyq3L0Y9oT8E6vbpWp CWEEl8syJKaN0iPnG8bnPZOmw7FY5FsFoq41C5LsCMAIjhuwnSFpx+pYBRvSeVyIMQfpON 1b/ozU4HJZlguYqL40Li+Du2euYkbYI= X-MC-Unique: MeoIkkyqPZez9B1h76t3EQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=22TAl+o1Pln9HwWBNDRYRw1yfkBwlpL9jm+XULzxcxc=; b=STbhfG0hlmntQBBx2RZG2m2RbEniNo/wYWSdRqcVo48VvJU7WL3pRvs7qD3nXssxJQ OXlH/TVD6JxnQAvYtvqauKgTamhTk9eimxpcnEBHax02JjpOmuZJ5jt2e+45lxn2m9Y1 LdRKZfp0PaTChEWaqClRpwXEDw3hagGkuDhsSvFbrWfhxU4eyXgysPgLTnA9UqSVMI9i LcIT40fOUwh/wdAI79hbTguzL5ZJ+5ZCkCq6Tp+0/zdbaSCDGlcXhdy9FecjIqKoR3Zz J2wbn77TaRW7nD8f3AUqDugkG1oJLTdz1VjCGYMPDQCH9yx4Rb6nBSwZFMbtWl10bMpe ziTw== X-Gm-Message-State: ACrzQf3kgrFKk46snh2iAH4AOMzBBSr1vi071nnBDo1O/ck3oVxuqnC7 8QV0/jWMmPXVIP75c21dppfN5kP1j4F928YeDWBtOEIexBctR+ab2i2pQSWZZ7ekFBFxpoGH+F3 1Hxns/iEe8i86LWsNoCQDbaxRj5EQ4P0hJ+D2tucRKI1bfrDD3GNwlFolpeJL4DL8X10= X-Received: by 2002:a17:907:25c5:b0:783:f5df:900e with SMTP id ae5-20020a17090725c500b00783f5df900emr17685609ejc.491.1665484074621; Tue, 11 Oct 2022 03:27:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4JDCe3DTg8aGQdCAM7Fdj65n7b1pv3QMo+ttQ0MGYwNm77/qGXoPPOnlk3qH6xi30hO3zoMQ== X-Received: by 2002:a17:907:25c5:b0:783:f5df:900e with SMTP id ae5-20020a17090725c500b00783f5df900emr17685590ejc.491.1665484074362; Tue, 11 Oct 2022 03:27:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 18/37] target/i386: Introduce DISAS_JUMP Date: Tue, 11 Oct 2022 12:26:41 +0200 Message-Id: <20221011102700.319178-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665485889444100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Drop the unused dest argument to gen_jr(). Remove most of the calls to gen_jr, and use DISAS_JUMP. Remove some unused loads of eip for lcall and ljmp. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-14-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index c8ef9f0356..7db6f617a1 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -135,6 +135,7 @@ typedef struct DisasContext { #define DISAS_EOB_ONLY DISAS_TARGET_0 #define DISAS_EOB_NEXT DISAS_TARGET_1 #define DISAS_EOB_INHIBIT_IRQ DISAS_TARGET_2 +#define DISAS_JUMP DISAS_TARGET_3 =20 /* The environment in which user-only runs is constrained. */ #ifdef CONFIG_USER_ONLY @@ -222,7 +223,7 @@ STUB_HELPER(wrmsr, TCGv_env env) #endif =20 static void gen_eob(DisasContext *s); -static void gen_jr(DisasContext *s, TCGv dest); +static void gen_jr(DisasContext *s); static void gen_jmp(DisasContext *s, target_ulong eip); static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); static void gen_op(DisasContext *s1, int op, MemOp ot, int d); @@ -2385,7 +2386,7 @@ static void gen_goto_tb(DisasContext *s, int tb_num, = target_ulong eip) } else { /* jump to another page */ gen_jmp_im(s, eip); - gen_jr(s, s->tmp0); + gen_jr(s); } } =20 @@ -2754,7 +2755,7 @@ static void gen_eob(DisasContext *s) } =20 /* Jump to register */ -static void gen_jr(DisasContext *s, TCGv dest) +static void gen_jr(DisasContext *s) { do_gen_eob_worker(s, false, false, true); } @@ -5328,7 +5329,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_push_v(s, s->T1); gen_op_jmp_v(s->T0); gen_bnd_jmp(s); - gen_jr(s, s->T0); + s->base.is_jmp =3D DISAS_JUMP; break; case 3: /* lcall Ev */ if (mod =3D=3D 3) { @@ -5349,8 +5350,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_const_i32(dflag - 1), tcg_const_i32(s->pc - s->cs_base)); } - tcg_gen_ld_tl(s->tmp4, cpu_env, offsetof(CPUX86State, eip)); - gen_jr(s, s->tmp4); + s->base.is_jmp =3D DISAS_JUMP; break; case 4: /* jmp Ev */ if (dflag =3D=3D MO_16) { @@ -5358,7 +5358,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_op_jmp_v(s->T0); gen_bnd_jmp(s); - gen_jr(s, s->T0); + s->base.is_jmp =3D DISAS_JUMP; break; case 5: /* ljmp Ev */ if (mod =3D=3D 3) { @@ -5376,8 +5376,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_op_movl_seg_T0_vm(s, R_CS); gen_op_jmp_v(s->T1); } - tcg_gen_ld_tl(s->tmp4, cpu_env, offsetof(CPUX86State, eip)); - gen_jr(s, s->tmp4); + s->base.is_jmp =3D DISAS_JUMP; break; case 6: /* push Ev */ gen_push_v(s, s->T0); @@ -6808,7 +6807,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v(s->T0); gen_bnd_jmp(s); - gen_jr(s, s->T0); + s->base.is_jmp =3D DISAS_JUMP; break; case 0xc3: /* ret */ ot =3D gen_pop_T0(s); @@ -6816,7 +6815,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v(s->T0); gen_bnd_jmp(s); - gen_jr(s, s->T0); + s->base.is_jmp =3D DISAS_JUMP; break; case 0xca: /* lret im */ val =3D x86_ldsw_code(env, s); @@ -8846,6 +8845,9 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase,= CPUState *cpu) gen_update_eip_cur(dc); gen_eob_inhibit_irq(dc, true); break; + case DISAS_JUMP: + gen_jr(dc); + break; default: g_assert_not_reached(); } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487640; cv=none; d=zohomail.com; s=zohoarc; b=LaxgDe2PKTlDQ3svFCTIqEjxRs1XC7E/SHq7O+28zWZEE18sxYRt+RT4dokxmco7dpKCe3MP7mtLEcRLVSX0hpf/4P2C9XDDWkf1TqyL5FuNUJpx5AwYULoZlx+pNUnI9Uarq3CQlBlErlNvCe6vuyfc7umAjanNuuJMGw8HHeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487640; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ISKWOoQ7K5a7RBXs1wPR0heFsShFz0InZehXmH2tzkw=; b=VbYh29WzKj1oWPKbcKc7e1GHJ9fnf/TPImN9DRxWJnw/7NwZFswyd1JcY9MnXlE2IaCXJhx3uo1X1fBZ4XCY0ikUAPD+GuWGcBz308dZzMqQj9IuUJz573Kpw8+91MZNzuv0LLxCMAQbr9leZ+bPLuMI0dJiKfeCJql0+wNIj/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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665487640942363.4590209104325; Tue, 11 Oct 2022 04:27:20 -0700 (PDT) Received: from localhost ([::1]:55088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDPr-00057G-H7 for importer@patchew.org; Tue, 11 Oct 2022 07:27:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUU-0002Es-L7 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33205) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUT-0004Yq-5m for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:02 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-164-JJnpyaa4PEmGX2TW2JeQ3g-1; Tue, 11 Oct 2022 06:27:59 -0400 Received: by mail-ed1-f69.google.com with SMTP id t19-20020a056402525300b00459546fd250so11016242edd.23 for ; Tue, 11 Oct 2022 03:27:58 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id b17-20020aa7c911000000b00458f82462a5sm8640695edt.25.2022.10.11.03.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ISKWOoQ7K5a7RBXs1wPR0heFsShFz0InZehXmH2tzkw=; b=ZOYVh48z0BdHyIeNVwpVBJECgn8KLvSuAtDNn6WnN0KB/w5M6G+f9zoMwZqsrFIMA7zrGm DGK5W7hKe+2dtwI0ZSDL1VsUDiDEY4n53Z+wCEapygZ4szF22fGwED9Li3HXsQnJ/EKs9Z E7+vc36DypacLvRO1n9eQf43jzRV1SY= X-MC-Unique: JJnpyaa4PEmGX2TW2JeQ3g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ISKWOoQ7K5a7RBXs1wPR0heFsShFz0InZehXmH2tzkw=; b=s6qvJDguQuGM5ZZkwHk1velcypM6KwF3pyPhX0VhtHDqs+FtyE1KhdTKnn6I0s4UdH 7lmMcoUTyrmXBsXjTt60KQySbcK+fQ7WCkmplApz32LeIkBFm58w2DOhk4IOv/OA3zE8 igxpznKdrnaacMzGVfpR/5UjMQZEPHuG8d1bN4cOXo9C+qO4XW8vPX6uqU4pdrzpM5rZ f9OPiFZDcGpp0ruNPz9Lv+qKdKHUpJmkFPAduJEmMS/+BMnuGiYABXrtbxlHLBsF/ai8 H8W02TjgmxqeGqVC2rza3pkdOdJ2yBS4Kyv5oIByg+xjr4PF++ay4oq3e1dJdC4a1Ltb 1jKA== X-Gm-Message-State: ACrzQf1GsncN5RtGZ85T+VdZGASTBQL53bTAxXH0bt873P+qA0r2e/f9 DD8KteQp02fv3h5BLPsOcdGWosK7CpW5vb+xHUxCfIdbCqRlJFosVGv35Rt7wT/gmxPT2yWe+BA HdcCeOuq9JzUpxNu0aDMxEoC8WXOmqryHRyC4+dYPhPL9oBQOw6groULvpIIjLi59AXs= X-Received: by 2002:a17:907:a065:b0:78d:c5dd:45cf with SMTP id ia5-20020a170907a06500b0078dc5dd45cfmr5719199ejc.117.1665484077415; Tue, 11 Oct 2022 03:27:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PovybUunWJXP+LQ+jKEKgCfbYJwpeM3+sqI+7hLH9VkTh+JGvYuIK9UYl0lLzYWUBANGcJw== X-Received: by 2002:a17:907:a065:b0:78d:c5dd:45cf with SMTP id ia5-20020a170907a06500b0078dc5dd45cfmr5719189ejc.117.1665484077158; Tue, 11 Oct 2022 03:27:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 19/37] target/i386: Truncate values for lcall_real to i32 Date: Tue, 11 Oct 2022 12:26:42 +0200 Message-Id: <20221011102700.319178-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487642881100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Use i32 not int or tl for eip and cs arguments. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-15-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/helper.h | 2 +- target/i386/tcg/seg_helper.c | 6 ++---- target/i386/tcg/translate.c | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/target/i386/helper.h b/target/i386/helper.h index ac3b4d1ee3..39a3c24182 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -37,7 +37,7 @@ DEF_HELPER_2(lldt, void, env, int) DEF_HELPER_2(ltr, void, env, int) DEF_HELPER_3(load_seg, void, env, int, int) DEF_HELPER_4(ljmp_protected, void, env, int, tl, tl) -DEF_HELPER_5(lcall_real, void, env, int, tl, int, int) +DEF_HELPER_5(lcall_real, void, env, i32, i32, int, i32) DEF_HELPER_5(lcall_protected, void, env, int, tl, int, tl) DEF_HELPER_2(iret_real, void, env, int) DEF_HELPER_3(iret_protected, void, env, int, int) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index bffd82923f..539189b4d1 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -1504,14 +1504,12 @@ void helper_ljmp_protected(CPUX86State *env, int ne= w_cs, target_ulong new_eip, } =20 /* real mode call */ -void helper_lcall_real(CPUX86State *env, int new_cs, target_ulong new_eip1, - int shift, int next_eip) +void helper_lcall_real(CPUX86State *env, uint32_t new_cs, uint32_t new_eip, + int shift, uint32_t next_eip) { - int new_eip; uint32_t esp, esp_mask; target_ulong ssp; =20 - new_eip =3D new_eip1; esp =3D env->regs[R_ESP]; esp_mask =3D get_sp_mask(env->segs[R_SS].flags); ssp =3D env->segs[R_SS].base; diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 7db6f617a1..1aa5b37ea6 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -5346,7 +5346,8 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_const_tl(s->pc - s->cs_base= )); } else { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); - gen_helper_lcall_real(cpu_env, s->tmp2_i32, s->T1, + tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T1); + gen_helper_lcall_real(cpu_env, s->tmp2_i32, s->tmp3_i32, tcg_const_i32(dflag - 1), tcg_const_i32(s->pc - s->cs_base)); } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486461; cv=none; d=zohomail.com; s=zohoarc; b=Zb3IgX0hwXyH7WrRWfdoD9acPh5m1jnvXkTuCNt3f6T0tD/NLf0WWuioG36N78Ttw7XNvlJiglxCEfCQmLNqCRqrBKBZ49ooGKCkAElbTx+t3FCBLYoR5G80S9ANLYq/Y4KukfMYKbMUKzEUcexgSKFjnJpXTgiwSdkauFodYgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486461; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RWkzp2G1GGRfPr9zZ4LH8Nm9HU3hhMu4BerVJTaCKpw=; b=g/jmFOseeOdDpkNaX/WhDYEcQdSLpTihQzhT95G2maOT8sO3pLWgHloL8d869mczGf7SNMsWi60T+tDdQicFQZBO1xt4gtqhOc+pRwtoKQfRlgHdIMNFC9D7SeIkxzuTgISto4ZRoBy/a1vG/HfGWMaUcIldHb8+2vVtq3vse6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486461758881.0085434720295; Tue, 11 Oct 2022 04:07:41 -0700 (PDT) Received: from localhost ([::1]:59404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiD6q-0007FI-7e for importer@patchew.org; Tue, 11 Oct 2022 07:07:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUX-0002Ia-8F for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUV-0004Zc-7T for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:04 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-562-dTkMAC0OMH6L1ZnR6RnjAQ-1; Tue, 11 Oct 2022 06:28:01 -0400 Received: by mail-ej1-f71.google.com with SMTP id gb42-20020a170907962a00b0078d194624a9so5721436ejc.11 for ; Tue, 11 Oct 2022 03:28:01 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id hv13-20020a17090760cd00b00782539a02absm6826615ejc.194.2022.10.11.03.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RWkzp2G1GGRfPr9zZ4LH8Nm9HU3hhMu4BerVJTaCKpw=; b=abHayjbpmh3Ixx2Rb2wYDeMm0MnKmyqFe32xzu92b4K8seMd9UXPSYlG/s9aCJjGcS2crD 3DRjjDQDr5fntW95EBVuKxWb8x96aijXFLYSubpuYQpalTY83cxoRu4MA9Hco4L+bRU5ot CsHrWheu43rSiGWmU8hfYWKY5I8oKbg= X-MC-Unique: dTkMAC0OMH6L1ZnR6RnjAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RWkzp2G1GGRfPr9zZ4LH8Nm9HU3hhMu4BerVJTaCKpw=; b=XDroIYMJYNSd5LyiJ2jTaWcnmiJhxaEiJh7ER6GBj+YxMoyj3ZTXW+ig8VpeLBsMzF +6zdVg4R3996Q+k6O9MHqTMo2GtZxA4My4mMgVQ/InOEKYWkkxF8+jqyzngMD5woHBW+ bsVhKr2Id0vICw7YY8g+LkU8oY4WpiOOpu2jH54UFujZfvnbMPY8jJnlZe6r0ay6qu8K SMaotortctFD31Vp/446bbD4E7sPLWkMj+1zHnN5FhnoVRE2aYesoqeZHe/Y9sEnbjKW bTdUvQS0hQJN+VJOiszlQxpFk10Zi5p7cWtUjnPSt2ngzR87ww79UtbXB8sXF0IK+EsQ ZobQ== X-Gm-Message-State: ACrzQf1f0URNFnN0yDAz5Py07V+8Euo+n2g0mQhK2eAPhkzWDTo8dTS/ Pc7Q7H8Kx0dXmLoU2H8qX5VOj2a+EWUMpJJxITRPvGMUY/QZ+F0hWZl5/G+u2gP0Jxnhu3u/F/7 oIhBhC5cJ5rk0mMbA620CPR40KuzARIEFbVleFLAwlS+1mye56ZPRbc1qGnSpZgfgEyE= X-Received: by 2002:a17:906:ee88:b0:78d:1a9a:b2db with SMTP id wt8-20020a170906ee8800b0078d1a9ab2dbmr18213832ejb.225.1665484080188; Tue, 11 Oct 2022 03:28:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Xo1vFMuSD/H2i7q+ZvCCFfHbMEKW4PZNcYMLG5wRGY9xKmw8tsMXGzsc0UViHf0zso66F2w== X-Received: by 2002:a17:906:ee88:b0:78d:1a9a:b2db with SMTP id wt8-20020a170906ee8800b0078d1a9ab2dbmr18213818ejb.225.1665484079880; Tue, 11 Oct 2022 03:27:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 20/37] target/i386: Create eip_next_* Date: Tue, 11 Oct 2022 12:26:43 +0200 Message-Id: <20221011102700.319178-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486463164100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Create helpers for loading the address of the next insn. Use tcg_constant_* in adjacent code where convenient. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-16-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 1aa5b37ea6..be29ea7a03 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -541,6 +541,27 @@ static TCGv_i32 cur_insn_len_i32(DisasContext *s) return tcg_constant_i32(cur_insn_len(s)); } =20 +static TCGv_i32 eip_next_i32(DisasContext *s) +{ + /* + * This function has two users: lcall_real (always 16-bit mode), and + * iret_protected (16, 32, or 64-bit mode). IRET only uses the value + * when EFLAGS.NT is set, which is illegal in 64-bit mode, which is + * why passing a 32-bit value isn't broken. To avoid using this where + * we shouldn't, return -1 in 64-bit mode so that execution goes into + * the weeds quickly. + */ + if (CODE64(s)) { + return tcg_constant_i32(-1); + } + return tcg_constant_i32(s->pc - s->cs_base); +} + +static TCGv eip_next_tl(DisasContext *s) +{ + return tcg_constant_tl(s->pc - s->cs_base); +} + /* Compute SEG:REG into A0. SEG is selected from the override segment (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to indicate no override. */ @@ -1213,12 +1234,9 @@ static void gen_bpt_io(DisasContext *s, TCGv_i32 t_p= ort, int ot) /* user-mode cpu should not be in IOBPT mode */ g_assert_not_reached(); #else - TCGv_i32 t_size =3D tcg_const_i32(1 << ot); - TCGv t_next =3D tcg_const_tl(s->pc - s->cs_base); - + TCGv_i32 t_size =3D tcg_constant_i32(1 << ot); + TCGv t_next =3D eip_next_tl(s); gen_helper_bpt_io(cpu_env, t_port, t_size, t_next); - tcg_temp_free_i32(t_size); - tcg_temp_free(t_next); #endif /* CONFIG_USER_ONLY */ } } @@ -5324,9 +5342,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (dflag =3D=3D MO_16) { tcg_gen_ext16u_tl(s->T0, s->T0); } - next_eip =3D s->pc - s->cs_base; - tcg_gen_movi_tl(s->T1, next_eip); - gen_push_v(s, s->T1); + gen_push_v(s, eip_next_tl(s)); gen_op_jmp_v(s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; @@ -5342,14 +5358,14 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) if (PE(s) && !VM86(s)) { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); gen_helper_lcall_protected(cpu_env, s->tmp2_i32, s->T1, - tcg_const_i32(dflag - 1), - tcg_const_tl(s->pc - s->cs_base= )); + tcg_constant_i32(dflag - 1), + eip_next_tl(s)); } else { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T1); gen_helper_lcall_real(cpu_env, s->tmp2_i32, s->tmp3_i32, - tcg_const_i32(dflag - 1), - tcg_const_i32(s->pc - s->cs_base)); + tcg_constant_i32(dflag - 1), + eip_next_i32(s)); } s->base.is_jmp =3D DISAS_JUMP; break; @@ -5372,7 +5388,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (PE(s) && !VM86(s)) { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); gen_helper_ljmp_protected(cpu_env, s->tmp2_i32, s->T1, - tcg_const_tl(s->pc - s->cs_base)= ); + eip_next_tl(s)); } else { gen_op_movl_seg_T0_vm(s, R_CS); gen_op_jmp_v(s->T1); @@ -6854,8 +6870,8 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_helper_iret_real(cpu_env, tcg_const_i32(dflag - 1)); } else { - gen_helper_iret_protected(cpu_env, tcg_const_i32(dflag - 1), - tcg_const_i32(s->pc - s->cs_base)); + gen_helper_iret_protected(cpu_env, tcg_constant_i32(dflag - 1), + eip_next_i32(s)); } set_cc_op(s, CC_OP_EFLAGS); s->base.is_jmp =3D DISAS_EOB_ONLY; @@ -6867,15 +6883,13 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } else { tval =3D (int16_t)insn_get(env, s, MO_16); } - next_eip =3D s->pc - s->cs_base; - tval +=3D next_eip; + tval +=3D s->pc - s->cs_base; if (dflag =3D=3D MO_16) { tval &=3D 0xffff; } else if (!CODE64(s)) { tval &=3D 0xffffffff; } - tcg_gen_movi_tl(s->T0, next_eip); - gen_push_v(s, s->T0); + gen_push_v(s, eip_next_tl(s)); gen_bnd_jmp(s); gen_jmp(s, tval); } @@ -7409,8 +7423,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) TCGLabel *l1, *l2, *l3; =20 tval =3D (int8_t)insn_get(env, s, MO_8); - next_eip =3D s->pc - s->cs_base; - tval +=3D next_eip; + tval +=3D s->pc - s->cs_base; if (dflag =3D=3D MO_16) { tval &=3D 0xffff; } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486973; cv=none; d=zohomail.com; s=zohoarc; b=EkFP+fAc7SxXYtOcFdolRCHI/7BzHaB3YSQpS1diIAe11HIRhUiM0XyJ3GMp3bRtgdQrOJztwbbvJuXnxv4g80YQHldWHHbqcy5FhjQMacI3aLV/8IQUT0N68+VxA+3ACkqjHNwTVH4IkmI8kLr6lOuESTAmhiE5bTHwXZx4ChA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ut8xDXgT2bBwGBL1E2m2HrBIy0yyf5iOFTclUOS+d3Q=; b=ESk10ic6AVvWsC8TYACfVoUlE4CS1eV14GmKKAYA+SYY72RXGRO2E5YhaO/AEBqfbet0YWvNfHNoRKA2PkQfbJQXx5inx1ipilqI5SDUUvXuKGgmK6THqCIVBHnyPbWOboGrhNeTjwZwZMAg0xFjR573LL02vBS4Y2scIN2udwk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486973128120.01968800226564; Tue, 11 Oct 2022 04:16:13 -0700 (PDT) Received: from localhost ([::1]:43644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDF4-0006Fy-PO for importer@patchew.org; Tue, 11 Oct 2022 07:16:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUb-0002RX-6g for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUZ-0004aX-CC for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:08 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-665--zHYnZ3cM-CIYxhohwp01Q-1; Tue, 11 Oct 2022 06:28:05 -0400 Received: by mail-ed1-f72.google.com with SMTP id y6-20020a056402358600b0045932521633so10939658edc.17 for ; Tue, 11 Oct 2022 03:28:04 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id zh15-20020a170906880f00b0078d8c1eee44sm5666008ejb.158.2022.10.11.03.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ut8xDXgT2bBwGBL1E2m2HrBIy0yyf5iOFTclUOS+d3Q=; b=YazBzE0j0wJmJjIwBg+0wEiu0Dazv7eOalpYkJx0Xx4YP+Uw5QBuL6q2+49fDwgpif32fl hwwqMLZFsT4wNIBKdOIJNvWWD1qx5IneWg8SjpFMujymxHXCsxFiznDBTdk2oeNjw3VdmA 6UAifOY4/60XE2Tgn9oZK4T+vt+0QIY= X-MC-Unique: -zHYnZ3cM-CIYxhohwp01Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ut8xDXgT2bBwGBL1E2m2HrBIy0yyf5iOFTclUOS+d3Q=; b=ZG2Jke8FN3WstVYyUkEb/ro08wrSGxT1d2kLpo3823p7PJAEOmfwNj+W+N8kjW/bcU wXZG8p5EyDE59b0HOuaHQI3JtGx+4V0QzwDdKI9CdkSOjULdUvuOvUqD+nGBPge3oC7a 0PeCX+vzgdSVjpL+AX5KVqC/4ovNd58aiQxzcozq3cuc/INPk5D3ulvJMRN/awxmeUIm nhOS8Vz8yl6tE1Pl6YTzTGJUMAZLqIDqsP2ctWKhAnE5mjxiqt6vKclGNep5ARLVaU4T 3OTxNtj53L813UrH2QlBgd7EAZci/WnV1Tye8z73YDrP4/iL773V2694+6oxS2350ter PCkg== X-Gm-Message-State: ACrzQf3rYNUBGI93ASvq14vicKqT+Gf73xg9rffV/+Ycj2P71RVRk85h LKRKj4mGgSwA4moGQh+by7X9VzpuMJf91TzX6cOp0cemlyrpFPnljnvxmm3qRv1Ta62RyYBxMuG G3czQRWmKeMwhg7VcZgDu+hESq6nL8vIfJzBilsSfuFV4L/Mmhc9mtXPupOhXOZI2rzQ= X-Received: by 2002:a17:906:ee88:b0:78d:1a9a:b2db with SMTP id wt8-20020a170906ee8800b0078d1a9ab2dbmr18213988ejb.225.1665484083441; Tue, 11 Oct 2022 03:28:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mwXFJ14t5yZbVetIKQC3M8Hdf+CL6i84Kh0IVHRJCLhNEaPbxqPrFZyBgDlH3QimkOV+lCw== X-Received: by 2002:a17:906:ee88:b0:78d:1a9a:b2db with SMTP id wt8-20020a170906ee8800b0078d1a9ab2dbmr18213966ejb.225.1665484083066; Tue, 11 Oct 2022 03:28:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 21/37] target/i386: Use DISAS_TOO_MANY to exit after gen_io_start Date: Tue, 11 Oct 2022 12:26:44 +0200 Message-Id: <20221011102700.319178-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486975089100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We can set is_jmp early, using only one if, and let that be overwritten by gen_rep*'s calls to gen_jmp_tb. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-17-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 42 +++++++++---------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index be29ea7a03..11aaba8a65 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -5660,14 +5660,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_helper_rdrand(s->T0, cpu_env); rm =3D (modrm & 7) | REX_B(s); gen_op_mov_reg_v(s, dflag, rm, s->T0); set_cc_op(s, CC_OP_EFLAGS); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; =20 default: @@ -6704,15 +6702,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { gen_repz_ins(s, ot); - /* jump generated by gen_repz_ins */ } else { gen_ins(s, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } } break; case 0x6e: /* outsS */ @@ -6725,15 +6720,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) { gen_repz_outs(s, ot); - /* jump generated by gen_repz_outs */ } else { gen_outs(s, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } } break; =20 @@ -6750,13 +6742,11 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_helper_in_func(ot, s->T1, s->tmp2_i32); gen_op_mov_reg_v(s, ot, R_EAX, s->T1); gen_bpt_io(s, s->tmp2_i32, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; case 0xe6: case 0xe7: @@ -6768,14 +6758,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_op_mov_v_reg(s, ot, s->T1, R_EAX); tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T1); gen_helper_out_func(ot, s->tmp2_i32, s->tmp3_i32); gen_bpt_io(s, s->tmp2_i32, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; case 0xec: case 0xed: @@ -6787,13 +6775,11 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_helper_in_func(ot, s->T1, s->tmp2_i32); gen_op_mov_reg_v(s, ot, R_EAX, s->T1); gen_bpt_io(s, s->tmp2_i32, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; case 0xee: case 0xef: @@ -6805,14 +6791,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_op_mov_v_reg(s, ot, s->T1, R_EAX); tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T1); gen_helper_out_func(ot, s->tmp2_i32, s->tmp3_i32); gen_bpt_io(s, s->tmp2_i32, ot); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; =20 /************************/ @@ -7478,11 +7462,9 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) gen_update_eip_cur(s); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_helper_rdtsc(cpu_env); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; case 0x133: /* rdpmc */ gen_update_cc_op(s); @@ -7939,11 +7921,9 @@ static bool disas_insn(DisasContext *s, CPUState *cp= u) gen_update_eip_cur(s); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } gen_helper_rdtscp(cpu_env); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } break; =20 default: @@ -8307,6 +8287,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) =20 if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); + s->base.is_jmp =3D DISAS_TOO_MANY; } if (b & 2) { gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0 + reg); @@ -8317,9 +8298,6 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_READ_CR0 + reg); gen_helper_read_crN(s->T0, cpu_env, tcg_constant_i32(reg)); gen_op_mov_reg_v(s, ot, rm, s->T0); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_jmp(s, s->pc - s->cs_base); - } } break; =20 --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487090; cv=none; d=zohomail.com; s=zohoarc; b=IlnC+hOmsETG9mICGGxPD5M2XT4wre+5qMKsxGrGasdrs+8AHMYcxX8TcS1U67bTXz3tKJvukSETi8CdNLvqU9fWNDkSfC6VM34WVV4dwmmNFEgbVrFYm0oSafUtHF98m6t3MFepyVwaxoDVR4CdnA/OqT9QacW4djtmlMoZPdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487090; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8EkHY0WoWXhFfht/JJLtepwJCD/svE3cJ5Ov63qiC58=; b=G068UKCs63nutj9rxOPvlngZW/XaBMsi8A71TK8+CKbGmdOfkDRgo7wfnuKyLzo/1txK8qMkCld5A7/2L6UAQ80WWwAUkqZjFM49ymrO4dIanNitvEpHKBp7c8058nCUtGozQmqyWLyfrEIFdYUe5M8bSuwo6eJoOWj08DmU6LA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166548709089678.92842378082048; Tue, 11 Oct 2022 04:18:10 -0700 (PDT) Received: from localhost ([::1]:32796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDGz-0000Y9-HZ for importer@patchew.org; Tue, 11 Oct 2022 07:18:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUe-0002WM-FK for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUb-0004b5-PO for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:11 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-29-FNCXTdXePOq-sTtUnbmwSA-1; Tue, 11 Oct 2022 06:28:08 -0400 Received: by mail-ed1-f70.google.com with SMTP id x4-20020a05640226c400b0045c09fc1bd4so4278120edd.7 for ; Tue, 11 Oct 2022 03:28:07 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id jw13-20020a17090776ad00b00731803d4d04sm6718907ejc.82.2022.10.11.03.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8EkHY0WoWXhFfht/JJLtepwJCD/svE3cJ5Ov63qiC58=; b=Y8sVAGaGpFCLL2gaGk/Gzp0kRBQnADVbmFyJcU408BkCN2Qwtt6gxJcxGz4P66v74kguWR bslmOsE4JQmiVUE4pw+U/8a6GX47Cn1h9Gt1djC8oS4h584X/Z9JTpqlcuPvb09+6IFIBz +BmdTXzGBAWsmHtVu+SUA+L+HrWKgL0= X-MC-Unique: FNCXTdXePOq-sTtUnbmwSA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8EkHY0WoWXhFfht/JJLtepwJCD/svE3cJ5Ov63qiC58=; b=42Uw4IWbbtOz/q90F8mydWQSqetkVIItjD6a+OghZKQCygaSVtJpIENCJ/6y3nNjwF M5JBMqwqsZk/KYiBQHuushcCVQtQH8HKQH0bCf7ttndRJYUZZUvXqCGTmjG2O1MAKBV2 oRnE5+84HMiv3YlUVxKdDkwrtEqMGJM36UgLQa/CSEZI3bG0Q/VtQR6souW0eAuz6Sbh pwoCUpi54f/hSJ2g00TZN5mMPgP8X59yOn0QVfbgq59T6wWcgC10GwKeN8QUrCHZ+Jbt LvlhskmJ+JPCR4WFz5iK74zSF6Muy/RfGxRUguzJs7K8g0Trhg8vJ3GX1mWDA0cru7h0 hqvg== X-Gm-Message-State: ACrzQf0D3Rlty2kDtNny53hsi8/9fHVG1U9y3rfTg2eXmBbYjtqIIVMC tnUUjpoxNByhHVA58TusT1heqdSJ3tXnMgKWp31zv0BRSlTz61NnYufmBq3z3Y691/J4+fytS38 hGcWHUqh97lHpkc3RVyORe+7DOKHrEQwmkcegshMahLvZj9aidWRG+sPprZENPs+wlqs= X-Received: by 2002:aa7:cc8a:0:b0:45b:f851:2943 with SMTP id p10-20020aa7cc8a000000b0045bf8512943mr12101519edt.103.1665484086379; Tue, 11 Oct 2022 03:28:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MEcdJvo8EoG1wYw4ePIUcEfTb3Gk/d/EIc1DSIFv0zzOGAuTItkisJfuSsl7YjLvS0ssgYA== X-Received: by 2002:aa7:cc8a:0:b0:45b:f851:2943 with SMTP id p10-20020aa7cc8a000000b0045bf8512943mr12101499edt.103.1665484086136; Tue, 11 Oct 2022 03:28:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 22/37] target/i386: Create gen_jmp_rel Date: Tue, 11 Oct 2022 12:26:45 +0200 Message-Id: <20221011102700.319178-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487091539100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Create a common helper for pc-relative branches. The jmp jb insn was missing a mask for CODE32. In all cases the CODE64 check was incorrectly placed, allowing PREFIX_DATA to truncate %rip to 16 bits. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-18-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 11aaba8a65..ba1bd7c707 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -226,6 +226,7 @@ static void gen_eob(DisasContext *s); static void gen_jr(DisasContext *s); static void gen_jmp(DisasContext *s, target_ulong eip); static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); +static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num); static void gen_op(DisasContext *s1, int op, MemOp ot, int d); static void gen_exception_gpf(DisasContext *s); =20 @@ -2792,6 +2793,21 @@ static void gen_jmp_tb(DisasContext *s, target_ulong= eip, int tb_num) } } =20 +static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num) +{ + target_ulong dest =3D s->pc - s->cs_base + diff; + + /* In 64-bit mode, operand size is fixed at 64 bits. */ + if (!CODE64(s)) { + if (ot =3D=3D MO_16) { + dest &=3D 0xffff; + } else { + dest &=3D 0xffffffff; + } + } + gen_jmp_tb(s, dest, tb_num); +} + static void gen_jmp(DisasContext *s, target_ulong eip) { gen_jmp_tb(s, eip, 0); @@ -6862,20 +6878,12 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) break; case 0xe8: /* call im */ { - if (dflag !=3D MO_16) { - tval =3D (int32_t)insn_get(env, s, MO_32); - } else { - tval =3D (int16_t)insn_get(env, s, MO_16); - } - tval +=3D s->pc - s->cs_base; - if (dflag =3D=3D MO_16) { - tval &=3D 0xffff; - } else if (!CODE64(s)) { - tval &=3D 0xffffffff; - } + int diff =3D (dflag !=3D MO_16 + ? (int32_t)insn_get(env, s, MO_32) + : (int16_t)insn_get(env, s, MO_16)); gen_push_v(s, eip_next_tl(s)); gen_bnd_jmp(s); - gen_jmp(s, tval); + gen_jmp_rel(s, dflag, diff, 0); } break; case 0x9a: /* lcall im */ @@ -6893,19 +6901,13 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } goto do_lcall; case 0xe9: /* jmp im */ - if (dflag !=3D MO_16) { - tval =3D (int32_t)insn_get(env, s, MO_32); - } else { - tval =3D (int16_t)insn_get(env, s, MO_16); + { + int diff =3D (dflag !=3D MO_16 + ? (int32_t)insn_get(env, s, MO_32) + : (int16_t)insn_get(env, s, MO_16)); + gen_bnd_jmp(s); + gen_jmp_rel(s, dflag, diff, 0); } - tval +=3D s->pc - s->cs_base; - if (dflag =3D=3D MO_16) { - tval &=3D 0xffff; - } else if (!CODE64(s)) { - tval &=3D 0xffffffff; - } - gen_bnd_jmp(s); - gen_jmp(s, tval); break; case 0xea: /* ljmp im */ { @@ -6922,12 +6924,10 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } goto do_ljmp; case 0xeb: /* jmp Jb */ - tval =3D (int8_t)insn_get(env, s, MO_8); - tval +=3D s->pc - s->cs_base; - if (dflag =3D=3D MO_16) { - tval &=3D 0xffff; + { + int diff =3D (int8_t)insn_get(env, s, MO_8); + gen_jmp_rel(s, dflag, diff, 0); } - gen_jmp(s, tval); break; case 0x70 ... 0x7f: /* jcc Jb */ tval =3D (int8_t)insn_get(env, s, MO_8); --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487719; cv=none; d=zohomail.com; s=zohoarc; b=dj8YtxJb896ktVlJxl/26kMyOTweb80yfO7I7HU8juZcgy/zcO7tgz/XTlI2i60emvL2SNkbnLm6F9+XeB5oXtjOeCNXRcAizpagKoy+401WvM6a3RacPW/4ynm7ENf8IYDraOWwbKox6uK1C6r1th4Bc7KWX4ocpmo83ajnW18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487719; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ote6W2AaAueogA+kCN16Qi/cdYSCsB0VLtYcDEY5NYo=; b=LMox0LTwHgCqfZA7bnnzopDH88woJKQJQxSXMNpEh6QJnQ8WiII6AMG2kxr8shZ0DPES5oOC617UbPVWsWtzTJUK5kZ1hVh2hTECvESRUzVl+vYT+Xv9kAq/bqBX7QNK4r6CsPDtFpW9c5DZQ9qChvCcp23Zo7VLzQLtIUA3Cd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665487719352280.4145061523253; Tue, 11 Oct 2022 04:28:39 -0700 (PDT) Received: from localhost ([::1]:40054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDR7-00070H-3E for importer@patchew.org; Tue, 11 Oct 2022 07:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUg-0002Zz-Nm for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUe-0004bT-M3 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:14 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-364-D5aM4FIrMwWCpPs0Q_Czag-1; Tue, 11 Oct 2022 06:28:11 -0400 Received: by mail-ej1-f72.google.com with SMTP id hr29-20020a1709073f9d00b0078333782c48so5666850ejc.10 for ; Tue, 11 Oct 2022 03:28:10 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id bm22-20020a0564020b1600b0044f21c69608sm8779170edb.10.2022.10.11.03.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ote6W2AaAueogA+kCN16Qi/cdYSCsB0VLtYcDEY5NYo=; b=ELi4SbmyPd+ezDGH4EqQTfsaJhBeAou9ec6FtJMf9A74qUeKVKfDb6rTWXoz5G9OsY3ud5 63NMPjpi+Hxb91KFeBTg887qmF5hCRj1b8mOI2xtDszYl9u4Jd0CmVAikZOg9ZzObvhm/h QzxcN3U9oS0doY72F51ucOG4TfwXH4A= X-MC-Unique: D5aM4FIrMwWCpPs0Q_Czag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ote6W2AaAueogA+kCN16Qi/cdYSCsB0VLtYcDEY5NYo=; b=eh85QKhPzkEc1Z2GtprLvTByMV2Ks5q6A4lWoSRzxstdU7vnxv21gz7nFe6VQ+PJMO 56ukNwHwmPZWfpkl71hxoicB+MJXYAtbQ3jqInpz85kNVS+oCWlFYW2Uopce9sdUBzP7 Vyh1T3GyuvrEgwtZbB8QvZ2SwDtJ6wgzB1zk5ZlDKvY/quqpwpFIuwL11cwIdaJrfoAP DbslAwwfo5d/96axtlhnN8XKiLzGgA2uoNZZAQzrUveVDZgzzFefMwiO8nXbiH4l4dff +AvXRRKQS9CG9We+BauCaRKm5OZqfxGEYccekuLfwzOG/hofsKyJYNlzhLbSHqaU8B5c HWUg== X-Gm-Message-State: ACrzQf1ORSFoEeuArZjJ6c//fZE3hl54nu+Rq9jp3lAFwX6Jrj695YR2 XgB5/0ZPr3wc75tpeQ1YjClXhSj8/6VUTyz8jQV13iay8LI8ha04GxNY9KGzeNlrBwg6K15R0FY NJmlsp4wlFRYRwp2aXGlnDurhgX99vFU5aAIfKIhToWQCcIwDUoCLVeRM1OAPdTDbW+U= X-Received: by 2002:a05:6402:3408:b0:43c:2dd3:d86b with SMTP id k8-20020a056402340800b0043c2dd3d86bmr22405179edc.108.1665484089243; Tue, 11 Oct 2022 03:28:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vsO5GCs68gNsznCCi8R9O3TXrbFt95hXrP/Y/1aO06ICmuSAXNHrgN9MZrKOq/Ol33NtyxQ== X-Received: by 2002:a05:6402:3408:b0:43c:2dd3:d86b with SMTP id k8-20020a056402340800b0043c2dd3d86bmr22405162edc.108.1665484088940; Tue, 11 Oct 2022 03:28:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 23/37] target/i386: Use gen_jmp_rel for loop, repz, jecxz insns Date: Tue, 11 Oct 2022 12:26:46 +0200 Message-Id: <20221011102700.319178-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487720788100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson With gen_jmp_rel, we may chain to the next tb instead of merely writing to eip and exiting. For repz, subtract cur_insn_len to restart the current insn. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-19-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index ba1bd7c707..434a6ad6cd 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -224,9 +224,9 @@ STUB_HELPER(wrmsr, TCGv_env env) =20 static void gen_eob(DisasContext *s); static void gen_jr(DisasContext *s); -static void gen_jmp(DisasContext *s, target_ulong eip); static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num); +static void gen_jmp_rel_csize(DisasContext *s, int diff, int tb_num); static void gen_op(DisasContext *s1, int op, MemOp ot, int d); static void gen_exception_gpf(DisasContext *s); =20 @@ -1185,7 +1185,7 @@ static TCGLabel *gen_jz_ecx_string(DisasContext *s) TCGLabel *l2 =3D gen_new_label(); gen_op_jnz_ecx(s, s->aflag, l1); gen_set_label(l2); - gen_jmp_tb(s, s->pc - s->cs_base, 1); + gen_jmp_rel_csize(s, 0, 1); gen_set_label(l1); return l2; } @@ -1288,7 +1288,7 @@ static void gen_repz(DisasContext *s, MemOp ot, if (s->repz_opt) { gen_op_jz_ecx(s, s->aflag, l2); } - gen_jmp(s, s->base.pc_next - s->cs_base); + gen_jmp_rel_csize(s, -cur_insn_len(s), 0); } =20 #define GEN_REPZ(op) \ @@ -1308,7 +1308,7 @@ static void gen_repz2(DisasContext *s, MemOp ot, int = nz, if (s->repz_opt) { gen_op_jz_ecx(s, s->aflag, l2); } - gen_jmp(s, s->base.pc_next - s->cs_base); + gen_jmp_rel_csize(s, -cur_insn_len(s), 0); } =20 #define GEN_REPZ2(op) \ @@ -2793,6 +2793,7 @@ static void gen_jmp_tb(DisasContext *s, target_ulong = eip, int tb_num) } } =20 +/* Jump to eip+diff, truncating the result to OT. */ static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num) { target_ulong dest =3D s->pc - s->cs_base + diff; @@ -2808,9 +2809,11 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, i= nt diff, int tb_num) gen_jmp_tb(s, dest, tb_num); } =20 -static void gen_jmp(DisasContext *s, target_ulong eip) +/* Jump to eip+diff, truncating to the current code size. */ +static void gen_jmp_rel_csize(DisasContext *s, int diff, int tb_num) { - gen_jmp_tb(s, eip, 0); + /* CODE64 ignores the OT argument, so we need not consider it. */ + gen_jmp_rel(s, CODE32(s) ? MO_32 : MO_16, diff, tb_num); } =20 static inline void gen_ldq_env_A0(DisasContext *s, int offset) @@ -7404,24 +7407,18 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) case 0xe2: /* loop */ case 0xe3: /* jecxz */ { - TCGLabel *l1, *l2, *l3; - - tval =3D (int8_t)insn_get(env, s, MO_8); - tval +=3D s->pc - s->cs_base; - if (dflag =3D=3D MO_16) { - tval &=3D 0xffff; - } + TCGLabel *l1, *l2; + int diff =3D (int8_t)insn_get(env, s, MO_8); =20 l1 =3D gen_new_label(); l2 =3D gen_new_label(); - l3 =3D gen_new_label(); gen_update_cc_op(s); b &=3D 3; switch(b) { case 0: /* loopnz */ case 1: /* loopz */ gen_op_add_reg_im(s, s->aflag, R_ECX, -1); - gen_op_jz_ecx(s, s->aflag, l3); + gen_op_jz_ecx(s, s->aflag, l2); gen_jcc1(s, (JCC_Z << 1) | (b ^ 1), l1); break; case 2: /* loop */ @@ -7434,14 +7431,11 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) break; } =20 - gen_set_label(l3); - gen_update_eip_next(s); - tcg_gen_br(l2); + gen_set_label(l2); + gen_jmp_rel_csize(s, 0, 1); =20 gen_set_label(l1); - gen_jmp_im(s, tval); - gen_set_label(l2); - s->base.is_jmp =3D DISAS_EOB_ONLY; + gen_jmp_rel(s, dflag, diff, 0); } break; case 0x130: /* wrmsr */ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665488133; cv=none; d=zohomail.com; s=zohoarc; b=an0AE8+3oPyX6EJ7yY+hEFjw6gX5RsjShcvdjaWigZnhNpcTMicudtCVeXCvw/dF5CVk+UH8jdDbcbPzBae+h3QAunFq2kNLiA98QqVmWCCz/3HWOtyKOnyGiM4wdTslmQAWGg7tBttoErxRuLG0FBTc4pzsSmIfmw3x6bsj5CQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665488133; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BS2g2X/V4dwTQ7sn/aL9gdQqszEHgXW7A6VLXMpwY9k=; b=Mmu1R4J5X9sUbi+wdtxfUHzbk1yMzw6OOEwMnPKoKQxOdlxfliWVcGEPFiCsPxCq/HnrhzGwWlfl7p9wV2sgrUxyoTGWSDaB6ZmU8xISwkMBiHu9enyaU5N3KjSQ94hMm3rANdHoxNfTNs+ciN5MV4xV1qqkxGWob1M1KYMqbvY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665488132992949.4720251606614; Tue, 11 Oct 2022 04:35:32 -0700 (PDT) Received: from localhost ([::1]:56642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDXn-0003l5-Nz for importer@patchew.org; Tue, 11 Oct 2022 07:35:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUo-0002hi-2s for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUh-0004cG-Af for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:19 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-61-5O-ZKwDtPgm5Al_OkchSyg-1; Tue, 11 Oct 2022 06:28:13 -0400 Received: by mail-ej1-f69.google.com with SMTP id qa14-20020a170907868e00b0078db5ba61bdso1972285ejc.12 for ; Tue, 11 Oct 2022 03:28:13 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id h19-20020a1709063b5300b0078d4c72e2cesm6693572ejf.44.2022.10.11.03.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BS2g2X/V4dwTQ7sn/aL9gdQqszEHgXW7A6VLXMpwY9k=; b=cb/1J58XuMc62/47NIH9TES9p1yqp+X2QU5I3gy1OGPScnNm22jxaE1ZESUdw0PysOd9Kh SupBykHfE9q0svHEqwcphfEB8RkC2M4UKSDfAqndi4BsApX8n0IWEzaSnYWNO9L5K1KT88 fbnUq45++yvDtWrMioekOyVQ2pu3kE0= X-MC-Unique: 5O-ZKwDtPgm5Al_OkchSyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BS2g2X/V4dwTQ7sn/aL9gdQqszEHgXW7A6VLXMpwY9k=; b=1AHt+nI//r0e8pixs4+Omoot0c2dS61KWhzgjIBwrRyDunFnZY5900ofrIHorfCWnP biR9I0Jrj9oWaFSHJJ7O/mk+xWOSRhd82ExawMXJ8dh6q66Np4myU9DdFyT9aLS5xcBH eIliPu/vk2as/BOTr3Ctx9hOyNw6ieHO/0eYJ1E0atXasuccL06sqda7P7tmlBA1mqAC HmdFAFfrxkkY0g3dRFtQaSJ1xVT45s5w5Px9CGs9QvBho2aqk8+ZoN+tU9Tk2os26yt9 Otn62ge7D9xXBKj1DfAQ6tCrNLQ+MT3tCrwa1LhdtZntF6b3FTwo2LNbXz3yepKFuhPt WqLQ== X-Gm-Message-State: ACrzQf0lgqSAT0YXU1KighPBS5SDB/gHvFK68ufAagi0tXTKu5UEis17 cUs4Q2zEy9PmMdStgCb7FWVZKMJjsoiGlKIr/Y+24uVYS+9HHd/hmETgmI6S1uY8tty164CXfBF AMfbp2qVCd2ZshNPAVNtX/v6EkNBxEPSdE0z/tIoffTqywK9jEQHOPI301k8B2Sbi8y4= X-Received: by 2002:a17:907:2c75:b0:78d:c201:e9aa with SMTP id ib21-20020a1709072c7500b0078dc201e9aamr5974321ejc.235.1665484091976; Tue, 11 Oct 2022 03:28:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uXQ5GQcRrYXJI6v+6yZBVduvLHYutyo1E2ZjTl4yGc2o6iKAqOmKD7h51biX2iGPaqZnwNQ== X-Received: by 2002:a17:907:2c75:b0:78d:c201:e9aa with SMTP id ib21-20020a1709072c7500b0078dc201e9aamr5974308ejc.235.1665484091689; Tue, 11 Oct 2022 03:28:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 24/37] target/i386: Use gen_jmp_rel for gen_jcc Date: Tue, 11 Oct 2022 12:26:47 +0200 Message-Id: <20221011102700.319178-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665488133300100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-20-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 57 ++++++++++++------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 434a6ad6cd..5b84be4975 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2409,32 +2409,14 @@ static void gen_goto_tb(DisasContext *s, int tb_num= , target_ulong eip) } } =20 -static inline void gen_jcc(DisasContext *s, int b, - target_ulong val, target_ulong next_eip) +static void gen_jcc(DisasContext *s, int b, int diff) { - TCGLabel *l1, *l2; + TCGLabel *l1 =3D gen_new_label(); =20 - if (s->jmp_opt) { - l1 =3D gen_new_label(); - gen_jcc1(s, b, l1); - - gen_goto_tb(s, 0, next_eip); - - gen_set_label(l1); - gen_goto_tb(s, 1, val); - } else { - l1 =3D gen_new_label(); - l2 =3D gen_new_label(); - gen_jcc1(s, b, l1); - - gen_jmp_im(s, next_eip); - tcg_gen_br(l2); - - gen_set_label(l1); - gen_jmp_im(s, val); - gen_set_label(l2); - gen_eob(s); - } + gen_jcc1(s, b, l1); + gen_jmp_rel_csize(s, 0, 1); + gen_set_label(l1); + gen_jmp_rel(s, s->dflag, diff, 0); } =20 static void gen_cmovcc1(CPUX86State *env, DisasContext *s, MemOp ot, int b, @@ -4780,7 +4762,6 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) int shift; MemOp ot, aflag, dflag; int modrm, reg, rm, mod, op, opreg, val; - target_ulong next_eip, tval; bool orig_cc_op_dirty =3D s->cc_op_dirty; CCOp orig_cc_op =3D s->cc_op; =20 @@ -6933,22 +6914,20 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) } break; case 0x70 ... 0x7f: /* jcc Jb */ - tval =3D (int8_t)insn_get(env, s, MO_8); - goto do_jcc; + { + int diff =3D (int8_t)insn_get(env, s, MO_8); + gen_bnd_jmp(s); + gen_jcc(s, b, diff); + } + break; case 0x180 ... 0x18f: /* jcc Jv */ - if (dflag !=3D MO_16) { - tval =3D (int32_t)insn_get(env, s, MO_32); - } else { - tval =3D (int16_t)insn_get(env, s, MO_16); + { + int diff =3D (dflag !=3D MO_16 + ? (int32_t)insn_get(env, s, MO_32) + : (int16_t)insn_get(env, s, MO_16)); + gen_bnd_jmp(s); + gen_jcc(s, b, diff); } - do_jcc: - next_eip =3D s->pc - s->cs_base; - tval +=3D next_eip; - if (dflag =3D=3D MO_16) { - tval &=3D 0xffff; - } - gen_bnd_jmp(s); - gen_jcc(s, b, tval, next_eip); break; =20 case 0x190 ... 0x19f: /* setcc Gv */ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665488801; cv=none; d=zohomail.com; s=zohoarc; b=mGkA4UbrcTXr5ZZNWzI7WK4GO6u/TrRNAcIlPwrUggyUh0+5SyGiHEdC902C8OVDTIslXernyljJL3CnOykr3Vt93Qn1c9wfEuUFWa8zOt/hQKsX1UwGAhqoYe9y4e4VSDzHRWpkn+Bn+DwacvsboyNzBbnV6ACe8bCU5txSkD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665488801; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jVXWu5so8eiOLbp5V+dPBJ9ZByv5+S3LZqNBcPkJT8s=; b=GDdfdSq07ynDCfIZNvcfxYAN1avzYQk8Uy1gJx9raUJ+6vv1sbNbncWwbq8zedeFqGYEBSEc4/304AJzuX8cX8doVehmn+ylQZnTQVwl5TxwtJhdW7FRVx81/rwDP4Nw4x5LHHVEcQemGBNBDcBhG9v4F3I5svOwiznfc6B1EY0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665488801845266.330032929626; Tue, 11 Oct 2022 04:46:41 -0700 (PDT) Received: from localhost ([::1]:54780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDiY-0001rp-OS for importer@patchew.org; Tue, 11 Oct 2022 07:46:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUr-0002jT-LV for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUk-0004cY-0R for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:24 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-78-SUWF49TPN_WyqSavXXHUlQ-1; Tue, 11 Oct 2022 06:28:16 -0400 Received: by mail-ed1-f69.google.com with SMTP id z9-20020a05640240c900b00458dae4ed9cso10828872edb.3 for ; Tue, 11 Oct 2022 03:28:16 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id ha6-20020a170906a88600b00780f24b797dsm6694115ejb.108.2022.10.11.03.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jVXWu5so8eiOLbp5V+dPBJ9ZByv5+S3LZqNBcPkJT8s=; b=OuMx+FebWTXSjwwBmR3a+jCqiunKsk95GKP5sPmPeqSwbQsUGEOQxtxHZBnJNP10Sbj9rn KV13HXxGkIl5lNgZcvIrdHA67hFvyhQV5/+OmbheTXY+DEMscXDZkF1/+TOXbvtG7sAF3T C6ZVDYHrr9bkXtFaUL5JQJcUAcDnlu0= X-MC-Unique: SUWF49TPN_WyqSavXXHUlQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jVXWu5so8eiOLbp5V+dPBJ9ZByv5+S3LZqNBcPkJT8s=; b=7TXw8l0JoIf/YqbigKIDH8jimsKLeSAYD6svxWcpvVsyY33xwTiRLGshBKnSB15K86 UKq2KTu6LRgCk3PVRNIZfeX1NsRMTqyQw9rYqcrt3birAaqobaUQ2A3CQPFNqFZKqkND s/yZyw5ztaJpVBpxRL9865jkw07bAp5vPSzoxLXEn46n/CVJJytnzoGW6M3anktqLHbV Cn6pI7eWBIE8PVbMdv3C/MehGSXmq8AOPn+J/IX3WmY4mLnRPW58SHVZbeckGOV+z/cI 5+fMPCoX8/S0LpW+E4t5HBW2d8+M+ezIL1C+nHCm28C6s5DGtNAvzZmqiBYJ/7GIgvE6 EknA== X-Gm-Message-State: ACrzQf1cbAkZ1hbnHJRW6kmUIUUjAoI27f7GrXbC3teVvEIY1ZB9L6q5 CvW5SSQiStB29NS9qj96JRiJv1FmHJzW554cJB906ZnSFOWjbMw/6fdI2ei/GAKvFZ9SWm4GAb+ YwZdUVAoi8PcShF7HQ3Xtkwdr2ZPliiQKHP7sdXDmTAIqYH/xmLwxuxK5gVkUv40AbbQ= X-Received: by 2002:a17:907:94d2:b0:783:e5dd:9c79 with SMTP id dn18-20020a17090794d200b00783e5dd9c79mr19257983ejc.18.1665484094789; Tue, 11 Oct 2022 03:28:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5P8nX/CzdZuaXR7CipFIfNgnRUdPQEMqUYe5GtOyhEU9S0We6yMrr0M0YQBUMm2wOkIOgkSg== X-Received: by 2002:a17:907:94d2:b0:783:e5dd:9c79 with SMTP id dn18-20020a17090794d200b00783e5dd9c79mr19257966ejc.18.1665484094541; Tue, 11 Oct 2022 03:28:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 25/37] target/i386: Use gen_jmp_rel for DISAS_TOO_MANY Date: Tue, 11 Oct 2022 12:26:48 +0200 Message-Id: <20221011102700.319178-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665488802506100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson With gen_jmp_rel, we may chain between two translation blocks which may only be separated because of TB size limits. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20221001140935.465607-21-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 5b84be4975..cf23ae6e5e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8798,6 +8798,9 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase,= CPUState *cpu) case DISAS_NORETURN: break; case DISAS_TOO_MANY: + gen_update_cc_op(dc); + gen_jmp_rel_csize(dc, 0, 0); + break; case DISAS_EOB_NEXT: gen_update_cc_op(dc); gen_update_eip_cur(dc); --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665486949; cv=none; d=zohomail.com; s=zohoarc; b=BX+fct69J9zTiTt/t0YYp2RnmRYpKCr5MFRYZEgl70ZZLOVT30sq7Gr+P+G1v6pU5C0+AHFJaY+zW2VTEDKS+l1TBUFjd+t8XyFMAB/qRuxYuIcG/3nRaQ53cr7Xqm+yiGOlpb5kQOsUbpw97+AyqkiJqNijIKJVizlOPnIYK3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665486949; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LrWqTWcEMDRoPxbx50bbd53b/m9uxh55LIU7TOsyOQ0=; b=SvOVmp0Pe2IJeWhnbPS2LV5B6ZxlmOBIgseQnoIekJpDBMOxeUDArSHkTrEoaOqD77eAVmA4U39Zdz8RvRvv00o0e2NFNjjwgvqfZ1nXX+OHuGiKs3b93CSQhxBBFb88kVAC9TuSitCUYBBMCfsBhuLOBviKGAkucJFjH9YzTso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665486949789403.40872012136344; Tue, 11 Oct 2022 04:15:49 -0700 (PDT) Received: from localhost ([::1]:35266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDEi-0005IX-9p for importer@patchew.org; Tue, 11 Oct 2022 07:15:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUv-0002pN-Ot for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUm-0004dM-TK for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:29 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-392-NW0DE9wqPh-gxBFGaOCLxA-1; Tue, 11 Oct 2022 06:28:19 -0400 Received: by mail-ed1-f70.google.com with SMTP id q17-20020a056402519100b00459a2e5adbcso10914248edd.16 for ; Tue, 11 Oct 2022 03:28:18 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id l2-20020aa7c302000000b00459cf672a65sm8907660edq.71.2022.10.11.03.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrWqTWcEMDRoPxbx50bbd53b/m9uxh55LIU7TOsyOQ0=; b=CQprChcJHL8k7MijvTM5NkWfQAHYMbtmNjvAEjTom/Noczz+fRTR5umNOZ3sBAjrXfD12f 8wMCaLHRKzxDOksLwP6ziCdwox6RwK9nyvPOtu25gCownd3DiRzaS2Aku8/ZUDY8uvhEKk JzF+yenK736vGnsvdlvPDdpABgIiDlk= X-MC-Unique: NW0DE9wqPh-gxBFGaOCLxA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LrWqTWcEMDRoPxbx50bbd53b/m9uxh55LIU7TOsyOQ0=; b=StYvUW/OqolnqTQprGIT7nIfptBStw+DLnuX2+j13hPWEgDsBlbdIE3dfNwW61l4Cj 8rlXD9wlQjxaAELDsysn8PmYopakbJRtnuX/l8306KjB3zvEhjqiigPgoL0BYAgE+5c8 l6fwwxv35PQYpIdjSLaQv2BkYTuc9zoG+aPt0N08z3rsDsOykfHq1ckgC3QxQWIK5K7u cpkva61mfemC0Uo4jMq0VHyrRasr8Mn4Ts3S88cGdzG3+kMN9SuM4gQ+ZXZISnpnwvM/ nj2gsLgXxPR8uE55+acApPmCS8TMhx78EhJNcQEHnNO3XHEqvSgrlv7Vznm513l/tmQP Lmag== X-Gm-Message-State: ACrzQf12zTGXWiaVKsGQc88do671TmE4tIIIAIpg0cE3rJYtfNNBFRtd s2spHUTlBfeboO27MDgYEjOgwkpkqViwEgo6OVp/mvhH+DUHzp0bfAPql3ykfzDCvdkMiYnReaO onyWz8ALc/ZrZs4PaYDaXR5KGkuF9iJlkDzoaNFmWiVCISXWNCBLiw6G6yH6PQl5jA0M= X-Received: by 2002:a05:6402:298b:b0:44f:20a:2db2 with SMTP id eq11-20020a056402298b00b0044f020a2db2mr22596140edb.138.1665484097440; Tue, 11 Oct 2022 03:28:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WbSO/9CC72oSORUXdrJapEjErhG2QFA44Q4GW/4LRi5xEzET8rDzYBv4wgImq01tMghTFxA== X-Received: by 2002:a05:6402:298b:b0:44f:20a:2db2 with SMTP id eq11-20020a056402298b00b0044f020a2db2mr22596119edb.138.1665484097049; Tue, 11 Oct 2022 03:28:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 26/37] target/i386: Remove MemOp argument to gen_op_j*_ecx Date: Tue, 11 Oct 2022 12:26:49 +0200 Message-Id: <20221011102700.319178-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665486950960100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These functions are always passed aflag, so we might as well read it from DisasContext directly. While we're at it, use a common subroutine for these two functions. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-22-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index cf23ae6e5e..9294f12f66 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -676,20 +676,21 @@ static void gen_exts(MemOp ot, TCGv reg) gen_ext_tl(reg, reg, ot, true); } =20 -static inline -void gen_op_jnz_ecx(DisasContext *s, MemOp size, TCGLabel *label1) +static void gen_op_j_ecx(DisasContext *s, TCGCond cond, TCGLabel *label1) { tcg_gen_mov_tl(s->tmp0, cpu_regs[R_ECX]); - gen_extu(size, s->tmp0); - tcg_gen_brcondi_tl(TCG_COND_NE, s->tmp0, 0, label1); + gen_extu(s->aflag, s->tmp0); + tcg_gen_brcondi_tl(cond, s->tmp0, 0, label1); } =20 -static inline -void gen_op_jz_ecx(DisasContext *s, MemOp size, TCGLabel *label1) +static inline void gen_op_jz_ecx(DisasContext *s, TCGLabel *label1) { - tcg_gen_mov_tl(s->tmp0, cpu_regs[R_ECX]); - gen_extu(size, s->tmp0); - tcg_gen_brcondi_tl(TCG_COND_EQ, s->tmp0, 0, label1); + gen_op_j_ecx(s, TCG_COND_EQ, label1); +} + +static inline void gen_op_jnz_ecx(DisasContext *s, TCGLabel *label1) +{ + gen_op_j_ecx(s, TCG_COND_NE, label1); } =20 static void gen_helper_in_func(MemOp ot, TCGv v, TCGv_i32 n) @@ -1183,7 +1184,7 @@ static TCGLabel *gen_jz_ecx_string(DisasContext *s) { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); - gen_op_jnz_ecx(s, s->aflag, l1); + gen_op_jnz_ecx(s, l1); gen_set_label(l2); gen_jmp_rel_csize(s, 0, 1); gen_set_label(l1); @@ -1286,7 +1287,7 @@ static void gen_repz(DisasContext *s, MemOp ot, * before rep string_insn */ if (s->repz_opt) { - gen_op_jz_ecx(s, s->aflag, l2); + gen_op_jz_ecx(s, l2); } gen_jmp_rel_csize(s, -cur_insn_len(s), 0); } @@ -1306,7 +1307,7 @@ static void gen_repz2(DisasContext *s, MemOp ot, int = nz, gen_update_cc_op(s); gen_jcc1(s, (JCC_Z << 1) | (nz ^ 1), l2); if (s->repz_opt) { - gen_op_jz_ecx(s, s->aflag, l2); + gen_op_jz_ecx(s, l2); } gen_jmp_rel_csize(s, -cur_insn_len(s), 0); } @@ -7397,16 +7398,16 @@ static bool disas_insn(DisasContext *s, CPUState *c= pu) case 0: /* loopnz */ case 1: /* loopz */ gen_op_add_reg_im(s, s->aflag, R_ECX, -1); - gen_op_jz_ecx(s, s->aflag, l2); + gen_op_jz_ecx(s, l2); gen_jcc1(s, (JCC_Z << 1) | (b ^ 1), l1); break; case 2: /* loop */ gen_op_add_reg_im(s, s->aflag, R_ECX, -1); - gen_op_jnz_ecx(s, s->aflag, l1); + gen_op_jnz_ecx(s, l1); break; default: case 3: /* jcxz */ - gen_op_jz_ecx(s, s->aflag, l1); + gen_op_jz_ecx(s, l1); break; } =20 --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665489442; cv=none; d=zohomail.com; s=zohoarc; b=AvmxuAzk+CEzrqg1cD9S4o/VMU0LKm1wwzTVIDRBUJt+eQro8k3DNVFe63K7atNF0TLP8Dy8N+amrMOaDx87PAGOJ9WMfsqj7GGo3MTAhuOJiEriKY/W7e0ET4575JmSUyNPRFTXkp4FPH9lh5F1C0ShLzV6iS6WA0JtHk02KXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665489442; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EFnej+uDib6DJO6FPJHynwF9HcD37KVfoaE0mz0H0dU=; b=M+bWisuwLXmleI6G6wGrwHS7EB2ScDEEVZX0I+llL8qEXCu+k/SDkNOrXKci5TgiVjamkEVrv5b2rI3tEBneA3J5FudRVbGyg4EmelRoHui+ZY0shRFbfH+hy8i4NXvdN8b2tL5IYM7y/Pt3ginXCJkXPQq6I+1wD9E6B/3xtac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665489442980271.5800893617791; Tue, 11 Oct 2022 04:57:22 -0700 (PDT) Received: from localhost ([::1]:52162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDsv-0008TX-VR for importer@patchew.org; Tue, 11 Oct 2022 07:57:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUt-0002kt-A0 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUr-0004ep-BA for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:27 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-267-Zctqsl16NqSqjqoftk1O6Q-1; Tue, 11 Oct 2022 06:28:21 -0400 Received: by mail-ed1-f71.google.com with SMTP id m13-20020a056402510d00b0045c1a055ee7so3955524edd.22 for ; Tue, 11 Oct 2022 03:28:21 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id b1-20020a1709063ca100b0078175601630sm6578620ejh.79.2022.10.11.03.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFnej+uDib6DJO6FPJHynwF9HcD37KVfoaE0mz0H0dU=; b=Llzjke9DjWoHWoytAd3pmPGyNeFkGIVG0nBQ8f/iXXgLtSmzHTeT2vNGitNCBhi4Pfu2Cn Nk1fg3p3jKNx2Fc8wrdLHOmKzqhMYImErlYNX3rJ0r5SFy2jC2NxBmCKI7TdbalLSJfGvN J4ExnJ39uhoaz2bc3wIT+TbzFsp3Pd8= X-MC-Unique: Zctqsl16NqSqjqoftk1O6Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EFnej+uDib6DJO6FPJHynwF9HcD37KVfoaE0mz0H0dU=; b=QT/cGIyU3wsKu+YAaz7aUViq9/ZZQya2CeeygZPlzHI8yqKCTORblKSl6/ISFYOD5U k5WBHp5hGPofas+15ClBA4tWN2gC+VXszXSTm8L65pWwhyYcgtZwNsdxnvqQqVUlGuPL eq5mihcpkJzGAzs385XsS8zOrPMvcU5hwv0S2sTo2UU0Uhi4Ust/nM98JXQaGksg3Y4f cIMgOd5PEExy3XwWP4biuL93YadE4juyQLEiSWpNIS6cBTIe0G5AWv45fMd159pPafLS hax4OaG2/YZH1wvArDZxvcG6+upmWVm3WG4TCtsGHhtnirhRR+FndYgLqz8BV4FAfkDr lOjg== X-Gm-Message-State: ACrzQf1dEAvieltJOCg0tahdo8/faPpaDcuniSMAzQfOzhrunBH20525 0bsFevLE0H3N5N1LRSnj6h9vZEcVPeEtRc/dCTtJL7bRSQ7TiM3GiLX2ZhPrEdzkK20i3LbJera eWjmoy3nkD2/H63tdNwfR9nVtXv0d/kKYBuAbZxZQkbZYc/+Z5tCq8YOmTnz/GHO/XIA= X-Received: by 2002:a05:6402:3552:b0:45c:1e45:6f92 with SMTP id f18-20020a056402355200b0045c1e456f92mr8780767edd.4.1665484100227; Tue, 11 Oct 2022 03:28:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM590uL+wPoIfpZqUJA7cpbm8zkWyxpu6eoRcGPp9sNlLHdSNg3rieLetRusI4/3Di4mSrXZeg== X-Received: by 2002:a05:6402:3552:b0:45c:1e45:6f92 with SMTP id f18-20020a056402355200b0045c1e456f92mr8780740edd.4.1665484099851; Tue, 11 Oct 2022 03:28:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 27/37] target/i386: Merge gen_jmp_tb and gen_goto_tb into gen_jmp_rel Date: Tue, 11 Oct 2022 12:26:50 +0200 Message-Id: <20221011102700.319178-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665489445366100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These functions have only one caller, and the logic is more obvious this way. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-23-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 50 +++++++++++++------------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 9294f12f66..2e7b94700b 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -224,7 +224,6 @@ STUB_HELPER(wrmsr, TCGv_env env) =20 static void gen_eob(DisasContext *s); static void gen_jr(DisasContext *s); -static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num); static void gen_jmp_rel_csize(DisasContext *s, int diff, int tb_num); static void gen_op(DisasContext *s1, int op, MemOp ot, int d); @@ -2393,23 +2392,6 @@ static inline int insn_const_size(MemOp ot) } } =20 -static void gen_goto_tb(DisasContext *s, int tb_num, target_ulong eip) -{ - target_ulong pc =3D s->cs_base + eip; - - if (translator_use_goto_tb(&s->base, pc)) { - /* jump to same page: we can use a direct jump */ - tcg_gen_goto_tb(tb_num); - gen_jmp_im(s, eip); - tcg_gen_exit_tb(s->base.tb, tb_num); - s->base.is_jmp =3D DISAS_NORETURN; - } else { - /* jump to another page */ - gen_jmp_im(s, eip); - gen_jr(s); - } -} - static void gen_jcc(DisasContext *s, int b, int diff) { TCGLabel *l1 =3D gen_new_label(); @@ -2762,20 +2744,6 @@ static void gen_jr(DisasContext *s) do_gen_eob_worker(s, false, false, true); } =20 -/* generate a jump to eip. No segment change must happen before as a - direct call to the next block may occur */ -static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num) -{ - gen_update_cc_op(s); - set_cc_op(s, CC_OP_DYNAMIC); - if (s->jmp_opt) { - gen_goto_tb(s, tb_num, eip); - } else { - gen_jmp_im(s, eip); - gen_eob(s); - } -} - /* Jump to eip+diff, truncating the result to OT. */ static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num) { @@ -2789,7 +2757,23 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, i= nt diff, int tb_num) dest &=3D 0xffffffff; } } - gen_jmp_tb(s, dest, tb_num); + + gen_update_cc_op(s); + set_cc_op(s, CC_OP_DYNAMIC); + if (!s->jmp_opt) { + gen_jmp_im(s, dest); + gen_eob(s); + } else if (translator_use_goto_tb(&s->base, dest)) { + /* jump to same page: we can use a direct jump */ + tcg_gen_goto_tb(tb_num); + gen_jmp_im(s, dest); + tcg_gen_exit_tb(s->base.tb, tb_num); + s->base.is_jmp =3D DISAS_NORETURN; + } else { + /* jump to another page */ + gen_jmp_im(s, dest); + gen_jr(s); + } } =20 /* Jump to eip+diff, truncating to the current code size. */ --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665488369; cv=none; d=zohomail.com; s=zohoarc; b=MHBP9d+HoNKrvJTziIC7EhciuMYiJGXCe8P1wDPwsD9WhocFDG/oVdaiXNsJ/eOTbdiEVrtpZGW+a/DFzTR/aoOsmbec2RWypPoUZOLxj1vooSsc7tqqQThZs5B6k5CEdPgtiY4vAtbo1zPSN3AEDzqfSmpdbw60fVI7xGJonGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665488369; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N5pThQV+AvZ9qttyOk+iasHOEoXj0JYQzOLb7Lr/VZk=; b=k+YXL9AXTVky8k+pxdmeAp+n4gykxFt/ll6WkIJ0ikf2hPs2cv+E355bOow+DWi3Iz9w/YptZ/LBKwmQnlsCz+ZpLChtF7LNNVTDonREcLME/4A8o0s4eCG+vk7IJytJ8hslw6+mTCy0IhuhvQb7QHlXtZxzkXbn/snxe+Mh9FI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665488369518786.295210301231; Tue, 11 Oct 2022 04:39:29 -0700 (PDT) Received: from localhost ([::1]:38384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDbT-0005M0-N3 for importer@patchew.org; Tue, 11 Oct 2022 07:39:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUu-0002n5-HL for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUs-0004fS-37 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:28 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-464-Qy1dy20SM0mJdbqslkBsig-1; Tue, 11 Oct 2022 06:28:24 -0400 Received: by mail-ed1-f71.google.com with SMTP id f18-20020a056402355200b0045c13ee57d9so4151415edd.20 for ; Tue, 11 Oct 2022 03:28:24 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id k5-20020a1709063fc500b0077f4f63a6f4sm6694752ejj.112.2022.10.11.03.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N5pThQV+AvZ9qttyOk+iasHOEoXj0JYQzOLb7Lr/VZk=; b=amXkIRykIDBzCE6MFyCsHl2pFRWWCOYV7aeJMN/TsIHMPFrT3D+nRa3mAOwnGbpt+qRnjJ 9pzE4IMc+FFJgPikdxmFEx+WKqgFewiujjVRHD+9MzbQqfnwgB96A/PQOPYqFLZIN3uv7H qQT0/Ror67rYDEl4WiOYU6hZrW7uGyo= X-MC-Unique: Qy1dy20SM0mJdbqslkBsig-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N5pThQV+AvZ9qttyOk+iasHOEoXj0JYQzOLb7Lr/VZk=; b=aXEB8z8bEwXol7NRgAdq2Bxcenptm9icQx5Cjz34WFVLUJWVq1qFt9W5RNbi3RQyjN /iI/iaWjM6lL2tQtqIRrgqDp/yQP52vAMLuPw1OiFX0fDeZ01hN0YubcV42pLh9Lhu7b RGIBG9rA1zAHncuqkkvdOkfhypAZIeQfy3FN6869xZIdgpOBIztMCMQr4l0DFK+P4tKG KS8k5n+Ja1oqOoHaC4j+r89gagheF16tKl0KaVHCgB0kXFOW+PGQ/R9Jx1MuMehkY5oU dCqITI3CsD+ShnfZZfbbWN7Gqm369JmFjLNjo/ptkySi7RXaHzMgiWfFxSNqD5fjJ9Gs dqOw== X-Gm-Message-State: ACrzQf3M/zqwMZ/r6G5fgEPls0FXWaCwe2nowSnh5PNgvdL84Etk+bnY 4XXDi4ePYdbXdTuUzmbRs+0nQ/QVhfyPN2WQcJBV1Zc6xyeq3WCIaivMvKiy5X5BdmzRJiHOXFn hpMWdH6zwi1d4vaQgyIWnghHNXzRcpFQxsh90ZKeK3g6Gy7qHCLGPql3++DEiWjdOcZs= X-Received: by 2002:a17:907:6e9e:b0:78c:5533:4158 with SMTP id sh30-20020a1709076e9e00b0078c55334158mr17662740ejc.417.1665484102818; Tue, 11 Oct 2022 03:28:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71UWjCw/CrXOHFUorTW8QP3KyR0R0ScZSYxLkDWlVBsu8jWFPjGPkR+MaRT7vf1p6GXjU0wQ== X-Received: by 2002:a17:907:6e9e:b0:78c:5533:4158 with SMTP id sh30-20020a1709076e9e00b0078c55334158mr17662722ejc.417.1665484102510; Tue, 11 Oct 2022 03:28:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 28/37] target/i386: Create eip_cur_tl Date: Tue, 11 Oct 2022 12:26:51 +0200 Message-Id: <20221011102700.319178-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665488371263100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-24-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 2e7b94700b..5b0dab8633 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -562,6 +562,11 @@ static TCGv eip_next_tl(DisasContext *s) return tcg_constant_tl(s->pc - s->cs_base); } =20 +static TCGv eip_cur_tl(DisasContext *s) +{ + return tcg_constant_tl(s->base.pc_next - s->cs_base); +} + /* Compute SEG:REG into A0. SEG is selected from the override segment (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to indicate no override. */ @@ -6617,7 +6622,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) offsetof(CPUX86State, segs[R_CS].selector)); tcg_gen_st16_i32(s->tmp2_i32, cpu_env, offsetof(CPUX86State, fpcs)); - tcg_gen_st_tl(tcg_constant_tl(s->base.pc_next - s->cs_base= ), + tcg_gen_st_tl(eip_cur_tl(s), cpu_env, offsetof(CPUX86State, fpip)); } } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665489963; cv=none; d=zohomail.com; s=zohoarc; b=FadYw1pcwJvgnPh2IRXCdF7IsuN6Q/igTVwEK8d/qdu7kfEOv5Mn8mYRVBvA3xffSmHYap3CMWicFOGb/JCLoS6YIwqA3ADBW9b7kcsnLszVUz7nvcZ3jS6dsKWnNGWHjo1NFVqnuqykZQ4fhXgHYi5bAD7Cut4GwKgDobO01EA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665489963; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r+0BlhMhr7upwayvFPnSFtEzgUe1qz5fNNE2zB0W/f8=; b=NEnuvj0JS1VyxQ4DHOAlj6inpX7zXNsIGLQbj13K16hi7CEyu4QCmouHU/koTvmP19cqbpYxwwZCXF/GXq1TXk8+lxEXzzwyG55a0IcJ6fC5pxa+0OUhxR4kVupj06+KoC6IZUGNxE6vGRXVxrGB7OmT3rtsTHPPyPQ0fA5D1mw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665489963709222.56545007148554; Tue, 11 Oct 2022 05:06:03 -0700 (PDT) Received: from localhost ([::1]:46070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiE1K-0006Hj-Kp for importer@patchew.org; Tue, 11 Oct 2022 08:06:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUw-0002pR-3q for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUu-0004gI-M9 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:29 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-126-AN4jFmwyNlOnDjVkmHY9AQ-1; Tue, 11 Oct 2022 06:28:26 -0400 Received: by mail-ej1-f69.google.com with SMTP id gb42-20020a170907962a00b0078d194624a9so5722003ejc.11 for ; Tue, 11 Oct 2022 03:28:26 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id g22-20020a170906199600b0078ae49ad169sm5090905ejd.91.2022.10.11.03.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+0BlhMhr7upwayvFPnSFtEzgUe1qz5fNNE2zB0W/f8=; b=NY1Ng/OEztMFYpt78Bvp8Oh+iaZ8L9kL1RzP8ZecOwJPLwfMWkQBafP0mSiqoBDCUN3xVG LVSoeG8X5JRq1rufx7RRxRQJEVRA56aWXZi3oecbf4aS+k02NfQW340IRQqf1lY4L3oY/8 b4xnQs0BxM1Csr0pCzTjwBvYaxflnrM= X-MC-Unique: AN4jFmwyNlOnDjVkmHY9AQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r+0BlhMhr7upwayvFPnSFtEzgUe1qz5fNNE2zB0W/f8=; b=qdSsy8m00o72dvojS0YnyHLjGYH8GoptyUT3pRCiHQ9eTNlMHYFiirK6ELIRn/wVpQ BnovajzgCGbLY/aJn102L4rZcjfY6M3MlfQOdN5OkzR2eTFiWT1jOwB29T51p1ZynK+G LT7sG3MChE7vvyF0NLCDLMxoSGcRqt9etBzpvai9hNPS6gIRON6BkBXpsg62UiRRuGw/ z2GMV2S7kCVGqqQQfkbW880+426/bzPNNqG0QkmP6iZEYFRrFhtViA9sLJn9a1RsfQ5t f/fvmmQV/nmvkVZZmPfLw2E7+lnyYC8f2OPkpagjfqM5F7eVI7ICLt4Dh5amS9olsimX shsA== X-Gm-Message-State: ACrzQf3oIps7m5tyRtEiLgSOsLiIQbxrGDhGge55e/++y6AB/0PV7Jrf P+ofl6GbUnQGIU5tEfDP+gbVXB3i+OoB9LYdmnqG7mV1pUfudIrJhv27XKotiA+up6188Unk2ip yHn8EPquqL78I6WD3+AuqdAxvRu/VAEUenVraeGi6nh08qLAzoQNs+B0QPZNbl4r037U= X-Received: by 2002:a17:907:78d:b0:740:33e1:998 with SMTP id xd13-20020a170907078d00b0074033e10998mr18564003ejb.162.1665484105327; Tue, 11 Oct 2022 03:28:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68eLHK+v9/EuSWhhRF1xPQUsx9oMWA9QVvAL36PBcjflohLN+TrQ5GI1+156d+gGS97wKeow== X-Received: by 2002:a17:907:78d:b0:740:33e1:998 with SMTP id xd13-20020a170907078d00b0074033e10998mr18563981ejb.162.1665484105012; Tue, 11 Oct 2022 03:28:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 29/37] target/i386: Add cpu_eip Date: Tue, 11 Oct 2022 12:26:52 +0200 Message-Id: <20221011102700.319178-30-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665489965909100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Create a tcg global temp for this, and use it instead of explicit stores. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-25-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 5b0dab8633..f08fa060c4 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -64,6 +64,7 @@ =20 /* global register indexes */ static TCGv cpu_cc_dst, cpu_cc_src, cpu_cc_src2; +static TCGv cpu_eip; static TCGv_i32 cpu_cc_op; static TCGv cpu_regs[CPU_NB_REGS]; static TCGv cpu_seg_base[6]; @@ -481,7 +482,7 @@ static void gen_add_A0_im(DisasContext *s, int val) =20 static inline void gen_op_jmp_v(TCGv dest) { - tcg_gen_st_tl(dest, cpu_env, offsetof(CPUX86State, eip)); + tcg_gen_mov_tl(cpu_eip, dest); } =20 static inline @@ -518,7 +519,7 @@ static inline void gen_op_st_rm_T0_A0(DisasContext *s, = int idx, int d) =20 static void gen_jmp_im(DisasContext *s, target_ulong pc) { - gen_op_jmp_v(tcg_constant_tl(pc)); + tcg_gen_movi_tl(cpu_eip, pc); } =20 static void gen_update_eip_cur(DisasContext *s) @@ -8614,6 +8615,13 @@ void tcg_x86_init(void) [R_EDI] =3D "edi", [R_EBP] =3D "ebp", [R_ESP] =3D "esp", +#endif + }; + static const char eip_name[] =3D { +#ifdef TARGET_X86_64 + "rip" +#else + "eip" #endif }; static const char seg_base_names[6][8] =3D { @@ -8640,6 +8648,7 @@ void tcg_x86_init(void) "cc_src"); cpu_cc_src2 =3D tcg_global_mem_new(cpu_env, offsetof(CPUX86State, cc_s= rc2), "cc_src2"); + cpu_eip =3D tcg_global_mem_new(cpu_env, offsetof(CPUX86State, eip), ei= p_name); =20 for (i =3D 0; i < CPU_NB_REGS; ++i) { cpu_regs[i] =3D tcg_global_mem_new(cpu_env, --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665490459; cv=none; d=zohomail.com; s=zohoarc; b=n/7jmDgfloewn7x7bdF4u5aTqUr5AFAauX3AtcDYzsU2A7fEM+OY7DFuAO2h7/TAgpGTOEQEVfNbvNTvDFqWAad6FZCn94OkYbxBZqzlLMspzV5bsfZOjgSI7AnBeiLcoSbtSr5S1oVR/I4raA6r0le6mcqvvOIMaDeeVzbgzOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665490459; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t4ucLDA6j0Bbg/VI+XXeZRk9uHhKo2fz6ppRd8eMxBo=; b=fy92wEjS3KhgGU8wWB+WF+VgPPLEH0nT0oicHBHKwpLmHmTTiK8emL5vYPdrJC6XyGumiCJ+KZikNuXcqLrs7eiDu4Roy4QcKXOeArbuCw7hLRwFffzC6yk4ZV7A1IX3hIoenvzzIkjpSFWhoL9JP3ea0kFqkv5cxQcjrraVEr4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665490459117740.3566840353546; Tue, 11 Oct 2022 05:14:19 -0700 (PDT) Received: from localhost ([::1]:33396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiE9J-00048e-SR for importer@patchew.org; Tue, 11 Oct 2022 08:14:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUz-0002wn-Mx for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCUx-0004iO-Az for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:33 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-240-AfNAiWYZPVuJvLH39pK4ug-1; Tue, 11 Oct 2022 06:28:29 -0400 Received: by mail-ej1-f71.google.com with SMTP id qa14-20020a170907868e00b0078db5ba61bdso1972614ejc.12 for ; Tue, 11 Oct 2022 03:28:29 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id 16-20020a170906311000b0073ce4abf093sm6656229ejx.214.2022.10.11.03.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t4ucLDA6j0Bbg/VI+XXeZRk9uHhKo2fz6ppRd8eMxBo=; b=TD6rrMP5QbKisTBl1OSIAecdHjG6SrDgl++GA9EFmVqOelLgKAGh6UO/UFu2Pk5Qc59bvz yiAuv4q9Le/l1BcudWqSj+MCV2/DzEqQQ87M4wve8YqqgCc1vGNEl2vQB4RGve3Ywq6NhT OmPs+ermd3ruNPFX7AELg+jzVA1cNUQ= X-MC-Unique: AfNAiWYZPVuJvLH39pK4ug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t4ucLDA6j0Bbg/VI+XXeZRk9uHhKo2fz6ppRd8eMxBo=; b=XpDx1/5vCxNGLDemkRdbYTA4IcWrppEbNKaRHe8NcvaqwzQnWsMS1eBD8jjrxiO+nB uTlQMAKYg1bYrv7QTroNJ072HDaH/YJEP17JkXlTd7W3J9VIFLmvm2MGlZZ8ZvHZdHxb RamKwGQBlp8xegnR9o+B+0uiglSP6TzoNDcYxugKFJzb9UWBTGKCnUB2YHO7ksMNDNy0 tg/7pUySRLicdO0OLeQDRVcxo6z8ZFSmFoIl2KQ3Zeviq3oGmBZHZud5r3g9h1cxl4AS xmp/QgWAGZvRw/ftYfxAkv6Ue5Oo7erOYxjXJ8LZoa0LZWLKlzx+k1yodgh34z128D2x xxTA== X-Gm-Message-State: ACrzQf1Gv5Yd0XRcBnVqa0C+sMhSD69WQ9FgiVWu1DEuY5xUl/dNBqP5 2aOcfWXPW1KdyY0t3Qiwwte/aHAyH6Vfpeldrm4tTW0XtUTyTtcllvbZurRBgNIB3LtPDjGWLPf /+6DfXO+2YzCawwbhufCxt4Sr0uH71L3AZAfe8S63j63j9WXcHC4TZDALV3Mrwo3kbLw= X-Received: by 2002:a17:906:eec9:b0:783:e662:2513 with SMTP id wu9-20020a170906eec900b00783e6622513mr18095900ejb.656.1665484108074; Tue, 11 Oct 2022 03:28:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/3j0AALCWDjiE7xBniRkM2V/zH/Oe7gk1s8f4Vj+S2fmfrwhgeVvAfPsX70kPhgNlUavdTA== X-Received: by 2002:a17:906:eec9:b0:783:e662:2513 with SMTP id wu9-20020a170906eec900b00783e6622513mr18095883ejb.656.1665484107842; Tue, 11 Oct 2022 03:28:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 30/37] target/i386: Inline gen_jmp_im Date: Tue, 11 Oct 2022 12:26:53 +0200 Message-Id: <20221011102700.319178-31-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665490459644100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Expand this function at each of its callers. Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-26-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index f08fa060c4..689a45256c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -517,19 +517,14 @@ static inline void gen_op_st_rm_T0_A0(DisasContext *s= , int idx, int d) } } =20 -static void gen_jmp_im(DisasContext *s, target_ulong pc) -{ - tcg_gen_movi_tl(cpu_eip, pc); -} - static void gen_update_eip_cur(DisasContext *s) { - gen_jmp_im(s, s->base.pc_next - s->cs_base); + tcg_gen_movi_tl(cpu_eip, s->base.pc_next - s->cs_base); } =20 static void gen_update_eip_next(DisasContext *s) { - gen_jmp_im(s, s->pc - s->cs_base); + tcg_gen_movi_tl(cpu_eip, s->pc - s->cs_base); } =20 static int cur_insn_len(DisasContext *s) @@ -2767,17 +2762,17 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, = int diff, int tb_num) gen_update_cc_op(s); set_cc_op(s, CC_OP_DYNAMIC); if (!s->jmp_opt) { - gen_jmp_im(s, dest); + tcg_gen_movi_tl(cpu_eip, dest); gen_eob(s); } else if (translator_use_goto_tb(&s->base, dest)) { /* jump to same page: we can use a direct jump */ tcg_gen_goto_tb(tb_num); - gen_jmp_im(s, dest); + tcg_gen_movi_tl(cpu_eip, dest); tcg_gen_exit_tb(s->base.tb, tb_num); s->base.is_jmp =3D DISAS_NORETURN; } else { /* jump to another page */ - gen_jmp_im(s, dest); + tcg_gen_movi_tl(cpu_eip, dest); gen_jr(s); } } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487243; cv=none; d=zohomail.com; s=zohoarc; b=Nsi/4B7ytmLWG/BvV5Htmy3KsBaC/krjV6/cyfk+BeKjRuHnlObM3Fwv0JPf4nfHrkWnXm0CpaDsLp8BdZ/2d4yUB2sPBK4LhYeglnYgYZ1if+X0iga1/m7iOwhr/vkF0WPwI4ac1V3M2fgn3iDf9XttDHwWtuSMNFpoGH5TLJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487243; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NTxqgtmvM6vM7LoW1rTnMsxQj7jZW6AAYTeeVOeHAoQ=; b=e3aA1f86B9p0hswhJXDIaeKWzVBgUo0XAby5URkkwVzUsLxRwYfeLX540AgFW3o1d/OUJSpI9BUKkwc7GOzRxGoLQVoJ+P6GCmZHVw1j8Rn+4L5XoeBxmhgXmsN5BWuUUtHiOSZ9S7g5NUNTmBAZA8IRypxGSQwHA3co14oPOjk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665487243126552.6338288259177; Tue, 11 Oct 2022 04:20:43 -0700 (PDT) Received: from localhost ([::1]:46188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDJR-00033a-VF for importer@patchew.org; Tue, 11 Oct 2022 07:20:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV2-00034q-GC for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV0-0004jI-Dl for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:36 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-339-TtvrMpv3MpyNI8Cq-cxbeg-1; Tue, 11 Oct 2022 06:28:32 -0400 Received: by mail-ej1-f71.google.com with SMTP id sc11-20020a1709078a0b00b0078d95df8a2eso2345689ejc.2 for ; Tue, 11 Oct 2022 03:28:32 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id z11-20020aa7d40b000000b00458d50b4a24sm8689358edq.96.2022.10.11.03.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NTxqgtmvM6vM7LoW1rTnMsxQj7jZW6AAYTeeVOeHAoQ=; b=KVcIql57foioWKOfXJg6tUDIWiarkZmTcuT5x+QbKaVyXjpzmhU4NDKs4celb+GdA9YlS9 jSbhAM3+IRo5pl7eI2ID5MzypQWSFxRYPaomZHCefS3nPNvLr+7G/J9/QdR9WQ3ksbxrte +JRLq/MUijKWDNd0p8CeYF5z42RTU74= X-MC-Unique: TtvrMpv3MpyNI8Cq-cxbeg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NTxqgtmvM6vM7LoW1rTnMsxQj7jZW6AAYTeeVOeHAoQ=; b=4F3SDa3jDijupVK6sArjL7Krim5ZN9CFzcl5h1ajQfzdjdgH/E+6qM6BSZ++fcEHT5 vFc53/bM+JJgflwOwJA8mxyEPJ3vh1dGGu9Js5udzJMVlc2R+eCCaKxiydHqZSyGunYV K9P39HT0mgHKzBTgFPsTilA7ygXyoXqDSmue77cFiI1IJ4jDMoBUk22+qegNg/fEvpKr sTWCB8GV9m8rtpsCpUk4m7tHS4Jsj/JrbYTBdbL0yfonJyQf40iJQObyd6lW1Rob3pES xPW9f9BGT4JeH6Nc05NVzI1y9hH+49xd3sjWuV9oQzGRajqpRzxIJzeWJGtMKVHJdoSi hVRQ== X-Gm-Message-State: ACrzQf1xBgk/TJ5LPUs256qFIwmlfLq7n+dVObzc4ZbQawsqftVEkj0p Nx1fCY713k1+xBf89SLlRC9BapUb9nTikuxGlgBseRwTr9PN8MT8xX7UVoWnfd1n4x7QpMhC3Ye vmAwBcs3u8rfkxtLp/KM1wWkjBoR+kUl2PsrSfGFg1yf6ifmkcrkoGisX8S0033qHZ1k= X-Received: by 2002:a17:907:6d8f:b0:78d:9b5e:1a0f with SMTP id sb15-20020a1709076d8f00b0078d9b5e1a0fmr12804330ejc.23.1665484110887; Tue, 11 Oct 2022 03:28:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4K1Z+XmHhUryG/sjGgHZv3yp9ooRmMd/lRn0FH3eljSn1mNrP8FIgHK9xVEO4Iil0i2uukUw== X-Received: by 2002:a17:907:6d8f:b0:78d:9b5e:1a0f with SMTP id sb15-20020a1709076d8f00b0078d9b5e1a0fmr12804306ejc.23.1665484110457; Tue, 11 Oct 2022 03:28:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 31/37] target/i386: Enable TARGET_TB_PCREL Date: Tue, 11 Oct 2022 12:26:54 +0200 Message-Id: <20221011102700.319178-32-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487243523100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini Message-Id: <20221001140935.465607-27-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/cpu-param.h | 4 ++ target/i386/tcg/tcg-cpu.c | 8 ++- target/i386/tcg/translate.c | 130 ++++++++++++++++++++++++++++-------- 3 files changed, 113 insertions(+), 29 deletions(-) diff --git a/target/i386/cpu-param.h b/target/i386/cpu-param.h index 9740bd7abd..1e79389761 100644 --- a/target/i386/cpu-param.h +++ b/target/i386/cpu-param.h @@ -25,4 +25,8 @@ #define TARGET_PAGE_BITS 12 #define NB_MMU_MODES 3 =20 +#ifndef CONFIG_USER_ONLY +# define TARGET_TB_PCREL 1 +#endif + #endif diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 6cf14c83ff..828244abe2 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -49,9 +49,11 @@ static void x86_cpu_exec_exit(CPUState *cs) static void x86_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - X86CPU *cpu =3D X86_CPU(cs); - - cpu->env.eip =3D tb_pc(tb) - tb->cs_base; + /* The instruction pointer is always up to date with TARGET_TB_PCREL. = */ + if (!TARGET_TB_PCREL) { + CPUX86State *env =3D cs->env_ptr; + env->eip =3D tb_pc(tb) - tb->cs_base; + } } =20 #ifndef CONFIG_USER_ONLY diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 689a45256c..279a3ae999 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -78,6 +78,7 @@ typedef struct DisasContext { =20 target_ulong pc; /* pc =3D eip + cs_base */ target_ulong cs_base; /* base of CS segment */ + target_ulong pc_save; =20 MemOp aflag; MemOp dflag; @@ -480,9 +481,10 @@ static void gen_add_A0_im(DisasContext *s, int val) } } =20 -static inline void gen_op_jmp_v(TCGv dest) +static inline void gen_op_jmp_v(DisasContext *s, TCGv dest) { tcg_gen_mov_tl(cpu_eip, dest); + s->pc_save =3D -1; } =20 static inline @@ -519,12 +521,24 @@ static inline void gen_op_st_rm_T0_A0(DisasContext *s= , int idx, int d) =20 static void gen_update_eip_cur(DisasContext *s) { - tcg_gen_movi_tl(cpu_eip, s->base.pc_next - s->cs_base); + assert(s->pc_save !=3D -1); + if (TARGET_TB_PCREL) { + tcg_gen_addi_tl(cpu_eip, cpu_eip, s->base.pc_next - s->pc_save); + } else { + tcg_gen_movi_tl(cpu_eip, s->base.pc_next - s->cs_base); + } + s->pc_save =3D s->base.pc_next; } =20 static void gen_update_eip_next(DisasContext *s) { - tcg_gen_movi_tl(cpu_eip, s->pc - s->cs_base); + assert(s->pc_save !=3D -1); + if (TARGET_TB_PCREL) { + tcg_gen_addi_tl(cpu_eip, cpu_eip, s->pc - s->pc_save); + } else { + tcg_gen_movi_tl(cpu_eip, s->pc - s->cs_base); + } + s->pc_save =3D s->pc; } =20 static int cur_insn_len(DisasContext *s) @@ -539,6 +553,7 @@ static TCGv_i32 cur_insn_len_i32(DisasContext *s) =20 static TCGv_i32 eip_next_i32(DisasContext *s) { + assert(s->pc_save !=3D -1); /* * This function has two users: lcall_real (always 16-bit mode), and * iret_protected (16, 32, or 64-bit mode). IRET only uses the value @@ -550,17 +565,38 @@ static TCGv_i32 eip_next_i32(DisasContext *s) if (CODE64(s)) { return tcg_constant_i32(-1); } - return tcg_constant_i32(s->pc - s->cs_base); + if (TARGET_TB_PCREL) { + TCGv_i32 ret =3D tcg_temp_new_i32(); + tcg_gen_trunc_tl_i32(ret, cpu_eip); + tcg_gen_addi_i32(ret, ret, s->pc - s->pc_save); + return ret; + } else { + return tcg_constant_i32(s->pc - s->cs_base); + } } =20 static TCGv eip_next_tl(DisasContext *s) { - return tcg_constant_tl(s->pc - s->cs_base); + assert(s->pc_save !=3D -1); + if (TARGET_TB_PCREL) { + TCGv ret =3D tcg_temp_new(); + tcg_gen_addi_tl(ret, cpu_eip, s->pc - s->pc_save); + return ret; + } else { + return tcg_constant_tl(s->pc - s->cs_base); + } } =20 static TCGv eip_cur_tl(DisasContext *s) { - return tcg_constant_tl(s->base.pc_next - s->cs_base); + assert(s->pc_save !=3D -1); + if (TARGET_TB_PCREL) { + TCGv ret =3D tcg_temp_new(); + tcg_gen_addi_tl(ret, cpu_eip, s->base.pc_next - s->pc_save); + return ret; + } else { + return tcg_constant_tl(s->base.pc_next - s->cs_base); + } } =20 /* Compute SEG:REG into A0. SEG is selected from the override segment @@ -2260,7 +2296,12 @@ static TCGv gen_lea_modrm_1(DisasContext *s, Address= Parts a) ea =3D cpu_regs[a.base]; } if (!ea) { - tcg_gen_movi_tl(s->A0, a.disp); + if (TARGET_TB_PCREL && a.base =3D=3D -2) { + /* With cpu_eip ~=3D pc_save, the expression is pc-relative. */ + tcg_gen_addi_tl(s->A0, cpu_eip, a.disp - s->pc_save); + } else { + tcg_gen_movi_tl(s->A0, a.disp); + } ea =3D s->A0; } else if (a.disp !=3D 0) { tcg_gen_addi_tl(s->A0, ea, a.disp); @@ -2748,32 +2789,58 @@ static void gen_jr(DisasContext *s) /* Jump to eip+diff, truncating the result to OT. */ static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num) { - target_ulong dest =3D s->pc - s->cs_base + diff; + bool use_goto_tb =3D s->jmp_opt; + target_ulong mask =3D -1; + target_ulong new_pc =3D s->pc + diff; + target_ulong new_eip =3D new_pc - s->cs_base; =20 /* In 64-bit mode, operand size is fixed at 64 bits. */ if (!CODE64(s)) { if (ot =3D=3D MO_16) { - dest &=3D 0xffff; + mask =3D 0xffff; + if (TARGET_TB_PCREL && CODE32(s)) { + use_goto_tb =3D false; + } } else { - dest &=3D 0xffffffff; + mask =3D 0xffffffff; } } + new_eip &=3D mask; =20 gen_update_cc_op(s); set_cc_op(s, CC_OP_DYNAMIC); - if (!s->jmp_opt) { - tcg_gen_movi_tl(cpu_eip, dest); - gen_eob(s); - } else if (translator_use_goto_tb(&s->base, dest)) { + + if (TARGET_TB_PCREL) { + tcg_gen_addi_tl(cpu_eip, cpu_eip, new_pc - s->pc_save); + /* + * If we can prove the branch does not leave the page and we have + * no extra masking to apply (data16 branch in code32, see above), + * then we have also proven that the addition does not wrap. + */ + if (!use_goto_tb || !is_same_page(&s->base, new_pc)) { + tcg_gen_andi_tl(cpu_eip, cpu_eip, mask); + use_goto_tb =3D false; + } + } + + if (use_goto_tb && + translator_use_goto_tb(&s->base, new_eip + s->cs_base)) { /* jump to same page: we can use a direct jump */ tcg_gen_goto_tb(tb_num); - tcg_gen_movi_tl(cpu_eip, dest); + if (!TARGET_TB_PCREL) { + tcg_gen_movi_tl(cpu_eip, new_eip); + } tcg_gen_exit_tb(s->base.tb, tb_num); s->base.is_jmp =3D DISAS_NORETURN; } else { - /* jump to another page */ - tcg_gen_movi_tl(cpu_eip, dest); - gen_jr(s); + if (!TARGET_TB_PCREL) { + tcg_gen_movi_tl(cpu_eip, new_eip); + } + if (s->jmp_opt) { + gen_jr(s); /* jump to another page */ + } else { + gen_eob(s); /* exit to main loop */ + } } } =20 @@ -5329,7 +5396,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_ext16u_tl(s->T0, s->T0); } gen_push_v(s, eip_next_tl(s)); - gen_op_jmp_v(s->T0); + gen_op_jmp_v(s, s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; break; @@ -5359,7 +5426,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (dflag =3D=3D MO_16) { tcg_gen_ext16u_tl(s->T0, s->T0); } - gen_op_jmp_v(s->T0); + gen_op_jmp_v(s, s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; break; @@ -5377,7 +5444,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) eip_next_tl(s)); } else { gen_op_movl_seg_T0_vm(s, R_CS); - gen_op_jmp_v(s->T1); + gen_op_jmp_v(s, s->T1); } s->base.is_jmp =3D DISAS_JUMP; break; @@ -6792,7 +6859,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) ot =3D gen_pop_T0(s); gen_stack_update(s, val + (1 << ot)); /* Note that gen_pop_T0 uses a zero-extending load. */ - gen_op_jmp_v(s->T0); + gen_op_jmp_v(s, s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; break; @@ -6800,7 +6867,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) ot =3D gen_pop_T0(s); gen_pop_update(s, ot); /* Note that gen_pop_T0 uses a zero-extending load. */ - gen_op_jmp_v(s->T0); + gen_op_jmp_v(s, s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; break; @@ -6818,7 +6885,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_op_ld_v(s, dflag, s->T0, s->A0); /* NOTE: keeping EIP updated is not a problem in case of exception */ - gen_op_jmp_v(s->T0); + gen_op_jmp_v(s, s->T0); /* pop selector */ gen_add_A0_im(s, 1 << dflag); gen_op_ld_v(s, dflag, s->T0, s->A0); @@ -8680,6 +8747,7 @@ static void i386_tr_init_disas_context(DisasContextBa= se *dcbase, CPUState *cpu) int iopl =3D (flags >> IOPL_SHIFT) & 3; =20 dc->cs_base =3D dc->base.tb->cs_base; + dc->pc_save =3D dc->base.pc_next; dc->flags =3D flags; #ifndef CONFIG_USER_ONLY dc->cpl =3D cpl; @@ -8743,9 +8811,14 @@ static void i386_tr_tb_start(DisasContextBase *db, C= PUState *cpu) static void i386_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); + target_ulong pc_arg =3D dc->base.pc_next; =20 dc->prev_insn_end =3D tcg_last_op(); - tcg_gen_insn_start(dc->base.pc_next, dc->cc_op); + if (TARGET_TB_PCREL) { + pc_arg -=3D dc->cs_base; + pc_arg &=3D ~TARGET_PAGE_MASK; + } + tcg_gen_insn_start(pc_arg, dc->cc_op); } =20 static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) @@ -8846,7 +8919,12 @@ void restore_state_to_opc(CPUX86State *env, Translat= ionBlock *tb, target_ulong *data) { int cc_op =3D data[1]; - env->eip =3D data[0] - tb->cs_base; + + if (TARGET_TB_PCREL) { + env->eip =3D (env->eip & TARGET_PAGE_MASK) | data[0]; + } else { + env->eip =3D data[0] - tb->cs_base; + } if (cc_op !=3D CC_OP_DYNAMIC) { env->cc_op =3D cc_op; } --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487315; cv=none; d=zohomail.com; s=zohoarc; b=JhiXm+7YjpSXtWdRqd8S9RFQZ5//jMJttoiW0GNNCjVqE028Y008StHHuGKraPBvxnCQTsr7y09oEJLSYxeICE0RHFK1wynrtO0iffMXZZJ2ek85E8Wetoq0P61gbLUbXLZ0ydNn4bapZwCPLvrtDsnTJK8mgKIv5//gKRxJ+0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487315; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ye3ewl4aeYucCtQhLF/MRjPSh0R7ZVGDM5ummeQfq3c=; b=mq4AlsOucleBGFMMTWUiMXkiQ9cwpavoYnC7brdGAjyBIsMTEYnqzAg7LTiAVWPV1wtOjY141S755vN058tYia5KWI/8zxq/vz1Fe/2KFn8L7Vng4EQjReNP6jlhZdvQ/vCLL2wlR6dsDg4BN3/YNMoOnBz5aX8CnhHV71ZBNHc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665487315636475.27281307014823; Tue, 11 Oct 2022 04:21:55 -0700 (PDT) Received: from localhost ([::1]:43838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDKc-00042Z-EA for importer@patchew.org; Tue, 11 Oct 2022 07:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV4-00036S-8a for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV2-0004js-L4 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:37 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-483-fWHYdA3RMHeubzJ_0ppuLg-1; Tue, 11 Oct 2022 06:28:34 -0400 Received: by mail-ed1-f69.google.com with SMTP id s17-20020a056402521100b0045bfaaab697so4639671edd.1 for ; Tue, 11 Oct 2022 03:28:34 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id f13-20020a056402160d00b0044657ecfbb5sm8803464edv.13.2022.10.11.03.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ye3ewl4aeYucCtQhLF/MRjPSh0R7ZVGDM5ummeQfq3c=; b=VzccYkVOGsxaqZSJexqqtjpQKpo6Gg4JWSjI/9P8X1pvmSIDjPDPF/nPcXS0iEdBgQFs+/ oDpBPYWoHsbNA8DFauDPb7kf4hms9ptGEM2GOS01m6Kq21vkODHr+CHGZpA2dmiZ39JX4w Q2Pk1AYUEfauTBr0vn/cnZs6StdgydI= X-MC-Unique: fWHYdA3RMHeubzJ_0ppuLg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ye3ewl4aeYucCtQhLF/MRjPSh0R7ZVGDM5ummeQfq3c=; b=jKi0xAxUZRlwwvkNQpv+WunQnFBHEvBxTHz3/GG2bfHgj5if+BsI6ulJZ6l0H2PDk7 W6qJwkUw/hS89fNTvK8L/x3IRWsfUp6qRNf8r2Tb53B/qm95Fh/gvI9UphgY39ZDlKTc +BRGgvmTPPtSeuxjRkJxIpYOJ55ZCKvOkro3OPweWhlphK+ysvNxMe/wCGoZhsseY3Zk nmnIAmZU8HGCDpmiKDnTQcPBq1A9Gd+b7J0NxejhNBRPl3dKjV54bLRH+N87zssWvrbw DQBcDh2T1S3NGrIFy3CIGXAMZzKAUJgukqFtX8kMtgiZhcA19zR6HIR3l/W7/6WVIiXC rwVQ== X-Gm-Message-State: ACrzQf2KxGKISWo33ymXchOtWuQ63QHt7nJaIxkuiNPAy2+JAochE6Jj lNthej/kV+VvdEYmyRgC/dbPjzkWXpwMLTWllciSLhV9NZQOVUujawkHzhneJvwycJPnq1rlFNU u9JsPnYEq7eXtXwT3p8AVqsvf5/9njNePuEKOPH4GJChqEndtopQfSY+toBFicPkM3tA= X-Received: by 2002:a17:906:15ca:b0:78d:b7b3:2afa with SMTP id l10-20020a17090615ca00b0078db7b32afamr7399889ejd.69.1665484113315; Tue, 11 Oct 2022 03:28:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bEh2FFNsl+r5bsWf7bGhCy/esq98jEHQVALRgNT6bnAvXcBh2XSxHi4CpFoxHZ0yeMfp4MQ== X-Received: by 2002:a17:906:15ca:b0:78d:b7b3:2afa with SMTP id l10-20020a17090615ca00b0078db7b32afamr7399873ejd.69.1665484113060; Tue, 11 Oct 2022 03:28:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alexander Graf Subject: [PULL 32/37] x86: Implement MSR_CORE_THREAD_COUNT MSR Date: Tue, 11 Oct 2022 12:26:55 +0200 Message-Id: <20221011102700.319178-33-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487316302100001 Content-Type: text/plain; charset="utf-8" From: Alexander Graf Intel CPUs starting with Haswell-E implement a new MSR called MSR_CORE_THREAD_COUNT which exposes the number of threads and cores inside of a package. This MSR is used by XNU to populate internal data structures and not implementing it prevents virtual machines with more than 1 vCPU from booting if the emulated CPU generation is at least Haswell-E. This patch propagates the existing hvf logic from patch 027ac0cb516 ("target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT") to TCG. Signed-off-by: Alexander Graf Message-Id: <20221004225643.65036-2-agraf@csgraf.de> Signed-off-by: Paolo Bonzini --- target/i386/tcg/sysemu/misc_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index 1328aa656f..e1528b7f80 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -450,6 +450,11 @@ void helper_rdmsr(CPUX86State *env) case MSR_IA32_UCODE_REV: val =3D x86_cpu->ucode_rev; break; + case MSR_CORE_THREAD_COUNT: { + CPUState *cs =3D CPU(x86_cpu); + val =3D (cs->nr_threads * cs->nr_cores) | (cs->nr_cores << 16); + break; + } default: if ((uint32_t)env->regs[R_ECX] >=3D MSR_MC0_CTL && (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL + --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665489544; cv=none; d=zohomail.com; s=zohoarc; b=fkFll/4juciNBNkVkzQp0OYykX5qBnl1yV8aEC6jsyQ/WkKKawNaIe6q+8UDPlc7vXO67vWKIgTsR/DlE3ItThKNoky7o+DCrdQzG4XiqyS6PyJGQpOhF1NwYf1YxLLW2Jjg87rD+Xb+puCe8kok5fOfexgwFnLWwyGEUJRuoU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665489544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ToFPMhLJnVe4uVf1Dq7DLra+WggrapIIKxhyIyn0yQA=; b=h0tW5jHiFZLVvpJ5GQ9CRdLLkvaIL6axZrZ03qjb1INuTy/1FLFnmtecke6y74uQ9eyTjoFZ5E/aKPucu8somd186kieyT5aIgnpHVUzT8GqRsJ0dh4wVLM4g3cJAiELP6USqmrb3165NTcDQ/P5Y18VzRl228TH7Rt53MO9oBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665489544297514.5610338456837; Tue, 11 Oct 2022 04:59:04 -0700 (PDT) Received: from localhost ([::1]:54712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDuZ-0001nm-8O for importer@patchew.org; Tue, 11 Oct 2022 07:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVI-0003CA-T7 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:29:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV5-0004kH-A4 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:51 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-68-fn9OJxgJMsm3-VQmZDQcRw-1; Tue, 11 Oct 2022 06:28:37 -0400 Received: by mail-ed1-f72.google.com with SMTP id r16-20020a05640251d000b004599cfb8b95so10726203edd.5 for ; Tue, 11 Oct 2022 03:28:37 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id p20-20020a170906785400b00782e3cf7277sm6563938ejm.120.2022.10.11.03.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ToFPMhLJnVe4uVf1Dq7DLra+WggrapIIKxhyIyn0yQA=; b=DXxqskLNqf2KEAokgdQ75UWzzO6gJpdTaOO5+9GT7MVG8lDKyOETRH99hXXg0w8iL+3i7c n4xNO6T9M4eOI4XAIdD88lCXs5FKuMsDClsGBs9gHgyDbAhcKOATsRXAkOa9Z0jZcY1hMF gaVlslh1eCu7XT/ZjmhiXjsn4ojkaXM= X-MC-Unique: fn9OJxgJMsm3-VQmZDQcRw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ToFPMhLJnVe4uVf1Dq7DLra+WggrapIIKxhyIyn0yQA=; b=zEfCghsdAo0s32LRa94vEJSW8eDAgi7FS5tfuGWWba4GhhF8LhYHe4xIEYiM2UqL2x /YrQtjTe0o0X/zq+Yjwqcb+d4KrSAGomI53cGjfW9iaEhRVUMdg2KTYDQjeD5lhZokBt zECusVVfvNpnpZIu7ZiH/SoEgfxZshB2Ai7EBfjAAF8py0xbC9OD5DSLw3HsjobVGEiH kroXF5kTFB7dnjGZiccum8B6xF0z7BJCz95iMO6UYOFvKjMOw8A7Wul4ai0C8Wqyb9ak v1IWXuVw3IfJgr4in6O0vZTujHNZgthOLcH/Cvkc9B2sAjFVeM3wlB7LrnNlgBR7q3U2 FYNA== X-Gm-Message-State: ACrzQf3JcXKFk61HYaW5Jl1eeHll7vuD48gFlsNzTxNXxZiaGp8FV1mq RJ432YL80jJRpH6lppWIPO4pWS8uZ5gEddNAqC2RWY3huiha5RWL0ycWpL4quPXNyp8u3LT9z2z O2YpLUbaIy/4JsnBtia2n5w4Hzpob3ABNh/GFtwYkPo5GKkFMMT/TqWt2zj5sj6yZAFg= X-Received: by 2002:a05:6402:40ce:b0:45a:b277:d94 with SMTP id z14-20020a05640240ce00b0045ab2770d94mr17170557edb.327.1665484116079; Tue, 11 Oct 2022 03:28:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7RsFO6jnr2CvADD5+4nj++ks03gnXMiPJwoeoUM0iEf55OSgKCLw01tGM1x9WH/43OOJeqIg== X-Received: by 2002:a05:6402:40ce:b0:45a:b277:d94 with SMTP id z14-20020a05640240ce00b0045ab2770d94mr17170538edb.327.1665484115781; Tue, 11 Oct 2022 03:28:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alexander Graf Subject: [PULL 33/37] i386: kvm: Add support for MSR filtering Date: Tue, 11 Oct 2022 12:26:56 +0200 Message-Id: <20221011102700.319178-34-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665489545354100001 Content-Type: text/plain; charset="utf-8" From: Alexander Graf KVM has grown support to deflect arbitrary MSRs to user space since Linux 5.10. For now we don't expect to make a lot of use of this feature, so let's expose it the easiest way possible: With up to 16 individually maskable MSRs. This patch adds a kvm_filter_msr() function that other code can call to install a hook on KVM MSR reads or writes. Signed-off-by: Alexander Graf Message-Id: <20221004225643.65036-3-agraf@csgraf.de> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 123 +++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 11 ++++ 2 files changed, 134 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ec63b5eb10..1d9a50b02b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -141,6 +141,8 @@ static struct kvm_cpuid2 *cpuid_cache; static struct kvm_cpuid2 *hv_cpuid_cache; static struct kvm_msr_list *kvm_feature_msrs; =20 +static KVMMSRHandlers msr_handlers[KVM_MSR_FILTER_MAX_RANGES]; + #define BUS_LOCK_SLICE_TIME 1000000000ULL /* ns */ static RateLimit bus_lock_ratelimit_ctrl; static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value); @@ -2610,6 +2612,15 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return ret; } } + if (kvm_vm_check_extension(s, KVM_CAP_X86_USER_SPACE_MSR)) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_USER_SPACE_MSR, 0, + KVM_MSR_EXIT_REASON_FILTER); + if (ret) { + error_report("Could not enable user space MSRs: %s", + strerror(-ret)); + exit(1); + } + } =20 return 0; } @@ -5109,6 +5120,108 @@ void kvm_arch_update_guest_debug(CPUState *cpu, str= uct kvm_guest_debug *dbg) } } =20 +static bool kvm_install_msr_filters(KVMState *s) +{ + uint64_t zero =3D 0; + struct kvm_msr_filter filter =3D { + .flags =3D KVM_MSR_FILTER_DEFAULT_ALLOW, + }; + int r, i, j =3D 0; + + for (i =3D 0; i < KVM_MSR_FILTER_MAX_RANGES; i++) { + KVMMSRHandlers *handler =3D &msr_handlers[i]; + if (handler->msr) { + struct kvm_msr_filter_range *range =3D &filter.ranges[j++]; + + *range =3D (struct kvm_msr_filter_range) { + .flags =3D 0, + .nmsrs =3D 1, + .base =3D handler->msr, + .bitmap =3D (__u8 *)&zero, + }; + + if (handler->rdmsr) { + range->flags |=3D KVM_MSR_FILTER_READ; + } + + if (handler->wrmsr) { + range->flags |=3D KVM_MSR_FILTER_WRITE; + } + } + } + + r =3D kvm_vm_ioctl(s, KVM_X86_SET_MSR_FILTER, &filter); + if (r) { + return false; + } + + return true; +} + +bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr, + QEMUWRMSRHandler *wrmsr) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(msr_handlers); i++) { + if (!msr_handlers[i].msr) { + msr_handlers[i] =3D (KVMMSRHandlers) { + .msr =3D msr, + .rdmsr =3D rdmsr, + .wrmsr =3D wrmsr, + }; + + if (!kvm_install_msr_filters(s)) { + msr_handlers[i] =3D (KVMMSRHandlers) { }; + return false; + } + + return true; + } + } + + return false; +} + +static int kvm_handle_rdmsr(X86CPU *cpu, struct kvm_run *run) +{ + int i; + bool r; + + for (i =3D 0; i < ARRAY_SIZE(msr_handlers); i++) { + KVMMSRHandlers *handler =3D &msr_handlers[i]; + if (run->msr.index =3D=3D handler->msr) { + if (handler->rdmsr) { + r =3D handler->rdmsr(cpu, handler->msr, + (uint64_t *)&run->msr.data); + run->msr.error =3D r ? 0 : 1; + return 0; + } + } + } + + assert(false); +} + +static int kvm_handle_wrmsr(X86CPU *cpu, struct kvm_run *run) +{ + int i; + bool r; + + for (i =3D 0; i < ARRAY_SIZE(msr_handlers); i++) { + KVMMSRHandlers *handler =3D &msr_handlers[i]; + if (run->msr.index =3D=3D handler->msr) { + if (handler->wrmsr) { + r =3D handler->wrmsr(cpu, handler->msr, run->msr.data); + run->msr.error =3D r ? 0 : 1; + return 0; + } + } + } + + assert(false); +} + static bool has_sgx_provisioning; =20 static bool __kvm_enable_sgx_provisioning(KVMState *s) @@ -5226,6 +5339,16 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_ru= n *run) ret =3D 0; } break; + case KVM_EXIT_X86_RDMSR: + /* We only enable MSR filtering, any other exit is bogus */ + assert(run->msr.reason =3D=3D KVM_MSR_EXIT_REASON_FILTER); + ret =3D kvm_handle_rdmsr(cpu, run); + break; + case KVM_EXIT_X86_WRMSR: + /* We only enable MSR filtering, any other exit is bogus */ + assert(run->msr.reason =3D=3D KVM_MSR_EXIT_REASON_FILTER); + ret =3D kvm_handle_wrmsr(cpu, run); + break; default: fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); ret =3D -1; diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 4124912c20..2ed586c11b 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -54,4 +54,15 @@ uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address); bool kvm_enable_sgx_provisioning(KVMState *s); void kvm_request_xsave_components(X86CPU *cpu, uint64_t mask); =20 +typedef bool QEMURDMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t *val); +typedef bool QEMUWRMSRHandler(X86CPU *cpu, uint32_t msr, uint64_t val); +typedef struct kvm_msr_handlers { + uint32_t msr; + QEMURDMSRHandler *rdmsr; + QEMUWRMSRHandler *wrmsr; +} KVMMSRHandlers; + +bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr, + QEMUWRMSRHandler *wrmsr); + #endif --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665488038; cv=none; d=zohomail.com; s=zohoarc; b=AxbDjuBHF2TmD47K4If163LoXbveTAwTJ73by6LmMaAQJjlm2ElFdUv7YkMN4Wn29ZKlB7keVKVjuDcgcW4Yj5WoYDjq3c6UB/X3zBpIlgjFJSGGs4p5wYBGmVbTfUjzZ+Fuu2nSjSdBvgnyb7P02S2jxFiWL+R+gkBxgdahHBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665488038; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lE+3hIF+2PbZ4iuQRADvCSs4OnkRFVpQtiwM4PqIKgY=; b=mIlG31V1L0xseozKMPOf0vrfGPv9fbIEnJchcwdRIfJilu8x5RV6Iyd8tR+399w047Xp2f4gefZsqzcBZ3JX2lWC+bV7kIqgOiSHG/2uWDczhUsIgfF9LPl7mkSr5X6wssXb2sz21BhqrKZVXRMzoGhAigB/OsadfKhWt7uZzqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665488038554762.0815107189766; Tue, 11 Oct 2022 04:33:58 -0700 (PDT) Received: from localhost ([::1]:60058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDWH-00034G-9J for importer@patchew.org; Tue, 11 Oct 2022 07:33:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVD-0003BZ-8D for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCV8-0004kj-01 for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:43 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-557-_CP4BGgKPUqW6jb6dA_4Qg-1; Tue, 11 Oct 2022 06:28:40 -0400 Received: by mail-ej1-f72.google.com with SMTP id xh12-20020a170906da8c00b007413144e87fso5666245ejb.14 for ; Tue, 11 Oct 2022 03:28:39 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id v2-20020a170906292200b0077086d2db8esm6825395ejd.140.2022.10.11.03.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lE+3hIF+2PbZ4iuQRADvCSs4OnkRFVpQtiwM4PqIKgY=; b=LIiknybvfczb/1ifm5jExKMT7sczy3J4MU3+UjOxcAmK7hBQvMJVgWWMdirE/lr7Ku5K/q mcBksfyzk8VZI2lePuUN4/UsuPG3lvw3b33hd0w1GJBf9gVH5h6AJTGKd93qPDW9TGvz+D TcibtDv3H3E/R6BAdtn9PGVpXAk53xY= X-MC-Unique: _CP4BGgKPUqW6jb6dA_4Qg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lE+3hIF+2PbZ4iuQRADvCSs4OnkRFVpQtiwM4PqIKgY=; b=vG5cAQDIzkNEVm1R+aGwg9k99dNcOhnv9eFHCopG2oIaYYa+yhl89vBl0Ytwr6dGar S5ivdN9MnDhSbDvhHODnDEdEGlkJLqfrD6nh8XqdQ8iSjaDMflTLkTMHYyiiNjOE5IgI p3A8YL6xY1QsL7BRuiso0G9qppptxEod94rCbOQl/JOGymum3ic8NV3jHGb14bfT5cAA e/6vdfkURq3wvukTn+8G3JlMo83YqMpx12i2N7FfBiLNpSwHWt0N7YV3QZg8DrSmDWYa cf9UO+TitTMg5P0simzqMJ88ImCJ7k7T54JBxb20HKHDFkdE8SGLqcKtRddsZ4HpeR1B dbNA== X-Gm-Message-State: ACrzQf1o6CrKPoHubdvR7Baz2GLt2/PumaCQRDxCvf9d2Y+xaJvrJJIX XhKCx7xJAB+/k5p5XKY3BishA1oy2PmsCVDzLR1bqxjjXQZWQPr6mLFhuSiGfQ8QJ+8Il2qaScR SNv3drbm5ZyjIiHD+qh0/IctwO28wE0WSEP+FO88nC3sj8xl/xRlKh5icVvSZ6cMDD60= X-Received: by 2002:a17:907:80b:b0:77a:86a1:db52 with SMTP id wv11-20020a170907080b00b0077a86a1db52mr18968205ejb.294.1665484118794; Tue, 11 Oct 2022 03:28:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YcTz8m1Hx6sGXsMeg43+DDr+EuVVm93XuzMLR7P63eDTAp/flbW0jlh65eO/qlq9ZDCBJAA== X-Received: by 2002:a17:907:80b:b0:77a:86a1:db52 with SMTP id wv11-20020a170907080b00b0077a86a1db52mr18968194ejb.294.1665484118569; Tue, 11 Oct 2022 03:28:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alexander Graf Subject: [PULL 34/37] KVM: x86: Implement MSR_CORE_THREAD_COUNT MSR Date: Tue, 11 Oct 2022 12:26:57 +0200 Message-Id: <20221011102700.319178-35-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665488040759100001 Content-Type: text/plain; charset="utf-8" From: Alexander Graf The MSR_CORE_THREAD_COUNT MSR describes CPU package topology, such as number of threads and cores for a given package. This is information that QEMU has readily available and can provide through the new user space MSR deflection interface. This patch propagates the existing hvf logic from patch 027ac0cb516 ("target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT") to KVM. Signed-off-by: Alexander Graf Message-Id: <20221004225643.65036-4-agraf@csgraf.de> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 1d9a50b02b..bed6c00f2c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2401,6 +2401,17 @@ static int kvm_get_supported_msrs(KVMState *s) return ret; } =20 +static bool kvm_rdmsr_core_thread_count(X86CPU *cpu, uint32_t msr, + uint64_t *val) +{ + CPUState *cs =3D CPU(cpu); + + *val =3D cs->nr_threads * cs->nr_cores; /* thread count, bits 15..0 */ + *val |=3D ((uint32_t)cs->nr_cores << 16); /* core count, bits 31..16 */ + + return true; +} + static Notifier smram_machine_done; static KVMMemoryListener smram_listener; static AddressSpace smram_address_space; @@ -2613,6 +2624,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } if (kvm_vm_check_extension(s, KVM_CAP_X86_USER_SPACE_MSR)) { + bool r; + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_USER_SPACE_MSR, 0, KVM_MSR_EXIT_REASON_FILTER); if (ret) { @@ -2620,6 +2633,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s) strerror(-ret)); exit(1); } + + r =3D kvm_filter_msr(s, MSR_CORE_THREAD_COUNT, + kvm_rdmsr_core_thread_count, NULL); + if (!r) { + error_report("Could not install MSR_CORE_THREAD_COUNT handler:= %s", + strerror(-ret)); + exit(1); + } } =20 return 0; --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665488998; cv=none; d=zohomail.com; s=zohoarc; b=GRlfwERi/eEgC6RP9/34/68SRQyQfQiHoFrGWluQ89d41wUhpUQPvB0oV10qOzJh3Mmx/Bu3tNL6ZRzKv4V0CSssLLSVlzgRtlUEkuqEVovjdfh52AFLH6RkHuZ4TpOfpAkHT9Cm5Qs+ipzRXaWKNrz3V7iJPNmeHFrPuOKN8/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665488998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b0ETrR474s4xPN6ye/nO2hHT6WBlhAAr4sx3ZXCNoqY=; b=hjp1Ud473iH4v7+0pZN5zJCaOnwpEuvY0E+vTDr91itRGXHZ/M3Dl3rs+Ok6QwUZk4IVF7ZT7zIv3q70yNTKH+fV3h3wkvYAYxm67JegnlB8WI0eWDjwFyP8vfdIkePwF4dHCbirrfdxsRymMCqPVDA390taNBnuQbHZqvt1bcI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665488998825800.2046541969864; Tue, 11 Oct 2022 04:49:58 -0700 (PDT) Received: from localhost ([::1]:47356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDll-0003T6-GT for importer@patchew.org; Tue, 11 Oct 2022 07:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVH-0003Bv-1l for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVD-0004lK-Md for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:49 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-665-Z5JgA9rGPXKRgVil0S4-gg-1; Tue, 11 Oct 2022 06:28:43 -0400 Received: by mail-ej1-f72.google.com with SMTP id nc4-20020a1709071c0400b0078a5ceb571bso5625264ejc.4 for ; Tue, 11 Oct 2022 03:28:43 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id f12-20020a170906c08c00b0073cd7cc2c81sm6734490ejz.181.2022.10.11.03.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b0ETrR474s4xPN6ye/nO2hHT6WBlhAAr4sx3ZXCNoqY=; b=JPlFRCCEZmntOo5o1RoIUKwXyXKg6rPfW4aK8VEvQF+tXPIvOhiMfd8iom1wAD+1FQ3b9n 6w4AKovEk7xV8pe6b3w+/u5dzr3il3X/Y76VBS4uI7fWSQz66VHK2dqqE1gByC6HRnGSIw gSRe9mmAhWqD5KnBXknTZP6RuMyoPI4= X-MC-Unique: Z5JgA9rGPXKRgVil0S4-gg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b0ETrR474s4xPN6ye/nO2hHT6WBlhAAr4sx3ZXCNoqY=; b=17rm6pNVUDHouZ3a7uElNtTAL2QW00bTHL1yN8jOfg2UdTj8k6C4Rpb+HpMhqYxwsI tc+LpFPXhLzZgNCiKmQ6Mkwl1YoTXPL+410+rPayaa+/yBF7J6AUTrvOB3e8oDiFh9n5 ZLMZa5cHArRuU2ctAIE7YKiZM7oSqgvJqr3yKlfCj9RSeh8zhjvD7F7kDbN0lAFGRkPp yFH4lAl8RiIbwWUvClbmPaSjI0GEbKSIbcqd85vOXyp2SgYJR1I4QGiVUVGbNIRWqNcn uZzWI0+7KBx46oXMPoYReVRO42f/3zJSjXTpXdCXJkp+ZqnEpCHhhsm2VwilygMJyRqw CV7Q== X-Gm-Message-State: ACrzQf0tZaovz94H0PBt4XANrt93AEpjqmGQBa2ElMY09Mid4LZ/etnt 1hHgXbrsjBNrTAf8PDRpgmzMLSlniLC7ZwQfdGib+xACO5GNJmiib7ZkrA5/QQMsO1MittsDN5E KER48cvm+wa2KMJLckVbfgWU0pGx3y/K6Qo9CLGLQEVU/c/XxnDluWGEs5Qrdba4rzK0= X-Received: by 2002:a17:907:2daa:b0:78d:4dca:43e with SMTP id gt42-20020a1709072daa00b0078d4dca043emr18289275ejc.134.1665484121736; Tue, 11 Oct 2022 03:28:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6mpMiqU+kH9eNCCh/VwOP2EPm1ATO1Xpm7tMX+7fjCYxvsTien8xa/Pr3f88qWBYTKBItlqQ== X-Received: by 2002:a17:907:2daa:b0:78d:4dca:43e with SMTP id gt42-20020a1709072daa00b0078d4dca043emr18289254ejc.134.1665484121418; Tue, 11 Oct 2022 03:28:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 35/37] linux-user: i386/signal: move fpstate at the end of the 32-bit frames Date: Tue, 11 Oct 2022 12:26:58 +0200 Message-Id: <20221011102700.319178-36-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665488999481100001 Content-Type: text/plain; charset="utf-8" Recent versions of Linux moved the 32-bit fpstate towards the end of the frame, so that the variable-sized xsave data does not overwrite the (ABI-defined) extramask[] field. Follow suit in QEMU. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- linux-user/i386/signal.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 4372621a4d..76317a3d16 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -163,9 +163,16 @@ struct sigframe { abi_ulong pretcode; int sig; struct target_sigcontext sc; - struct target_fpstate fpstate; + /* + * The actual fpstate is placed after retcode[] below, to make + * room for the variable-sized xsave data. The older unused fpstate + * has to be kept to avoid changing the offset of extramask[], which + * is part of the ABI. + */ + struct target_fpstate fpstate_unused; abi_ulong extramask[TARGET_NSIG_WORDS-1]; char retcode[8]; + struct target_fpstate fpstate; }; =20 struct rt_sigframe { @@ -175,8 +182,8 @@ struct rt_sigframe { abi_ulong puc; struct target_siginfo info; struct target_ucontext uc; - struct target_fpstate fpstate; char retcode[8]; + struct target_fpstate fpstate; }; =20 #else --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665487979; cv=none; d=zohomail.com; s=zohoarc; b=TwUedibSdJy3R4+Edilk0XulsnW0pd1HEua70a2EUBnoSnixlBsVJ/Pq6lgWBzWFZ5KBoO+lI3JfqgIw+RC0vJETJxISESUumwelO3wNFbCP6eV91UiHFx+D5iB+qhQQcIicCTfV7/4IQUS8wyvwPmdviGC1CN7S2UEZ1Y0mk3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665487979; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d/gzeaTPbWY5heUfJjmM0txX2wzVxil3gvzIxWo/PXA=; b=DdwUhhl5ZIqVt0XSHEz6fwAktxhNq8hFyGX5Y0m68f8VRXnQQ/FGcvnii476wwKHGVwOeCrGaeBaHQrBB7cFdf49NfCN+qgVA2fZ62Yj0/WLFmjOMzVLNrdqFdXC7JCeK/QmZf5wE4Cjpu67a3ncOPokQdFWMlnrbK55UrTy0Cw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665487979305817.785847498713; Tue, 11 Oct 2022 04:32:59 -0700 (PDT) Received: from localhost ([::1]:51004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDVJ-0001qT-Jz for importer@patchew.org; Tue, 11 Oct 2022 07:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVR-0003CY-Il for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:29:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVG-0004mT-Pl for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:29:01 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-647-h-35MmpFMBaXRerkOUbP3Q-1; Tue, 11 Oct 2022 06:28:46 -0400 Received: by mail-ej1-f70.google.com with SMTP id hr29-20020a1709073f9d00b0078333782c48so5667539ejc.10 for ; Tue, 11 Oct 2022 03:28:45 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id lg15-20020a170906f88f00b0072af4af2f46sm6617844ejb.74.2022.10.11.03.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d/gzeaTPbWY5heUfJjmM0txX2wzVxil3gvzIxWo/PXA=; b=WvZNVQDmayIfQQLX0xpodeJTlYyQpHL+hjPaq3d5/yJ7M0uMnJv7q7Aw5qDsY2Q4zHaLIl H1rh1gRwwt1TyaCHfCE7HHBE9iazRlcLugC+eXRidXs61qfQr2IVBgRfKV2qir1TVP0pi4 uWnk/mbmdfZ/gC+GOiaGZWV1auCZMM4= X-MC-Unique: h-35MmpFMBaXRerkOUbP3Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d/gzeaTPbWY5heUfJjmM0txX2wzVxil3gvzIxWo/PXA=; b=nDy4dILHilrUddTvDPJItGF1XPvkIWsOmk1vypvzHtr5xO/WkAUpNuguVVHNNS3H3i bqscQpPY9NeICM0PKzDrwyVeC6ngpXgVeBKvr+Pg+zUNQHsfjFwrBc9Eyhki4JbCUrg2 jbBaP8/FgsgIUOAj5D8LVyNN+x7Wl9xgJZS+RTZqv9AMq5jv3xtGyc4ValHSSqCPmeZJ 8MUODjVZucXUJjVZrDc8TTp9mtjM2A10RuMkJYR+njwqk9YYPXWFDeOEpQrOZ8rggTRV WXrD5kDbSlDt48sEH06z5pSUqBqaPh1BlFY0/hRGw4neZYqNHZXV9ycu+3CWIvzVpkya VsIg== X-Gm-Message-State: ACrzQf3GFj/ZWdw0NU3NBksn/1PQWj8nbo5R3kpxUHPM4Xw4EFEi898k EgRn8MAbQuVl/w+/jVbSywefGWlVuOXmoJu9e9OSE1qnpcaq0awYPAYHCFAN3Q7DoCzwDrNyCzS 0DdQi1G0LBUTsUXI8h9UvdfFiSx4lmvNM3mb8K9frmH7pzpkGIeXYrzSi8HyNoJHMAC0= X-Received: by 2002:a17:907:6e9e:b0:78c:5533:4158 with SMTP id sh30-20020a1709076e9e00b0078c55334158mr17663708ejc.417.1665484124407; Tue, 11 Oct 2022 03:28:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gbqHqNFfiU29Z7zWmrFO7eOBZOUT5xlSzwFf02awMqvBYLJk8Xf0gaG1sdFRakrcM+4UMdw== X-Received: by 2002:a17:907:6e9e:b0:78c:5533:4158 with SMTP id sh30-20020a1709076e9e00b0078c55334158mr17663687ejc.417.1665484124049; Tue, 11 Oct 2022 03:28:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 36/37] linux-user: i386/signal: support FXSAVE fpstate on 32-bit emulation Date: Tue, 11 Oct 2022 12:26:59 +0200 Message-Id: <20221011102700.319178-37-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665487980539100001 Content-Type: text/plain; charset="utf-8" Linux can use FXSAVE to save/restore XMM registers even on 32-bit systems. This requires some care in order to keep the FXSAVE area aligned to 16 bytes; for this reason, get_sigframe is changed to pass the offset into the FXSAVE area rather than the full frame size. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- linux-user/i386/signal.c | 129 +++++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 76317a3d16..58b11be116 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -39,29 +39,7 @@ struct target_xmmreg { uint32_t element[4]; }; =20 -struct target_fpstate_32 { - /* Regular FPU environment */ - uint32_t cw; - uint32_t sw; - uint32_t tag; - uint32_t ipoff; - uint32_t cssel; - uint32_t dataoff; - uint32_t datasel; - struct target_fpreg st[8]; - uint16_t status; - uint16_t magic; /* 0xffff =3D regular FPU data only */ - - /* FXSR FPU environment */ - uint32_t _fxsr_env[6]; /* FXSR FPU env is ignored */ - uint32_t mxcsr; - uint32_t reserved; - struct target_fpxreg fxsr_st[8]; /* FXSR FPU reg data is ignored */ - struct target_xmmreg xmm[8]; - uint32_t padding[56]; -}; - -struct target_fpstate_64 { +struct target_fpstate_fxsave { /* FXSAVE format */ uint16_t cw; uint16_t sw; @@ -75,11 +53,36 @@ struct target_fpstate_64 { uint32_t xmm_space[64]; uint32_t reserved[24]; }; +#define TARGET_FXSAVE_SIZE sizeof(struct target_fpstate_fxsave) +QEMU_BUILD_BUG_ON(TARGET_FXSAVE_SIZE !=3D 512); + +struct target_fpstate_32 { + /* Regular FPU environment */ + uint32_t cw; + uint32_t sw; + uint32_t tag; + uint32_t ipoff; + uint32_t cssel; + uint32_t dataoff; + uint32_t datasel; + struct target_fpreg st[8]; + uint16_t status; + uint16_t magic; /* 0xffff =3D regular FPU data only */ + struct target_fpstate_fxsave fxsave; +}; + +/* + * For simplicity, setup_frame aligns struct target_fpstate_32 to + * 16 bytes, so ensure that the FXSAVE area is also aligned. + */ +QEMU_BUILD_BUG_ON(offsetof(struct target_fpstate_32, fxsave) & 15); =20 #ifndef TARGET_X86_64 # define target_fpstate target_fpstate_32 +# define TARGET_FPSTATE_FXSAVE_OFFSET offsetof(struct target_fpstate_32, f= xsave) #else -# define target_fpstate target_fpstate_64 +# define target_fpstate target_fpstate_fxsave +# define TARGET_FPSTATE_FXSAVE_OFFSET 0 #endif =20 struct target_sigcontext_32 { @@ -172,8 +175,16 @@ struct sigframe { struct target_fpstate fpstate_unused; abi_ulong extramask[TARGET_NSIG_WORDS-1]; char retcode[8]; - struct target_fpstate fpstate; + + /* + * This field will be 16-byte aligned in memory. Applying QEMU_ALIGNED + * to it ensures that the base of the frame has an appropriate alignme= nt + * too. + */ + struct target_fpstate fpstate QEMU_ALIGNED(8); }; +#define TARGET_SIGFRAME_FXSAVE_OFFSET ( = \ + offsetof(struct sigframe, fpstate) + TARGET_FPSTATE_FXSAVE_OFFSET) =20 struct rt_sigframe { abi_ulong pretcode; @@ -183,25 +194,35 @@ struct rt_sigframe { struct target_siginfo info; struct target_ucontext uc; char retcode[8]; - struct target_fpstate fpstate; + struct target_fpstate fpstate QEMU_ALIGNED(8); }; - +#define TARGET_RT_SIGFRAME_FXSAVE_OFFSET ( = \ + offsetof(struct rt_sigframe, fpstate) + TARGET_FPSTATE_FXSAVE_OFFSET) #else =20 struct rt_sigframe { abi_ulong pretcode; struct target_ucontext uc; struct target_siginfo info; - struct target_fpstate fpstate; + struct target_fpstate fpstate QEMU_ALIGNED(16); }; - +#define TARGET_RT_SIGFRAME_FXSAVE_OFFSET ( = \ + offsetof(struct rt_sigframe, fpstate) + TARGET_FPSTATE_FXSAVE_OFFSET) #endif =20 /* * Set up a signal frame. */ =20 -/* XXX: save x87 state */ +static void fxsave_sigcontext(CPUX86State *env, struct target_fpstate_fxsa= ve *fxsave, + abi_ulong fxsave_addr) +{ + /* fxsave_addr must be 16 byte aligned for fxsave */ + assert(!(fxsave_addr & 0xf)); + + cpu_x86_fxsave(env, fxsave_addr); +} + static void setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate, CPUX86State *env, abi_ulong mask, abi_ulong fpstate_addr) @@ -233,13 +254,14 @@ static void setup_sigcontext(struct target_sigcontext= *sc, =20 cpu_x86_fsave(env, fpstate_addr, 1); fpstate->status =3D fpstate->sw; - magic =3D 0xffff; + if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { + magic =3D 0xffff; + } else { + fxsave_sigcontext(env, &fpstate->fxsave, + fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSET); + magic =3D 0; + } __put_user(magic, &fpstate->magic); - __put_user(fpstate_addr, &sc->fpstate); - - /* non-iBCS2 extensions.. */ - __put_user(mask, &sc->oldmask); - __put_user(env->cr[2], &sc->cr2); #else __put_user(env->regs[R_EDI], &sc->rdi); __put_user(env->regs[R_ESI], &sc->rsi); @@ -269,15 +291,14 @@ static void setup_sigcontext(struct target_sigcontext= *sc, __put_user((uint16_t)0, &sc->fs); __put_user(env->segs[R_SS].selector, &sc->ss); =20 + fxsave_sigcontext(env, fpstate, fpstate_addr); +#endif + + __put_user(fpstate_addr, &sc->fpstate); + + /* non-iBCS2 extensions.. */ __put_user(mask, &sc->oldmask); __put_user(env->cr[2], &sc->cr2); - - /* fpstate_addr must be 16 byte aligned for fxsave */ - assert(!(fpstate_addr & 0xf)); - - cpu_x86_fxsave(env, fpstate_addr); - __put_user(fpstate_addr, &sc->fpstate); -#endif } =20 /* @@ -285,7 +306,7 @@ static void setup_sigcontext(struct target_sigcontext *= sc, */ =20 static inline abi_ulong -get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_s= ize) +get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t fxsave_= offset) { unsigned long esp; =20 @@ -309,11 +330,11 @@ get_sigframe(struct target_sigaction *ka, CPUX86State= *env, size_t frame_size) #endif } =20 -#ifndef TARGET_X86_64 - return (esp - frame_size) & -8ul; -#else - return ((esp - frame_size) & (~15ul)) - 8; -#endif + if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { + return (esp - (fxsave_offset + TARGET_FXSAVE_SIZE)) & -8ul; + } else { + return ((esp - TARGET_FXSAVE_SIZE) & -16ul) - fxsave_offset; + } } =20 #ifndef TARGET_X86_64 @@ -341,7 +362,7 @@ void setup_frame(int sig, struct target_sigaction *ka, struct sigframe *frame; int i; =20 - frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); + frame_addr =3D get_sigframe(ka, env, TARGET_SIGFRAME_FXSAVE_OFFSET); trace_user_setup_frame(env, frame_addr); =20 if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) @@ -397,7 +418,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, struct rt_sigframe *frame; int i; =20 - frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); + frame_addr =3D get_sigframe(ka, env, TARGET_RT_SIGFRAME_FXSAVE_OFFSET); trace_user_setup_rt_frame(env, frame_addr); =20 if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) @@ -529,7 +550,11 @@ restore_sigcontext(CPUX86State *env, struct target_sig= context *sc) goto badframe; } #ifndef TARGET_X86_64 - cpu_x86_frstor(env, fpstate_addr, 1); + if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { + cpu_x86_frstor(env, fpstate_addr, 1); + } else { + cpu_x86_fxrstor(env, fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFS= ET); + } #else cpu_x86_fxrstor(env, fpstate_addr); #endif --=20 2.37.3 From nobody Mon Feb 9 14:35:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665490164; cv=none; d=zohomail.com; s=zohoarc; b=meitZoil8FLT4MDY0282us19RGbZn4qMtd6uPg9Hu8mrNcbf88pHK/WJ2rxJ+tHGqGmGcT0OxDFR1Q7AWMUDJBn4DaCpylqOJJZtYmJeLrEEEkSQJqgw4sdh1wHgvDxz3iy3ks71DNNmLgWdDCZ2yomCcfpfHMVwi3fb7IqU+Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665490164; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+zch28MyvyfFbvtCLtqZkoEXshw0n579O3a7dkpE/m4=; b=n6xiB89MAteuOYYTiQjFmNiKUD1rTzSh8oRP5IrvKzPrh3guukYmwpp0dEPSpz9AESY8eXOmM4jVrqcb6mB/Hd8JLhcEU4p/nG0igocZFfFe/1PEGTyCRfViSdVvqh30wv5BtvEI45HBFZnqXsKMMVs3RraD7r3K/shJMgT2o2g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665490164125552.1370885383807; Tue, 11 Oct 2022 05:09:24 -0700 (PDT) Received: from localhost ([::1]:55776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiE4Y-000814-UJ for importer@patchew.org; Tue, 11 Oct 2022 08:09:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVO-0003CO-KW for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:29:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCVG-0004mc-PO for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:28:53 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-7-URFH1OwfNweBjHRpKSv1PQ-1; Tue, 11 Oct 2022 06:28:48 -0400 Received: by mail-ej1-f70.google.com with SMTP id xh12-20020a170906da8c00b007413144e87fso5666377ejb.14 for ; Tue, 11 Oct 2022 03:28:48 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:aad8:f393:e009:e014]) by smtp.gmail.com with ESMTPSA id b38-20020a509f29000000b00458b41d9460sm8773557edf.92.2022.10.11.03.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 03:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+zch28MyvyfFbvtCLtqZkoEXshw0n579O3a7dkpE/m4=; b=LZix3WBUkN2xbwWf0cNkIJE1RKoj7rlaMrY2Oi4xBf1Cf0pyPRkfHeoJMZuOlAJSWp+i6D zLXI+aRhZ7NMjoiv73OUMQ2bd18ioKQF70h/L0HWmA8SWDMrhCgN839TuEzqq6PwApvYWS 1cthunP2ZKF0yiYO3Nazoyn/J6zYo68= X-MC-Unique: URFH1OwfNweBjHRpKSv1PQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+zch28MyvyfFbvtCLtqZkoEXshw0n579O3a7dkpE/m4=; b=lfEDLANcnscd9j5XKM+7LTrWKer8DnVNccxIcZGhyre0NuLE58LqGfs4/LyVgsLZkq lwsGgP0xED1UudJoMeqgCMTSYDHGY53XhD+Rgl8mGSIS14KKFEMIRRIgu//Tv2y+lKCu i5+fIi51tOULqhnVURL3UTfy18wa7xdccZSUn/vkZdOaqFGUao63Pbz3Jr+A6PCL95Dk i7WcNFQxAixio69D/DDCCCo6vK4kBn9Oeq3zlJwEQYXRI8Lvp3nbMr/uNXEcZGzmQIVZ xQrhuPdocU+d0dr6YXAU3QrEH0sRd5cD2ylPWyqF8TvvRlFi+kG+wjXEUqAiQbgYNwj0 KzrQ== X-Gm-Message-State: ACrzQf2izp4LmxFrWPJE01mIEKDANHMsa7z2i8RpoCeF+f467y+gVMVS YrWUdPNKArZx7iGGbSEk9BdIF3FEpL1JNDMQ5pp2Vj5IEpPT3lFkSmdoY0Ha7jrbc1D9za1IOxp JYM/aWJp6Ns3g5NRX/+mVvHjBiJnFVFzPVNmjmI8rXHQ8pOsqv4uvKyxLzkWWD5VBU+g= X-Received: by 2002:aa7:d454:0:b0:459:9ae7:725b with SMTP id q20-20020aa7d454000000b004599ae7725bmr21562453edr.165.1665484127136; Tue, 11 Oct 2022 03:28:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GoPlf6qv6gikzKZ2RJr/axHrB478JsvXNquKAfEzf4jdGarHakIF92JlOxn8DwT71uHtaVg== X-Received: by 2002:aa7:d454:0:b0:459:9ae7:725b with SMTP id q20-20020aa7d454000000b004599ae7725bmr21562432edr.165.1665484126826; Tue, 11 Oct 2022 03:28:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 37/37] linux-user: i386/signal: support XSAVE/XRSTOR for signal frame fpstate Date: Tue, 11 Oct 2022 12:27:00 +0200 Message-Id: <20221011102700.319178-38-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011102700.319178-1-pbonzini@redhat.com> References: <20221011102700.319178-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665490165513100001 Content-Type: text/plain; charset="utf-8" Add support for saving/restoring extended save states when signals are delivered. This allows using AVX, MPX or PKRU registers in signal handlers. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- linux-user/i386/signal.c | 119 +++++++++++++++++++++++++++++------ target/i386/cpu.c | 2 +- target/i386/cpu.h | 3 + target/i386/tcg/fpu_helper.c | 64 +++++++++++-------- 4 files changed, 142 insertions(+), 46 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 58b11be116..60fa07d6f9 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -24,6 +24,10 @@ =20 /* from the Linux kernel - /arch/x86/include/uapi/asm/sigcontext.h */ =20 +#define TARGET_FP_XSTATE_MAGIC1 0x46505853U /* FPXS */ +#define TARGET_FP_XSTATE_MAGIC2 0x46505845U /* FPXE */ +#define TARGET_FP_XSTATE_MAGIC2_SIZE 4 + struct target_fpreg { uint16_t significand[4]; uint16_t exponent; @@ -39,6 +43,15 @@ struct target_xmmreg { uint32_t element[4]; }; =20 +struct target_fpx_sw_bytes { + uint32_t magic1; + uint32_t extended_size; + uint64_t xfeatures; + uint32_t xstate_size; + uint32_t reserved[7]; +}; +QEMU_BUILD_BUG_ON(sizeof(struct target_fpx_sw_bytes) !=3D 12*4); + struct target_fpstate_fxsave { /* FXSAVE format */ uint16_t cw; @@ -51,10 +64,13 @@ struct target_fpstate_fxsave { uint32_t mxcsr_mask; uint32_t st_space[32]; uint32_t xmm_space[64]; - uint32_t reserved[24]; + uint32_t hw_reserved[12]; + struct target_fpx_sw_bytes sw_reserved; + uint8_t xfeatures[]; }; #define TARGET_FXSAVE_SIZE sizeof(struct target_fpstate_fxsave) QEMU_BUILD_BUG_ON(TARGET_FXSAVE_SIZE !=3D 512); +QEMU_BUILD_BUG_ON(offsetof(struct target_fpstate_fxsave, sw_reserved) !=3D= 464); =20 struct target_fpstate_32 { /* Regular FPU environment */ @@ -214,13 +230,39 @@ struct rt_sigframe { * Set up a signal frame. */ =20 -static void fxsave_sigcontext(CPUX86State *env, struct target_fpstate_fxsa= ve *fxsave, - abi_ulong fxsave_addr) +static void xsave_sigcontext(CPUX86State *env, struct target_fpstate_fxsav= e *fxsave, + abi_ulong fxsave_addr) { - /* fxsave_addr must be 16 byte aligned for fxsave */ - assert(!(fxsave_addr & 0xf)); + if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) { + /* fxsave_addr must be 16 byte aligned for fxsave */ + assert(!(fxsave_addr & 0xf)); =20 - cpu_x86_fxsave(env, fxsave_addr); + cpu_x86_fxsave(env, fxsave_addr); + __put_user(0, &fxsave->sw_reserved.magic1); + } else { + uint32_t xstate_size =3D xsave_area_size(env->xcr0, false); + uint32_t xfeatures_size =3D xstate_size - TARGET_FXSAVE_SIZE; + + /* + * extended_size is the offset from fpstate_addr to right after th= e end + * of the extended save states. On 32-bit that includes the legacy + * FSAVE area. + */ + uint32_t extended_size =3D TARGET_FPSTATE_FXSAVE_OFFSET + + xstate_size + TARGET_FP_XSTATE_MAGIC2_SIZE; + + /* fxsave_addr must be 64 byte aligned for xsave */ + assert(!(fxsave_addr & 0x3f)); + + /* Zero the header, XSAVE *adds* features to an existing save stat= e. */ + memset(fxsave->xfeatures, 0, 64); + cpu_x86_xsave(env, fxsave_addr); + __put_user(TARGET_FP_XSTATE_MAGIC1, &fxsave->sw_reserved.magic1); + __put_user(extended_size, &fxsave->sw_reserved.extended_size); + __put_user(env->xcr0, &fxsave->sw_reserved.xfeatures); + __put_user(xstate_size, &fxsave->sw_reserved.xstate_size); + __put_user(TARGET_FP_XSTATE_MAGIC2, (uint32_t *) &fxsave->xfeature= s[xfeatures_size]); + } } =20 static void setup_sigcontext(struct target_sigcontext *sc, @@ -257,8 +299,8 @@ static void setup_sigcontext(struct target_sigcontext *= sc, if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { magic =3D 0xffff; } else { - fxsave_sigcontext(env, &fpstate->fxsave, - fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSET); + xsave_sigcontext(env, &fpstate->fxsave, + fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSET); magic =3D 0; } __put_user(magic, &fpstate->magic); @@ -291,7 +333,7 @@ static void setup_sigcontext(struct target_sigcontext *= sc, __put_user((uint16_t)0, &sc->fs); __put_user(env->segs[R_SS].selector, &sc->ss); =20 - fxsave_sigcontext(env, fpstate, fpstate_addr); + xsave_sigcontext(env, fpstate, fpstate_addr); #endif =20 __put_user(fpstate_addr, &sc->fpstate); @@ -332,8 +374,12 @@ get_sigframe(struct target_sigaction *ka, CPUX86State = *env, size_t fxsave_offset =20 if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { return (esp - (fxsave_offset + TARGET_FXSAVE_SIZE)) & -8ul; - } else { + } else if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) { return ((esp - TARGET_FXSAVE_SIZE) & -16ul) - fxsave_offset; + } else { + size_t xstate_size =3D + xsave_area_size(env->xcr0, false) + TARGET_FP_XSTATE_MAGIC2= _SIZE; + return ((esp - xstate_size) & -64ul) - fxsave_offset; } } =20 @@ -437,7 +483,11 @@ void setup_rt_frame(int sig, struct target_sigaction *= ka, } =20 /* Create the ucontext. */ - __put_user(0, &frame->uc.tuc_flags); + if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) { + __put_user(1, &frame->uc.tuc_flags); + } else { + __put_user(0, &frame->uc.tuc_flags); + } __put_user(0, &frame->uc.tuc_link); target_save_altstack(&frame->uc.tuc_stack, env); setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, @@ -491,10 +541,37 @@ give_sigsegv: force_sigsegv(sig); } =20 +static int xrstor_sigcontext(CPUX86State *env, struct target_fpstate_fxsav= e *fxsave, + abi_ulong fxsave_addr) +{ + if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) { + uint32_t extended_size =3D tswapl(fxsave->sw_reserved.extended_siz= e); + uint32_t xstate_size =3D tswapl(fxsave->sw_reserved.xstate_size); + uint32_t xfeatures_size =3D xstate_size - TARGET_FXSAVE_SIZE; + + /* Linux checks MAGIC2 using xstate_size, not extended_size. */ + if (tswapl(fxsave->sw_reserved.magic1) =3D=3D TARGET_FP_XSTATE_MAG= IC1 && + extended_size >=3D TARGET_FPSTATE_FXSAVE_OFFSET + xstate_size = + TARGET_FP_XSTATE_MAGIC2_SIZE) { + if (!access_ok(env_cpu(env), VERIFY_READ, fxsave_addr, + extended_size - TARGET_FPSTATE_FXSAVE_OFFSET)) { + return 1; + } + if (tswapl(*(uint32_t *) &fxsave->xfeatures[xfeatures_size]) = =3D=3D TARGET_FP_XSTATE_MAGIC2) { + cpu_x86_xrstor(env, fxsave_addr); + return 0; + } + } + /* fall through to fxrstor */ + } + + cpu_x86_fxrstor(env, fxsave_addr); + return 0; +} + static int restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) { - unsigned int err =3D 0; + int err =3D 1; abi_ulong fpstate_addr; unsigned int tmpflags; =20 @@ -545,24 +622,28 @@ restore_sigcontext(CPUX86State *env, struct target_si= gcontext *sc) =20 fpstate_addr =3D tswapl(sc->fpstate); if (fpstate_addr !=3D 0) { - if (!access_ok(env_cpu(env), VERIFY_READ, fpstate_addr, - sizeof(struct target_fpstate))) { - goto badframe; + struct target_fpstate *fpstate; + if (!lock_user_struct(VERIFY_READ, fpstate, fpstate_addr, + sizeof(struct target_fpstate))) { + return err; } #ifndef TARGET_X86_64 if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { cpu_x86_frstor(env, fpstate_addr, 1); + err =3D 0; } else { - cpu_x86_fxrstor(env, fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFS= ET); + err =3D xrstor_sigcontext(env, &fpstate->fxsave, + fpstate_addr + TARGET_FPSTATE_FXSAVE_O= FFSET); } #else - cpu_x86_fxrstor(env, fpstate_addr); + err =3D xrstor_sigcontext(env, fpstate, fpstate_addr); #endif + unlock_user_struct(fpstate, fpstate_addr, 0); + } else { + err =3D 0; } =20 return err; -badframe: - return 1; } =20 /* Note: there is no sigreturn on x86_64, there is only rt_sigreturn */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 06884177fa..8a11470507 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1467,7 +1467,7 @@ ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT= ] =3D { }, }; =20 -static uint32_t xsave_area_size(uint64_t mask, bool compacted) +uint32_t xsave_area_size(uint64_t mask, bool compacted) { uint64_t ret =3D x86_ext_save_areas[0].size; const ExtSaveArea *esa; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d4124973ce..9327353fff 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2071,6 +2071,8 @@ void cpu_x86_fsave(CPUX86State *s, target_ulong ptr, = int data32); void cpu_x86_frstor(CPUX86State *s, target_ulong ptr, int data32); void cpu_x86_fxsave(CPUX86State *s, target_ulong ptr); void cpu_x86_fxrstor(CPUX86State *s, target_ulong ptr); +void cpu_x86_xsave(CPUX86State *s, target_ulong ptr); +void cpu_x86_xrstor(CPUX86State *s, target_ulong ptr); =20 /* cpu.c */ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, @@ -2327,6 +2329,7 @@ bool cpu_is_bsp(X86CPU *cpu); =20 void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t bufle= n); void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen); +uint32_t xsave_area_size(uint64_t mask, bool compacted); void x86_update_hflags(CPUX86State* env); =20 static inline bool hyperv_feat_enabled(X86CPU *cpu, int feat) diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index 30bc44fcf8..ad58931751 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -2502,18 +2502,6 @@ void helper_frstor(CPUX86State *env, target_ulong pt= r, int data32) do_frstor(env, ptr, data32, GETPC()); } =20 -#if defined(CONFIG_USER_ONLY) -void cpu_x86_fsave(CPUX86State *env, target_ulong ptr, int data32) -{ - do_fsave(env, ptr, data32, 0); -} - -void cpu_x86_frstor(CPUX86State *env, target_ulong ptr, int data32) -{ - do_frstor(env, ptr, data32, 0); -} -#endif - #define XO(X) offsetof(X86XSaveArea, X) =20 static void do_xsave_fpu(CPUX86State *env, target_ulong ptr, uintptr_t ra) @@ -2787,21 +2775,8 @@ void helper_fxrstor(CPUX86State *env, target_ulong p= tr) do_fxrstor(env, ptr, GETPC()); } =20 -#if defined(CONFIG_USER_ONLY) -void cpu_x86_fxsave(CPUX86State *env, target_ulong ptr) +static void do_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm, u= intptr_t ra) { - do_fxsave(env, ptr, 0); -} - -void cpu_x86_fxrstor(CPUX86State *env, target_ulong ptr) -{ - do_fxrstor(env, ptr, 0); -} -#endif - -void helper_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm) -{ - uintptr_t ra =3D GETPC(); uint64_t xstate_bv, xcomp_bv, reserve0; =20 rfbm &=3D env->xcr0; @@ -2894,6 +2869,43 @@ void helper_xrstor(CPUX86State *env, target_ulong pt= r, uint64_t rfbm) =20 #undef XO =20 +void helper_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm) +{ + do_xrstor(env, ptr, rfbm, GETPC()); +} + +#if defined(CONFIG_USER_ONLY) +void cpu_x86_fsave(CPUX86State *env, target_ulong ptr, int data32) +{ + do_fsave(env, ptr, data32, 0); +} + +void cpu_x86_frstor(CPUX86State *env, target_ulong ptr, int data32) +{ + do_frstor(env, ptr, data32, 0); +} + +void cpu_x86_fxsave(CPUX86State *env, target_ulong ptr) +{ + do_fxsave(env, ptr, 0); +} + +void cpu_x86_fxrstor(CPUX86State *env, target_ulong ptr) +{ + do_fxrstor(env, ptr, 0); +} + +void cpu_x86_xsave(CPUX86State *env, target_ulong ptr) +{ + do_xsave(env, ptr, -1, get_xinuse(env), -1, 0); +} + +void cpu_x86_xrstor(CPUX86State *env, target_ulong ptr) +{ + do_xrstor(env, ptr, -1, 0); +} +#endif + uint64_t helper_xgetbv(CPUX86State *env, uint32_t ecx) { /* The OS must have enabled XSAVE. */ --=20 2.37.3