From patchwork Tue Apr 17 18:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 133573 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5035807ljb; Tue, 17 Apr 2018 11:38:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/rIijPehGZPMqhMaVV4IleaIxzCstOLUPsDNB90CnOJe9wPUsS0xlKL3FyiABe0VM3rLDQ X-Received: by 10.167.130.85 with SMTP id e21mr3027153pfn.86.1523990284457; Tue, 17 Apr 2018 11:38:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523990284; cv=none; d=google.com; s=arc-20160816; b=JhZ/Mo1vYOkG3JMkax4JYWPAB8/Fbx7/Qqi/shn3PRyYZXNzbiAbdjxzKOMws/3W+h 8KVlWGO5o4ldLF1vBOSBQQ2O8yukIDiuFdDU8FgtYGMMtINQ9eABKXw4U0wfcO2EII7A 3PzZ6rT0tWbBgj1l515aeKp45obUSGr1/gQAJlCwe0NShthL4affPGOpxdqcq5Mc/4Ww xfEuQCfRT3J56kDSnoTfxeFwmERo/tGrt3RlYGH2IfIKS8grC7pvCidiMGXQcrePKX0c kjTEICdaTj8UojNtzfLOw//widKuZZNOTzfvwbZUQVoqDOyFHnabGRKgbrdkqtlGR+wM QE3g== 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:arc-authentication-results; bh=Fn8xtB+CwNlvAku6GAuXB7RMe1286hdtILaL+6SVwIU=; b=DmqEFs4GznLldcRRpLCtnOGmDBuPUwnsugt/5bXeCMtIKDs2hGfrLoHeqAwaqE0mrt tDTZwL43IiON0bUy+wCP031TtprCNUzQhsw43bwAsxhD83kxEz9Mc4iCrJ8jVxlVZBlJ NTf2RYxDAyOcU7tTJrvv4bSmXNPxePyXuNrH57e7GGRk/cDWOwzKp+hXY3gejey4hF8K qJ5yKydbhk8yWLDt5f9/CRLBt3SZrBsz9RHpsATZ/TXPOmBz4ksl2F8UswDiqtywiRgd 6QArB8s8QElqD50So36Acikm6CNUS4hGqWhaxhAh14ZiEPBJ1CVLMoG0l27mgusupb64 7j/w== 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 a5-v6si15012195pls.571.2018.04.17.11.38.04; Tue, 17 Apr 2018 11:38:04 -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 S1752747AbeDQSiA (ORCPT + 29 others); Tue, 17 Apr 2018 14:38:00 -0400 Received: from foss.arm.com ([217.140.101.70]:46984 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604AbeDQSh6 (ORCPT ); Tue, 17 Apr 2018 14:37:58 -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 A6B4915BF; Tue, 17 Apr 2018 11:37:58 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C7953F587; Tue, 17 Apr 2018 11:37:56 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: arnd@arndb.de, catalin.marinas@arm.com, cdall@kernel.org, drjones@redhat.com, kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, ramana.radhakrishnan@arm.com, suzuki.poulose@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, awallis@codeaurora.org, kernel-hardening@lists.openwall.com Subject: [PATCHv3 04/11] arm64: Don't trap host pointer auth use to EL2 Date: Tue, 17 Apr 2018 19:37:28 +0100 Message-Id: <20180417183735.56985-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180417183735.56985-1-mark.rutland@arm.com> References: <20180417183735.56985-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: 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 89b3dda7e3cb..4d57e1e58323 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_TEA (UL(1) << 37) #define HCR_TERR (UL(1) << 36) #define HCR_TLOR (UL(1) << 35) @@ -86,7 +88,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 */