Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1086166ybl; Wed, 14 Aug 2019 10:28:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwG+pRdZbKN5+BWUBDAfL4CoGBew2Mzh++D2iBPCFYAIBAL+jLJn4KVpx+2woZtiI5A5bLX X-Received: by 2002:a17:90a:ab0d:: with SMTP id m13mr769806pjq.84.1565803703390; Wed, 14 Aug 2019 10:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803703; cv=none; d=google.com; s=arc-20160816; b=bOJbFJhARW6kDqzsVGNhU4cbZ5RruJgoliQJynrfdW+7AnMzRWpSN0UotORS3wMNX0 Ncltqx0wd6174luUibVe5L7WIYREpdb0IQ5n2GUVmJFRuYH+XmIamPdpgdoG0K+SN2bl FK3qlUX3l+fFVQMsEroeHCYi0gpFWhQYYzsUQ4VFdU1Kl5bink64XBGyWuVoMov40Y6n lPHKm3+4h/Dgj+u5lvlKRvt6uNY50fOjoXxOFc+VxxaHhOzAit1+NTCpcFBYcFjGv3eT 8edRZI4IFeSNS4kpgYI50WmlX0wpERK5F6QFClsrCpER/94l3lKQFaA8cztM2UV/QlC9 /GMA== 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=St/dHIl1qLokjCCL5g9j9j0os7pl7rWMrmGJl8LVFyw=; b=Qv7gfTpycW3Cloe643YWf2EfG00X4XNxACIjB0BLQ4VW2ss60dyGnXVewvRzV6d3OM pjwGmpjpXWT6gQ8VntWaZ/ZnR5UAO6/nOzSelYiOjlclMpLAO7sVm7XWDCeUgW8vYDX+ lfDyhEdQEaS+VYyFQKOmq1CGtCsNP8vItS4r21kNQrRCUhEWm8uo1T0E9CCarxDoQBA6 eh8DWz0FnRKKQSv1KZFWpT6GFpDVQ+yKk4FZB0dkL6X5OEz6/9+A7KM5jzwAsBJlPmGr 4Ys5Ipedz+MhajnnrwALx1ZTRdw+JG5LUa/DD2nKQETFHWavyMGyODfFL0f5XvSle+3H XiPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L+GPEKfe; 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 e18si216561pgv.139.2019.08.14.10.28.07; Wed, 14 Aug 2019 10:28:23 -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=L+GPEKfe; 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 S1728950AbfHNRDc (ORCPT + 99 others); Wed, 14 Aug 2019 13:03:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728935AbfHNRD2 (ORCPT ); Wed, 14 Aug 2019 13:03:28 -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 068A6216F4; Wed, 14 Aug 2019 17:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802207; bh=3e8u2wVo3Mi0CvtIBcwuCZF7hG1t1mMuqe5WMIxKoYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+GPEKfeRNLwacOGHu7ANtU6UnJb9J4UJRab/CbvloyhHvf49RMdYV4YTdxRY4OHr N36dECOWx/km0Be0aSu5IWKvEJ4AXW9ZetOSKiKH8GQI8XJ6lEWl/gCc/yVg10lj11 FK9OnpOlLYgpPqf/FhhTsayDNa0pBwpXjPMTKoBU= 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 5.2 028/144] x86/mm: Sync also unmappings in vmalloc_sync_all() Date: Wed, 14 Aug 2019 18:59:44 +0200 Message-Id: <20190814165801.017320362@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 @@ -194,11 +194,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)); @@ -220,17 +221,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); }