From patchwork Thu May 3 13:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 134901 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1921459lji; Thu, 3 May 2018 06:22:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJVYZXb6YrkOo/Bp16bsCv8lCU+ENchXUH11GGDJ2NFdL7gd8NsYdjg2lWBNoukM3ORvmq X-Received: by 2002:a17:902:5502:: with SMTP id f2-v6mr23921120pli.108.1525353733445; Thu, 03 May 2018 06:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525353733; cv=none; d=google.com; s=arc-20160816; b=YI04SuKKrBsPXL3NZyqiUZxNcq1+8Ns6+d3+1/MT5zETCU0PAW5R/1vv0MutwOcsRm PipYsPzZ2pIPNwpQ7H+HYGJXs00T8pBEmSu+s4xs5Q88kj3SWavK5IM62IoLwPdblDdA bPjdbMzkcFbpL5aIMHQsg5F7dRWNfZsdvhWcgY4WRleRPH9iUlhFyTqV1OjsfZqWDuyG JNyoGjyYPvH14WydxXcHwV5J2SoPxJVaBGUsa8n0MYEulO0qPxwilgL+2LsU7JVPWu2/ hM5blgkZBupgN93UZFg59U9jLbnVj9PP3yVSHcbQQSg3WeRwEoQc5jTVO3qZgepdXtvK 5BIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KTRIMMpA1HriBhZ8sAEbOPNjjHXf22iLZfXNUFQHGNQ=; b=QAaQeJZ/f1+3Adg/pji0nnPx0EHxW3QSCTA5dz3S9b8fmuVlf2lAOrh7pWB2fEeC3j HQgJ0kZaX6ibOm9x+iDadm26KlW9DfjOxHIYE9GFq16C8+LbiWeWmIytk+aFWdITF4yT W2uH21RBZNSO6JOvD9BXqhSiG8OhrO1S3aRP9lhLKb4kEHceSUUjb2PLe2qJbPbKSbUR eFD0kILRzVx2aUO68/6WtFitBV/RIWSxGfhri3QKxSisjx++woo15RHtEcUIZ0EuEiP9 o+EuA7q/oOXT5sQZoMlrNqJ7GhJt+orC8Z3C0d7J64TUsELXkj4MDeAWJ5OzleN2pQKn iKbQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11-v6si11278100pgn.403.2018.05.03.06.22.13; Thu, 03 May 2018 06:22:13 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751713AbeECNWL (ORCPT + 29 others); Thu, 3 May 2018 09:22:11 -0400 Received: from foss.arm.com ([217.140.101.70]:41608 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751412AbeECNUu (ORCPT ); Thu, 3 May 2018 09:20:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DFA51682; Thu, 3 May 2018 06:20:50 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F18D03F487; Thu, 3 May 2018 06:20:47 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, catalin.marinas@arm.com, christoffer.dall@arm.com, drjones@redhat.com, marc.zyngier@arm.com, mark.rutland@arm.com, ramana.radhakrishnan@arm.com, suzuki.poulose@arm.com, will.deacon@arm.com, awallis@codeaurora.org Subject: [PATCHv4 04/10] arm64: Don't trap host pointer auth use to EL2 Date: Thu, 3 May 2018 14:20:25 +0100 Message-Id: <20180503132031.25705-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180503132031.25705-1-mark.rutland@arm.com> References: <20180503132031.25705-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To allow EL0 (and/or EL1) to use pointer authentication functionality, we must ensure that pointer authentication instructions and accesses to pointer authentication keys are not trapped to EL2. This patch ensures that HCR_EL2 is configured appropriately when the kernel is booted at EL2. For non-VHE kernels we set HCR_EL2.{API,APK}, ensuring that EL1 can access keys and permit EL0 use of instructions. For VHE kernels host EL0 (TGE && E2H) is unaffected by these settings, and it doesn't matter how we configure HCR_EL2.{API,APK}, so we don't bother setting them. This does not enable support for KVM guests, since KVM manages HCR_EL2 itself when running VMs. Signed-off-by: Mark Rutland Acked-by: Christoffer Dall Cc: Catalin Marinas Cc: Marc Zyngier Cc: Will Deacon Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/include/asm/kvm_arm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 89b3dda7e3cb..4d57e1e58323 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -23,6 +23,8 @@ #include /* Hyp Configuration Register (HCR) bits */ +#define HCR_API (UL(1) << 41) +#define HCR_APK (UL(1) << 40) #define HCR_TEA (UL(1) << 37) #define HCR_TERR (UL(1) << 36) #define HCR_TLOR (UL(1) << 35) @@ -86,7 +88,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ HCR_FMO | HCR_IMO) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) -#define HCR_HOST_NVHE_FLAGS (HCR_RW) +#define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) /* TCR_EL2 Registers bits */