From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758611AbdEAQAJ (ORCPT ); Mon, 1 May 2017 12:00:09 -0400 Received: from mail-io0-f174.google.com ([209.85.223.174]:33715 "EHLO mail-io0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758591AbdEAQAG (ORCPT ); Mon, 1 May 2017 12:00:06 -0400 MIME-Version: 1.0 In-Reply-To: <1493654135-16645-1-git-send-email-bhe@redhat.com> References: <1493654135-16645-1-git-send-email-bhe@redhat.com> From: Dan Williams Date: Mon, 1 May 2017 09:00:04 -0700 Message-ID: Subject: Re: [PATCH v2] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds To: Baoquan He Cc: "linux-kernel@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , Kees Cook , Thomas Garnier , Andrew Morton , Yasuaki Ishimatsu , Jinbum Park , Dave Hansen , "Kirill A. Shutemov" , Yinghai Lu , Dave Young Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 1, 2017 at 8:55 AM, Baoquan He wrote: > Jeff Moyer reported that on his system with two memory regions 0~64G and > 1T~1T+192G, and kernel option "memmap=192G!1024G" added, enabling kaslr > will make system hang intermittently during boot. While adding 'nokaslr' > won't. > > This is because the for loop count calculation in sync_global_pgds is > not correct. When a mapping area crosses pgd entries, we should > calculate the starting address of region which next pgd covers and assign > it to next for loop count, but not add PGDIR_SIZE directly. The old > code works right only if the mapping area is times of PGDIR_SIZE, > otherwize the end region could be skipped so that it can't be synchronized > to all other processes from kernel pgd init_mm.pgd. > > In Jeff's system, emulated pmem area [1024G, 1216G) is smaller than > PGDIR_SIZE. While 'nokaslr' works because PAGE_OFFSET is 1T aligned, it > makes this area be mapped inside one pgd entry. With kaslr enabled, > this area could cross two pgd entries, then the next pgd entry won't > be synced to all other processes. That is why we saw empty PGD. > > Fix it in this patch. > [..] > > Reported-by: Jeff Moyer > Signed-off-by: Baoquan He [..] Reviewed-by: Dan Williams