Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1863900pxb; Thu, 4 Nov 2021 09:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJu2B+14y6fG8bELMeMFpy+rLVSpC0C3wp1Hak6BMYA0PDXrf3RB+bQKcF3r0E3+PbG2Q8 X-Received: by 2002:a05:6e02:1bed:: with SMTP id y13mr17077917ilv.279.1636044272047; Thu, 04 Nov 2021 09:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636044272; cv=none; d=google.com; s=arc-20160816; b=q52nsxxQYlaTgqzJ56XT0mLMXywfpV73/mRMrTMzmCD3FReH+yAIweXCgV/LehyEGm nqp/pi0xuIn2ePC1ZSguy8dJwxte9NT9JN/BLPYZR6tf739WX33fOpQPvwHzsuuFfixl OGaom2O02LmxH0T/TeTz2+lOLtNCwm9zm/27ww421se5y9G7dr6BGSsLcJna9EzLJTUN x4HsyUpvC67vqm3+lofURLsF1KQqjDLD2WXu77FeUdpf/+KB2UMSF9ezmuhv29X+pPx3 LfIvJfzDXPugFmL/ttPd+ZLhNy4Sfc0WdRqLSKgqxPk3MLBc5e9eZ/M7rdVGDy7dIPo0 yeQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=BLpO0fOkHXhU49HszP9J7IBUy0ZTyjUC3dOvZNy0mdE=; b=e+J/ZORXmAGuKH3F/mgbG8GcclFVxlgPxZW4TFW/CzbxniiudysiWswoUrQLOf3+l8 zCj5914p50WBy7cT/Yh8t4ip1VKZ4el7WDG1ugsEtc5GBZR6v6MM3e2XmopK3mCsaVr6 nqcHMt8u+MDzbFBD/YtEx0AeaBBqxQ6jEUk/d1ow+TinP/XA+9XbDCX4V5zS6Cyc+d4b 2CN7/sPGeYcGNK0pibVz7YATgxSCsI9cTXWagxfgd6rXu3b/nHaQxwSbi6soL34zZxgy fGEqaY42mgBl2Fwv/u/aAkntjq0Hvz5kkKIQ2XLw9z/YoS2UyZjeVOs+5Xlc/nPt/vuL 8pwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TCwN7LDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si9271016ilu.91.2021.11.04.09.44.17; Thu, 04 Nov 2021 09:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TCwN7LDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbhKDQn5 (ORCPT + 99 others); Thu, 4 Nov 2021 12:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbhKDQnz (ORCPT ); Thu, 4 Nov 2021 12:43:55 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DBB1C061714 for ; Thu, 4 Nov 2021 09:41:17 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id z4-20020a634c04000000b00299bdd9abdbso4099909pga.13 for ; Thu, 04 Nov 2021 09:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=BLpO0fOkHXhU49HszP9J7IBUy0ZTyjUC3dOvZNy0mdE=; b=TCwN7LDAPJdrI3JQ0PhC2yCcI5yLMhPl7ApX+9DhRmXyfPHERawX2DwxsXfzQpe9j7 aiStPhF6p6Nc0rQj0cQ6Mr+Q2jbguwuqGoltihH6LYnjeNZb1UignEIOlPkm8hFbdlgN yVynl+h5lLQhr4jXpCj1CaYf7Rkv4LndwkROKDmusS+uaL/A6tmofBzuYAEpvgY3MF+w 6pOCDVv8jBPc3PnWz2YdpXTN+WHrksH3DawZW7qu7EHw0YH3LzXmKSA2r4O46Hfslcwg adnajvryDs/Nm5UcX0GdIbmqjM7LYEUxG51G5Dy6nlYavqc2vn+hQO5BP+l8Bw+wIvLC LD2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=BLpO0fOkHXhU49HszP9J7IBUy0ZTyjUC3dOvZNy0mdE=; b=OaUG8B+OiX5M3d3qipnWGOj5iSdyPIMYkwSs8y2/KLWqSWfj0ZCaCbmd2I9N5N7I/X lJGe0TZBUnqRlT7KXvyHDmqtqcZsXJw7xovBdBU+jOEA+rfbuQSeNH3RTSRjvu1Fg4hP TiSuPzdKdPpTSr2r5mnV6OHaBWg+X0S8jMoQFGb6Xai7s2bqQUuvfmBmcKzWSPPD6WYW 6g5fzk17UAapEkFBGLmq4dBAGxJq3Hdd2fx22FIM2GamyeOYewbtlDBrWlgDSJv2WdW2 hGuieiJGS+nxjNaIfJzm4hXA7M+KUQK47eSLAv9GcQWhHJhu1gOkpowlODQKfAGBxNhP aKRw== X-Gm-Message-State: AOAM531wk5OagMVNvpwZQ0cHMquwnC39LQtcy3BBOXoIKqn2TX1MDn6+ S840FbWd4N20XzZVMzTDD0FEh/9Uj5U= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:a50b:b0:141:dc7b:b2dc with SMTP id s11-20020a170902a50b00b00141dc7bb2dcmr29202914plq.4.1636044076879; Thu, 04 Nov 2021 09:41:16 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 4 Nov 2021 16:41:06 +0000 In-Reply-To: <20211104164107.1291793-1-seanjc@google.com> Message-Id: <20211104164107.1291793-2-seanjc@google.com> Mime-Version: 1.0 References: <20211104164107.1291793-1-seanjc@google.com> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog Subject: [PATCH 1/2] KVM: RISC-V: Unmap stage2 mapping when deleting/moving a memslot From: Sean Christopherson To: Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Atish Patra , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Sean Christopherson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unmap stage2 page tables when a memslot is being deleted or moved. It's the architectures' responsibility to ensure existing mappings are removed when kvm_arch_flush_shadow_memslot() returns. Fixes: 99cdc6c18c2d ("RISC-V: Add initial skeletal KVM support") Signed-off-by: Sean Christopherson --- arch/riscv/kvm/mmu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index d81bae8eb55e..fc058ff5f4b6 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -453,6 +453,12 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm) void kvm_arch_flush_shadow_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) { + gpa_t gpa = slot->base_gfn << PAGE_SHIFT; + phys_addr_t size = slot->npages << PAGE_SHIFT; + + spin_lock(&kvm->mmu_lock); + stage2_unmap_range(kvm, gpa, size, false); + spin_unlock(&kvm->mmu_lock); } void kvm_arch_commit_memory_region(struct kvm *kvm, -- 2.34.0.rc0.344.g81b53c2807-goog