From patchwork Fri Nov 23 18:40:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 10696289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34D0D5A4 for ; Fri, 23 Nov 2018 18:41:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 232622BFC0 for ; Fri, 23 Nov 2018 18:41:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1782E2BFC3; Fri, 23 Nov 2018 18:41:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9FD02BFC0 for ; Fri, 23 Nov 2018 18:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395445AbeKXF0n (ORCPT ); Sat, 24 Nov 2018 00:26:43 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51144 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728423AbeKXF0n (ORCPT ); Sat, 24 Nov 2018 00:26:43 -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 6A8B53620; Fri, 23 Nov 2018 10:41:16 -0800 (PST) Received: from filthy-habits.cambridge.arm.com (filthy-habits.cambridge.arm.com [10.1.196.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E402B3F5CF; Fri, 23 Nov 2018 10:41:14 -0800 (PST) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Will Deacon , Catalin Marinas , Christoffer Dall , Mark Rutland , Suzuki K Poulose Subject: [PATCH v2 0/8] Workaround for Cortex-A76 erratum 1165522 Date: Fri, 23 Nov 2018 18:40:59 +0000 Message-Id: <20181123184107.39334-1-marc.zyngier@arm.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Early Cortex-A76 suffer from an erratum that can result in invalid TLBs when the CPU speculatively executes an AT instruction in the middle of a guest world switch, while the guest virtual memory configuration is in an inconsistent state. We handle this issue by mandating the use of VHE and making sure that the guest context is fully installed before switching HCR_EL2.TGE to zero. This ensures that a speculated AT instruction is either executed on the host context (TGE set) or the guest context (TGE clear), and that there is no intermediate state. There is some additional complexity in the TLB invalidation code, where we most make sure that a speculated AT instruction cannot mess the stage-1 TLBs. * From v1: - VHE TLB invalidation now atomic - Avoid speculated AT during TLB invalidation - Addressed most comments from Christoffer - Resplit to ease reviewing Marc Zyngier (8): arm64: KVM: Make VHE Stage-2 TLB invalidation operations non-interruptible KVM: arm64: Rework detection of SVE, !VHE systems arm64: KVM: Install stage-2 translation before enabling traps arm64: Add TCR_EPD{0,1} definitions arm64: KVM: Force VHE for systems affected by erratum 1165522 arm64: KVM: Add synchronization on translation regime change for erratum 1165522 arm64: KVM: Handle ARM erratum 1165522 in TLB invalidation arm64: Add configuration/documentation for Cortex-A76 erratum 1165522 Documentation/arm64/silicon-errata.txt | 1 + arch/arm/include/asm/kvm_host.h | 2 +- arch/arm64/Kconfig | 12 +++++ arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/kvm_host.h | 10 ++-- arch/arm64/include/asm/kvm_hyp.h | 7 +++ arch/arm64/include/asm/pgtable-hwdef.h | 4 ++ arch/arm64/kernel/cpu_errata.c | 8 +++ arch/arm64/kvm/hyp/switch.c | 23 +++++++- arch/arm64/kvm/hyp/tlb.c | 73 ++++++++++++++++++++++---- virt/kvm/arm/arm.c | 8 +-- 11 files changed, 130 insertions(+), 21 deletions(-)