From patchwork Tue Jul 21 09:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11675267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DED3B13A4 for ; Tue, 21 Jul 2020 09:46:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8DD3206E9 for ; Tue, 21 Jul 2020 09:46:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z097BSI3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="tWR9rnlY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8DD3206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QrzA50D1w4MlCfWNFKnkYu7GbJSj2cnD427RwkA3CYo=; b=Z097BSI3rH9sbTJBXttvnegdx f2sYJEQPEVcLhLcgjvqsQyOeL+PEAV9AKVTTGpO8J8862ZKKg0EWuqZ5RX/AE3aFoBBN9qtKNFIBF O2zK0O9OdNOiAlXrncPVEMUK9pqYBQdQUhKcdzuitA6BOvmnSLRek8faBxusNdwX12kXMRDnHnPe6 n02Ze7WpVoU8F4RbIumxYCEglTjZQHxXZ1wCUT8JC3N+FkDEaZt07dG7oS2Z/u45vNaEBRGwLLkkq 6ecdGDKGi3g5iTZm51Q6/F0oaAE5v5XDycxlAsQuSM8yY/z2FOc6jE6zQg5lKLY4/qYasXE/FDojT GaNaBKs1Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxopm-0002KL-Qe; Tue, 21 Jul 2020 09:45:16 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxopb-0002GD-Qp for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2020 09:45:05 +0000 Received: by mail-wm1-x343.google.com with SMTP id o8so2149636wmh.4 for ; Tue, 21 Jul 2020 02:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O5bPnopOLq11q64kzXObPPX3zXeboctA7LnF6OeX/Us=; b=tWR9rnlYloerCveUYnUsgHR6uCRBFYzwqBsetdUug9EvMRIwBXaG4SCjOMjVtauMUJ 97N1WZ621rikPNoHQXNmrVmESpg0gZnwcNLiH60UOxggwcfd4lAZ6EYDxsBtqU3x9EYS Y7Exsd59gYnIzinxGWKObN+zfguxbE7NftfkR2U02GA1SsvSbV8d+qC3Bno2dVpbGuDQ adG6BsK3byX4yKpmDko9Usb+E4ha4gtYeYEf3lYAUSUkxD2CtRzicn8iWMWaf0ivy4p7 Xp+2/knS7ku/h2J4ZPmygJeDRN0zN0AJf4u5D2FkFmKcY58v7CfFg5L0yCEre3Dwa1GQ 7UZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O5bPnopOLq11q64kzXObPPX3zXeboctA7LnF6OeX/Us=; b=s7w1JYebzWNJcBJ1EqJHwfHZIIRX5nBrV8Q9AsFmjk9KPlkBxdytr8DOvtcCIZEddD v80wfXfGLWQeTbfEFFRNEzZJM0nxYRHtbTsWiCU3kSiRDMsx0WsyOIRRs3bDNRWT51Pv pp4n20VEOU2KwrvrMOJe3D1dxBmjQI11rTq2siZpruoOBc6jUeGFkjYUpf7501PL6NQ/ Db3ZL8vAFKM2tfD3gd9aCOMCnpGMz2rtPw8F+8GavBKFDx7NgdI5Hy5SqMwqqCiJldT1 N40bA4dUohKNEoHMoMQG5V0929dY8Bi5/+P4St1WZpJzRQxzfBCWojD7jj70I64Yo623 xKRg== X-Gm-Message-State: AOAM532/iTxNDSdp9EYXEe/W43zzb0fwp2o8emkkSqBSX69ZqoSu9Jka inPioxdhQxUvCFfZGBvrafm8eg== X-Google-Smtp-Source: ABdhPJwAbje3FiMydnF5IO/xJvjntypm8jgHonmXqBcBqkgG96tfrwMxDpijIOUo3wHwTBkkF6mM/A== X-Received: by 2002:a1c:48d:: with SMTP id 135mr3387581wme.102.1595324702381; Tue, 21 Jul 2020 02:45:02 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:cd93:4ca4:af31:19e5]) by smtp.gmail.com with ESMTPSA id s203sm2809491wms.32.2020.07.21.02.45.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2020 02:45:01 -0700 (PDT) From: David Brazdil To: Marc Zyngier , Will Deacon , Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose Subject: [PATCH 2/2] KVM: arm64: Substitute RANDOMIZE_BASE for HARDEN_EL2_VECTORS Date: Tue, 21 Jul 2020 10:44:45 +0100 Message-Id: <20200721094445.82184-3-dbrazdil@google.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200721094445.82184-1-dbrazdil@google.com> References: <20200721094445.82184-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200721_054503_972902_E7831F3E X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -15.7 (---------------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-15.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: android-kvm@google.com, linux-kernel@vger.kernel.org, David Brazdil , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The HARDEN_EL2_VECTORS config maps vectors at a fixed location on cores which are susceptible to Spector variant 3a (A57, A72) to prevent defeating hyp layout randomization by leaking the value of VBAR_EL2. Since this feature is only applicable when EL2 layout randomization is enabled, unify both behind the same RANDOMIZE_BASE Kconfig. Majority of code remains conditional on a capability selected for the affected cores. Signed-off-by: David Brazdil --- arch/arm64/Kconfig | 16 ---------------- arch/arm64/include/asm/mmu.h | 6 ++---- arch/arm64/kernel/cpu_errata.c | 4 ++-- arch/arm64/kvm/Kconfig | 2 +- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 66dc41fd49f2..527d217baf55 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1182,22 +1182,6 @@ config HARDEN_BRANCH_PREDICTOR If unsure, say Y. -config HARDEN_EL2_VECTORS - bool "Harden EL2 vector mapping against system register leak" if EXPERT - default y - help - Speculation attacks against some high-performance processors can - be used to leak privileged information such as the vector base - register, resulting in a potential defeat of the EL2 layout - randomization. - - This config option will map the vectors to a fixed location, - independent of the EL2 code mapping, so that revealing VBAR_EL2 - to an attacker does not give away any extra information. This - only gets enabled on affected CPUs. - - If unsure, say Y. - config ARM64_SSBD bool "Speculative Store Bypass Disable" if EXPERT default y diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 8444df000181..e26542c0e79e 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -45,12 +45,10 @@ struct bp_hardening_data { bp_hardening_cb_t fn; }; -#if (defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \ - defined(CONFIG_HARDEN_EL2_VECTORS)) - +#ifdef CONFIG_KVM_INDIRECT_VECTORS extern char __bp_harden_hyp_vecs[]; extern atomic_t arm64_el2_vector_last_slot; -#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR || CONFIG_HARDEN_EL2_VECTORS */ +#endif #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR DECLARE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data); diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 79728bfb5351..6bd1d3ad037a 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -632,7 +632,7 @@ has_neoverse_n1_erratum_1542419(const struct arm64_cpu_capabilities *entry, return is_midr_in_range(midr, &range) && has_dic; } -#if defined(CONFIG_HARDEN_EL2_VECTORS) +#ifdef CONFIG_RANDOMIZE_BASE static const struct midr_range ca57_a72[] = { MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), @@ -891,7 +891,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, .matches = check_branch_predictor, }, -#ifdef CONFIG_HARDEN_EL2_VECTORS +#ifdef CONFIG_RANDOMIZE_BASE { .desc = "EL2 vector hardening", .capability = ARM64_HARDEN_EL2_VECTORS, diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 13489aff4440..318c8f2df245 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -58,7 +58,7 @@ config KVM_ARM_PMU virtual machines. config KVM_INDIRECT_VECTORS - def_bool HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS + def_bool HARDEN_BRANCH_PREDICTOR || RANDOMIZE_BASE endif # KVM