Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp959967pxb; Wed, 27 Oct 2021 16:09:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWyiigHDVdCSgD0f/1Ieyv/XcadiAMJn96RSLStGGoVaZoqpsoR+T5z1McO0pXXO07GEe2 X-Received: by 2002:a17:902:6b4a:b0:13f:8e99:2149 with SMTP id g10-20020a1709026b4a00b0013f8e992149mr611122plt.87.1635376144482; Wed, 27 Oct 2021 16:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635376144; cv=none; d=google.com; s=arc-20160816; b=FNaIU8wKSzkHCtSsTkQ/Sk2fDsx2TPT5OQx76B6Wzwn/1E/5gt04gHDH6Giy780lD9 DThElUrOMdi02vkh8X5SCLR4vyagDKQHXKVaDKJcFK5OKwPgechIO/mgKu5Pwr6HSgv4 gt6pS6dnPJbYIzqS7DTG6s43+PkZSGwTTtx7LNSzCXmAqr81zowPF0PmhXqTqy7upX9I ROroM6XnCpu281oRbdujaXrO6qtBgv3yynhnm9MTtfkadD0z1QtZlYVJIc+2vBcVTVVK 2JXNMkAId2kfrt0gN74yO8Tsou3j5DMhDIN5gmy07mK/6CVVrRKqJA1j6/K6lbVVDd2V Ziyg== 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=qq3Zte+b3gvW8aVUSoj11hufNXWtcNy5WKvRt4opsbo=; b=EjWhHoVCA1YkKqbTAc6AjqJyKq7rvJFoRoijSr3gscwZe8DV8HXfaq90qsWet5wx1N +Z2FxHqn9yZLAtnNeOPpWyC8qp3gJh0gKmZJziPt9AhQsetT0z+PJCnG3WXJDHANGSPQ YY1CYdqFATVgseiu2r6WWe5RctxEbmJCyUk9ojugT+5ZaBMA4ET8/EGoMo3nhJDgnukP NQzJ3treuE1leHIxKPZ5EnfqdA0CazHoggqeZYYfdbirukDS8/ChOxNO4sdhCCVRQGIJ 1HfVZlluF9r48/AOtCGErk9/n3Hv/LlizAhf3V2fu7krfr4kQuJ0fe6MfQoo3dgvcLwj awfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=7y5UZL3r; 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 k126si1822672pgc.501.2021.10.27.16.08.51; Wed, 27 Oct 2021 16:09:04 -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=7y5UZL3r; 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 S230080AbhJ0XIv (ORCPT + 99 others); Wed, 27 Oct 2021 19:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbhJ0XIv (ORCPT ); Wed, 27 Oct 2021 19:08:51 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C48C061570 for ; Wed, 27 Oct 2021 16:06:25 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id h193so4501984pgc.1 for ; Wed, 27 Oct 2021 16:06:25 -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=qq3Zte+b3gvW8aVUSoj11hufNXWtcNy5WKvRt4opsbo=; b=7y5UZL3rxbZp4tvqsYjA0PSihfwGo2dxmv9dANT4KDkwtKlsd4EoZH5BgFjkxWwrJE 2/gCrvWOjjaEVpOr6/JrF6H+ZzfKQox2Vg9ZHvu9PXip1qdGjyF8mUGSQEqhxy/YUnBa IrpRZJuZPA/8znNDIcvJBYFnlOS8M6mdo1HVcNspkw2G737P6sBVl923LGfWRi2k1/OK jQfkqKacsO5o+iNweytFnLyVs6V9iBR3RnJ6zjCInvvzrw4SAFPkJ2VIpeLXj1Yc5ome Tp6cF3kgiluFW/TayK9FlC+IsK/GJwSP9fnxFwx97BTeLHMDp1HvQAch5PPeqqY/cv6M ImcA== 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=qq3Zte+b3gvW8aVUSoj11hufNXWtcNy5WKvRt4opsbo=; b=UxmUlrnHiairgiHHQoKISulUpbFCXnMK8N5SKIX+Z59tFoxAbM7SlIoNV0EXAyPwlO UnhbHKa7yk2RlSXLaBWKZgwiUhCTklGj04lAjy9RFlDCOT/lLZQs9MFLEM03FMRsrb8h nce2cbfqVXMv3osE1a19TE0zgS6XVFMCiHKXrO+qbNjSek3GXepUiT7O9BnEX12gXHGN PwnwgQsI4mToYB1kpWG13eXasfnADrwiicOhzCoTrf6c9zWXqlBTeE2bxbaeZbSkzYZV 6ZMFvAapFYeiDO3eU60hSvbEf+RdyperKgHnpA72mmwEU5hlYAWIj6EhOsK3lgbzTYi4 WwbQ== X-Gm-Message-State: AOAM531uHAzFlz0MhAW4kPQLyWac1hwwLHykG4VrAB+yNU2O9rmFPMx6 SyjiMcRhbG9e5yKBcBt25vMm3g== X-Received: by 2002:a63:84c6:: with SMTP id k189mr479739pgd.245.1635375984652; Wed, 27 Oct 2021 16:06:24 -0700 (PDT) Received: from localhost ([2620:0:1000:5e10:60fc:a50:6d27:9fd3]) by smtp.gmail.com with ESMTPSA id j1sm751742pgb.5.2021.10.27.16.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 16:06:24 -0700 (PDT) Date: Wed, 27 Oct 2021 16:06:24 -0700 (PDT) X-Google-Original-Date: Wed, 27 Oct 2021 16:06:21 PDT (-0700) Subject: Re: [PATCH 1/2] riscv: Fix asan-stack clang build In-Reply-To: <20211027045843.1770770-1-alexandre.ghiti@canonical.com> 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, alexandre.ghiti@canonical.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 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? > + > 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),