Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1080899ybl; Wed, 14 Aug 2019 10:23:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx8ybnRFUfcskeijke4VbF3BxisCDHaPKYzOw5Y49r/sC31nezR1aKx3oWXg7YnaInF/D1 X-Received: by 2002:a17:902:1027:: with SMTP id b36mr424448pla.203.1565803385906; Wed, 14 Aug 2019 10:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803385; cv=none; d=google.com; s=arc-20160816; b=nNEMMbV5882v7IOojNUHWOqIVuLXXAMEl8XvHJmcFy9V8qfWZav9n6orNzwl3VJq2c 3HAXmGmMMJoxTBb2Zw03L4HIgkfMpdIfpB+a63bSRGm1nJ6VBlx2xtBxC3lV/oulJAdy HU59A1PjINltmV5WKSaE5X1OZnq3L1JFJzLv+fZpWzgNgVekerF88TpGVmynzNwcY5et TwQKXUIN35lnv1rAhtfqPKPvvqxJCXrM3gZ158rmtjo7TRiIWq0rwPMcJXYhEsjZ7mE1 PAVD6JKGY5HA8Rj10Hj9u2bxmAGuhwoVDc4e0za5tMTp7XyfwZ8bVemnp8pOoi26Cc0O pqTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/TqGCrIFr+7fiHxdmE3g3exWx1G+atxWx3Srj9JIzSI=; b=VipbbD/eMlbLh4i+pz+cvWQvd75zyiD6vU0AHtNqXlzvR+3f86az7xogdmpf3aGPk+ /pCSoj5zYrKUDhYd5v/D4jeaBUO67d0VzCEmVhE61e5+ZsW69mrYcfFvCdxbsoJgkSvX DtPOjhYGEZlfYpN7ZKH+N99JbJ1HVC3bzajp7tCm3N5f2+B4DkCEhuxFL1k69d+yMsf2 fPyEomSJ35RRPW9VVvOV1u3eddl10YVzCmtANmKLhPa57+weMyG3uPks+XJl5jJAiqyF OTVra0eu5EUOJCGDRHSdvW7ZQznYxsGTPLE6HBHorsMF21IHzBdoFiKtROJBLks3PGrr ipXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IH0ekc1n; 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 m127si201975pgm.100.2019.08.14.10.22.48; Wed, 14 Aug 2019 10:23:05 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=IH0ekc1n; 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 S1728897AbfHNRIy (ORCPT + 99 others); Wed, 14 Aug 2019 13:08:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730223AbfHNRIw (ORCPT ); Wed, 14 Aug 2019 13:08:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9AFA208C2; Wed, 14 Aug 2019 17:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802531; bh=n0qBG/a3GFpuKWNftyN0W4yVsGfHWbgQGMmXyCJAkEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IH0ekc1niey02H06myEhvZWhj1s44XrDDA0Wd9LmZCNF4Voa1oAftxUaQbzrJcFnM fOa4bipiJufu4YAxEl17C610A27uM0X13EWaIecdf2jpNMxGdU+eg7XvgfHzWcOyLc 2VPP28gT7D7EGVchFJzo8cLiIKY1ErfZc4kIa/J4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Thomas Gleixner , Dave Hansen Subject: [PATCH 4.19 18/91] x86/mm: Sync also unmappings in vmalloc_sync_all() Date: Wed, 14 Aug 2019 19:00:41 +0200 Message-Id: <20190814165750.512161708@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel commit 8e998fc24de47c55b47a887f6c95ab91acd4a720 upstream. With huge-page ioremap areas the unmappings also need to be synced between all page-tables. Otherwise it can cause data corruption when a region is unmapped and later re-used. Make the vmalloc_sync_one() function ready to sync unmappings and make sure vmalloc_sync_all() iterates over all page-tables even when an unmapped PMD is found. Fixes: 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F') Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Reviewed-by: Dave Hansen Link: https://lkml.kernel.org/r/20190719184652.11391-3-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/fault.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -261,11 +261,12 @@ static inline pmd_t *vmalloc_sync_one(pg pmd = pmd_offset(pud, address); pmd_k = pmd_offset(pud_k, address); - if (!pmd_present(*pmd_k)) - return NULL; - if (!pmd_present(*pmd)) + if (pmd_present(*pmd) != pmd_present(*pmd_k)) set_pmd(pmd, *pmd_k); + + if (!pmd_present(*pmd_k)) + return NULL; else BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k)); @@ -287,17 +288,13 @@ void vmalloc_sync_all(void) spin_lock(&pgd_lock); list_for_each_entry(page, &pgd_list, lru) { spinlock_t *pgt_lock; - pmd_t *ret; /* the pgt_lock only for Xen */ pgt_lock = &pgd_page_get_mm(page)->page_table_lock; spin_lock(pgt_lock); - ret = vmalloc_sync_one(page_address(page), address); + vmalloc_sync_one(page_address(page), address); spin_unlock(pgt_lock); - - if (!ret) - break; } spin_unlock(&pgd_lock); }