Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1199252pxb; Wed, 27 Oct 2021 22:08:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/BNhLOj4zYXtEe25v30sOtZN0oMz897L/NMdg9mabAm7aBhLE9lcPNj+5TTLeUC1Ysrt0 X-Received: by 2002:a17:90a:7e93:: with SMTP id j19mr10495107pjl.172.1635397731045; Wed, 27 Oct 2021 22:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635397731; cv=none; d=google.com; s=arc-20160816; b=goUecBMTNEyoVhsADu5Qe0R7vXgLfTwvlC7ZdjIr6ekRIpwZjoLTeTwiNus9nYgmXS S2yK7KfjcZSWDZHCMp17mYEARgU8jZ/KQDGU8z4L/Ma+g80T9jz2S0mkGiO1fWl+Zkth LgT6Ln+P8kDbEvKYnNCtXQqJPnt0oz2cbQXrL1evzOpkQJbHUUUEm3W50KBeM48+0o6H kuqFH5AIuqiLAFsTbznvFJBt7N+vc167caBskz7fZSNHIAmvIhZvfk9pZxPsiF4JkDF1 5pdrDUOj7DBw5bRaIVtpsojPOTD8uXe6rBl5hZzi4vMLi9t/ZeO2vbeekgabQUOf0aou oPUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=ET9rgc2cPQO0D9fY/bz0XEDC7bhtrK0ZvnRrK6wQ7eU=; b=izZRWZ0ojFUbO2vW2SMzpOc9epiE28G7h0zWPJTM+G4SDyCHZVPYGPPAasog8MtDlc 16fI3iYttJxArWxzX/yGJTASVu1RZP9vg5L6wfqk5d7DaqtGsB2C1Sfgjb85u0vWwq2R 8zeSUmWevjt+Q1ZDIomLUEcLaWD0Oo0htEUbcGsPo2PsvtEFUN0YB6cySLmOjg5e7MMq HU6EQdAT79z+Jet236UD6lofXf4+1+W0+FBLmGFs/qeXmDAHuIxlrWTCq/rHBT7FbUuU rXFqN+qlPM1lT7MPaWbfM92o7nOKF/ZIKzKoGRLuGLQeUuoS+s0edJKyEqXAfkxqoKRs 1wGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=WxFhA8TZ; 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 h6si2866752pfc.21.2021.10.27.22.08.36; Wed, 27 Oct 2021 22:08:51 -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; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=WxFhA8TZ; 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 S229772AbhJ1FFL (ORCPT + 99 others); Thu, 28 Oct 2021 01:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbhJ1FFK (ORCPT ); Thu, 28 Oct 2021 01:05:10 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CBC9C061570 for ; Wed, 27 Oct 2021 22:02:44 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id v1-20020a17090a088100b001a21156830bso7024270pjc.1 for ; Wed, 27 Oct 2021 22:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=ET9rgc2cPQO0D9fY/bz0XEDC7bhtrK0ZvnRrK6wQ7eU=; b=WxFhA8TZckMYBBHxPkT45pXRfhhAuA5TLksn3+jhe2UniPM+VgCSRN9knqFI2+mfR/ tSsW9UmbE4i8fwnsR9gUbcAc74ThkukJ/QwqzpG7E4MMA05eLavgqwUQBQN5/ICtAUuB OXtb9ujB0ObDBev8152CdCY8SaC3C2vV0qUP0ZaW392Gm7lRQ643/jtEM/EeOETL2rGQ Qc+Teh5HTCEiWZaq2AsKtucP/FUniW4EG7ptd6qQvAVbT/3cixYp6hShn+hZLHeUkF0i XOrafyjMRZHHDCCK1ngLG9flycq1vCZ5RzSy/u4ri0kIP4AbVn5hYaN0p6vceJonlUcc jn9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=ET9rgc2cPQO0D9fY/bz0XEDC7bhtrK0ZvnRrK6wQ7eU=; b=luHAZYxO6eRfRISne8SMDsbdIf/VoIK8CuomGb5NjdPTQbdGFCAKYwtLNZRRIk16qI AzpsACC/VNtF541HPTpTA2dvQ44j9gLKKTWWICBq4NlJx+h+ZWjWJxcZbvKoc92pvEym aH0gXSHYMZMwaTAUbfJuSXj/k7G8cwiDZf/BPNnhXoFU3rvHgG2K5TzPakAl0z5nV0Vd mH06mfF5coWWosWKE5bzmrtW8Ydn+/rO2rOlzgcRfHMrvz2vxtvMB6f8zPvUGwR0ofcI FwEGhklL0hk8zr8hhv4RTXv813IdLxTV6aQSSQbkR8Km9GctnnzrorWUZT3/EYJDtTXm O3Fg== X-Gm-Message-State: AOAM533lRpk+II9NJURVPx/wsYLvYEW5/shl9mScPbdqAfNVfl/ur81p NtznL/AQhmiVUnayvEVXtowLUA== X-Received: by 2002:a17:90b:f82:: with SMTP id ft2mr911134pjb.107.1635397363825; Wed, 27 Oct 2021 22:02:43 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id y6sm1667005pfi.154.2021.10.27.22.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 22:02:43 -0700 (PDT) Date: Wed, 27 Oct 2021 22:02:43 -0700 (PDT) X-Google-Original-Date: Wed, 27 Oct 2021 22:02:39 PDT (-0700) Subject: Re: [PATCH 1/2] riscv: Fix asan-stack clang build In-Reply-To: CC: Paul Walmsley , aou@eecs.berkeley.edu, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, nathan@kernel.org From: Palmer Dabbelt To: alexandre.ghiti@canonical.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Oct 2021 21:15:28 PDT (-0700), alexandre.ghiti@canonical.com wrote: > On Thu, Oct 28, 2021 at 1:06 AM Palmer Dabbelt wrote: >> >> On Tue, 26 Oct 2021 21:58:42 PDT (-0700), alexandre.ghiti@canonical.com wrote: >> > Nathan reported that because KASAN_SHADOW_OFFSET was not defined in >> > Kconfig, it prevents asan-stack from getting disabled with clang even >> > when CONFIG_KASAN_STACK is disabled: fix this by defining the >> > corresponding config. >> > >> > Reported-by: Nathan Chancellor >> > Signed-off-by: Alexandre Ghiti >> > --- >> > arch/riscv/Kconfig | 6 ++++++ >> > arch/riscv/include/asm/kasan.h | 3 +-- >> > arch/riscv/mm/kasan_init.c | 3 +++ >> > 3 files changed, 10 insertions(+), 2 deletions(-) >> > >> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig >> > index c1abbc876e5b..79250b1ed54e 100644 >> > --- a/arch/riscv/Kconfig >> > +++ b/arch/riscv/Kconfig >> > @@ -162,6 +162,12 @@ config PAGE_OFFSET >> > default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB >> > default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB >> > >> > +config KASAN_SHADOW_OFFSET >> > + hex >> > + depends on KASAN_GENERIC >> > + default 0xdfffffc800000000 if 64BIT >> > + default 0xffffffff if 32BIT >> >> I thought I posted this somewhere, but this is exactly what my first >> guess was. The problem is that it's hanging on boot for me. I don't >> really have anything exotic going on, it's just a defconfig with >> CONFIG_KASAN=y running in QEMU. >> >> Does this boot for you? > > Yes with the 2nd patch of this series which fixes the issue > encountered here. And that's true I copied/pasted this part of your > patch which was better than what I had initially done, sorry I should > have mentioned you did that, please add a Codeveloped-by or something > like that. Not sure if I'm missing something, but it's still not booting for me. I've put what I'm testing on palmer/to-test, it's these two on top of fixes and merged into Linus' tree * 6d7d351902ff - (HEAD -> to-test, palmer/to-test) Merge remote-tracking branch 'palmer/fixes' into to-test (7 minutes ago) |\ | * 782551edf8f8 - (palmer/fixes) riscv: Fix CONFIG_KASAN_STACK build (6 hours ago) | * 47383e5b3c4f - riscv: Fix asan-stack clang build (6 hours ago) | * 64a19591a293 - (riscv/fixes) riscv: fix misalgned trap vector base address (9 hours ago) * | 1fc596a56b33 - (palmer/master, linus/master, linus/HEAD, master) Merge tag 'trace-v5.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace (11 hours ago) Am I missing something else? > > Thanks, > > Alex > >> >> > + >> > config ARCH_FLATMEM_ENABLE >> > def_bool !NUMA >> > >> > diff --git a/arch/riscv/include/asm/kasan.h b/arch/riscv/include/asm/kasan.h >> > index a2b3d9cdbc86..b00f503ec124 100644 >> > --- a/arch/riscv/include/asm/kasan.h >> > +++ b/arch/riscv/include/asm/kasan.h >> > @@ -30,8 +30,7 @@ >> > #define KASAN_SHADOW_SIZE (UL(1) << ((CONFIG_VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT)) >> > #define KASAN_SHADOW_START KERN_VIRT_START >> > #define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE) >> > -#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \ >> > - (64 - KASAN_SHADOW_SCALE_SHIFT))) >> > +#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL) >> > >> > void kasan_init(void); >> > asmlinkage void kasan_early_init(void); >> > diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c >> > index d7189c8714a9..8175e98b9073 100644 >> > --- a/arch/riscv/mm/kasan_init.c >> > +++ b/arch/riscv/mm/kasan_init.c >> > @@ -17,6 +17,9 @@ asmlinkage void __init kasan_early_init(void) >> > uintptr_t i; >> > pgd_t *pgd = early_pg_dir + pgd_index(KASAN_SHADOW_START); >> > >> > + BUILD_BUG_ON(KASAN_SHADOW_OFFSET != >> > + KASAN_SHADOW_END - (1UL << (64 - KASAN_SHADOW_SCALE_SHIFT))); >> > + >> > for (i = 0; i < PTRS_PER_PTE; ++i) >> > set_pte(kasan_early_shadow_pte + i, >> > mk_pte(virt_to_page(kasan_early_shadow_page),