From patchwork Fri Dec 7 18:39:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 153188 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp831468ljp; Fri, 7 Dec 2018 10:40:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VkkGwSwmgEGGBBIIpidlTQuCYXJQMKfXgW6e46qyaNjiktSyP03NesFd8KSGTLmwVRo4zm X-Received: by 2002:a62:29c3:: with SMTP id p186mr3361227pfp.117.1544208024201; Fri, 07 Dec 2018 10:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544208024; cv=none; d=google.com; s=arc-20160816; b=X/VspfMmJmB4cweYFK295S8FGBwzZN6pmmc5PdmwaCmYXqpuA7H6Ga3v/ljywAcxtv 7x0tYGrxAWxYcN72ZoafLdDAuAl/MrZZepoAhqzc4Pf8jibslEWxhKM37Xgxdrh9S/ag +uI8EmoWwm9bSnVrNyRYErNKrLmjlaFw30T6V9r3Ifti+QQ910frpp2Xniw1sWRRSoAv eqISK/iDUy3n0f8uuA4JYr+07lgvxGPnpFlCb6dka1Gp968Cyb31sjS1oeHkTwGO94t3 vSk5RSDPV1P3Sdio0F+TWb2IHfGum3hovDUP01LafIbw/jPHT1LYZyHSyLKfs+yv3hSx EGMQ== 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; bh=5w/sl/Rt/OtFe0TehiZwFIexvw0GuwIR1aoZZqswglg=; b=sGSIElDgdZTBO05vTU49FXExqpbUo7aEcqP6cYzmxtyAFBjYpD9AT8aDMV8R+g003V cyCJR4/YN9wayW5BbL00JBiFqoT7NsqoATvlp6NF/UGM4JVDrbGBx2aumXW+jJFgjWA5 5WGW/00T2m8BVArIfRHjPpmDwmnhFpzfbsibNAtVB7Rxu3WO8axLE5B4ad49ENHMp587 47ZcAJqimBrvuIuWKlSbFdHHQsdm2mhgFpfamL0beJhghIQvHD7sD3b/dyi3VecxPTYj EpztXfSX8AC+/CPDx1Wuk8haWBlEpNyAlxYlk8y+QtDuqrQJk8mBoKulgL0C7343KCgN sBlw== 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 x16si3150685pga.407.2018.12.07.10.40.23; Fri, 07 Dec 2018 10:40:24 -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; 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 S1726329AbeLGSkW (ORCPT + 31 others); Fri, 7 Dec 2018 13:40:22 -0500 Received: from foss.arm.com ([217.140.101.70]:52018 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbeLGSkU (ORCPT ); Fri, 7 Dec 2018 13:40:20 -0500 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 13B8815AD; Fri, 7 Dec 2018 10:40:20 -0800 (PST) Received: from moonbear.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE0B33F5AF; Fri, 7 Dec 2018 10:40:16 -0800 (PST) From: Kristina Martsenko To: linux-arm-kernel@lists.infradead.org Cc: Adam Wallis , Amit Kachhap , Andrew Jones , Ard Biesheuvel , Catalin Marinas , Christoffer Dall , Cyrill Gorcunov , Dave P Martin , Jacob Bramley , Kees Cook , Marc Zyngier , Mark Rutland , Ramana Radhakrishnan , Richard Henderson , Suzuki K Poulose , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [PATCH v6 05/13] arm64: Don't trap host pointer auth use to EL2 Date: Fri, 7 Dec 2018 18:39:23 +0000 Message-Id: <20181207183931.4285-6-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181207183931.4285-1-kristina.martsenko@arm.com> References: <20181207183931.4285-1-kristina.martsenko@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland 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 Signed-off-by: Kristina Martsenko 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 Reviewed-by: Richard Henderson diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index c8825c5a8dd0..f9123fe8fcf3 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -24,6 +24,8 @@ /* Hyp Configuration Register (HCR) bits */ #define HCR_FWB (UL(1) << 46) +#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) @@ -87,7 +89,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 */