From patchwork Sun Aug 14 20:23:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 9279921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07BDF60839 for ; Sun, 14 Aug 2016 20:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED3C2289F3 for ; Sun, 14 Aug 2016 20:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15B028A13; Sun, 14 Aug 2016 20:28:41 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54B4628A33 for ; Sun, 14 Aug 2016 20:28:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ1zG-0006OG-63; Sun, 14 Aug 2016 20:26:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ1zF-0006Ni-DQ for xen-devel@lists.xenproject.org; Sun, 14 Aug 2016 20:26:25 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 5F/9B-12285-0F3D0B75; Sun, 14 Aug 2016 20:26:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42LpubySR/fD5Q3 hBh3trBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bGr/8ZC1ZKVHQ8/sfcwHhBpIuRi0NIYBuj xJ2O+YxdjBwcbAKmEjP+q3QxcnKICChIbO59xgpSwyzQziIx7/FsVpCEsICfxLRp75lBbBYBV YnTnW3sIDavgJVE3/kHYDUSAnISl7Z9AavhFLCW6Py1hgnEFgKqOT29BaxGVEBMYnPbLlaIXk GJkzOfsIDcwCygLrF+ntAERt5ZSDKzEDILGJlWMWoUpxaVpRbpGprpJRVlpmeU5CZm5ugaGpj q5aYWFyemp+YkJhXrJefnbmIEhg4DEOxgPH/a8xCjJAeTkiivjvm6cCG+pPyUyozE4oz4otKc 1OJDjDIcHEoSvD8vbQgXEixKTU+tSMvMAQYxTFqCg0dJhHcNSJq3uCAxtzgzHSJ1ilFRSpx3L khCACSRUZoH1waLnEuMslLCvIxAhwjxFKQW5WaWoMq/YhTnYFQS5t0NMoUnM68EbvoroMVMQI v1pcEWlyQipKQaGA3PSBw0ZXjsJxUXqdFlGlWazHH9DUMum/GCjeWTYkIO+Qef8gpkTVrSrL+ qzp57s9T7wNCPppH7H07dc2K2wBWmxZI9xhGZKbybVGUEXC54TWnR3z5v8vtwj2mPFGKOTH1n nXP+qHNss+KZjqC8jpD3z5JOfDu4ZPdOpuqQK29Pn59018ZAUomlOCPRUIu5qDgRAHK7JyqXA gAA X-Env-Sender: gregkh@linuxfoundation.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1471206382!18102831!1 X-Originating-IP: [140.211.169.12] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31845 invoked from network); 14 Aug 2016 20:26:23 -0000 Received: from mail.linuxfoundation.org (HELO mail.linuxfoundation.org) (140.211.169.12) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Aug 2016 20:26:23 -0000 Received: from localhost (pes75-3-78-192-101-3.fbxo.proxad.net [78.192.101.3]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4D22726C; Sun, 14 Aug 2016 20:26:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Date: Sun, 14 Aug 2016 22:23:30 +0200 Message-Id: <20160814202304.142983388@linuxfoundation.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160814202302.493206349@linuxfoundation.org> References: <20160814202302.493206349@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Cc: "Paul E. McKenney" , Toshi Kani , Peter Zijlstra , Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , David Vrabel , kernel test robot , xen-devel@lists.xenproject.org, Andrew Morton , Borislav Petkov , Linus Torvalds , Thomas Gleixner Subject: [Xen-devel] [PATCH 4.4 30/49] x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toshi Kani commit 1886297ce0c8d563a08c8a8c4c0b97743e06cd37 upstream. The following BUG_ON() crash was reported on QEMU/i386: kernel BUG at arch/x86/mm/physaddr.c:79! Call Trace: phys_mem_access_prot_allowed mmap_mem ? mmap_region mmap_region do_mmap vm_mmap_pgoff SyS_mmap_pgoff do_int80_syscall_32 entry_INT80_32 after commit: edfe63ec97ed ("x86/mtrr: Fix Xorg crashes in Qemu sessions") PAT is now set to disabled state when MTRRs are disabled. Thus, reactivating the __pa(high_memory) check in phys_mem_access_prot_allowed(). When CONFIG_DEBUG_VIRTUAL is set, __pa() calls __phys_addr(), which in turn calls slow_virt_to_phys() for 'high_memory'. Because 'high_memory' is set to (the max direct mapped virt addr + 1), it is not a valid virtual address. Hence, slow_virt_to_phys() returns 0 and hit the BUG_ON. Using __pa_nodebug() instead of __pa() will fix this BUG_ON. However, this code block, originally written for Pentiums and earlier, is no longer adequate since a 32-bit Xen guest has MTRRs disabled and supports ZONE_HIGHMEM. In this setup, this code sets UC attribute for accessing RAM in high memory range. Delete this code block as it has been unused for a long time. Reported-by: kernel test robot Reviewed-by: Borislav Petkov Signed-off-by: Toshi Kani Cc: Andrew Morton Cc: David Vrabel Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/1460403360-25441-1-git-send-email-toshi.kani@hpe.com Link: https://lkml.org/lkml/2016/4/1/608 Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/pat.c | 19 ------------------- 1 file changed, 19 deletions(-) --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -777,25 +777,6 @@ int phys_mem_access_prot_allowed(struct if (file->f_flags & O_DSYNC) pcm = _PAGE_CACHE_MODE_UC_MINUS; -#ifdef CONFIG_X86_32 - /* - * On the PPro and successors, the MTRRs are used to set - * memory types for physical addresses outside main memory, - * so blindly setting UC or PWT on those pages is wrong. - * For Pentiums and earlier, the surround logic should disable - * caching for the high addresses through the KEN pin, but - * we maintain the tradition of paranoia in this code. - */ - if (!pat_enabled() && - !(boot_cpu_has(X86_FEATURE_MTRR) || - boot_cpu_has(X86_FEATURE_K6_MTRR) || - boot_cpu_has(X86_FEATURE_CYRIX_ARR) || - boot_cpu_has(X86_FEATURE_CENTAUR_MCR)) && - (pfn << PAGE_SHIFT) >= __pa(high_memory)) { - pcm = _PAGE_CACHE_MODE_UC; - } -#endif - *vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) | cachemode2protval(pcm)); return 1;