From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5E7p-0001oh-EW for qemu-devel@nongnu.org; Thu, 10 Jul 2014 09:11:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5E7g-0001Z6-D4 for qemu-devel@nongnu.org; Thu, 10 Jul 2014 09:11:01 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:52184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5E7g-0001Yy-3s for qemu-devel@nongnu.org; Thu, 10 Jul 2014 09:10:52 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Jul 2014 14:10:50 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6E2001B08069 for ; Thu, 10 Jul 2014 14:10:56 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6ADAIhc34275444 for ; Thu, 10 Jul 2014 13:10:18 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6ADAHBJ015783 for ; Thu, 10 Jul 2014 07:10:17 -0600 From: Christian Borntraeger Date: Thu, 10 Jul 2014 15:10:38 +0200 Message-Id: <1404997839-29038-5-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1404997839-29038-1-git-send-email-borntraeger@de.ibm.com> References: <1404997839-29038-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PATCH/RFC 4/5] s390x/kvm: test whether a cpu is STOPPED when checking "has_work" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: KVM , qemu-devel Cc: linux-s390 , Christian Borntraeger , Alexander Graf , David Hildenbrand , Jens Freimann , Cornelia Huck , Paolo Bonzini From: David Hildenbrand If a cpu is stopped, it must never be allowed to run and no interrupt may wake it up. A cpu also has to be unhalted if it is halted and has work to do - this scenario wasn't hit in kvm case yet, as only "disabled wait" is processed within QEMU. Signed-off-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Christian Borntraeger Signed-off-by: Christian Borntraeger --- target-s390x/cpu.c | 6 ++++++ target-s390x/kvm.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index c5ab98f..1d32f5a 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -72,6 +72,12 @@ static bool s390_cpu_has_work(CPUState *cs) S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; + /* stopped cpus can never run */ + if (env->cpu_state == CPU_STATE_STOPPED || + env->cpu_state == CPU_STATE_CHECK_STOP) { + return false; + } + return (cs->interrupt_request & CPU_INTERRUPT_HARD) && (env->psw.mask & PSW_MASK_EXT); } diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index db2e42c..00125f1 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -553,6 +553,11 @@ void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run) int kvm_arch_process_async_events(CPUState *cs) { + if (cs->halted && CPU_GET_CLASS(cs)->has_work(cs)) { + /* has_work will take care of stopped cpus */ + s390_cpu_unhalt(S390_CPU(cs)); + } + return cs->halted; } -- 1.8.4.2