From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua0-f199.google.com (mail-ua0-f199.google.com [209.85.217.199]) by kanga.kvack.org (Postfix) with ESMTP id A96ED6B0292 for ; Mon, 29 May 2017 07:20:21 -0400 (EDT) Received: by mail-ua0-f199.google.com with SMTP id h12so17658929uaa.4 for ; Mon, 29 May 2017 04:20:21 -0700 (PDT) Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 80sor1498971uai.11.2017.05.29.04.20.20 for (Google Transport Security); Mon, 29 May 2017 04:20:20 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <71e11033-f95c-887f-4e4e-351bcc3df71e@virtuozzo.com> References: <20170525203334.867-1-kirill.shutemov@linux.intel.com> <20170525203334.867-8-kirill.shutemov@linux.intel.com> <20170526221059.o4kyt3ijdweurz6j@node.shutemov.name> <71e11033-f95c-887f-4e4e-351bcc3df71e@virtuozzo.com> From: Dmitry Vyukov Date: Mon, 29 May 2017 13:19:59 +0200 Message-ID: Subject: Re: KASAN vs. boot-time switching between 4- and 5-level paging Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Ryabinin Cc: "Kirill A. Shutemov" , Alexander Potapenko , "Kirill A. Shutemov" , Linus Torvalds , Andrew Morton , "x86@kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Dave Hansen , Andy Lutomirski , linux-arch@vger.kernel.org, "linux-mm@kvack.org" , LKML , kasan-dev On Mon, May 29, 2017 at 1:18 PM, Andrey Ryabinin wrote: > > > On 05/29/2017 01:02 PM, Dmitry Vyukov wrote: >> On Sat, May 27, 2017 at 12:10 AM, Kirill A. Shutemov >> wrote: >>> On Thu, May 25, 2017 at 11:33:33PM +0300, Kirill A. Shutemov wrote: >>>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig >>>> index 0bf81e837cbf..c795207d8a3c 100644 >>>> --- a/arch/x86/Kconfig >>>> +++ b/arch/x86/Kconfig >>>> @@ -100,7 +100,7 @@ config X86 >>>> select HAVE_ARCH_AUDITSYSCALL >>>> select HAVE_ARCH_HUGE_VMAP if X86_64 || X86_PAE >>>> select HAVE_ARCH_JUMP_LABEL >>>> - select HAVE_ARCH_KASAN if X86_64 && SPARSEMEM_VMEMMAP >>>> + select HAVE_ARCH_KASAN if X86_64 && SPARSEMEM_VMEMMAP && !X86_5LEVEL >>>> select HAVE_ARCH_KGDB >>>> select HAVE_ARCH_KMEMCHECK >>>> select HAVE_ARCH_MMAP_RND_BITS if MMU >>> >>> Looks like KASAN will be a problem for boot-time paging mode switching. >>> It wants to know CONFIG_KASAN_SHADOW_OFFSET at compile-time to pass to >>> gcc -fasan-shadow-offset=. But this value varies between paging modes... >>> >>> I don't see how to solve it. Folks, any ideas? >> >> +kasan-dev >> >> I wonder if we can use the same offset for both modes. If we use >> 0xFFDFFC0000000000 as start of shadow for 5 levels, then the same >> offset that we use for 4 levels (0xdffffc0000000000) will also work >> for 5 levels. Namely, ending of 5 level shadow will overlap with 4 >> level mapping (both end at 0xfffffbffffffffff), but 5 level mapping >> extends towards lower addresses. The current 5 level start of shadow >> is actually close -- 0xffd8000000000000 and it seems that the required >> space after it is unused at the moment (at least looking at mm.txt). >> So just try to move it to 0xFFDFFC0000000000? >> > > Yeah, this should work, but note that 0xFFDFFC0000000000 is not PGDIR aligned address. Our init code > assumes that kasan shadow stars and ends on the PGDIR aligned address. > Fortunately this is fixable, we'd need two more pages for page tables to map unaligned start/end > of the shadow. I think we can extend the shadow backwards (to the current address), provided that it does not affect shadow offset that we pass to compiler. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org