From patchwork Thu Jan 8 11:59:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 5592261 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2C29BBFF04 for ; Thu, 8 Jan 2015 11:59:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C3782037F for ; Thu, 8 Jan 2015 11:59:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66C6A2038A for ; Thu, 8 Jan 2015 11:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756539AbbAHL7Y (ORCPT ); Thu, 8 Jan 2015 06:59:24 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:57753 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756455AbbAHL7X (ORCPT ); Thu, 8 Jan 2015 06:59:23 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id 27A054E5; Thu, 8 Jan 2015 05:59:19 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id 9651B5FAD8; Thu, 8 Jan 2015 05:59:11 -0600 (CST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.209.148]) by collaborate-mta1.arm.com (Postfix) with ESMTP id DBEAA13F6FA; Thu, 8 Jan 2015 05:59:10 -0600 (CST) From: Marc Zyngier To: Christoffer Dall , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: Steve Capper Subject: [PATCH 1/4] mm: Correct ordering of *_clear_flush_young_notify Date: Thu, 8 Jan 2015 11:59:06 +0000 Message-Id: <1420718349-24152-2-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1420718349-24152-1-git-send-email-marc.zyngier@arm.com> References: <1420718349-24152-1-git-send-email-marc.zyngier@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Capper ptep_clear_flush_young_notify and pmdp_clear_flush_young_notify both call the notifiers *after* the pte/pmd has been made young. This can cause problems with KVM that relies on being able to block MMU notifiers when carrying out maintenance of second stage descriptors. This patch ensures that the MMU notifiers are called before ptes and pmds are made old. Signed-off-by: Steve Capper --- include/linux/mmu_notifier.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 95243d2..c454c76 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -290,11 +290,11 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) int __young; \ struct vm_area_struct *___vma = __vma; \ unsigned long ___address = __address; \ - __young = ptep_clear_flush_young(___vma, ___address, __ptep); \ - __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \ + __young = mmu_notifier_clear_flush_young(___vma->vm_mm, \ ___address, \ ___address + \ PAGE_SIZE); \ + __young |= ptep_clear_flush_young(___vma, ___address, __ptep); \ __young; \ }) @@ -303,11 +303,11 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) int __young; \ struct vm_area_struct *___vma = __vma; \ unsigned long ___address = __address; \ - __young = pmdp_clear_flush_young(___vma, ___address, __pmdp); \ - __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \ + __young = mmu_notifier_clear_flush_young(___vma->vm_mm, \ ___address, \ ___address + \ PMD_SIZE); \ + __young |= pmdp_clear_flush_young(___vma, ___address, __pmdp); \ __young; \ })