Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp189532ybv; Wed, 12 Feb 2020 22:08:53 -0800 (PST) X-Google-Smtp-Source: APXvYqy6m0gEnInt2przTidz9nUuMxC1XnTRNPXgC2zrx8b92YsdP5Jq3xgItw//rhaxoET5QOrR X-Received: by 2002:aca:2407:: with SMTP id n7mr1936147oic.14.1581574133188; Wed, 12 Feb 2020 22:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581574133; cv=none; d=google.com; s=arc-20160816; b=IcdND80/1xay7Sfy6dO2PACmhO7I54+DhOHaUV+QBB11IMjWEWv1Ya+DDkTaVKTHnv BExEZph+NqzBc4mUA0077D0ma60aoGNDKjrPhq3syWpeXi3SN1v9QdpOOtGcyUy9GeTL N6cqBCgw1agIc0eYqv7xsuqv6IGX4bjqkADPHA6TBxg5HDiGduwURNJ577sJu7crhjY6 UhlOXMMY/TqHBKji76V2M0a0S4qSvnWUEa0Z0/M5uF8MUMFxlV1x1MDeAyFDEyeKHPoX LvifprRpbS0HmI/DM3j3M+DW6P6B06xKOVOgzg/gI2cEPJK660HvUgBvBSeyG/xaNUzQ eQ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=AKmjbGNoqXYmXrUzT0AKVVfZXpSdbAFvNtOP0PQkAVk=; b=XeYnxxuPdnzHgDtSid9e/GtFhgXTOgcIyLq/XcHzN1tZ/AMszvUc8DJ/K81AIzop0G UnrsZ6fZ61OVqOLLtJoDQFQXCffOzxQz8df+KmWlrGMuFaquLj50TlML7XVbSFJWq25D MA1qpM8hOK4O4rcmyAfOo9vZJwlbWQ4I5zgzxndgOb77taJtwCBrCkgUXkJI5SkRx2LW TYlXDNjU3yBPJT+IP4U1shMAf+S/z61IJNVchS1il0OiZkWRZRgWxTCYrTy3DuHPM441 A3WZR2UMgxDXz3vogvLHuq0qCgAUDklQwf12HnHlBrnzXACPknLwVCf7kFvX2ufBa6b2 FDUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=Bo8PZYyO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t130si747738oib.202.2020.02.12.22.08.38; Wed, 12 Feb 2020 22:08:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=Bo8PZYyO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729526AbgBMGIa (ORCPT + 99 others); Thu, 13 Feb 2020 01:08:30 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:61064 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgBMGIa (ORCPT ); Thu, 13 Feb 2020 01:08:30 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48J5fg1vBSz9txqP; Thu, 13 Feb 2020 07:08:27 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=Bo8PZYyO; dkim-adsp=pass; dkim-atps=neutral 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 W3ooT9PICKBs; Thu, 13 Feb 2020 07:08:27 +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 48J5fg0KvXz9txpx; Thu, 13 Feb 2020 07:08:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1581574107; bh=AKmjbGNoqXYmXrUzT0AKVVfZXpSdbAFvNtOP0PQkAVk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Bo8PZYyOEZ7qD+MevGwQsu8UvvqAisxHMQmlLFbb5ZCOOdcEU4xLcfXvv0aEn1OwF 3fkTo5JOrKAuArtvzKFZe5s3giihd2TCJnKCFWYoV92r76w9omaLNFtSsL82MjHDrb voS3bNq/47yELGACslffHb3qsSDzMPtFyeJQjXQU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D2FE68B752; Thu, 13 Feb 2020 07:08:27 +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 5eeoAwa3yMGD; Thu, 13 Feb 2020 07:08:27 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2F9C88B795; Thu, 13 Feb 2020 07:08:27 +0100 (CET) Subject: Re: [PATCH v7 4/4] powerpc: Book3S 64-bit "heavyweight" KASAN support 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 Cc: Michael Ellerman References: <20200213004752.11019-1-dja@axtens.net> <20200213004752.11019-5-dja@axtens.net> From: Christophe Leroy Message-ID: <67370fc6-8fe8-c5ba-d97a-4a4c399b0ae0@c-s.fr> Date: Thu, 13 Feb 2020 07:08:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200213004752.11019-5-dja@axtens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 13/02/2020 à 01:47, Daniel Axtens a écrit : > KASAN support on Book3S is a bit tricky to get right: > > - It would be good to support inline instrumentation so as to be able to > catch stack issues that cannot be caught with outline mode. > > - Inline instrumentation requires a fixed offset. > > - Book3S runs code in real mode after booting. Most notably a lot of KVM > runs in real mode, and it would be good to be able to instrument it. > > - Because code runs in real mode after boot, the offset has to point to > valid memory both in and out of real mode. > > [ppc64 mm note: The kernel installs a linear mapping at effective > address c000... onward. This is a one-to-one mapping with physical > memory from 0000... onward. Because of how memory accesses work on > powerpc 64-bit Book3S, a kernel pointer in the linear map accesses the > same memory both with translations on (accessing as an 'effective > address'), and with translations off (accessing as a 'real > address'). This works in both guests and the hypervisor. For more > details, see s5.7 of Book III of version 3 of the ISA, in particular > the Storage Control Overview, s5.7.3, and s5.7.5 - noting that this > KASAN implementation currently only supports Radix.] > > One approach is just to give up on inline instrumentation. This way all > checks can be delayed until after everything set is up correctly, and the > address-to-shadow calculations can be overridden. However, the features and > speed boost provided by inline instrumentation are worth trying to do > better. > > If _at compile time_ it is known how much contiguous physical memory a > system has, the top 1/8th of the first block of physical memory can be set > aside for the shadow. This is a big hammer and comes with 3 big > consequences: > > - there's no nice way to handle physically discontiguous memory, so only > the first physical memory block can be used. > > - kernels will simply fail to boot on machines with less memory than > specified when compiling. > > - kernels running on machines with more memory than specified when > compiling will simply ignore the extra memory. > > Implement and document KASAN this way. The current implementation is Radix > only. > > Despite the limitations, it can still find bugs, > e.g. http://patchwork.ozlabs.org/patch/1103775/ > > At the moment, this physical memory limit must be set _even for outline > mode_. This may be changed in a later series - a different implementation > could be added for outline mode that dynamically allocates shadow at a > fixed offset. For example, see https://patchwork.ozlabs.org/patch/795211/ > > Suggested-by: Michael Ellerman > Cc: Balbir Singh # ppc64 out-of-line radix version > Cc: Christophe Leroy # ppc32 version > Signed-off-by: Daniel Axtens Reviewed-by: # focussed mainly on Documentation and things impacting PPC32