From nobody Wed Nov 5 20:11:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537203154604763.1748141672026; Mon, 17 Sep 2018 09:52:34 -0700 (PDT) Received: from localhost ([::1]:36553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1wlF-00075u-Gt for importer@patchew.org; Mon, 17 Sep 2018 12:52:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1wQo-0006Qu-St for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1wQk-00027e-Hz for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:26 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:37671) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1wQk-0001oO-5V for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:22 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EF06752D; Mon, 17 Sep 2018 12:31:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 17 Sep 2018 12:31:08 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 368D2E414C; Mon, 17 Sep 2018 12:31:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=R6YkdbRBWNDYxq +xQ7yYzUncIUlNaMbqKET0rSKULMk=; b=bonpgmBepQzKBKCQua/8/xR/43kF+H RBJBTcdteXelGT/pQ+ez74Mea1+9Il7LPWmmjKHZgoP+wNHmDLFj7Z4DUuRk08OO +zuWr/zCkzPAzoYtdWIcv9unt8kz4sLq09Fc4LnhKSYGptITsVp+MQx1dCZJO1gJ aX6UYNXUFfdaA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=R6YkdbRBWNDYxq+xQ7yYzUncIUlNaMbqKET0rSKULMk=; b=C6R4xAkY ZMeOmzqlgpq9O3VxKdWgM9qei9hJSkPUi8I1ZDZvj2yGs29lTwohsZinQpCONMQy hc6PH9mtDzc5WL19iwtxX3wTbnYr+KpUuv7jSbx9muHwQmfWdr+L2S0OvTaJsha5 nV76a5To+27fZpL3FiGnfOIrDdkGO+62on5gF3Ix8wkqb3LWAcGt94K7VeJ9mB+T KqFmBCbcBRhma/bSknPJoC1X02d7OHgahIWbJt1IXPPCZkzFMb54qCF3LjOVwAct 0vY+GISXG8p7JURrE98cdmDKOYVqV0MvlIy83vRgqqk4CxvwuKUXPfn0eg+Vxatg 9vUFjLFK82RPBA== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2018 12:30:40 -0400 Message-Id: <20180917163103.6113-13-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917163103.6113-1-cota@braap.org> References: <20180917163103.6113-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [PATCH 12/35] hax: access cpu->interrupt_request with atomics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" I am not familiar with hax, so I opted for the safe (and slow) route of performing probably many unnecessary atomic_reads. Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: Emilio G. Cota --- target/i386/hax-all.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index ae8b678db0..56f999d5ba 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -293,7 +293,7 @@ int hax_vm_destroy(struct hax_vm *vm) =20 static void hax_handle_interrupt(CPUState *cpu, int mask) { - cpu->interrupt_request |=3D mask; + atomic_or(&cpu->interrupt_request, mask); =20 if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); @@ -427,7 +427,7 @@ static int hax_vcpu_interrupt(CPUArchState *env) * Unlike KVM, HAX kernel check for the eflags, instead of qemu */ if (ht->ready_for_interrupt_injection && - (cpu->interrupt_request & CPU_INTERRUPT_HARD)) { + (atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_HARD)) { int irq; =20 irq =3D cpu_get_pic_interrupt(env); @@ -441,7 +441,7 @@ static int hax_vcpu_interrupt(CPUArchState *env) * interrupt, request an interrupt window exit. This will * cause a return to userspace as soon as the guest is ready to * receive interrupts. */ - if ((cpu->interrupt_request & CPU_INTERRUPT_HARD)) { + if (atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_HARD) { ht->request_interrupt_window =3D 1; } else { ht->request_interrupt_window =3D 0; @@ -482,19 +482,19 @@ static int hax_vcpu_hax_exec(CPUArchState *env) =20 cpu->halted =3D 0; =20 - if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { + if (atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_POLL) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); apic_poll_irq(x86_cpu->apic_state); } =20 - if (cpu->interrupt_request & CPU_INTERRUPT_INIT) { + if (atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_INIT) { DPRINTF("\nhax_vcpu_hax_exec: handling INIT for %d\n", cpu->cpu_index); do_cpu_init(x86_cpu); hax_vcpu_sync_state(env, 1); } =20 - if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) { + if (atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_SIPI) { DPRINTF("hax_vcpu_hax_exec: handling SIPI for %d\n", cpu->cpu_index); hax_vcpu_sync_state(env, 0); @@ -503,6 +503,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env) } =20 do { + int interrupt_request; int hax_ret; =20 if (cpu->exit_request) { @@ -553,8 +554,9 @@ static int hax_vcpu_hax_exec(CPUArchState *env) ret =3D -1; break; case HAX_EXIT_HLT: - if (!(cpu->interrupt_request & CPU_INTERRUPT_HARD) && - !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) { + interrupt_request =3D atomic_read(&cpu->interrupt_request); + if (!(interrupt_request & CPU_INTERRUPT_HARD) && + !(interrupt_request & CPU_INTERRUPT_NMI)) { /* hlt instruction with interrupt disabled is shutdown */ env->eflags |=3D IF_MASK; cpu->halted =3D 1; --=20 2.17.1