From patchwork Fri Oct 5 08:47:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 148160 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp180006lji; Fri, 5 Oct 2018 01:50:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Tmqvy+IPRHr4j/dHkr9/bpEYZ/dSauUc1NaD5PCogB8KkN5TT/jT7r19AUIixiPw4xdK7 X-Received: by 2002:a63:4907:: with SMTP id w7-v6mr9227324pga.123.1538729401530; Fri, 05 Oct 2018 01:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538729401; cv=none; d=google.com; s=arc-20160816; b=Baw/Acz8sXw0vIO20H0XzwfhT7QYaHD8pDRfnVipPMGiYE/6CquqDGWTkErV/HMeSv yuolW9BkaNcr1Z1WCj1f82re8YSXi/Vh1j0+OpUIFh4eoD6o5XQh+g64ZQH75QDBiFTp OeLiMBlRvXVWCuO4+2bPZWM7GKUTwzfM4mD19XR2mNUUUJjvEM89GhmR7lNX+jNg+bub hox6/NrSAKKurL39KKi8AvM6UgUGVyzuEY5Lh8Hg43Xuv245JRe/UZYke1poaLw2dO+m K8jIk9DHm4puZxhGfx/FocnDrMgmctPCaTnbQOvol6tcGpIwBR37AbXYGJFalcc61FRt GNwg== 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 e92-v6si8102633pld.358.2018.10.05.01.50.01; Fri, 05 Oct 2018 01:50:01 -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 S1728772AbeJEPrn (ORCPT + 32 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(-) -- 2.11.0 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 */