Received: by 10.223.185.116 with SMTP id b49csp2185298wrg; Thu, 15 Feb 2018 07:47:53 -0800 (PST) X-Google-Smtp-Source: AH8x226gK/p5FSIen2kDNlRqB6+1knzH+1Hon5oZ8hRrIDfIz45D1VRNAtH3c46UFsqKSKtN/ilu X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr2067966pln.172.1518709673140; Thu, 15 Feb 2018 07:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518709673; cv=none; d=google.com; s=arc-20160816; b=lTZ5b/zXhTQluUVui7vk4gxJr/dbLbTUkYqlOX/tGvGDEntY8HXJj31LL59C5UQJlu AXw/R3Kbrtu2OAKVkJYs2+TZTH3pErL7SUxzpGsQvh8oKFsUpC4mXs/YfraLK4rZvqGk lQKH6KpzLfAD+G4b2nwHbz3Vex+JTIXgaBy4LJa5KMk+UomBZ2sN0eszqHcPMi3mKhmE aG7Q0ZA5UTpNfNiOufl7xobtxV4+v6zqMjI6ERpAbeKfTmcrugmyQ8eRGWjXJDTZgrbr cF0myutqNckLfXEWTnk1wDzdIayIVmc84Rz4x1yHKrzM0mnvYZzC7wdX9HsZ4N9ZbXTd UCeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=kqZ7jxm9xXEoJSAbIWwowPulwEGc2IYKJH9zPYCgz7g=; b=hiFI5k3Wi7GUrNRz9gvEtkftaDZHVBwGijxlj17+qCJCSABk/sceeuEEcov0xLa6N9 66vHoWWnldZrFERToqEEYeeM/g0IBBI8/NEBFVF+OMhjF/fUDESLTL7WttCP2HYbym4j O+HiluOdG4pK+p4tGkEqReNS6Il3On6p2HofugAgiFQHsR1g6S/ORFx1+FC0DxNExIgc PmgmrBcXmgI2QDwiZJ2/JV4JFi7IgCjtV0QasQZUTL5xyUITEa9kMPA/BfOOjAWST1C+ P2bOhZwLHhGNLJrYLPHTVDkv0qReUJfEL2Bfvyb9aeU4HY81bpRBdMc+EQTTtSaoAeKj rEnA== 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 76si2716789pga.261.2018.02.15.07.47.38; Thu, 15 Feb 2018 07:47:53 -0800 (PST) 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 S1424680AbeBOPq1 (ORCPT + 99 others); Thu, 15 Feb 2018 10:46:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35468 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424630AbeBOPqY (ORCPT ); Thu, 15 Feb 2018 10:46:24 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 43E36C26; Thu, 15 Feb 2018 15:46:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Mackerras Subject: [PATCH 4.15 133/202] KVM: PPC: Book3S HV: Make sure we dont re-enter guest without XIVE loaded Date: Thu, 15 Feb 2018 16:17:13 +0100 Message-Id: <20180215151720.117639469@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Mackerras commit 43ff3f65234061e08d234bdef5a9aadc19832b74 upstream. This fixes a bug where it is possible to enter a guest on a POWER9 system without having the XIVE (interrupt controller) context loaded. This can happen because we unload the XIVE context from the CPU before doing the real-mode handling for machine checks. After the real-mode handler runs, it is possible that we re-enter the guest via a fast path which does not load the XIVE context. To fix this, we move the unloading of the XIVE context to come after the real-mode machine check handler is called. Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller") Signed-off-by: Paul Mackerras Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -1423,6 +1423,26 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) blt deliver_guest_interrupt guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ + /* Save more register state */ + mfdar r6 + mfdsisr r7 + std r6, VCPU_DAR(r9) + stw r7, VCPU_DSISR(r9) + /* don't overwrite fault_dar/fault_dsisr if HDSI */ + cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE + beq mc_cont + std r6, VCPU_FAULT_DAR(r9) + stw r7, VCPU_FAULT_DSISR(r9) + + /* See if it is a machine check */ + cmpwi r12, BOOK3S_INTERRUPT_MACHINE_CHECK + beq machine_check_realmode +mc_cont: +#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING + addi r3, r9, VCPU_TB_RMEXIT + mr r4, r9 + bl kvmhv_accumulate_time +#endif #ifdef CONFIG_KVM_XICS /* We are exiting, pull the VP from the XIVE */ lwz r0, VCPU_XIVE_PUSHED(r9) @@ -1460,26 +1480,6 @@ guest_exit_cont: /* r9 = vcpu, r12 = tr eieio 1: #endif /* CONFIG_KVM_XICS */ - /* Save more register state */ - mfdar r6 - mfdsisr r7 - std r6, VCPU_DAR(r9) - stw r7, VCPU_DSISR(r9) - /* don't overwrite fault_dar/fault_dsisr if HDSI */ - cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE - beq mc_cont - std r6, VCPU_FAULT_DAR(r9) - stw r7, VCPU_FAULT_DSISR(r9) - - /* See if it is a machine check */ - cmpwi r12, BOOK3S_INTERRUPT_MACHINE_CHECK - beq machine_check_realmode -mc_cont: -#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING - addi r3, r9, VCPU_TB_RMEXIT - mr r4, r9 - bl kvmhv_accumulate_time -#endif mr r3, r12 /* Increment exit count, poke other threads to exit */