From patchwork Fri Dec 13 18:25:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11290967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADB9B188B for ; Fri, 13 Dec 2019 20:38:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6243424796 for ; Fri, 13 Dec 2019 20:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576269508; bh=7Oe9UOh8V8HiBdebN5JrWKM6Yw6faFdNR32/Y97JVRk=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=IHadI3MS7pI94oiBO3gUo8otlOSLPIu54nTnQuKy2rFk8PVblX3PsFO8rp0yC2vEI f2BmDrK/XiudWtOs4UFZVePNA4OVj5KMMr3w3ozE23OrBETacczfxLzhpjlC+SFE/P YjZ0+SDDPAapa5pCEGlOQGcrZEWSLxIDWAUKbI5E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728840AbfLMS15 (ORCPT ); Fri, 13 Dec 2019 13:27:57 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:36299 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728800AbfLMS1z (ORCPT ); Fri, 13 Dec 2019 13:27:55 -0500 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1ifpdJ-0001O7-JV; Fri, 13 Dec 2019 19:25:45 +0100 From: Marc Zyngier Cc: James Morse , Julien Thierry , Suzuki K Poulose , James Hogan , Paul Mackerras , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 7/7] KVM: arm/arm64: Elide CMOs when unmapping a range Date: Fri, 13 Dec 2019 18:25:03 +0000 Message-Id: <20191213182503.14460-8-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213182503.14460-1-maz@kernel.org> References: <20191213182503.14460-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, jhogan@kernel.org, paulus@ozlabs.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false To: unlisted-recipients:; (no To-header on input) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If userspace issues a munmap() on a set of pages, there is no expectation that the pages are cleaned to the PoC. So let's not do more work than strictly necessary, and set the magic flag that avoids CMOs in this case. Signed-off-by: Marc Zyngier --- virt/kvm/arm/mmu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index c55022dbac89..6749be33d822 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -2056,7 +2056,13 @@ static int handle_hva_to_gpa(struct kvm *kvm, static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data) { - unmap_stage2_range(kvm, gpa, size, 0); + struct mmu_notifier_range *range = data; + unsigned long flags = 0; + + if (range->event == MMU_NOTIFY_UNMAP) + flags = KVM_UNMAP_ELIDE_CMO; + + unmap_stage2_range(kvm, gpa, size, flags); return 0; } @@ -2067,7 +2073,7 @@ int kvm_unmap_hva_range(struct kvm *kvm, const struct mmu_notifier_range *range) trace_kvm_unmap_hva_range(range->start, range->end); handle_hva_to_gpa(kvm, range->start, range->end, - &kvm_unmap_hva_handler, NULL); + &kvm_unmap_hva_handler, (void *)range); return 0; }