From nobody Fri Nov 7 22:57:21 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548811241179438.0359496355801; Tue, 29 Jan 2019 17:20:41 -0800 (PST) Received: from localhost ([127.0.0.1]:58212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goeYN-0000Y3-3F for importer@patchew.org; Tue, 29 Jan 2019 20:20:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goe3w-00005X-MW for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goe3s-0001GO-Tl for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:06 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:47561) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goe3s-00010I-Lr for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:49:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 541182212C; Tue, 29 Jan 2019 19:48:24 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 29 Jan 2019 19:48:24 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 714E2E4559; Tue, 29 Jan 2019 19:48:23 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=Tr/1UGmocX9rJxwXIUlhc73I7UHQgFSK5+BvfBugJ9k=; b=kNrrf lEFpW5XyvVNWrjt4C+2mN7Cw9kAoeSEZY80rTEmO0XNHtWOrEl/pPz8OKLrQ1ceE 81wwd8PDjwkQDfF1kY/B8/iKhqsinX0lmDaJb+H2JSw0FdnWceLyeGMknPpxgU9A 73nNS1OSiREjbKXGQRzP5MT4+C5aljmVaQcu88= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=Tr/1UGmocX9rJxwXIUlhc73I7UHQg FSK5+BvfBugJ9k=; b=sGlfj3pQU7SSzvbROe6LU6G++wwHV2T7pHYZ89zAbVvCo v+0Joi2ZCqy3Nkt5756P7fczF5DDr319PlS3GRiuczkby4u5R/3iD4negACnoTV0 nWO64C4BI7GpCLXjRU5lb70tw9W7t+Ky/+aBanN5Ek4seftreqhcderDtTXranPv E0qkClgVL8MPo3EnIdHFBXRLQOLkFuAX13CAXPF53ugyz8gURYOfgRwZGKf1pget iorzsPbcYrPn7GNg6k1supi2JwD+eLVX7Jt0MtNtcCu7iSQVXzGINuwg45p/LFQP xM7h6oYHzg38Je3E10/K4KMEM59Js9NuYgh7XQ0Tw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrjeefgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojg hfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcuoegt ohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeinecurf grrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhushht vghrufhiiigvpeek X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 19:47:38 -0500 Message-Id: <20190130004811.27372-41-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190130004811.27372-1-cota@braap.org> References: <20190130004811.27372-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v6 40/73] i386/kvm: convert to cpu_interrupt_request 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 , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- target/i386/kvm.c | 54 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index ca2629f0fe..3f3c670897 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2888,11 +2888,14 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int lev= el) events.smi.smm =3D !!(env->hflags & HF_SMM_MASK); events.smi.smm_inside_nmi =3D !!(env->hflags2 & HF2_SMM_INSIDE_NMI= _MASK); if (kvm_irqchip_in_kernel()) { + uint32_t interrupt_request; + /* As soon as these are moved to the kernel, remove them * from cs->interrupt_request. */ - events.smi.pending =3D cs->interrupt_request & CPU_INTERRUPT_S= MI; - events.smi.latched_init =3D cs->interrupt_request & CPU_INTERR= UPT_INIT; + interrupt_request =3D cpu_interrupt_request(cs); + events.smi.pending =3D interrupt_request & CPU_INTERRUPT_SMI; + events.smi.latched_init =3D interrupt_request & CPU_INTERRUPT_= INIT; cpu_reset_interrupt(cs, CPU_INTERRUPT_INIT | CPU_INTERRUPT_SMI= ); } else { /* Keep these in cs->interrupt_request. */ @@ -3183,14 +3186,14 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run= *run) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; + uint32_t interrupt_request; int ret; =20 + interrupt_request =3D cpu_interrupt_request(cpu); /* Inject NMI */ - if (cpu->interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { - if (cpu->interrupt_request & CPU_INTERRUPT_NMI) { - qemu_mutex_lock_iothread(); + if (interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { + if (interrupt_request & CPU_INTERRUPT_NMI) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_NMI); - qemu_mutex_unlock_iothread(); DPRINTF("injected NMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_NMI); if (ret < 0) { @@ -3198,10 +3201,8 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run = *run) strerror(-ret)); } } - if (cpu->interrupt_request & CPU_INTERRUPT_SMI) { - qemu_mutex_lock_iothread(); + if (interrupt_request & CPU_INTERRUPT_SMI) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_SMI); - qemu_mutex_unlock_iothread(); DPRINTF("injected SMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_SMI); if (ret < 0) { @@ -3215,16 +3216,18 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run= *run) qemu_mutex_lock_iothread(); } =20 + interrupt_request =3D cpu_interrupt_request(cpu); + /* Force the VCPU out of its inner loop to process any INIT requests * or (for userspace APIC, but it is cheap to combine the checks here) * pending TPR access reports. */ - if (cpu->interrupt_request & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR))= { - if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) && + if (interrupt_request & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { + if ((interrupt_request & CPU_INTERRUPT_INIT) && !(env->hflags & HF_SMM_MASK)) { cpu->exit_request =3D 1; } - if (cpu->interrupt_request & CPU_INTERRUPT_TPR) { + if (interrupt_request & CPU_INTERRUPT_TPR) { cpu->exit_request =3D 1; } } @@ -3232,7 +3235,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) if (!kvm_pic_in_kernel()) { /* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && - (cpu->interrupt_request & CPU_INTERRUPT_HARD) && + (interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) { int irq; =20 @@ -3256,7 +3259,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) * 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 ((cpu_interrupt_request(cpu) & CPU_INTERRUPT_HARD)) { run->request_interrupt_window =3D 1; } else { run->request_interrupt_window =3D 0; @@ -3302,8 +3305,9 @@ int kvm_arch_process_async_events(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; + uint32_t interrupt_request; =20 - if (cs->interrupt_request & CPU_INTERRUPT_MCE) { + if (cpu_interrupt_request(cs) & CPU_INTERRUPT_MCE) { /* We must not raise CPU_INTERRUPT_MCE if it's not supported. */ assert(env->mcg_cap); =20 @@ -3326,7 +3330,7 @@ int kvm_arch_process_async_events(CPUState *cs) } } =20 - if ((cs->interrupt_request & CPU_INTERRUPT_INIT) && + if ((cpu_interrupt_request(cs) & CPU_INTERRUPT_INIT) && !(env->hflags & HF_SMM_MASK)) { kvm_cpu_synchronize_state(cs); do_cpu_init(cpu); @@ -3336,20 +3340,21 @@ int kvm_arch_process_async_events(CPUState *cs) return 0; } =20 - if (cs->interrupt_request & CPU_INTERRUPT_POLL) { + if (cpu_interrupt_request(cs) & CPU_INTERRUPT_POLL) { cpu_reset_interrupt(cs, CPU_INTERRUPT_POLL); apic_poll_irq(cpu->apic_state); } - if (((cs->interrupt_request & CPU_INTERRUPT_HARD) && + interrupt_request =3D cpu_interrupt_request(cs); + if (((interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) || - (cs->interrupt_request & CPU_INTERRUPT_NMI)) { + (interrupt_request & CPU_INTERRUPT_NMI)) { cpu_halted_set(cs, 0); } - if (cs->interrupt_request & CPU_INTERRUPT_SIPI) { + if (interrupt_request & CPU_INTERRUPT_SIPI) { kvm_cpu_synchronize_state(cs); do_cpu_sipi(cpu); } - if (cs->interrupt_request & CPU_INTERRUPT_TPR) { + if (cpu_interrupt_request(cs) & CPU_INTERRUPT_TPR) { cpu_reset_interrupt(cs, CPU_INTERRUPT_TPR); kvm_cpu_synchronize_state(cs); apic_handle_tpr_access_report(cpu->apic_state, env->eip, @@ -3363,10 +3368,13 @@ static int kvm_handle_halt(X86CPU *cpu) { CPUState *cs =3D CPU(cpu); CPUX86State *env =3D &cpu->env; + uint32_t interrupt_request; + + interrupt_request =3D cpu_interrupt_request(cs); =20 - if (!((cs->interrupt_request & CPU_INTERRUPT_HARD) && + if (!((interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) && - !(cs->interrupt_request & CPU_INTERRUPT_NMI)) { + !(interrupt_request & CPU_INTERRUPT_NMI)) { cpu_halted_set(cs, 1); return EXCP_HLT; } --=20 2.17.1