From patchwork Fri Jan 18 17:55:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 156035 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3535759jaa; Fri, 18 Jan 2019 09:56:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN7hA1oUTveUHjYo5ggcgo92BW3XYnp0syLNg4/GfpHH6dJ9VHL5PZhvY3N0PF+KGEQiv4LL X-Received: by 2002:a17:902:5ac2:: with SMTP id g2mr20121047plm.313.1547834184877; Fri, 18 Jan 2019 09:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834184; cv=none; d=google.com; s=arc-20160816; b=U8uaf15U0+DIoU5dpK31i7VCIs6AWxXPNJ7lH9+pDtbsq7YXQnUHChRbbd3T/PMzZL Bjnp4vclDEg7aswU7Gt9aMx2ClRBYjbjULfD+HvvuK1vYtSyV3PLVy/pG9R2U2r98piy H+sGts7K0YWY+n916poSp6B8UCIaUK88ov4pg6pg27CfLrXdvnSF2WLF4wvtyj3r/FIZ D1SlPUX73ck7pVXwD7Uqc6Xe/OAKMpaZcSEPOL9vLpbN748asBH+DxOzgl2wWeBvPtbq EkFfyU0sw6jsdL8BScse0CovYzrziSvXacda2qJ1kaNo08d8mC0maePZpTHX263IhDL7 6zyA== 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=FFwYXZZQrd1TTTwnIe3xDvleKxgDIT+N81KhFsFsF/E=; b=i9aO5M2szFviYggmLZCf64bMWftTEB9H4YxsUGwtsb1UCVWC4ALBJR8cdRssiYjbvb zLzzJUqsBKdD3fuGtZGkMkTSMwca8Fm2AF5SF/h+PM7aahkp7tapaujGMhNoHJBgZH7P SWpajgtws9s3gQWF/m1+veTzECQsocEcWtm+Z+gaOMdUpF6WRPRKVd5XoasxbjQ7sURE +51BOJ+EQb62/OYF9obuEY9UpbhzBHTaDH20OW1Z5kTeGeQsJdKVXitUknNjKym5g2Sl 2nhB903cL++xOLsNZEC+1Rt9KdxoRZXogMFl5MjufuNuOR9zQaagOpmhcTC9PVVWQxIS 9Kdw== 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.24; Fri, 18 Jan 2019 09:56:24 -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 S1728511AbfARR4Y (ORCPT + 15 others); Fri, 18 Jan 2019 12:56:24 -0500 Received: from foss.arm.com ([217.140.101.70]:35866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728439AbfARR4Y (ORCPT ); Fri, 18 Jan 2019 12:56:24 -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 7E54D80D; Fri, 18 Jan 2019 09:56:23 -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 4A27F3F7BE; Fri, 18 Jan 2019 09:56:22 -0800 (PST) From: Kristina Martsenko To: stable@vger.kernel.org Cc: Catalin Marinas , Christoffer Dall , Marc Zyngier , Mark Rutland , Will Deacon Subject: [PATCH 4.4 1/2] arm64/kvm: consistently handle host HCR_EL2 flags Date: Fri, 18 Jan 2019 17:55:53 +0000 Message-Id: <20190118175554.6359-1-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <7acde9fd-242b-0850-81b3-6dbd4cc75565@arm.com> References: <7acde9fd-242b-0850-81b3-6dbd4cc75565@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 4eaed6aa2c628101246bcabc91b203bfac1193f8 ] In KVM we define the configuration of HCR_EL2 for a VHE HOST in HCR_HOST_VHE_FLAGS, but we don't have a similar definition for the non-VHE host flags, and open-code HCR_RW. Further, in head.S we open-code the flags for VHE and non-VHE configurations. In future, we're going to want to configure more flags for the host, so lets add a HCR_HOST_NVHE_FLAGS defintion, and consistently use both HCR_HOST_VHE_FLAGS and HCR_HOST_NVHE_FLAGS in the kvm code and head.S. We now use mov_q to generate the HCR_EL2 value, as we use when configuring other registers in head.S. Reviewed-by: Marc Zyngier Reviewed-by: Richard Henderson Signed-off-by: Mark Rutland Reviewed-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.4.y: non-VHE only; __deactivate_traps_nvhe in assembly; add #include] Signed-off-by: Kristina Martsenko --- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/kernel/head.S | 3 ++- arch/arm64/kvm/hyp.S | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index ef8e13d379cb..013b7de45ee7 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -81,6 +81,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) #define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO) +#define HCR_HOST_NVHE_FLAGS (HCR_RW) /* Hyp System Control Register (SCTLR_EL2) bits */ diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index d019c3a58cc2..0382eba4bf7b 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -464,7 +465,7 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 ret /* Hyp configuration. */ -2: mov x0, #(1 << 31) // 64-bit EL1 +2: mov_q x0, HCR_HOST_NVHE_FLAGS msr hcr_el2, x0 /* Generic timers. */ diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S index 86c289832272..8d3da858c257 100644 --- a/arch/arm64/kvm/hyp.S +++ b/arch/arm64/kvm/hyp.S @@ -494,7 +494,7 @@ .endm .macro deactivate_traps - mov x2, #HCR_RW + mov_q x2, HCR_HOST_NVHE_FLAGS msr hcr_el2, x2 msr hstr_el2, xzr From patchwork Fri Jan 18 17:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristina Martsenko X-Patchwork-Id: 156036 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3535796jaa; Fri, 18 Jan 2019 09:56:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN4RI9SelrT6GaTFSw4S5okEygHqjqXHziKohG544iE+YXj/tjNe+51vqsOO9RkjZnn0xE35 X-Received: by 2002:a62:8e19:: with SMTP id k25mr20240795pfe.185.1547834188128; Fri, 18 Jan 2019 09:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834188; cv=none; d=google.com; s=arc-20160816; b=ZaCuolgWEyVkE0AUfENRaBQEj4UgXd9+oLfRSnnUQScq4xUrynuMuHf61a7C11jIB9 z0uLXw8EAwnBdHMwhr/mwAyac9EH0Qpi6bDXojtwTHC+1NQ6uFGSE7ICppzluVs3PuVp TwgGdFSvb1jV5WXgjVIjcnOX+CP2WyN4FINeSnh6fGO+YsTGfQxDwBjvZHQgbJEDLA0u n16w1LSdETSL747w9c6tpBXhm6q3uvokg2+Q6blyGRGmWM4ndVjTIFAHdp49e5D8Qy+E 57DGAb6hNRJ11btZlAnbOoUZrPcjD+Cb6qXHwjeoVXyj3oOfhtevf9oRszFaW/kkr5OD lQfg== 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=FrmxMtHBx9SmZqyHxD3OSzgaGHTreKiEIM0FWTyCGvs=; b=h/4d8S/HFLFKOYgwTXZTNme5GGTMYlZW6gtFtvlBS1PLOUe3lSkLyRP/8QbdgU6XDj MKBWcgtex/v57PZ4NAzaI29QiT+U/HupvbIN/t3rgyakJ3R5USaW+KoWmccP//MEPNqY ND1BPM83nJUc00Me4QxJSOp4TdQViM/ZjfNU1AvS56yMaMPCNrSmFCpahICF4CoNrqRL /tiuWxg84ZmzAVGrBuUe49rXSbc7ADzTp2PJr6Uy+HUHo2SHwCCimWMtCSazzYVgoa/y jxVjOjyC2y4iFcD4a8ZLxqWe93PW+iDraF+gfrbKYRRp/XCimDL1WmVyMRtnc2eyKnjM WLig== 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.27; Fri, 18 Jan 2019 09:56:28 -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 S1727285AbfARR41 (ORCPT + 15 others); Fri, 18 Jan 2019 12:56:27 -0500 Received: from foss.arm.com ([217.140.101.70]:35872 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728439AbfARR41 (ORCPT ); Fri, 18 Jan 2019 12:56:27 -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 D0FA180D; Fri, 18 Jan 2019 09:56:26 -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 9DB633F7BE; Fri, 18 Jan 2019 09:56:25 -0800 (PST) From: Kristina Martsenko To: stable@vger.kernel.org Cc: Catalin Marinas , Christoffer Dall , Marc Zyngier , Mark Rutland , Will Deacon Subject: [PATCH 4.4 2/2] arm64: Don't trap host pointer auth use to EL2 Date: Fri, 18 Jan 2019 17:55:54 +0000 Message-Id: <20190118175554.6359-2-kristina.martsenko@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190118175554.6359-1-kristina.martsenko@arm.com> References: <7acde9fd-242b-0850-81b3-6dbd4cc75565@arm.com> <20190118175554.6359-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.4.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 013b7de45ee7..d7e7cf56e8d6 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_ID (UL(1) << 33) #define HCR_CD (UL(1) << 32) #define HCR_RW_SHIFT 31 @@ -81,7 +83,7 @@ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) #define HCR_VIRT_EXCP_MASK (HCR_VA | 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) /* Hyp System Control Register (SCTLR_EL2) bits */