Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2831145pxb; Mon, 1 Nov 2021 02:45:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ6VT8VPdhfA+AOtzlRURhMWLGHi/uS8NAETLwHN6wl45qZQfV02+JK6HMQs0rwsf0edEW X-Received: by 2002:a05:6402:781:: with SMTP id d1mr38762882edy.313.1635759907771; Mon, 01 Nov 2021 02:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759907; cv=none; d=google.com; s=arc-20160816; b=JxWASstZJC7csoSXQ2vNHxFpD1qcph1k/kv5e2TS6vBL2CSIBs+7VN52QXLmPqg5Ci FYjxKq+/Oawf190kic1GkdDXSwbdVI9v1WiZVYbreiSmRP8EO0GbJuLrCWalv6TgOnRC g4v0Uw6fA7G8PguA4dxC05itgPPq6edvQwMaFFQ2RIZKYUd1Y4G/MQA9dt7IFI/QVdyz 89anQHD4vfx08S6vEU340A+Efd9gZOB+ngUhmTRkBq1K8VZ0IVfD/cdDM7i/3LEPQ5yp zDZQyPLI+lwjEpoyP2SZcVnP9aaJlY9NEIha66UiILu0CPTCQ9qRGLgJ3R8hyajTTm2K dXKA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Jf2tPZPYXfWJx+i311epoL/2vwNsyfCwwtdE70QGp0=; b=To9AUoVhfwR1IIvKF/7sVve4YPRr20H4uFI1sdsNq8oYvZGOfk1fbaYTb5oNDidG8n bGyOUkrRXYU+N6t+a+PEaVfXABlQcD8Rt5+ABYKgFo2NvX1DOLpFJTOx/d01EUl4Mxkv Hn/+A0nBcMeO/fFOhReMMinPJ1n9BhJOacfdTZoWO7CQcbMQtK5TcisgC5IIVBsuPIwy 6zd/bC1vdZLjD6L4szJRVunsgi3FyorWYalTes45VdnNvZv9x2tPyATQJ8JRol9740k/ gTaJbfzcOIT9KbkqpPKGM8TdylVyPkrnXtcmsMzWgA8zR6zDkONp5C6coVtTsjPqm6wE fetA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0VPPXl6T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ak20si7962605ejc.221.2021.11.01.02.44.44; Mon, 01 Nov 2021 02:45:07 -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=@linuxfoundation.org header.s=korg header.b=0VPPXl6T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233500AbhKAJmP (ORCPT + 99 others); Mon, 1 Nov 2021 05:42:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:47854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233455AbhKAJjr (ORCPT ); Mon, 1 Nov 2021 05:39:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A577C61360; Mon, 1 Nov 2021 09:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758847; bh=IWRUI0SyL1hEyhmCpWwl37mSrbmg1wKo4wvR1IQOjsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0VPPXl6Tk7i2/3iu3qNhB4jZHEPZ34BtgpWu5HDkarlSDHiqnP3NWD84I1rlPL8yp 1pzOiuQnE4RLmaO5EtwNGIt+6iNcJnkt1gopKMb6zjXvnjcda2vYYXuVq27C474udW 5G80sH4xIvN+VInxUDmfGvJQhTDlm16GSxfuXKoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Alexandre Ghiti , Palmer Dabbelt Subject: [PATCH 5.10 76/77] riscv: Fix asan-stack clang build Date: Mon, 1 Nov 2021 10:18:04 +0100 Message-Id: <20211101082527.351745789@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Ghiti commit 54c5639d8f507ebefa814f574cb6f763033a72a5 upstream. 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 Fixes: 8ad8b72721d0 ("riscv: Add KASAN support") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- 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(-) --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -138,6 +138,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 + config ARCH_FLATMEM_ENABLE def_bool y --- a/arch/riscv/include/asm/kasan.h +++ b/arch/riscv/include/asm/kasan.h @@ -14,8 +14,7 @@ #define KASAN_SHADOW_START KERN_VIRT_START /* 2^64 - 2^38 */ #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); --- a/arch/riscv/mm/kasan_init.c +++ b/arch/riscv/mm/kasan_init.c @@ -16,6 +16,9 @@ asmlinkage void __init kasan_early_init( 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),