Received: by 10.223.185.116 with SMTP id b49csp3890324wrg; Mon, 19 Feb 2018 07:39:51 -0800 (PST) X-Google-Smtp-Source: AH8x2241cNkhLM+tfDmoVsC+uJmZwbma/I8yTjgYLAwGNDo0P/S+K/08wLuBcHmtCbRX2NWMqDSK X-Received: by 2002:a17:902:8d81:: with SMTP id v1-v6mr14514993plo.430.1519054791795; Mon, 19 Feb 2018 07:39:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519054791; cv=none; d=google.com; s=arc-20160816; b=fLcFhh6LOXoelp3uQ0pNkbvwSfPcuCCn1pjKQvXnOyONba+Spg7aV6ig6YmBFjGou5 LPaEy0YMVfapQ69YzXf5lswoJoSGJ3LriinMXS9bmxdgP0vtJbFK1gcKG0/BbW3uhUb5 5DzFN50Cvy1rRgCKWBhGFaUj59CrxPKxSSfD8IetvpbxJzm9hcXZ7Lnvtj4/T372tI2H r13nYcL29tSiPJm+7jITvjtfnB7Zy+4eax7MgbtAiZWfIvHI2jSp6E4xEokLYX4SUJEz o3YaE8hKbeRPgMAgslLNfc0QiztDkg3jG63BwyOjhQjWdDibFSvYnoysHFd4FFlCKTnE G2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=UARXxr1RzGA3EDkG5y6LEi06/XemIPUadFCmMqbM05k=; b=mb5u6+U34jPzHPIoTFCT6NGvhs+Dd0JTjSKAb+XiPyvBrfjHfuYuTZnpxW1XQi7qFQ LkekJxJstgCde9D5l/KLSJFkzoKuPwfItBlc8pM+tMgf5Rg0eNO+vR0PwlC4NOM3XId8 tTFdZ62Bb7L9pP766JwYmvy910UsDigMGns9SSEs/CNr27eO3apHsATreLYLY7CODNZc bKmIYo1yuUx//EqOrlX09REhmzdnqj08GVJsSRK1MVLsBU/lZ+yzYG3g9M0EUw2KbcQq cAtZx8xtowFa2RB7sUcodpRmnKIRqVeAq7uRa0Mf0H+O5p2usrf1D//feU/sZAy6f/9R ySeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=MnbIlmng; dkim=pass header.i=@codeaurora.org header.s=default header.b=MnbIlmng; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si5952603plb.472.2018.02.19.07.39.37; Mon, 19 Feb 2018 07:39:51 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=MnbIlmng; dkim=pass header.i=@codeaurora.org header.s=default header.b=MnbIlmng; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753010AbeBSPib (ORCPT + 99 others); Mon, 19 Feb 2018 10:38:31 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:45710 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752587AbeBSPia (ORCPT ); Mon, 19 Feb 2018 10:38:30 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AF5A56079C; Mon, 19 Feb 2018 15:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519054709; bh=lRiYUVO1+VlNmizQQV+gLbh51nEjn6vpMf2xqxgqrPw=; h=From:To:Cc:Subject:Date:From; b=MnbIlmnggIrEXH8amCcjRJjnfQj9K/DFUu8UdOXpI3cJ34WtKByh3D5V2bVb2cK0f Mzthbk8YiVbArh4xs4VHvwSVX/s51bN+Nf5rGtIWLnrT8I4e+P0e/wbZ6yWOqMHUAR VUgGgDLYfts3gOMa2SYXRdSbCZf0d4DlmRs5JX+I= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from shankerd-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shankerd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5C9C760240; Mon, 19 Feb 2018 15:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519054709; bh=lRiYUVO1+VlNmizQQV+gLbh51nEjn6vpMf2xqxgqrPw=; h=From:To:Cc:Subject:Date:From; b=MnbIlmnggIrEXH8amCcjRJjnfQj9K/DFUu8UdOXpI3cJ34WtKByh3D5V2bVb2cK0f Mzthbk8YiVbArh4xs4VHvwSVX/s51bN+Nf5rGtIWLnrT8I4e+P0e/wbZ6yWOqMHUAR VUgGgDLYfts3gOMa2SYXRdSbCZf0d4DlmRs5JX+I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5C9C760240 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=shankerd@codeaurora.org From: Shanker Donthineni To: Christoffer Dall , Marc Zyngier , linux-kernel , linux-arm-kernel , kvmarm Cc: Vikram Sethi , Shanker Donthineni Subject: [PATCH] KVM: arm/arm64: No need to zero CNTVOFF in kvm_timer_vcpu_put() for VHE Date: Mon, 19 Feb 2018 09:38:07 -0600 Message-Id: <1519054687-14405-1-git-send-email-shankerd@codeaurora.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In AArch64/AArch32, the virtual counter uses a fixed virtual offset of zero in the following situations as per ARMv8 specifications: 1) HCR_EL2.E2H is 1, and CNTVCT_EL0/CNTVCT are read from EL2. 2) HCR_EL2.{E2H, TGE} is {1, 1}, and either: — CNTVCT_EL0 is read from Non-secure EL0 or EL2. — CNTVCT is read from Non-secure EL0. So, no need to zero CNTVOFF_EL2/CNTVOFF for VHE case. Signed-off-by: Shanker Donthineni --- virt/kvm/arm/arch_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 70268c0..86eca324 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -541,9 +541,11 @@ void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) * The kernel may decide to run userspace after calling vcpu_put, so * we reset cntvoff to 0 to ensure a consistent read between user * accesses to the virtual counter and kernel access to the physical - * counter. + * counter of non-VHE case. For VHE, the virtual counter uses a fixed + * virtual offset of zero, so no need to zero CNTVOFF_EL2 register. */ - set_cntvoff(0); + if (!has_vhe()) + set_cntvoff(0); } /* -- Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.