From patchwork Fri Jan 18 17:56:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 156038 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3535889jaa; Fri, 18 Jan 2019 09:56:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/2LKVbhIiqkYo0HdhpR3wqORbbdNTKQj1k7dXkjecY6msbH11OX/BXRgrgxpImuMx/NeO X-Received: by 2002:a63:ee0e:: with SMTP id e14mr18193631pgi.8.1547834194248; Fri, 18 Jan 2019 09:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834194; cv=none; d=google.com; s=arc-20160816; b=EhN9Q9oUSwOMihFMm1UjrvWdnTRISUBGjDaN8jqku8dYMKvwpROTKGqYs/ln5DiyOW 6gYzeCktcR71twMPpWBAIgdhGh4a3F57sAZYAAfiye0EzByCR8tk+jUFmYINYAz3ouF6 MxbGhQPqJlDG+EoMv7on4dvthQD59alOh22ZeAucfcvpWeu2aN36sljo2Yl+Eyy8Cv10 yDkSslbVrKFClOa1c4J/PE5SoTz0t3wVMN96Y4BbkGaOS+HMARzCbqXdrvbAOsTvsbMI tv2FEIuJhaGW1/nNk2ZEkZIjI67+xLije2SENvJ09VQtph6oWpaUdp+rCA3hW6FRHllY ONkQ== 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=o0ntWXbzuvClr2pvb7HxmhHc3QxBR86MJ7L+ymCyBHg=; b=mG1XMdQ/FYRYmAPJG55O5euovU3XUpPOfBlZDk7tH85Z4rQewXhUlLZfZvXwC9RI+6 JptAZ+D/bh+XjGpUlRv9ytvkKTjI2amnol2MnexEnOmLe35z3lZgx2xsis6tXG5tUhKv SUUoFGgqQbypTaXXh53v60ZRslnaFGev2x0lB9t8Pf8GrpNwGp+Xg2ovzDzSICzO7scm 1dW+6+QAPn/1J1TpeZlIfPwpc6BIHrHD7ULc2HWzK35I8j/4I0i6JEcKLZgz9dZglZ0i p00h6nZluhlELrLbraRqZsqB4zRha3puTj0uQbvJ0xy0DSzCvbPp//tRnDUlBbdhYRaH vCYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 11si5084692pgy.408.2019.01.18.09.56.33; Fri, 18 Jan 2019 09:56:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728610AbfARR4d (ORCPT + 15 others); Fri, 18 Jan 2019 12:56:33 -0500 Received: from foss.arm.com ([217.140.101.70]:35880 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbfARR4d (ORCPT ); Fri, 18 Jan 2019 12:56:33 -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 E42CA80D; Fri, 18 Jan 2019 09:56:32 -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 B114B3F7BE; Fri, 18 Jan 2019 09:56:31 -0800 (PST) From: Kristina Martsenko To: stable@vger.kernel.org Cc: Catalin Marinas , Christoffer Dall , Marc Zyngier , Mark Rutland , Will Deacon Subject: [PATCH 4.9 2/2] arm64: Don't trap host pointer auth use to EL2 Date: Fri, 18 Jan 2019 17:56:27 +0000 Message-Id: <20190118175627.6412-2-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190118175627.6412-1-kristina.martsenko@arm.com> References: <7acde9fd-242b-0850-81b3-6dbd4cc75565@arm.com> <20190118175627.6412-1-kristina.martsenko@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland [ Backport of upstream commit b3669b1e1c09890d61109a1a8ece2c5b66804714 ] 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. Reviewed-by: Richard Henderson Signed-off-by: Mark Rutland Acked-by: Christoffer Dall Cc: Catalin Marinas Cc: Marc Zyngier Cc: Will Deacon Cc: kvmarm@lists.cs.columbia.edu Signed-off-by: Will Deacon [kristina: backport to 4.9.y: adjust context] Signed-off-by: Kristina Martsenko --- 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 352bf2f7f60a..a11c8c2915c9 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_E2H (UL(1) << 34) #define HCR_ID (UL(1) << 33) #define HCR_CD (UL(1) << 32) @@ -82,7 +84,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) #define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO) -#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 */