From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5956C433FF for ; Fri, 2 Aug 2019 13:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D20220B7C for ; Fri, 2 Aug 2019 13:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564752794; bh=QcgvIIDsNZptxD3T3bLMAHQHwgH6687hBii/JdkT8cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=o+MfMSh9npKiYIdHsn9SGZo1Bglf8owvthr+fuSKGhHl7lOccAQw/MJqy89aFmqb/ dry7uJhh0vNZZEX2RHP6fQLr+YNWY75T6WgWERPzUL/tYhDaH7XCbi7AfXm5HJnai3 0fABIx54aXG71CvSWMfybhNbiysGq+cb68I+FUx0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405488AbfHBNdN (ORCPT ); Fri, 2 Aug 2019 09:33:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394016AbfHBNXn (ORCPT ); Fri, 2 Aug 2019 09:23:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4187021852; Fri, 2 Aug 2019 13:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564752222; bh=QcgvIIDsNZptxD3T3bLMAHQHwgH6687hBii/JdkT8cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjhKSvUrw+H+ZDHpnpyLfWDx0HaueLDx7vg3THcY+zCf3d/eUEFMvvZkYGep1PLWp IzjL6AMRA740kLse6ChsFTishMv4B6zUbd0PcZ4ZMXcb1GGGxUZ3Ih9wyIA+Q3EQWK YtPxjdIF4whDZdDbNLRQZf5nlRhA112H5AM4IN88= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Joerg Roedel , Thomas Gleixner , Dave Hansen , Sasha Levin Subject: [PATCH AUTOSEL 4.19 18/42] x86/mm: Sync also unmappings in vmalloc_sync_all() Date: Fri, 2 Aug 2019 09:22:38 -0400 Message-Id: <20190802132302.13537-18-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802132302.13537-1-sashal@kernel.org> References: <20190802132302.13537-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 [ Upstream commit 8e998fc24de47c55b47a887f6c95ab91acd4a720 ] 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: Sasha Levin --- arch/x86/mm/fault.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 4d12176a470ee..1bcb7242ad79a 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -261,11 +261,12 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) 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); } -- 2.20.1