From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f70.google.com (mail-vk0-f70.google.com [209.85.213.70]) by kanga.kvack.org (Postfix) with ESMTP id 3FF8F6B02A0 for ; Mon, 2 Jul 2018 19:39:54 -0400 (EDT) Received: by mail-vk0-f70.google.com with SMTP id t13-v6so51661vke.15 for ; Mon, 02 Jul 2018 16:39:54 -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 j27-v6sor6119500uah.220.2018.07.02.16.39.52 for (Google Transport Security); Mon, 02 Jul 2018 16:39:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180702203321.GA8371@bombadil.infradead.org> References: <20180627160800.3dc7f9ee41c0badbf7342520@linux-foundation.org> <20180702203321.GA8371@bombadil.infradead.org> From: Evgenii Stepanov Date: Mon, 2 Jul 2018 16:39:51 -0700 Message-ID: Subject: Re: [PATCH v4 00/17] khwasan: kernel hardware assisted address sanitizer Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Matthew Wilcox Cc: Kostya Serebryany , Andrew Morton , Andrey Konovalov , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg KH , Kate Stewart , Mike Rapoport , kasan-dev , linux-doc@vger.kernel.org, LKML , Linux ARM , linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan On Mon, Jul 2, 2018 at 1:33 PM, Matthew Wilcox wrote: > On Wed, Jun 27, 2018 at 05:04:28PM -0700, Kostya Serebryany wrote: >> The problem is more significant on mobile devices than on desktop/server. >> I'd love to have [K]HWASAN on x86_64 as well, but it's less trivial since x86_64 >> doesn't have an analog of aarch64's top-byte-ignore hardware feature. > > Well, can we emulate it in software? > > We've got 48 bits of virtual address space on x86. If we need all 8 > bits, then that takes us down to 40 bits (39 bits for user and 39 bits > for kernel). My laptop only has 34 bits of physical memory, so could > we come up with a memory layout which works for me? Yes, probably. We've tried this in userspace by mapping a file multiple times, but that's very slow, likely because of the extra TLB pressure. It should be possible to achieve better performance in the kernel with some page table tricks (i.e. if we take top 8 bits out of 48, then there would be only two second-level tables, and the top-level table will look like [p1, p2, p1, p2, ...]). I'm not 100% sure if that would work. I don't think this should be part of this patchset, but it's good to keep this in mind.