From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 0892E6B0008 for ; Fri, 20 Jul 2018 18:20:29 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id f91-v6so6137515plb.10 for ; Fri, 20 Jul 2018 15:20:29 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p19-v6sor869677pfo.123.2018.07.20.15.20.27 for (Google Transport Security); Fri, 20 Jul 2018 15:20:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/3] perf/core: Make sure the ring-buffer is mapped in all page-tables From: Andy Lutomirski In-Reply-To: <20180720213700.gh6d2qd2ck6nt4ax@suse.de> Date: Fri, 20 Jul 2018 12:20:24 -1000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1532103744-31902-1-git-send-email-joro@8bytes.org> <1532103744-31902-2-git-send-email-joro@8bytes.org> <20180720174846.GF18541@8bytes.org> <20180720213700.gh6d2qd2ck6nt4ax@suse.de> Sender: owner-linux-mm@kvack.org List-ID: To: Joerg Roedel Cc: Andy Lutomirski , Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , X86 ML , LKML , Linux-MM , Linus Torvalds , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , "Liguori, Anthony" , Daniel Gruss , Hugh Dickins , Kees Cook , Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim > On Jul 20, 2018, at 11:37 AM, Joerg Roedel wrote: >=20 >> On Fri, Jul 20, 2018 at 12:32:10PM -0700, Andy Lutomirski wrote: >> I'm just reading your changelog, and you said the PMDs are no longer >> shared between the page tables. So this presumably means that >> vmalloc_fault() no longer actually works correctly on PTI systems. I >> didn't read the code to figure out *why* it doesn't work, but throwing >> random vmalloc_sync_all() calls around is wrong. >=20 > Hmm, so the whole point of vmalloc_fault() fault is to sync changes from > swapper_pg_dir to process page-tables when the relevant parts of the > kernel page-table are not shared, no? >=20 > That is also the reason we don't see this on 64 bit, because there these > parts *are* shared. >=20 > So with that reasoning vmalloc_fault() works as designed, except that > a warning is issued when it's happens in the NMI path. That warning comes > from >=20 > ebc8827f75954 x86: Barf when vmalloc and kmemcheck faults happen in NMI= >=20 > which went into 2.6.37 and was added because the NMI handler were not > nesting-safe back then. Reason probably was that the handler on 64 bit > has to use an IST stack and a nested NMI would overwrite the stack of > the upper handler. We don't have this problem on 32 bit as a nested NMI > will not do another stack-switch there. >=20 Thanks for digging! The problem was presumably that vmalloc_fault() will IR= ET and re-enable NMIs on the way out. But we=E2=80=99ve supported page faul= ts on user memory in NMI handlers on 32-bit and 64-bit for quite a while, an= d it=E2=80=99s fine now. I would remove the warning, re-test, and revert the other patch. The one case we can=E2=80=99t handle in vmalloc_fault() is a fault on a stac= k access. I don=E2=80=99t expect this to be a problem for PTI. It was a prob= lem for CONFIG_VMAP_STACK, though. > I am not sure about 64 bit, but there is a lot of assembly magic to make > NMIs nesting-safe, so I guess the problem should be gone there too. >=20 >=20 > Regards, >=20 > Joerg