From patchwork Mon Feb 19 15:38:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 10228063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6BE6602B7 for ; Mon, 19 Feb 2018 15:38:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6BB728A92 for ; Mon, 19 Feb 2018 15:38:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB57A28ABF; Mon, 19 Feb 2018 15:38:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E00A28A92 for ; Mon, 19 Feb 2018 15:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UF+cNIjuiyXJxor+3f+UJErQseoQ4q8ToBhVxFpSg6M=; b=YMBkWkS1nv0fkS iMno1SNdHj03VLGsD05OMBxkA2hhDrMgNpr/rH5XYEzwUZBUqLejbXOEVMm/d06QoV/58Q0Nl8Dnj OaBblv1rEoGa5OipEfH5Ij18yjjlD9N+/8YmuhsUtjXRHcTJgFAtlh6BqGJryXZlmpgn3h3X0BTG1 BxVG/WFtimZWeyVwZDa0+OG4AjO/l0U3fcwwMAI2ffkDK1hciA7Wm4Rdd2X4xEL+tcu2Nc3+pJ6YS D7UGzl43Jbtg3P073b7qRH+6Mh/u2iCXjkq5noar0OK65bzh+kDT4qBmTQR4yrtV2zKPEC7vrIK/C Gm1K7pAXG5RRU+zaKM6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ennWe-00059f-CU; Mon, 19 Feb 2018 15:38:44 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ennWa-00057d-E4 for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2018 15:38:41 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 85EA560721; 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= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180219_073840_538500_E82F9250 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shanker Donthineni , Vikram Sethi Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Marc Zyngier --- 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); } /*