Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4256798pxf; Tue, 23 Mar 2021 06:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZUjRbYXMTfzb7ltdQDS3d78aVYrXpPFzY6r7l8dCyi5ROnPhlauA3Sqve/pEtD+vU8Rnb X-Received: by 2002:aa7:d987:: with SMTP id u7mr4593820eds.326.1616506952284; Tue, 23 Mar 2021 06:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616506952; cv=none; d=google.com; s=arc-20160816; b=PYZYYxh1Xs/1Q1nRpoeyHd4UGCKrjx2NIjepByOkQQ94ajj34Jm/KWLlI0tNQF41N4 jXzaBrbnSbByzzB+eLo7FSw8j47i9JkJq5k+bPfMA2POT8atEJDKW8foiR79al81cPlc qjRtDoM64PEF6ZqZsvX0xwEH0vJOpCBXOys5C19wA8xByUW1TnmP41xnan4kE3MnzlFb sOUPWX6dOJMTsW+fNY5+caZe9iVaVuw0Y/jZtwJGStMSry0qIethtl+dOmG1ScO7n1s1 Y1ib50WJMjGQpCihdwHBJ33uEGhhTT0J52uJi2L5rpLqSx1znKwoeNJrPNeAUOSdtLTB 1Sow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=1rOUnW7NvGNH2LyWXIunVzbWEl/X2yO1xmTpmk4o97U=; b=iX70iN9FlxB5KPLleE+tkTonJACo+6r3BuWnoJVIQpzut5kgMqveTJcPOH4LI0iLsu UkM5eai9iEM3NrsWRis9rmLr57uKR2kQynIeIs87VOoRRlvKbMrCbMTVRiIxzDRz0unS dPzVaHb+IcaWWcfJkZDvRBhJEN0Wyt0J0mfrjxyPakSC3yrV7Ed+JORjPUA4c5r91BJY nHGXWVn5QsswtQ9PFEMhQkawJItJqGx6x7ytWrW2m5zoq+IMDYRrSZKxZUFEIXS9DqQg Ywk6+dLkV4mS/u2R9qnIReGdEg/hFFUjOPp0FwxC4QrSbsTiZSxx6s41QzXmp5x/u78e CJLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h26si13318307edq.453.2021.03.23.06.42.08; Tue, 23 Mar 2021 06:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbhCWN2X (ORCPT + 99 others); Tue, 23 Mar 2021 09:28:23 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:55358 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbhCWN1u (ORCPT ); Tue, 23 Mar 2021 09:27:50 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4F4XH70jjqz9v1GL; Tue, 23 Mar 2021 14:27:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id RzqWHqF5nznC; Tue, 23 Mar 2021 14:27:47 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4F4XH66lWHz9v1GJ; Tue, 23 Mar 2021 14:27:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4CFA18B7F7; Tue, 23 Mar 2021 14:27:48 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id TWHHaF8PUfFg; Tue, 23 Mar 2021 14:27:48 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B4B0A8B7F4; Tue, 23 Mar 2021 14:27:47 +0100 (CET) Subject: Re: [PATCH v11 0/6] KASAN for powerpc64 radix To: Daniel Axtens , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, aneesh.kumar@linux.ibm.com, bsingharora@gmail.com References: <20210319144058.772525-1-dja@axtens.net> <5a3b5952-b31f-42bf-eaf4-ea24444f8df6@csgroup.eu> <87ft0mbr6r.fsf@dja-thinkpad.axtens.net> From: Christophe Leroy Message-ID: Date: Tue, 23 Mar 2021 14:27:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <87ft0mbr6r.fsf@dja-thinkpad.axtens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 23/03/2021 à 02:21, Daniel Axtens a écrit : > Hi Christophe, > >> In the discussion we had long time ago, >> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20190806233827.16454-5-dja@axtens.net/#2321067 >> , I challenged you on why it was not possible to implement things the same way as other >> architectures, in extenso with an early mapping. >> >> Your first answer was that too many things were done in real mode at startup. After some discussion >> you said that finally there was not that much things at startup but the issue was KVM. >> >> Now you say that instrumentation on KVM is fully disabled. >> >> So my question is, if KVM is not a problem anymore, why not go the standard way with an early shadow >> ? Then you could also support inline instrumentation. > > Fair enough, I've had some trouble both understanding the problem myself > and clearly articulating it. Let me try again. > > We need translations on to access the shadow area. > > We reach setup_64.c::early_setup() with translations off. At this point > we don't know what MMU we're running under, or our CPU features. What do you need to know ? Whether it is Hash or Radix, or more/different details ? IIUC, today we only support KASAN on Radix. Would it make sense to say that a kernel built with KASAN can only run on processors having Radix capacility ? Then select CONFIG_PPC_RADIX_MMU_DEFAULT when KASAN is set, and accept that the kernel crashes if Radix is not available ? > > To determine our MMU and CPU features, early_setup() calls functions > (dt_cpu_ftrs_init, early_init_devtree) that call out to generic code > like of_scan_flat_dt. We need to do this before we turn on translations > because we can't set up the MMU until we know what MMU we have. > > So this puts us in a bind: > > - We can't set up an early shadow until we have translations on, which > requires that the MMU is set up. > > - We can't set up an MMU until we call out to generic code for FDT > parsing. > > So there will be calls to generic FDT parsing code that happen before the > early shadow is set up. I see some logic in kernel/prom_init.c for detecting MMU. Can we get the information from there in order to setup the MMU ? > > The setup code also prints a bunch of information about the platform > with printk() while translations are off, so it wouldn't even be enough > to disable instrumentation for bits of the generic DT code on ppc64. I'm sure the printk() stuff can be avoided or delayed without much problems, I guess the main problem is the DT code, isn't it ? As far as I can see the code only use udbg_printf() before MMU is on, and this could be simply skipped when KASAN is selected, I see no situation where you need early printk together with KASAN. > > Does that make sense? If you can figure out how to 'square the circle' > here I'm all ears. Yes it is a lot more clear now, thanks you. Gave a few ideas above, does it help ? > > Other notes: > > - There's a comment about printk() being 'safe' in early_setup(), that > refers to having a valid PACA, it doesn't mean that it's safe in any > other sense. > > - KVM does indeed also run stuff with translations off but we can catch > all of that by disabling instrumentation on the real-mode handlers: > it doesn't seem to leak out to generic code. So you are right that > KVM is no longer an issue. > Christophe