From patchwork Fri Jul 19 18:46:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11050513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2DB91800 for ; Fri, 19 Jul 2019 18:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E85D2285BE for ; Fri, 19 Jul 2019 18:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC6E628991; Fri, 19 Jul 2019 18:47:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D089285BE for ; Fri, 19 Jul 2019 18:47:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07C716B0005; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F1F606B000A; Fri, 19 Jul 2019 14:46:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA5C76B0005; Fri, 19 Jul 2019 14:46:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 941AC6B0005 for ; Fri, 19 Jul 2019 14:46:57 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id n3so22565456edr.8 for ; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=U8VhW7NMRWIw2lQUClIkQJ0jdR5sgitKIPURN1A8TyA=; b=RtXX4W/lrheDEOLw5KJ4pSDwiJSe+dMj6NVZlhgRv90TZ7Ulvt8y7hiVeJcLwpx31N JExlTe2uDf3K6OGe/tW+FmmHLHhWZ3vFp+Ya/MjeLNcfg1/YWYauCRHyrs+vZAylEhov 6hCCnLnsIo0XCVQYGfezMp8pdbjcPBM6Bk4uJeceqPnGRMnRbIFRHoMwlnc4LD2ds8SP 2X+Ws2UqiiCYDLR7kr8be1DdIyS18SqtsOJLz0xF4Bcf9lPfg47NnanqEC3nz9FpnUOd swVDOLtNDSHjC3tmQtcpsn9X5iZ+T9LNT39o5iAZDRRr96DRMVoBUfsC+jFhSLSdLuUd cy1w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org X-Gm-Message-State: APjAAAUbMWkIvfG7OEWxy0kLRZUhtJrQhkTadU86Qg9XfEaxiPYeOAvd RAm4ouIa0rKpKEdzjqE+lLp23C25KVzey080Muoe6zqvfkgHmYUjjen4dvxmmNVNTqNUHZ/0MwG Z7TgSq/0m/2gJmZssx6DPR296Ql9YpOHz6v8kpaSbjBjSZVo1ytbxnXlEnwezSB4i4w== X-Received: by 2002:a50:9999:: with SMTP id m25mr48467005edb.183.1563562017136; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzhrVL+c+Jc6MA0dE5AHB9vzq2por6vrfwTlZKRdMeMtrHdFvDoufgEVHmvJapaBjETDx0 X-Received: by 2002:a50:9999:: with SMTP id m25mr48466921edb.183.1563562015853; Fri, 19 Jul 2019 11:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563562015; cv=none; d=google.com; s=arc-20160816; b=QWlFNR+lSNwDKPinCkMZMJuepEqpT+B1ZbFm2BgLjm5ItiwwYa/PiZ6xuBlmfS465B BUcgFUgf874O7rYpZNzljJfTbpnpBr5ZEL3Zh5OJyhZ1As67E7+sHCBP3tZt8fv90q2o cn7zi1jFMpm0TjbSA08KRNQWArkqMsERPsof2f9AaFV9RPF449k+/vMNRFbMARcrF4lC ORKMD53pSvxewFDC7zTuUI9n+4BekFFHeb6OUJPaFL8lZ5UHpC+sfgQDSCUNh8b4+8pR AED8ScUfXmCeZJa7HkZqQkEPK8cTvzfPWtnRfp/SuSsW7JUVqIX+1BZb7iWw2bVVZQ/d rwwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=U8VhW7NMRWIw2lQUClIkQJ0jdR5sgitKIPURN1A8TyA=; b=HEfmBce82zRDcuniokHbK6fQGg0c/fmr+7Z9ybQOUuosTgrmIpCI3qvq9dMjNZrucA SJ1tjfuGp1kGl/9oXyKuoGnHQP5/h2ZZgrXPa/TMkX5PFhGnvKWpy+EVRYMR1jV+OOPV uCoe8A9ojAi1c6AwppQMcGZMyyr/BJ3BJ56TlqJoQzp73HmwxKLE0M20Hf8k0QUJtFlO lzhjoqc0YYD67dFO7l65NuxbT90flRuCCoRXP93EP9eDt6Ys1owu1a8WZR8VkL5gBdx9 GrnGv3U8coNrVfnhKgnIvLPxgnpQ8uQBrwG5evOP51qRnM/howcoziyB7NHAgIMh1uMN 2CqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id t23si143787eju.143.2019.07.19.11.46.55 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 11:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id 89FE81D3; Fri, 19 Jul 2019 20:46:54 +0200 (CEST) From: Joerg Roedel To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joerg Roedel Subject: [PATCH 1/3] x86/mm: Check for pfn instead of page in vmalloc_sync_one() Date: Fri, 19 Jul 2019 20:46:50 +0200 Message-Id: <20190719184652.11391-2-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719184652.11391-1-joro@8bytes.org> References: <20190719184652.11391-1-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel Do not require a struct page for the mapped memory location because it might not exist. This can happen when an ioremapped region is mapped with 2MB pages. Fixes: 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F') Reviewed-by: Dave Hansen Signed-off-by: Joerg Roedel --- arch/x86/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index d1634c59ed56..d69f4e4d6918 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -183,7 +183,7 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) if (!pmd_present(*pmd)) set_pmd(pmd, *pmd_k); else - BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k)); + BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k)); return pmd_k; } From patchwork Fri Jul 19 18:46:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11050515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7063112C for ; Fri, 19 Jul 2019 18:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99CE228987 for ; Fri, 19 Jul 2019 18:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E34328989; Fri, 19 Jul 2019 18:47:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E925289BC for ; Fri, 19 Jul 2019 18:47:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 549816B0007; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4BE3D8E0001; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EBDA6B000A; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id BF7726B0007 for ; Fri, 19 Jul 2019 14:46:57 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id d27so22582509eda.9 for ; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=frhztlN5AYKYRdcM3ZCTEqvQvVkkG6CWbRdHoyjRbAE=; b=RAA1tsrxHNtAHDKfiVcbmdKE+TPy7jL5Z8bTec7HDtDoVXIctXbpEvS2btmfsO2RjT ay03RnAQgO1on++RKwdiVIhB947Ov1OarxmMUmvfEVoMv5dzsuHNjbue+AedLvMOmEoR EiTpSdmfBNdlbt7LWm/JYHMBv1WQ7qLP4VUzy+cCXb1yUZIjN6sRz42reK9cE2FTPCBd OyiwFGRNrdk9SLt/usUTRX5KH3esbC/oOD/C9dbFiRjOsqepMNMjoGd51I1t7S6O5q8X YNZQ/gOMvf/A9aj1zVhvrksCIeCOJRWCR2hwybxfsNE0r1Qk5nEDpBt3gSIUMCv2LPT9 gAew== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org X-Gm-Message-State: APjAAAVi2QQ0H6J+3Wgpc1X/R9Q98cN1lx9Aps3AbUnqKQp3OoTARDNb gpqUpe1AKhvWi9RsxMLXOlTpWqFY1Cop60r30nbzXfP5rgpvrdDXdW3zQ4xCmMoceaUbE/KlQbr 9naRGOH5EAp5A1iq0nJJkEGbBemJPsMdeVNJn2uvZLeFdBpM8TsTRvwNa5nty541eCQ== X-Received: by 2002:a17:906:a417:: with SMTP id l23mr30717293ejz.20.1563562017356; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjgtrWT/UikRyRwWz7dAU9AIfMNj/CtBjpzOO1MjUmIokPiYkXFzrKObibcbs0CqXdtZ3b X-Received: by 2002:a17:906:a417:: with SMTP id l23mr30717227ejz.20.1563562016260; Fri, 19 Jul 2019 11:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563562016; cv=none; d=google.com; s=arc-20160816; b=dwwVnvrsK8tP7V01aXM9hR25Vn8IojU3tS5pDM8OfPWlVb1SjjMKG62ep1uPmX2CDp /1CrPWc1pYcoencjG60Y9T/MKWjw4KInoWBYUnNb5GoXLGsFfQ4v0Tlu62Y1BLOTIpyc n9Okj83vrqQwUT9CmtGoMo3vO4+Qvy6FArtu4GhnM5Rcu7VjhT0eiQjXdY3L4NzUH2c0 TlArsFtb+MS/IIZAEPJKAbR2OU6iAynf5cGp6TfV+yKfkHKPDu/MDTouXU+QDZmtvylM BrvUGCXF+JNznloRcSV+ouoeHP98ZTqJt+jYzWvwASYUMfLdQ2+R5OOPo8/0MMe0lGwe /5Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=frhztlN5AYKYRdcM3ZCTEqvQvVkkG6CWbRdHoyjRbAE=; b=G56QaFCfXmlmksVgarRyhCzIfcBYDOjslclE4BmdfWkoOdiEmWu5Kc4jyOyJxP/qHS xk4f1MCf1LuUyeQSvR+Oez/cRyckLcxOBLERJB8AsIBEJFzfkdJywZ1+stena6PSfZre F5rnB8YX9prURsJZRmBLtlbiAbKm3de9qlH441hL21Rp25ZopbrUE9nyMjL2GNmJfs3Y 0BIjjqb3Icr6BZ97oZUaI8U6xd/veenOADDhW2PsDSH+YHWiHjRbR1RvQQ5rHqLAjEYO 91mRPwA2zPsTs9nGqEs4/TAHqnomicfwVwY79L++Xs3wTQfHtjdjVr81M3vMmnWSwyfW WaEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id f13si858693eda.21.2019.07.19.11.46.56 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 11:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id B973B273; Fri, 19 Jul 2019 20:46:54 +0200 (CEST) From: Joerg Roedel To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joerg Roedel Subject: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_all() Date: Fri, 19 Jul 2019 20:46:51 +0200 Message-Id: <20190719184652.11391-3-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719184652.11391-1-joro@8bytes.org> References: <20190719184652.11391-1-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel 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') Reviewed-by: Dave Hansen Signed-off-by: Joerg Roedel --- 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 d69f4e4d6918..8807916c712d 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -177,11 +177,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)); @@ -203,17 +204,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); } From patchwork Fri Jul 19 18:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11050517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2039E112C for ; Fri, 19 Jul 2019 18:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1504628986 for ; Fri, 19 Jul 2019 18:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0954728989; Fri, 19 Jul 2019 18:47:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96130289BC for ; Fri, 19 Jul 2019 18:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E4996B0008; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 75AA56B000A; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4499A6B000C; Fri, 19 Jul 2019 14:46:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id D68B78E0001 for ; Fri, 19 Jul 2019 14:46:57 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id a5so22568755edx.12 for ; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=uCDkeNVbjDAM8yrLHlMPqnxhh17i0B5p0qCieHpy4M0=; b=DMN7M/kd12VAP828pqTkIf8Ktm4h/0HtlhLLh0IfO2JicYzc5gX1vsr0qoSVGt8G4K 9JEg//M/qfY8OydLnBnlLbByeZo70u8Ii2b46YslOXliGUjlc0YTXQcZk7JA2k1FMlBW xtl7C4CTid8k24EmNpwsFrLgUg2LyNssBE/E7bouQYcTnz0Mn8s+HuIdqdjXW3k+wlmY h1WVK9WVf9g3Sd0kBrqQqNMoQhq4Sb+0N7CgT0bRnl3Cf5ap8EvhyK4xMBWwDBNA7Zr6 k1pzIx0sZNEzaei+MjV/eT3WCMgm+NN7helfTr0D7XRbi5ZNWgtQDspff3TzVWl/A7qD xTNQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org X-Gm-Message-State: APjAAAVVuX0Dvc+0EDryy4pyup/Zu09h9TRvxu9+cyemDLNyFBGtveDB LIR100pTkTJ+RZZkERVydrks0EySy1A5qY//nKxAJ0G/Dtne4DVhU15p1bg4bNVppMVDcOJ/Lpo yHT7o/Alf4cwfyvdaL/JyibXxJ75w7Kpy273skpC26cIiN+PMANU0HpewvWuvxWq3Pw== X-Received: by 2002:a17:906:8409:: with SMTP id n9mr41583945ejx.128.1563562017422; Fri, 19 Jul 2019 11:46:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+e7qfGhKBOC0/JKMaK3d1FvEwdwzl/LIyj1I6xgXTT8b24/YVjJf4Nu3pcFBfYIH+ADCO X-Received: by 2002:a17:906:8409:: with SMTP id n9mr41583902ejx.128.1563562016542; Fri, 19 Jul 2019 11:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563562016; cv=none; d=google.com; s=arc-20160816; b=MXhFjleQS8LcYPzDf1DMoSOqDcLtwxrRwwuq3hrosw3HKYQzYAk8tXn6JEnRYBlxc3 4OGDIDeJJgdGmAsZpDCS3oj6A1GS1iEYPny60/Y+JDeobnj5oxQdpI7aJzRrhdzg8Szt 2Ec85Jc8SPYCx80xgdhUfzyyjL9UyVE0Z7qE+ptizVWzl0wDtOkC/d4SSa7p2m4+t1db Xj1Jgr7qZoxZ4F2nHJNay+0PF90UCej3p41INbclhuyLvixOlxNtqDhzPl+5AOA/B6qb QArIs06JvVu5Ed+pGLMs8x4IReDTR8rYraG7jx28MZ60b3+lEuz9q1eAI+/tpi5QW4e1 lu6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=uCDkeNVbjDAM8yrLHlMPqnxhh17i0B5p0qCieHpy4M0=; b=RgA9BSSV8i12J7k6wFGVPZUr9YOGbX7i03/A6NZkh734jm5wtG8NLfCDeBevpyuLf+ FKR2qug3qIEFLYnHKahiEIa3//wedsNa32b1g3R0CSray6yIQ/e39Ccpc+81p7mLC+Ra jPwG8n8iJoJ3Sde0kCvMHuz9ltMnKb4V7PGtMTWEeH1UkqdhD8FBvvgYArAnPRxBRJvm Io4GlGbluzMB7VnYssvTDbrrx0xkQ+5Jymg+fdmmfjlBPFVTaaFrPFGF+ba0l094pwc1 VQl/uq9b5TIgSxzFz1yej9Zkk86NvhfjHi78asJcS7ELC9yMXDiLDF9QbDeXkaWVSZbM LoLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id b8si124695ejp.210.2019.07.19.11.46.56 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 11:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id D322026B; Fri, 19 Jul 2019 20:46:54 +0200 (CEST) From: Joerg Roedel To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joerg Roedel Subject: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range() Date: Fri, 19 Jul 2019 20:46:52 +0200 Message-Id: <20190719184652.11391-4-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719184652.11391-1-joro@8bytes.org> References: <20190719184652.11391-1-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel On x86-32 with PTI enabled, parts of the kernel page-tables are not shared between processes. This can cause mappings in the vmalloc/ioremap area to persist in some page-tables after the region is unmapped and released. When the region is re-used the processes with the old mappings do not fault in the new mappings but still access the old ones. This causes undefined behavior, in reality often data corruption, kernel oopses and panics and even spontaneous reboots. Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to all page-tables in the system before the regions can be re-used. References: https://bugzilla.suse.com/show_bug.cgi?id=1118689 Reviewed-by: Dave Hansen Fixes: 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F') Signed-off-by: Joerg Roedel --- mm/vmalloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4fa8d84599b0..e0fc963acc41 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1258,6 +1258,12 @@ static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end) if (unlikely(valist == NULL)) return false; + /* + * First make sure the mappings are removed from all page-tables + * before they are freed. + */ + vmalloc_sync_all(); + /* * TODO: to calculate a flush range without looping. * The list can be up to lazy_max_pages() elements. @@ -3038,6 +3044,9 @@ EXPORT_SYMBOL(remap_vmalloc_range); /* * Implement a stub for vmalloc_sync_all() if the architecture chose not to * have one. + * + * The purpose of this function is to make sure the vmalloc area + * mappings are identical in all page-tables in the system. */ void __weak vmalloc_sync_all(void) {