Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp179887imm; Fri, 5 Oct 2018 01:50:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV61L5Ibn5v/kW4nRfs4ByohDI8luC0T/RIbo2DPRU/TY7s3gJ9KxgEHtzmShn9/wX40Cvloq X-Received: by 2002:a63:4343:: with SMTP id q64-v6mr9470007pga.276.1538729442396; Fri, 05 Oct 2018 01:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538729442; cv=none; d=google.com; s=arc-20160816; b=OZYcSbxJ9EjE9s7aKhjOMO/V/lwhUB0j8927mR2lO5gQJOSXu1tUPOyWEO/aUzK3ch 4smo968RzcXUiKe8y8i5FGhFfxuH5+6czzyajhU4Ee2nvwrzNZLdidfftxPRq03K1IoW HPhJnog6Lb911YyPiMadcTq/RX/roJqRfvzPwKfcRuYTZ9nI4CSZWCgJ1bCj17MG1gxu NTKllp05P2biajysOwzwUlbMHvRU9PrO56z/9TtR8J3YCM4p64chN9sUzRQVFK1F8NRX VL/CNSqWP4Y+LIAprMFxlao2QDXNNP+e4sISdufy4oOQ8npyqolQq4etXEse33d+3OPh YDDQ== 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=IJC+bErrrPCxZKrk0SrvFxVMowYvffsVjpH9R0nOJEo=; b=Sosl/FS0IcXhnjnAlI+8xXxSRC39ht6KjDbedIwbYj75ckodBJpeswfmuoTGB9W1Ge dKaR19uILGMHK7T6T+haK0L1R0e5SecAoiVIW5di+shJcbhCYIgcYw65ZlqiNhwP+o9Y WiSHxl9zOGX0jJNP1IPqObzpIG/JSv3Zqc4e+AXOZAqGitAc28hnbOhaNYloTHaM7sJ9 lfE2gK5bi0HYs/R4uHDgrujQGQnaRePo9j7ICNZF+iRj57UpBqkMcp3H/VqylWZRky6v 8xXQ3jAR1t39iJ+jp06dFNufMRh3CGRWPODTpmzkXYZIAqgcY1xckNf7EeS9MIiIryip dIgA== 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 p3-v6si7926389pld.329.2018.10.05.01.50.26; Fri, 05 Oct 2018 01:50:42 -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 S1728768AbeJEPrn (ORCPT + 99 others); Fri, 5 Oct 2018 11:47:43 -0400 Received: from foss.arm.com ([217.140.101.70]:47816 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728625AbeJEPrm (ORCPT ); Fri, 5 Oct 2018 11:47:42 -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 AF5DD15BE; Fri, 5 Oct 2018 01:49:58 -0700 (PDT) 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 79D113F5B3; Fri, 5 Oct 2018 01:49:55 -0700 (PDT) From: Kristina Martsenko To: linux-arm-kernel@lists.infradead.org Cc: Adam Wallis , Amit Kachhap , Andrew Jones , Ard Biesheuvel , Arnd Bergmann , Catalin Marinas , Christoffer Dall , Dave P Martin , Jacob Bramley , Kees Cook , Marc Zyngier , Mark Rutland , Ramana Radhakrishnan , "Suzuki K . Poulose" , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/17] arm64: Don't trap host pointer auth use to EL2 Date: Fri, 5 Oct 2018 09:47:41 +0100 Message-Id: <20181005084754.20950-5-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181005084754.20950-1-kristina.martsenko@arm.com> References: <20181005084754.20950-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(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index f885f4e96002..1405bb24acac 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 */ -- 2.11.0