From patchwork Mon Feb 26 08:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129601 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3359829lja; Mon, 26 Feb 2018 00:27:54 -0800 (PST) X-Google-Smtp-Source: AH8x225p7gr/V2hI/QtTp1e2muSu/u6Qr0bbHLcrc8aa5ccTvfZRlejrokXRDNQ3D05Jl5KV8135 X-Received: by 2002:a17:902:a504:: with SMTP id s4-v6mr10155526plq.43.1519633674865; Mon, 26 Feb 2018 00:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633674; cv=none; d=google.com; s=arc-20160816; b=C0wVx3vGrmQhY1ePenvNeCbmlhwbgCRvNNVYMXIDJli8HKkpg5rYkUYWVXSLNjh/lW lavbhMDHi8R7YlXKOqunTfOqHZh9Miq2ShNctfvcCWw3SNFPdGt5ilcym81VN4hOTpFq 33QswwZ+P5WJl6O04XnTd/mTXySrwGt7G4suii8r1AOEDrnwdURv634Fky+vnMe0+rYE 0dzxpvTZpU9lNleImhJ6tvKl3S7ItaRXSO6s/adUNkjgPaxdp5FgWy4xN2S6BO7B1JZ+ nh6DZqAc6jl8KpEsLDy+rU1FdNKjaXPVC/siSJTwCB4HXVZlvIZRDZfvEFSKZOzUQEzm BKnQ== 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:to:from:dkim-signature:arc-authentication-results; bh=TVG6WlEkeS+IhPzLyRKtulufYo3MBwa/boLRfDGGR6U=; b=WmjBr3+QGi0T9KITuYI4LhwStcOzvno7qyDBBY2kXzCHtJ6hfURKFsq+Bo+wqJ3m31 eUqbUnHt2bwf+Iy+VRA76w1Cc0UTmhdWg1z1vESMzRMjxprc5K+6O/q7OoaUJh41p+BE avFR93IUosQjGWUYUO/2hV+o4NY3rYWgIJgXyW2AjlTC23lREih7DGCIuvs6ykLSe0ut HLeQps/Mt16SUJZlcLxjP5Nkc4HogZMW6pL3/cTBKkF7T++VLay3F+u4G8S9EipWu4vn eUNXXFxWQAWvZcvqz4ZUEvIFGuzG+OmvCbCeRst3KLC84KMUAOenofkrGn7Tz7xwjZnn EZtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D16PV8HT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23-v6si6600728plk.810.2018.02.26.00.27.54; Mon, 26 Feb 2018 00:27:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=D16PV8HT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752433AbeBZI1x (ORCPT + 10 others); Mon, 26 Feb 2018 03:27:53 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39720 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752890AbeBZI1t (ORCPT ); Mon, 26 Feb 2018 03:27:49 -0500 Received: by mail-pl0-f67.google.com with SMTP id s13so8864839plq.6 for ; Mon, 26 Feb 2018 00:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=TVG6WlEkeS+IhPzLyRKtulufYo3MBwa/boLRfDGGR6U=; b=D16PV8HTTATeyZl6Ni3Yo6Wioqh3zuHxq2xZnFTqUYLnViWRyw0VIfd2HrfiZuJs+G ogt+dGmsiCyIaXdIMNe3S+YzeN8SgV8C54djUtgwJviaAL8Ez88fUgWVWMEUQkfpSoxr Bra4SXrMnYnQr8PnS9P9bEH2zZaUG2mZO1qxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TVG6WlEkeS+IhPzLyRKtulufYo3MBwa/boLRfDGGR6U=; b=UWB0Vov8OqyJZxlhgp5PVmundOKwv1bfKJyV2kV+u2WpR0OxoNmk2Vpd4fu0e3Ez0T IFfDHlQPddrCcBDDdfxauNRJz8rNaEY0QiqVF4yMw6bx28xKenn8rWkM62jESLf+de9T xrd3GO5ORryzFXLCkJD+ivAC17rNgr2GE+SvuZATlhSCKcDBI27qF7x0WcR1tLdBbMHM UmiInk9spwRap1gV+r0mbtlyNWe4vhWbs1JAd0l7gFXqh04lWNRtdf6gb/tG8YuQjHgi 9TjwxEOazJ4ocqPkRRXxnW0ShjhRZYun3HqRmRD5N4ikar0vt+1s9/snYk4Vl1aqXpub 5r5w== X-Gm-Message-State: APf1xPBij0L2ig/PIzS7MtbVV2AV2KmOgz2kACAfGNuNsjnL/xjF4XA+ L70jfWSihR78Koxm9uJg6/i1qQ== X-Received: by 2002:a17:902:5e3:: with SMTP id f90-v6mr9954123plf.413.1519633669077; Mon, 26 Feb 2018 00:27:49 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:27:48 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Christoffer Dall , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Russell King , linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE (KVM) FOR ARM), kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE (KVM) FOR ARM), kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 51/52] arm: KVM: Invalidate icache on guest exit for Cortex-A15 Date: Mon, 26 Feb 2018 16:20:25 +0800 Message-Id: <1519633227-29832-52-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier ** Not yet queued for inclusion in mainline ** In order to avoid aliasing attacks against the branch predictor on Cortex-A15, let's invalidate the BTB on guest exit, which can only be done by invalidating the icache (with ACTLR[0] being set). We use the same hack as for A12/A17 to perform the vector decoding. Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- arch/arm/include/asm/kvm_mmu.h | 5 +++++ arch/arm/kvm/hyp/hyp-entry.S | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) -- 2.7.4 diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h index 2887129..a602467 100644 --- a/arch/arm/include/asm/kvm_mmu.h +++ b/arch/arm/include/asm/kvm_mmu.h @@ -235,6 +235,11 @@ static inline void *kvm_get_hyp_vector(void) return kvm_ksym_ref(__kvm_hyp_vector_bp_inv); } + case ARM_CPU_PART_CORTEX_A15: + { + extern char __kvm_hyp_vector_ic_inv[]; + return kvm_ksym_ref(__kvm_hyp_vector_ic_inv); + } #endif default: { diff --git a/arch/arm/kvm/hyp/hyp-entry.S b/arch/arm/kvm/hyp/hyp-entry.S index b6b8cb1..4492768 100644 --- a/arch/arm/kvm/hyp/hyp-entry.S +++ b/arch/arm/kvm/hyp/hyp-entry.S @@ -73,6 +73,28 @@ __kvm_hyp_vector: #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR .align 5 +__kvm_hyp_vector_ic_inv: + .global __kvm_hyp_vector_ic_inv + + /* + * We encode the exception entry in the bottom 3 bits of + * SP, and we have to guarantee to be 8 bytes aligned. + */ + W(add) sp, sp, #1 /* Reset 7 */ + W(add) sp, sp, #1 /* Undef 6 */ + W(add) sp, sp, #1 /* Syscall 5 */ + W(add) sp, sp, #1 /* Prefetch abort 4 */ + W(add) sp, sp, #1 /* Data abort 3 */ + W(add) sp, sp, #1 /* HVC 2 */ + W(add) sp, sp, #1 /* IRQ 1 */ + W(nop) /* FIQ 0 */ + + mcr p15, 0, r0, c7, c5, 0 /* ICIALLU */ + isb + + b decode_vectors + + .align 5 __kvm_hyp_vector_bp_inv: .global __kvm_hyp_vector_bp_inv @@ -92,6 +114,8 @@ __kvm_hyp_vector_bp_inv: mcr p15, 0, r0, c7, c5, 6 /* BPIALL */ isb +decode_vectors: + #ifdef CONFIG_THUMB2_KERNEL /* * Yet another silly hack: Use VPIDR as a temp register.