Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5986675pxb; Tue, 16 Feb 2021 12:44:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKT19WXFHUxvKSEdMvtAY+Ucv2RqxbaGDuMQACt6tglvOaa+QU0bF2Tt47gc9qcepDvx13 X-Received: by 2002:a17:906:eda8:: with SMTP id sa8mr11971578ejb.536.1613508282789; Tue, 16 Feb 2021 12:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613508282; cv=none; d=google.com; s=arc-20160816; b=crOdEc7MoKrrYWosZjdc0UzVnvqGGQ4iWDKBWyCf4cdM6xc/BA4bQBoJWnQjUajbHr 5eaAQltu1m1Py2ivLpc9qSY+4E/iKLL0iiccbxaHmfHEmZlQNX3pJzB0gN7M/3Q/nUVu 92TynOR4YPP3odpJ/pqH1NZQUEfu297iYHnhnM8aHxYjw3lFgyba0AjvDRQB8+QsN13h C7rVWN8WNRJk0Ck46utUOqs+hBsbEsnV9h9ylJrQn2z5P61jXjtKT38tojltTnX2YL6D bYiM+Od/caTP5gw2uNA7k5KP6CgX1FvkB1qp9tUqsQJnQEkv9daaMgBK15n2F1WuEG7N Lceg== 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 :cc:to:subject; bh=kC5SNAS3e4larHYBzPxoMxsAsEMUY/9/GpoGUYd0GCA=; b=JzjkuIWsa2bSMC+Qe8gEnjOjt+inOO50gPc1GqR3dEaXVlxbhytHZlVhsCHDsukaWz y+3N1c8PLbiLjLZSX9EmgYjFUpI6lNZJFet21UmwWOo8smOdTUBdyVp8er2DvXguQgdA n9+WlLz6vDQsf6/F5qCiyQPU2ltZBsPLo5ahPNgXjs7Cu3rjNIDencVM/Mj53Fu9s/xX 8hz975aruEX60g7sbqXV6ejBLkwDsu85OsBzjN97R24h47KPrcM1tBrd+15JWd7DQtg2 eQ3g0dQRj5TAU8PI3OypP0HroxYQixv0AckAFeu+B0cfKP2OGoHP6SRCEoBytUw6TMCo vaKA== 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 j7si15424227ejm.408.2021.02.16.12.44.19; Tue, 16 Feb 2021 12:44:42 -0800 (PST) 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 S230162AbhBPUnY (ORCPT + 99 others); Tue, 16 Feb 2021 15:43:24 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:54399 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbhBPUnV (ORCPT ); Tue, 16 Feb 2021 15:43:21 -0500 X-Originating-IP: 2.7.49.219 Received: from [192.168.1.12] (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 050001C0003; Tue, 16 Feb 2021 20:42:29 +0000 (UTC) Subject: Re: riscv+KASAN does not boot To: Dmitry Vyukov Cc: Albert Ou , Bjorn Topel , Palmer Dabbelt , LKML , nylon7@andestech.com, syzkaller , Andreas Schwab , Paul Walmsley , Tobias Klauser , linux-riscv References: <20210118145310.crnqnh6kax5jqicj@distanz.ch> <6e9ee3a1-0e16-b1fc-a690-f1ca8e9823a5@ghiti.fr> From: Alex Ghiti Message-ID: <24857bfc-c557-f141-8ae7-2e3da24f67f5@ghiti.fr> Date: Tue, 16 Feb 2021 15:42:29 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, Le 2/16/21 ? 6:25 AM, Dmitry Vyukov a ?crit?: > On Tue, Feb 16, 2021 at 12:17 PM Dmitry Vyukov wrote: >> >> On Fri, Jan 29, 2021 at 9:11 AM Dmitry Vyukov wrote: >>>> I was fixing KASAN support for my sv48 patchset so I took a look at your >>>> issue: I built a kernel on top of the branch riscv/fixes using >>>> https://github.com/google/syzkaller/blob/269d24e857a757d09a898086a2fa6fa5d827c3e1/dashboard/config/linux/upstream-riscv64-kasan.config >>>> and Buildroot 2020.11. I have the warnings regarding the use of >>>> __virt_to_phys on wrong addresses (but that's normal since this function >>>> is used in virt_addr_valid) but not the segfaults you describe. >>> >>> Hi Alex, >>> >>> Let me try to rebuild buildroot image. Maybe there was something wrong >>> with my build, though, I did 'make clean' before doing. But at the >>> same time it worked back in June... >>> >>> Re WARNINGs, they indicate kernel bugs. I am working on setting up a >>> syzbot instance on riscv. If there a WARNING during boot then the >>> kernel will be marked as broken. No further testing will happen. >>> Is it a mis-use of WARN_ON? If so, could anybody please remove it or >>> replace it with pr_err. >> >> >> Hi, >> >> I've localized one issue with riscv/KASAN: >> KASAN breaks VDSO and that's I think the root cause of weird faults I >> saw earlier. The following patch fixes it. >> Could somebody please upstream this fix? I don't know how to add/run >> tests for this. >> Thanks >> >> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile >> index 0cfd6da784f84..cf3a383c1799d 100644 >> --- a/arch/riscv/kernel/vdso/Makefile >> +++ b/arch/riscv/kernel/vdso/Makefile >> @@ -35,6 +35,7 @@ CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os >> # Disable gcov profiling for VDSO code >> GCOV_PROFILE := n >> KCOV_INSTRUMENT := n >> +KASAN_SANITIZE := n >> >> # Force dependency >> $(obj)/vdso.o: $(obj)/vdso.so What's weird is that I don't have any issue without this patch with the following config whereas it indeed seems required for KASAN. But when looking at the segfaults you got earlier, the segfault address is 0xbb0 and the cause is an instruction page fault: this address is the PLT base address in vdso.so and an instruction page fault would mean that someone tried to jump at this address, which is weird. At first sight, that does not seem related to your patch above, but clearly I may be wrong. Tobias, did you observe the same segfaults as Dmitry ? > > > > Second issue I am seeing seems to be related to text segment size. > I check out v5.11 and use this config: > https://gist.github.com/dvyukov/6af25474d455437577a84213b0cc9178 This config gave my laptop a hard time ! Finally I was able to boot correctly to userspace, but I realized I used my sv48 branch...Either I fixed your issue along the way or I can't reproduce it, I'll give it a try tomorrow. > > Then trying to boot it using: > QEMU emulator version 5.2.0 (Debian 1:5.2+dfsg-3) > $ qemu-system-riscv64 -machine virt -smp 2 -m 4G ... > > It shows no output from the kernel whatsoever, even though I have > earlycon and output shows very early with other configs. > Kernel boots fine with defconfig and other smaller configs. > > If I enable KASAN_OUTLINE and CC_OPTIMIZE_FOR_SIZE, then this config > also boots fine. Both of these options significantly reduce kernel > size. However, I can also boot the kernel without these 2 configs, if > I disable a whole lot of subsystem configs. This makes me think that > there is an issue related to kernel size somewhere in > qemu/bootloader/kernel bootstrap code. > Does it make sense to you? Can somebody reproduce what I am seeing? > I did not bring any answer to your question, but at least you know I'm working on it, I'll keep you posted. Thanks for taking the time to setup syzkaller. Alex > Thanks > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >