From patchwork Mon Nov 28 16:37:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9449747 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 08F45600CB for ; Mon, 28 Nov 2016 16:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2A427D4A for ; Mon, 28 Nov 2016 16:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3C8B27F07; Mon, 28 Nov 2016 16:40:17 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E55AA27D4A for ; Mon, 28 Nov 2016 16:40:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBOww-00082L-Ok; Mon, 28 Nov 2016 16:38:38 +0000 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBOwr-00081F-9o for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2016 16:38:34 +0000 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id uASGXn0N065310 for ; Mon, 28 Nov 2016 11:38:05 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id D7A2E8D for ; Mon, 28 Nov 2016 11:38:05 -0500 (EST) Received: from sendprodmail04.cc.columbia.edu (sendprodmail04.cc.columbia.edu [128.59.72.16]) by hazelnut (Postfix) with ESMTP id 637D7B0 for ; Mon, 28 Nov 2016 11:38:04 -0500 (EST) Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by sendprodmail04.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id uASGc4nL039387 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 28 Nov 2016 11:38:04 -0500 Received: by mail-qk0-f197.google.com with SMTP id k201so114267982qke.6 for ; Mon, 28 Nov 2016 08:38:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HAKnOFkY+tUUIXCv7iFlBqgvaT0CR+2L6fM15Q2+SIg=; b=SHEkobw0vAEAYdsdx6X/JZrxP1hPXTIlLvpSRPczZyCiH4sXJdZr6k7ZMyeCdWiiWY N3NmTRq22tbeGy+eLseInhtSt0Hsb8pM5y8+GpeD1ce1UXMZ9NqkfusERPqkOSgJi8MX bjX/osgRib6qU3CMrmAOqxDUS2oXMpdXPZ4j0dzduh2ulhzdGjoHh7eXM8LAi8Y3NXTY jTujbWINdtsGFXspDorc5p5ldQhIb6WmFLngwHS21rMBjuV9D5MTrHLHP+2Zej4hEmS0 TSwx+Fdaj33se9rgd9xwMALekL19qtz5Vu4hXlBTm3eMw0qPPZdtOFIjB8NHez4WjiOg 4cMg== X-Gm-Message-State: AKaTC01IQX+mAsdsKpR54qa/owafMAAAVIyJcgzMdgyBaEsjfeT9U0x/gXEyOVzBzrcFph0q77wztoKHRe15l+Dic9O9Yx6jp9n7+TwNqfQkCfqZ7MGthCeZWfg0RRJGamOvw69/kNyTKuizLno3oy6fdY8uCv78RupCpA== X-Received: by 10.237.63.8 with SMTP id p8mr19534358qtf.169.1480351083918; Mon, 28 Nov 2016 08:38:03 -0800 (PST) X-Received: by 10.237.63.8 with SMTP id p8mr19534329qtf.169.1480351083658; Mon, 28 Nov 2016 08:38:03 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id d78sm20209037qkg.49.2016.11.28.08.38.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 08:38:02 -0800 (PST) From: Jintack Lim To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: head.S: Fix CNTHCTL_EL2 access on VHE system Date: Mon, 28 Nov 2016 11:37:39 -0500 Message-Id: <1480351059-11370-1-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.16 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_083833_576275_D343C5E2 X-CRM114-Status: GOOD ( 11.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Jintack , kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org MIME-Version: 1.0 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 From: Jintack Bit positions of CNTHCTL_EL2 are changing depending on HCR_EL2.E2H bit. EL1PCEN and EL1PCTEN are 1st and 0th bits when E2H is not set, but they are 11th and 10th bits respectively when E2H is set. Current code is unintentionally setting wrong bits to CNTHCTL_EL2 with E2H set. In fact, we don't need to set those two bits, which allow EL1 and EL0 to access physical timer and counter respectively, if E2H and TGE are set for the host kernel. They will be configured later as necessary. First, we don't need to configure those bits for EL1, since the host kernel runs in EL2. It is a hypervisor's responsibility to configure them before entering a VM, which runs in EL0 and EL1. Second, EL0 accesses are configured in the later stage of boot process. Signed-off-by: Jintack Lim --- arch/arm64/kernel/head.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 332e331..bc3d2db 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -524,10 +524,16 @@ set_hcr: msr hcr_el2, x0 isb - /* Generic timers. */ + /* + * Allow Non-secure EL1 and EL0 to access physical timer and counter. + * This is not necessary for VHE, since the host kernel runs in EL2, + * and EL0 accesses are configured in the later stage of boot process. + */ + cbnz x2, 1f mrs x0, cnthctl_el2 orr x0, x0, #3 // Enable EL1 physical timers msr cnthctl_el2, x0 +1: msr cntvoff_el2, xzr // Clear virtual offset #ifdef CONFIG_ARM_GIC_V3