Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3711830ybl; Sun, 15 Dec 2019 16:21:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzxlmbBcGM472/CwbjZTiaQXdSBZiSywr7/qUBxdW9a01COlk6lOvLs6CC8MvQpiTu7dnNZ X-Received: by 2002:a9d:7f16:: with SMTP id j22mr9495580otq.256.1576455679737; Sun, 15 Dec 2019 16:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576455679; cv=none; d=google.com; s=arc-20160816; b=AY6d/V5JBI7IvJBlT4cSQx2Q9t0nZ0x9lDT3OlaEDHpiq1gOohYygLXbO4JCutwNj8 pyPjkuLxhPML8RSCE4GuoBL0+Mm47HLUdVJPXkQZcge9bTgnyGOO9Oe5dNnW5et1bXrh uNFxGEswrzDPJVYaMIWnbi1oymEsuxZP25vv6ggMF65VQ7m6bh+Z0/dbjn4SRcGSfnQD kTEjqhy5aUDuST3Kl6Y/aF8axJVmOvpp9dc7vqfBm2OIpcIDqopJvJjqbsH3TKRcoG8a OsXCAVvo0pdBZCTLDPMgbCImWLLdpB0DcLhxkyf8xhvIcm7PPJ7NthktMPlJgjpgetj0 /zcg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=usI7ZLlrtnzO1xtvE7qJdWgNGyWRiX0DoyyW1z56fjQ=; b=GPULw7KBrr+/Iqte8L1unaaDIfNqfJ+c5DEQPIs15uk1kELJFYaYUTjK/gNS7BFDPU k0tbjj/RTgeXF4fbQJx7gZROcaeKO0fDpwtZI25/yhUSdXXUKzyIuONJ1F0uCHHDXAdS DS7dgEbBgQHTgfwWJWipLv6Z0z6ICbh90DR36CERbfno/pzo9SVp65JwsCEgZCEBnDzt 9Bi4nbHw7eHxaIA3WB24ZjiurFlR21MirmWk2axXLx2MtkgMVXdUTDMpbApSGX9ai2P5 4oPBuJSAFTTxXqjtml6JdFRbu1D5fB+9bMBsWtTHk+6rOJ/BUTTFdsuOCuhM6jXxg3gq L5eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZcL1vAcU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si9153346otr.233.2019.12.15.16.21.08; Sun, 15 Dec 2019 16:21:19 -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=@gmail.com header.s=20161025 header.b=ZcL1vAcU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726772AbfLPAUB (ORCPT + 99 others); Sun, 15 Dec 2019 19:20:01 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:34231 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfLPAT7 (ORCPT ); Sun, 15 Dec 2019 19:19:59 -0500 Received: by mail-qk1-f195.google.com with SMTP id j9so2937925qkk.1; Sun, 15 Dec 2019 16:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=usI7ZLlrtnzO1xtvE7qJdWgNGyWRiX0DoyyW1z56fjQ=; b=ZcL1vAcUgKjuyp97OeIAQ0epiqggmuG3QljxDovgnIuPeifT/+ziT7ngleb475gqEn 9Id1YfFkwJtqKMX0R1rk4968ygu0mENq1hVBHVVJjj7GS6YEfuggH3SpS/odI+aZbuZ+ wR1yKLxVoaENYO8aHVbpIBMGdc4fc6a0jRTmluYEgR7vyqYJmsDxWaczEy3PKU2+pxMW 4r5P1g4JLkfLLzURF05vGcUJxbw7J3nbdZaBY2LNdkHfzssQ0qogl+PdzqVn4BSuUfn+ nbAbEfWsiinDCitUgRfKhjdzIctPFTcitdQwBDqSgMyKeBA1RokL0sW+os4Hxyvm/m+6 lbXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=usI7ZLlrtnzO1xtvE7qJdWgNGyWRiX0DoyyW1z56fjQ=; b=ZXRWdmH8bJgFbs6je6/NmY8A2hpxRqAQqyo/XA9BF/CKzobhbq/SgyV7USPi6bL/qG 9UFjFvI3WTWjQKGELbfFpdXnNo7S8r9NoEAQgTK6RSkwcT6Loo/YWOdB6uVhC77NIw/o 7O22cBAMXQQc/JLikW8yhmK0O+H0P6AEqmCp7SVSszICGs7erhC7pRJIStdmpWdZXAV1 SzSRyM0xKWfkOiG8DdL2tqAacE+uo9PH/I9CCByr3g/0AOaUFqXCJZzAT9IVdBF4zan0 ExI0et+ZlryLuv6w7rXLjw+VRD26uW6Mgs8rptpypzLlrv9kKTmCMhkX5CkL5eigkz2b sTXg== X-Gm-Message-State: APjAAAWEVvSeEoG3Tl3x0RwFK1dHSrGBwLBKrw6/VNqxbV+f4xtCTR8k 1sVS26yrxLEe3Yfa1QVSJ3U= X-Received: by 2002:a05:620a:12d5:: with SMTP id e21mr24635272qkl.44.1576455598605; Sun, 15 Dec 2019 16:19:58 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id c3sm5440772qkk.8.2019.12.15.16.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2019 16:19:58 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 9C34422430; Sun, 15 Dec 2019 19:19:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 15 Dec 2019 19:19:57 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddtgedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvffufffkofgjfhgggfes tdekredtredttdenucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnh hgsehgmhgrihhlrdgtohhmqeenucfkphephedvrdduheehrdduuddurdejudenucfrrghr rghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrg hlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeep ghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvnecuvehluhhsthgvrhfuihiivgepfe X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 1C0B1306012F; Sun, 15 Dec 2019 19:19:56 -0500 (EST) From: Boqun Feng To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Michael Kelley , Vincenzo Frascino , Catalin Marinas , Will Deacon , Thomas Gleixner , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , xen-devel@lists.xenproject.org, Stefano Stabellini , Boqun Feng Subject: [RFC 5/6] arm64: hyperv: Enable userspace to read cntvct Date: Mon, 16 Dec 2019 08:19:21 +0800 Message-Id: <20191216001922.23008-6-boqun.feng@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191216001922.23008-1-boqun.feng@gmail.com> References: <20191216001922.23008-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since reading hyperv-timer clocksource requires reading cntvct, userspace should be allowed to read it, otherwise reading cntvct will result in traps, which makes vsyscall's cost similar compared to syscall's. So enable it on every cpu when a Hyper-V guest booting up. Signed-off-by: Boqun Feng (Microsoft) --- arch/arm64/hyperv/hv_init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/hyperv/hv_init.c b/arch/arm64/hyperv/hv_init.c index 86e4621d5885..1ea97ecfb143 100644 --- a/arch/arm64/hyperv/hv_init.c +++ b/arch/arm64/hyperv/hv_init.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ EXPORT_SYMBOL_GPL(hv_max_vp_index); static int hv_cpu_init(unsigned int cpu) { u64 msr_vp_index; + u32 cntkctl; hv_get_vp_index(msr_vp_index); @@ -53,6 +55,11 @@ static int hv_cpu_init(unsigned int cpu) if (msr_vp_index > hv_max_vp_index) hv_max_vp_index = msr_vp_index; + /* Enable EL0 to access cntvct */ + cntkctl = arch_timer_get_cntkctl(); + cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN; + arch_timer_set_cntkctl(cntkctl); + return 0; } -- 2.24.0