Received: by 10.192.165.156 with SMTP id m28csp377793imm; Tue, 17 Apr 2018 11:39:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx480P+jB0eifVjGN1/PK+pZ7L/9BzLI+pfHwM+/9hz8uLZtOkf3+X7h/2AfEOLxmELEUdKAa X-Received: by 2002:a17:902:a582:: with SMTP id az2-v6mr3088322plb.210.1523990378279; Tue, 17 Apr 2018 11:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523990378; cv=none; d=google.com; s=arc-20160816; b=kdWhyQ46eVonGEnKNzrJpi/dGXsEdUPSPsFC7T3BPkLOh1bqhQmFPziJlwU5Ej30m6 3vDaSVShXVdhGlUkNjRJ5CFaqYCnoXMUYUDtN5b16keV6ELj1GRzmxM7j5LKqZAKcMb7 6Z+rLUhb4uAUovZAsMcZo+//0YGfdybKhJys5zTCE8WWa1Cn0L+NDLr51HzRhJKdHrsu WbZ+DSmjUFVD1CUbB8EQbt2iERYqCVv/sQxXA9Frqni2oVm7V/DyFDv8e2P/5GQ8KNYg 7wFz06T4G5pmUQMN3qNu8JusovS2fKaQx20CF2gMBbdSf6/JzkMnLpRw6loQEOpbEKGk BN5Q== 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 az11-v6si13540250plb.81.2018.04.17.11.39.23; Tue, 17 Apr 2018 11:39:38 -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 S1752741AbeDQSiA (ORCPT + 99 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(-) 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 */ -- 2.11.0