From patchwork Tue Mar 8 03:08:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 593839 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46F82140557 for ; Tue, 8 Mar 2016 14:41:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=F6FyxPRt; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 0C8661A0C6F for ; Tue, 8 Mar 2016 14:41:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=F6FyxPRt; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 8C1B01A0311 for ; Tue, 8 Mar 2016 14:09:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=F6FyxPRt; dkim-atps=neutral Received: by ozlabs.org (Postfix, from userid 1007) id 6556A140BF9; Tue, 8 Mar 2016 14:09:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1457406554; bh=gAAEY6ohk6Ty8AwM/BndlFkUWo7keLvqNuQxP4JcJ0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F6FyxPRtMehbvFD3prK8Ni9zpohENoeKKQcuob8cTbc55z+ASwPvYLnnPFJlap3wD nzYwbQX92WrnAA2vwCGFEea1syhEKuqF2Fd8A9ajRvoZuhVN+Y+l6cGWQqrEB+ZSKy uC0x475OImPAwJPSfZjweAG+o4UOZ717POq7TJmg= From: David Gibson To: paulus@samba.org, aik@ozlabs.ru, benh@kernel.crashing.org Subject: [RFCv2 21/25] powerpc/kvm: Make MMU notifiers HPT resize aware Date: Tue, 8 Mar 2016 14:08:58 +1100 Message-Id: <1457406542-6210-22-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457406542-6210-1-git-send-email-david@gibson.dropbear.id.au> References: <1457406542-6210-1-git-send-email-david@gibson.dropbear.id.au> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , linuxppc-dev@lists.ozlabs.org, bharata@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" While an HPT resize operation is in progress, specifically when a tentative HPT has been allocated and we are possibly in the middle of populating it various host side MM events need to be reflected in the tentative resized HPT as well as the currently active one. This extends the powerpc KVM MMU notifiers to act on both the active and tentative HPTs (and reverse maps) when there is an active resize in progress. Signed-off-by: David Gibson --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index db070ad..5b84347 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -97,6 +97,17 @@ static void resize_hpt_set_state(struct kvm_resize_hpt *resize, wake_up_all(&kvm->arch.resize_hpt_wq); } +static struct kvm_resize_hpt *kvm_active_resize_hpt(struct kvm *kvm) +{ + struct kvm_resize_hpt *resize = kvm->arch.resize_hpt; + + if (resize && (resize->state & RESIZE_HPT_PREPARED) + && !(resize->state & RESIZE_HPT_FAILED)) + return resize; + + return NULL; +} + static long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags, long pte_index, unsigned long pteh, unsigned long ptel, unsigned long *pte_idx_ret); @@ -755,6 +766,7 @@ static int kvm_handle_hva_range(struct kvm *kvm, int retval = 0; struct kvm_memslots *slots; struct kvm_memory_slot *memslot; + struct kvm_resize_hpt *resize = kvm_active_resize_hpt(kvm); slots = kvm_memslots(kvm); kvm_for_each_memslot(memslot, slots) { @@ -776,6 +788,10 @@ static int kvm_handle_hva_range(struct kvm *kvm, retval |= kvm_handle_hva_range_slot(kvm, &kvm->arch.hpt, memslot, memslot->arch.rmap, gfn, gfn_end, handler); + if (resize) + retval |= kvm_handle_hva_range_slot(kvm, &resize->hpt, + memslot, resize->rmap[memslot->id], + gfn, gfn_end, handler); } return retval;