From patchwork Tue Mar 7 18:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vd4tD3g0Mz9sN9; Wed, 8 Mar 2017 05:28:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="rvZMYTM9"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1clJqk-0001dv-AC; Tue, 07 Mar 2017 18:28:42 +0000 Received: from mail-io0-f175.google.com ([209.85.223.175]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1clJqf-0001dl-5D for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 18:28:37 +0000 Received: by mail-io0-f175.google.com with SMTP id f84so10372382ioj.0 for ; Tue, 07 Mar 2017 10:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=t5jC06A+Z63850TRP3aA6JkLvjc6/fqCaR1edesbcN8=; b=rvZMYTM9BMHkwTPe/vqzsAJ+344Ha5HET6eEO/CocOVEZlh1TUwHpPpwro+oBzAVwz D9GcHWzNQNe5c7488peyFTo7bqcEUw2yPS1XoTPSjI5M+/oj73p2Lm4SJCYYGKcCURNh JMAn9X9IYAUcwpe/g0oAerIhj9saXV10nGQQXLE7x+bAIPofSiuf7bRE3rUBJtYN95cV jdsctG4gbNGUP8CTX4gWFkQV+BvZ+8XWAmM0Neq4FeM0YQ4FqbmjNGHZlWF0/heYeA9J nwTRyPryFtm0n1WXzx9ptOrjT3E4FBd1epcAPf1abGd1H9e7E5RKLJrglsFagTcVfWTf F9Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=t5jC06A+Z63850TRP3aA6JkLvjc6/fqCaR1edesbcN8=; b=aJExeR4J5y0dO3UFCnOZVXgi6hJFX9/rgOkRubmGkoS7crPyUhda4fzAqxHzXGMM0X pg6/jRZ3P2dvQkOtyohjPgxwO0MewPpCrTSlUR9OJ+T8330bHdridpbG9FSRuPA9f6BG Wc8Hif2Iw2p0AMJRXVvEG0/Leno8kM97J1Cil5vQ7CIyMvRM4ZPyVWi8HTIohHUJo89k lpIIufk4MUCMbP/34IxEk5xuXLRnVVyhjFc1cOF9DWVaSC8+yu967uUENPa58Tz6tAyF P7bGguFcXG2DYWzOMsr+NtBOtK2FsKEcRIri5Ha+zmTpEluRuw6iSHYUDuzMlFww1O/B zbgw== X-Gm-Message-State: AMke39k1BsvIOmzOl+s7AvOIr5BDllZlPgJzfzoQ3Mqmm+OJ6yzY1Lv90YFHCmgrl8Po7C6A X-Received: by 10.107.35.211 with SMTP id j202mr2343953ioj.158.1488911315801; Tue, 07 Mar 2017 10:28:35 -0800 (PST) Received: from localhost.localdomain (host-98-127-250-84.bln-mt.client.bresnan.net. [98.127.250.84]) by smtp.gmail.com with ESMTPSA id a21sm6581380itc.28.2017.03.07.10.28.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 10:28:35 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH Yakkety SRU] KVM: PPC: Book3S HV: Fix H_PROD to actually wake the target vcpu Date: Tue, 7 Mar 2017 11:28:15 -0700 Message-Id: <1488911295-4627-1-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Paul Mackerras BugLink: http://bugs.launchpad.net/bugs/1670726 The H_PROD hypercall is supposed to wake up an idle vcpu. We have an implementation, but because Linux doesn't use it except when doing cpu hotplug, it was never tested properly. AIX does use it, and reported it broken. It turns out we were waking the wrong vcpu (the one doing H_PROD, not the target of the prod) and we weren't handling the case where the target needs an IPI to wake it. Fix it by using the existing kvmppc_fast_vcpu_kick_hv() function, which is intended for this kind of thing, and by using the target vcpu not the current vcpu. We were also not looking at the prodded flag when checking whether a ceded vcpu should wake up, so this adds checks for the prodded flag alongside the checks for pending exceptions. Signed-off-by: Paul Mackerras (cherry picked from commit 8464c8842de2249061d3c5abc2ccce1bbbd10e7a) Signed-off-by: Tim Gardner --- arch/powerpc/kvm/book3s_hv.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 8dcbe37..eb69ce0 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -773,12 +773,8 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) } tvcpu->arch.prodded = 1; smp_mb(); - if (vcpu->arch.ceded) { - if (swait_active(&vcpu->wq)) { - swake_up(&vcpu->wq); - vcpu->stat.halt_wakeup++; - } - } + if (tvcpu->arch.ceded) + kvmppc_fast_vcpu_kick_hv(tvcpu); break; case H_CONFER: target = kvmppc_get_gpr(vcpu, 4); @@ -2621,7 +2617,8 @@ static int kvmppc_vcore_check_block(struct kvmppc_vcore *vc) int i; for_each_runnable_thread(i, vcpu, vc) { - if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded) + if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded || + vcpu->arch.prodded) return 1; } @@ -2807,7 +2804,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) break; n_ceded = 0; for_each_runnable_thread(i, v, vc) { - if (!v->arch.pending_exceptions) + if (!v->arch.pending_exceptions && !v->arch.prodded) n_ceded += v->arch.ceded; else v->arch.ceded = 0;