Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4639045pxb; Tue, 22 Feb 2022 03:13:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxV9XwimvSgx4SgHo3rnhbgkOWnr+qVBH0m59/h9RT8XskPNHOjSUjlLWe0h17poZiBuMh7 X-Received: by 2002:a17:906:dd3:b0:698:3e07:dcee with SMTP id p19-20020a1709060dd300b006983e07dceemr19109961eji.487.1645528424863; Tue, 22 Feb 2022 03:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645528424; cv=none; d=google.com; s=arc-20160816; b=Xn+5zREp+/jMqxUmFsMc+AcUIKIMsCl9ZffCv4+tXEnl1iAf5CBDxX9luhPfeN0klZ XW2KNBzIdqI3Va7HM8l2znBLjB57TlDdfbayNJcBWx6/v7WAx+NkKLr2OUCv/Ew/XAsz OzI8TaVm4YXngLeipYBWLwQT4SU4v+z11nKc4Pf4ywkI49XG4slJdpUswdrV/zuxwBau CmV2ZWzv368l+MS+2WWP0F49xX8VRm3dMVX1FbToA9qIslDfLfuspnRjD+aaLkKFBS72 E7hLSLIPsz3bKIlsjSF60RaScnW/39R+xU3kxLXeE4L7pB3c2n2GLhxxuoWfjLQKMo4V qCDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eS2A2SDIO/vp8PmlyWTYQFrSZtShYqNTX+yWJ9M+0YE=; b=tSn4KwVLw87uavHnTOd/bm1p2Rf2a149junUKU0EnN3LAx1WrdSvQxCffbk4qyZDw2 5gHUrGk0kVttuQSbNgH2T5OwRCoftoT3e2lFHeqDmU07af3sQWB+8JXvG/xjB5Aa9hB+ gDQGx2icac9O+9zXk3Rh1AyKfv5En3UhQAWFNLu0KhBtTevB2J8QeEtnCam9plZHwxmp xvOOxH7YBu5B2q/l49bzIFhwnCL1AXuawK87DUFEI6BTRrc3jydqngzraO2XWzUBP/vZ 0SCiXw6ruTFIpELI0XVtvB4nRXZRQ78Vlkl4kFDdiavHGSV4oq+IeGPiR/t01CR8Kh1V BUDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DLkDqBLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy11si9599915ejb.767.2022.02.22.03.13.20; Tue, 22 Feb 2022 03:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DLkDqBLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbiBVK3M (ORCPT + 99 others); Tue, 22 Feb 2022 05:29:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbiBVK3K (ORCPT ); Tue, 22 Feb 2022 05:29:10 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772ED15A229 for ; Tue, 22 Feb 2022 02:28:45 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id f2so658018ilq.1 for ; Tue, 22 Feb 2022 02:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eS2A2SDIO/vp8PmlyWTYQFrSZtShYqNTX+yWJ9M+0YE=; b=DLkDqBLdcGNOzANvpMjGVxmycBjJ8eQh4h1LoBysLfd2y+YbDaXBykiqIcmdP5G8sL Ia0sqOOIwPTBZlBvMYfiZ1YH3LdwBPuDA7xIGGw3LXytjESyafL1BrBMU78Ark6gsWNs Lh+cDryQPwsMlv8MlvmFXNIL/SBVAw5YAfsh0wRwO7oFIMBPR1qfGK0Csn0LkENjfufS YiCxl9x9qyIBAHDu1XeffFwUiMU396z7WIEcaQEJo3+HA9FMuIQ0T0JAmoXhMgBXhixZ nef+txSPZ8AVffXJUYlytFS5sSVRylCtIopU549RgCWmTZCt8P9bqBzBFHQ4zZhOOJdR emHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eS2A2SDIO/vp8PmlyWTYQFrSZtShYqNTX+yWJ9M+0YE=; b=dcMBCerdzHkp0+zBnDtvee/XTgEDLXRttZvDdIHD1mvsoCKT+G1p3IkLPr8jwb+uDV skwkZEkiNk4f/PRzfeiSo4PFm1QhrdSsQOjXJCGmNipsWQ2b7tMScjiK4Tb2VL6KZnLs gVylpl3W7lSg1vsUV9t5Q5C1aC0FhPMEdIMwpde0gy7+Z/rse7tT5DlLHYRNrsT/GKW/ so4O4l+hx9hvtL/irJJdvaSAOt8gTSKX0LDIl0i7WLtxgvOFpqUn3uYSMub74E0aUR2R Wken46/PUxYARz64w7nyE9W46F5vwEA103x9Nc+aiyldNqAlxI83YsrWnfK5i7pFpKG/ xHpw== X-Gm-Message-State: AOAM531AdQNzhUvKDgnzE62AzH1To2YoBZIJTkVU7RAVlmFEYYapCHks VLxmwU3ZUPVbebPC+++Tyf9HV3FMDBpAOUBebfJw0w== X-Received: by 2002:a92:c241:0:b0:2b9:80f9:e2a with SMTP id k1-20020a92c241000000b002b980f90e2amr19663534ilo.208.1645525724716; Tue, 22 Feb 2022 02:28:44 -0800 (PST) MIME-Version: 1.0 References: <20220221161232.2168364-1-alexandre.ghiti@canonical.com> <20220221161232.2168364-5-alexandre.ghiti@canonical.com> In-Reply-To: <20220221161232.2168364-5-alexandre.ghiti@canonical.com> From: Aleksandr Nogikh Date: Tue, 22 Feb 2022 11:28:33 +0100 Message-ID: Subject: Re: [PATCH -fixes v2 4/4] riscv: Fix config KASAN && DEBUG_VIRTUAL To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Nick Hu , linux-riscv@lists.infradead.org, LKML , kasan-dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, Thanks for the series! However, I still haven't managed to boot the kernel. What I did: 1) Checked out the riscv/fixes branch (this is the one we're using on syzbot). The latest commit was 6df2a016c0c8a3d0933ef33dd192ea6606b115e3. 2) Applied all 4 patches. 3) Used the config from the cover letter: https://gist.github.com/a-nogikh/279c85c2d24f47efcc3e865c08844138 4) Built with `make -j32 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-` 5) Ran with `qemu-system-riscv64 -m 2048 -smp 1 -nographic -no-reboot -device virtio-rng-pci -machine virt -device virtio-net-pci,netdev=net0 -netdev user,id=net0,restrict=on,hostfwd=tcp:127.0.0.1:12529-:22 -device virtio-blk-device,drive=hd0 -drive file=~/kernel-image/riscv64,if=none,format=raw,id=hd0 -snapshot -kernel ~/linux-riscv/arch/riscv/boot/Image -append "root=/dev/vda console=ttyS0 earlyprintk=serial"` (this is similar to how syzkaller runs qemu). Can you please hint at what I'm doing differently? A simple config with KASAN, KASAN_OUTLINE and DEBUG_VIRTUAL now indeed leads to a booting kernel, which was not the case before. make defconfig ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- ./scripts/config -e KASAN -e KASAN_OUTLINE -e DEBUG_VIRTUAL make olddefconfig ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -- Best Regards, Aleksandr On Mon, Feb 21, 2022 at 5:17 PM Alexandre Ghiti wrote: > > __virt_to_phys function is called very early in the boot process (ie > kasan_early_init) so it should not be instrumented by KASAN otherwise it > bugs. > > Fix this by declaring phys_addr.c as non-kasan instrumentable. > > Signed-off-by: Alexandre Ghiti > --- > arch/riscv/mm/Makefile | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile > index 7ebaef10ea1b..ac7a25298a04 100644 > --- a/arch/riscv/mm/Makefile > +++ b/arch/riscv/mm/Makefile > @@ -24,6 +24,9 @@ obj-$(CONFIG_KASAN) += kasan_init.o > ifdef CONFIG_KASAN > KASAN_SANITIZE_kasan_init.o := n > KASAN_SANITIZE_init.o := n > +ifdef CONFIG_DEBUG_VIRTUAL > +KASAN_SANITIZE_physaddr.o := n > +endif > endif > > obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o > -- > 2.32.0 >