Received: by 10.223.185.116 with SMTP id b49csp8497476wrg; Fri, 2 Mar 2018 02:54:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvD66QB123rFFIUUBq5GTs6unmvnLbc9xJiyw8kwlkU0X167Kt4hsOJYC1PROoJpw6sBbAe X-Received: by 2002:a17:902:1486:: with SMTP id k6-v6mr5042682pla.376.1519988063221; Fri, 02 Mar 2018 02:54:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519988063; cv=none; d=google.com; s=arc-20160816; b=EIv+IkZQQcM1YwvoG8Kbhyp3hxkFu+y/LuRlL76Iv1u16M3NKiXWF27VQSmFYiSxiN oC8ndEIeYvy8Zs+mS2qVF7aUFM65VR+/TY1H8xiwD8bJb2Cpm0oMgp9GjeBe+Nj2nwGE dpNmW1TC/I6tVU8fN4jlDCzguZ3kBly4iH9MQPnnnD5FnR74LTAsa9NIkEdU8GrVSrJ0 5gRf/EJwWbvRtqi6XyEGtkIaZEXc75CR/0ZdateIUyiNwwBe0q7XCZckOFfqoXRQoU61 zMa6A/gtVW3OeEm7aW6mvpPGtmnRdSl/DPe4zP5wITk6JwPbCHrBVhrJqbQUXnlxP2DP bmAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=lsyNLk0MJnZAH2PiBqHevEFofARGBuCnMyeJnRBzlmU=; b=CE06wxPff4rhOq1hTcSQPK6FVZXr9ZQll5QY3rqcva88nj+W/4G2K/aqTk3Z9FD+XG 1nZ7CVsU+D04RNgrbZ7BG/Q2e5vrOjiwhz5IVL2xn8mNgOvky8Q1VhWLY3j/PwdED/zj seGKr+D6EruizNVo6wiRM/UyK1IqBRH9kuheDaj257V1tRTlEFy8hAqSWdA8CohJuELO O5TncRUdNgaHA8/60OQlE8zeUH5jY1cKer1OxjkRSz9Na8/vQ4woKBKdqVJXWo4tu3Cv DhIcR+ad+6fM5vGtoQJ8kFRzw8TQ4pZsqJ5CnbHSgrVxtKm3NKrkM1vxtB4poW7syvRU nRkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f90-v6si4642925plb.63.2018.03.02.02.54.08; Fri, 02 Mar 2018 02:54:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426664AbeCBKwb (ORCPT + 99 others); Fri, 2 Mar 2018 05:52:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1426610AbeCBKwN (ORCPT ); Fri, 2 Mar 2018 05:52:13 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99B01404084B; Fri, 2 Mar 2018 10:52:12 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.36.118.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1AC32144B24; Fri, 2 Mar 2018 10:52:10 +0000 (UTC) From: Laurent Vivier To: linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, Paul Mackerras , David Gibson , Paolo Bonzini , Laurent Vivier Subject: [PATCH] KVM: PPC: Book3S HV: Fix guest time accounting with VIRT_CPU_ACCOUNTING_GEN Date: Fri, 2 Mar 2018 11:51:56 +0100 Message-Id: <20180302105156.19506-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 02 Mar 2018 10:52:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 02 Mar 2018 10:52:12 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lvivier@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 8b24e69fc47e ("KVM: PPC: Book3S HV: Close race with testing for signals on guest entry"), if CONFIG_VIRT_CPU_ACCOUNTING_GEN is set, the guest time is not accounted to guest time and user time, but instead to system time. This is because guest_enter()/guest_exit() are called while interrupts are disabled and the tick counter cannot be updated between them. To fix that, move guest_exit() after local_irq_enable(), and as guest_enter() is called with IRQ disabled, calls guest_enter_irqoff() instead. Fixes: 8b24e69fc47e ("KVM: PPC: Book3S HV: Close race with testing for signals on guest entry") Signed-off-by: Laurent Vivier --- arch/powerpc/kvm/book3s_hv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 89707354c2ef..8274c2807202 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2885,7 +2885,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) */ trace_hardirqs_on(); - guest_enter(); + guest_enter_irqoff(); srcu_idx = srcu_read_lock(&vc->kvm->srcu); @@ -2893,8 +2893,6 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) srcu_read_unlock(&vc->kvm->srcu, srcu_idx); - guest_exit(); - trace_hardirqs_off(); set_irq_happened(trap); @@ -2937,6 +2935,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) kvmppc_set_host_core(pcpu); local_irq_enable(); + guest_exit(); /* Let secondaries go back to the offline loop */ for (i = 0; i < controlled_threads; ++i) { -- 2.14.3