From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 894096B0005 for ; Fri, 9 Mar 2018 13:21:35 -0500 (EST) Received: by mail-it0-f69.google.com with SMTP id p203so2834494itc.1 for ; Fri, 09 Mar 2018 10:21:35 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d7sor935463iog.311.2018.03.09.10.21.34 for (Google Transport Security); Fri, 09 Mar 2018 10:21:34 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <739eecf573b6342fc41c4f89d7f64eb8c183e312.1520017438.git.andreyknvl@google.com> <20180305143625.vtrfvsbw7loxngaj@lakrids.cambridge.arm.com> From: Andrey Konovalov Date: Fri, 9 Mar 2018 19:21:32 +0100 Message-ID: Subject: Re: [RFC PATCH 06/14] khwasan: enable top byte ignore for the kernel Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Marc Zyngier Cc: Mark Rutland , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Jonathan Corbet , Catalin Marinas , Will Deacon , Theodore Ts'o , Jan Kara , Christopher Li , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Masahiro Yamada , Michal Marek , Ard Biesheuvel , Yury Norov , Nick Desaulniers , Suzuki K Poulose , Kristina Martsenko , Punit Agrawal , Dave Martin , James Morse , Julien Thierry , Michael Weiser , Steve Capper , Ingo Molnar , Thomas Gleixner , Sandipan Das , Paul Lawrence , David Woodhouse , Kees Cook , Geert Uytterhoeven , Josh Poimboeuf , Arnd Bergmann , kasan-dev , linux-doc@vger.kernel.org, LKML , Linux ARM , linux-ext4@vger.kernel.org, linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Kees Cook , Jann Horn , Mark Brand On Tue, Mar 6, 2018 at 3:24 PM, Marc Zyngier wrote: > On 05/03/18 14:36, Mark Rutland wrote: >> On Fri, Mar 02, 2018 at 08:44:25PM +0100, Andrey Konovalov wrote: >>> KHWASAN uses the Top Byte Ignore feature of arm64 CPUs to store a pointer >>> tag in the top byte of each pointer. This commit enables the TCR_TBI1 bit, >>> which enables Top Byte Ignore for the kernel, when KHWASAN is used. >>> --- >>> arch/arm64/include/asm/pgtable-hwdef.h | 1 + >>> arch/arm64/mm/proc.S | 8 +++++++- >>> 2 files changed, 8 insertions(+), 1 deletion(-) >> >> Before it's safe to do this, I also think you'll need to fix up at >> least: >> >> * virt_to_phys() >> >> * access_ok() >> >> ... and potentially others which assume that bits [63:56] of kernel >> addresses are 0xff. For example, bits of the fault handling logic might >> need fixups. > > Indeed. I have the ugly feeling that KVM (and anything that leaves in a > separate address space) will not be very happy with that change, as it > derives HYP VAs from the kernel VA, and doesn't expect lingering bits. > Nothing that cannot be addressed, but worth keeping in mind. > Hi Marc! Yes, I would expect there would be issues with KVM. I'll see if I can figure them out, but I think I'll just add a depends on !KVM or something like this, and will have to deal with KVM once the main part is committed. Thanks!