From nobody Mon Nov 25 07:45:27 2024 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=1717485675; cv=none; d=zohomail.com; s=zohoarc; b=Um6PQcHTz/Gc8XsSlLCgff5IGUPSgzICGBRvixN06INpDIdBT4CnaFdDCtnNSclLQp5lV1gxASlr7aoCI3/3PHjPLNy7bxwLGm2W6BeldXRHY+cdsZ3JLxAAyEC8WWP2ShpDO75nfHi8DO82a0Mmag6QazC6zA3tCUPeD5JreO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717485675; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JE1l3mnnViu2bSu14FqFVuNS+di8GAj9jPlWPGLObPQ=; b=HB8laNsyB1aMc48WhvrLc/6fCEXREHv4rpmH7xza0hE/2xB2BqFRqa5lSKLwG46+pmGkJ8X2j0IQMfSoGaqoP6Tpejp9ovzNgd/tH0UTwMRRB5cp+wQBn+9D+nLCfhMlg7uC6rQLVoErl3mWvWFcXyKszktsOS1NJHIcY7K3wQU= 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 1717485675601331.95008178822513; Tue, 4 Jun 2024 00:21:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEORu-0003Nn-2T; Tue, 04 Jun 2024 03:19:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEORs-0003Jv-Hl for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:19:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEORq-0005ea-Lh for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:19:12 -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_256_GCM_SHA384) id us-mta-473-4pccu4QMO96Lu7Bxg9Zc6w-1; Tue, 04 Jun 2024 03:19:07 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6905050583so98639466b.0 for ; Tue, 04 Jun 2024 00:19:07 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68f10450besm342684566b.35.2024.06.04.00.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 00:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717485549; 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=JE1l3mnnViu2bSu14FqFVuNS+di8GAj9jPlWPGLObPQ=; b=Dx9CgANCQrw0FWlcDdPVHm3+zjno0Feq6tKAHzMqVEvFFR2cGcAPGNV8ZT7/P2x0VJn5Q9 ka9jb47eHbbRy/zvT0LPeMOp1XTvJ8lElWXswdG03nRPSxxnQ/jQAePyv7E5QhX8ORgkwm ExyriNwBESsXwHtwHQwySg7kvTLSEi4= X-MC-Unique: 4pccu4QMO96Lu7Bxg9Zc6w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717485545; x=1718090345; 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=JE1l3mnnViu2bSu14FqFVuNS+di8GAj9jPlWPGLObPQ=; b=jDvhN5Vkbqxa++MX8vyZ/hIn5ns9wHEybG8sfC3V14R+D4Ei/kNJfWfHpPggZ7CG3O Q7Iy1bLMLd8GaNBlN78LHmUjBPBWNUx4jXtfoRKsx39favC5gHJ0JSbkvIzMsBe5DQsl EuAubcAYTYKqWLNSbHlXqMt9Sg5yD4hsLmtXd2jo9AgksBlqw3k0+CFgn67ZkEuXb2ht GRRJci+Qx71PUKeJ2bbkrfKFEoHqZi5OQN4kPpyQQFJf5xGSaobFRRQQCX4RyNNiX1C7 ylU4NmCCy1sO6obI7qkJG2xmeaZXBqpAMD8ikIctKggyGwOLYGgx5MU3PgGVLhYvRp4S JO8g== X-Gm-Message-State: AOJu0Yw1g0mS7LhJ2lUHA2tX3nDzmcRfaWrSfl5WPruQESVMILsF63jU oMi4Y8eYu/yl5O9rDTjv/RFgNY2HfX4lVxOKcLcnhC+60PPeUBuBlpCsi3MyNkk0AAHkdqbSip0 ATlNrh4/y6Tc3pQ2KebCXdpSxadrLmfBoj2kT2vIGjKxcWRnO3bX2kCK054l37akJK6YYP7JfuK 90ywz81jl6MdSplm6jp3cvaLIh+7RIXs2ZY8zt X-Received: by 2002:a17:907:86ab:b0:a68:e6a5:b3ea with SMTP id a640c23a62f3a-a68e6a5b62emr482088466b.5.1717485545486; Tue, 04 Jun 2024 00:19:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENzK6nQS1tseB7U+OjQCdrGXaLXdU4IzYUBYvuiHaq08HZ1dNBP2xLwrAvziQzb4BvIRSaag== X-Received: by 2002:a17:907:86ab:b0:a68:e6a5:b3ea with SMTP id a640c23a62f3a-a68e6a5b62emr482086566b.5.1717485545075; Tue, 04 Jun 2024 00:19:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 09/11] target/i386: fix TF/RF handling for HLT Date: Tue, 4 Jun 2024 09:18:31 +0200 Message-ID: <20240604071833.962574-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240604071833.962574-1-pbonzini@redhat.com> References: <20240604071833.962574-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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717485675762100001 Content-Type: text/plain; charset="utf-8" HLT uses DISAS_NORETURN because the corresponding helper calls cpu_loop_exit(). However, while gen_eob() clears HF_RF_MASK and synthesizes a #DB exception if single-step is active, none of this is done by HLT. Note that the single-step trap is generated after the halt is finished. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/sysemu/misc_helper.c | 2 +- target/i386/tcg/sysemu/seg_helper.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index 093cc2d0f90..7fa0c5a06de 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -520,7 +520,7 @@ G_NORETURN void helper_hlt(CPUX86State *env) { CPUState *cs =3D env_cpu(env); =20 - env->hflags &=3D ~HF_INHIBIT_IRQ_MASK; /* needed if sti is just before= */ + do_end_instruction(env); cs->halted =3D 1; cs->exception_index =3D EXCP_HLT; cpu_loop_exit(cs); diff --git a/target/i386/tcg/sysemu/seg_helper.c b/target/i386/tcg/sysemu/s= eg_helper.c index 9ba94deb3aa..05174a79e73 100644 --- a/target/i386/tcg/sysemu/seg_helper.c +++ b/target/i386/tcg/sysemu/seg_helper.c @@ -130,15 +130,26 @@ void x86_cpu_do_interrupt(CPUState *cs) =20 bool x86_cpu_exec_halt(CPUState *cpu) { - if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { - X86CPU *x86_cpu =3D X86_CPU(cpu); + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; =20 + if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { bql_lock(); apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); bql_unlock(); } - return cpu_has_work(cpu); + + if (!cpu_has_work(cpu)) { + return false; + } + + /* Complete HLT instruction. */ + if (env->eflags & TF_MASK) { + env->dr[6] |=3D DR6_BS; + do_interrupt_all(x86_cpu, EXCP01_DB, 0, 0, env->eip, 0); + } + return true; } =20 bool x86_need_replay_interrupt(int interrupt_request) --=20 2.45.1