Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp694337pxm; Fri, 25 Feb 2022 17:28:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2e9n9XBm+BhJ9026DJA1Hc9/oK6FnlC4TH05ZNgh3Er2Cvk2GmBRCKFp0dNbmyxGhdKzF X-Received: by 2002:a65:464b:0:b0:36c:58da:5892 with SMTP id k11-20020a65464b000000b0036c58da5892mr8378421pgr.439.1645838934189; Fri, 25 Feb 2022 17:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645838934; cv=none; d=google.com; s=arc-20160816; b=Rq2zXdUPtUHItCDmCaqEKylTjN3u972wLVxONeowTGP279HwqerN+7gJdKB0dPupKp rPqM2KaENzQjq/w5dbJuM2VjOILLuqYsLp1/eW8k+xOPNpIKJxT84pbEaZp46h3XbvrX BC4tV5kgKTELr0lJJUuKP570LxnbaOc4kttCfpa6d8OOMUNc6DtkTXOmYrrZTL827j3l apJCTqlCMHKeNg/KXxkrzU2cC/KWtZh7Ze+FW6DXK5y50w3ThNMMK0sajNFz1GYCGoB4 RSCLOG6TIff1R/grZxDsb2pRXmB+iVVQBeFHUYygcj+Cbv9eI1R9rqR1q7OTjk4Ee7OI a24w== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PQyFtNV3tW1qRmwZ8HqaxvUDcyO7BHPqZZLC0geQ1k0=; b=hLO1o78chpr7z1JF4W4N7fKKuOAU2DoZsKgev6ODXhTBYYx0ApKUE9b/9FlqxMBMlZ OwNoU9aw7SGw2NqpTkIBb2VdSDWl9Nke2qOIGeucT0cJoKTwoP0PkL000YrffEku5W84 gMwuMBpyOfK0KwBYEqmI2A4LpdRvo3h1HkjXC++jCeFThrxPqvktCcvXH5giko/s3OT9 nHKyZ54+gVPf9bcbbE4Iw3VGPGwHBWrPtosGOcQfCrmuKqNXoEXmZNkZZMpBqisSoLBu NglZ0kDPB+eyJBVBVoDif0zpjmrIN9R55Z8P3mgk1V/Izf0k4rnj2F5Nl4Gbscmt6oBB LORQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Ae6uwJoC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w11-20020a170902a70b00b0014fbb61ad21si3152455plq.604.2022.02.25.17.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Ae6uwJoC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 77FC920FC98; Fri, 25 Feb 2022 17:27:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234788AbiBYMlb (ORCPT + 99 others); Fri, 25 Feb 2022 07:41:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbiBYMlb (ORCPT ); Fri, 25 Feb 2022 07:41:31 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 369991E4820 for ; Fri, 25 Feb 2022 04:40:59 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 11CA33FCAC for ; Fri, 25 Feb 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645792858; bh=PQyFtNV3tW1qRmwZ8HqaxvUDcyO7BHPqZZLC0geQ1k0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ae6uwJoC7HFzBfCRFar5n4oo8URjTrhqDLUy+iEc11IBAdnXENDiWBeq0HdQzIx6O JKgMxNIz31k2Mew4emurIYzwawPv9ApigXVoU8I02ZEUlflbvFssM0pewq75qziPwK Fpvo3VOJkzq4ze0RbML8LpiFue7xYyjWaxrDtxxsixyf7sSZAYUs8ctumU4VXid72e eKVNy4VvGF4iT0VMSVkbehNqX7ZljzmzqLh98pr0yQ8XPBM2o+hsMcFBz/yUeAUOun G5BdTWqcoKX+Z0rsY6GafwqjatY1bTgQ3CrHg/5M0B8+EYJdlZsSy9Gcse7lMqljJv 82nOslOOxrEsA== Received: by mail-wm1-f72.google.com with SMTP id i131-20020a1c3b89000000b0037bb9f6feeeso1508042wma.5 for ; Fri, 25 Feb 2022 04:40:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PQyFtNV3tW1qRmwZ8HqaxvUDcyO7BHPqZZLC0geQ1k0=; b=t9yoZphzXm4qiJDAq2KDTkzGhW29tOxIMTiXIyfssRYNbN3CY3Ygmg8j4Elwc2HPGt uPKygaBYxslS0J8G8+yHEpSu/EB6wWW3mfT6K5INASAn6vW1Lpf4+v6UUEl4CATjDDHv lYooiTJqEvpJPyjrZtc5miEjtBOweyv8gjmbVj2bzWNt58lls1gWAnjBRuhrBwoBaZ8x KFhcMWKo4Biy3bGDvS1K/CoAsEQCSzpfz9IvrqPK41nMJbm+MD//Iz7YPeT5HI3uFeIR qmav9MWMzhp4ZIq/+PDN0y2nniTMQdULtCng3QIwTneqI5ZBXjcKRznp9Atg5TMfNSKP L7EQ== X-Gm-Message-State: AOAM530MKou4eAPSa5zeX46oF2+OSvWy1A9Rq0j4REu3Sh8RjgSSlz3x q6NJXafLEO/PTnf86Psy5aAfnW/iY5FQvDkXsS9rAlzlO/yt4KGasYOXGoGqr0r67hU2RMsJblx GfDEd/5UE0AJQ8cyI+weXDaUHnWeD3IOhls8tzuhvNA== X-Received: by 2002:adf:a54c:0:b0:1ed:ab82:d5c with SMTP id j12-20020adfa54c000000b001edab820d5cmr5903436wrb.636.1645792857567; Fri, 25 Feb 2022 04:40:57 -0800 (PST) X-Received: by 2002:adf:a54c:0:b0:1ed:ab82:d5c with SMTP id j12-20020adfa54c000000b001edab820d5cmr5903415wrb.636.1645792857391; Fri, 25 Feb 2022 04:40:57 -0800 (PST) Received: from localhost.localdomain (lfbn-gre-1-195-1.w90-112.abo.wanadoo.fr. [90.112.158.1]) by smtp.gmail.com with ESMTPSA id b10-20020a5d550a000000b001e551ce8a64sm3228332wrv.9.2022.02.25.04.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 04:40:57 -0800 (PST) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Alexandre Ghiti , Aleksandr Nogikh , Nick Hu , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH -fixes v3 1/6] riscv: Fix is_linear_mapping with recent move of KASAN region Date: Fri, 25 Feb 2022 13:39:48 +0100 Message-Id: <20220225123953.3251327-2-alexandre.ghiti@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220225123953.3251327-1-alexandre.ghiti@canonical.com> References: <20220225123953.3251327-1-alexandre.ghiti@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 KASAN region was recently moved between the linear mapping and the kernel mapping, is_linear_mapping used to check the validity of an address by using the start of the kernel mapping, which is now wrong. Fix this by using the maximum size of the physical memory. Fixes: f7ae02333d13 ("riscv: Move KASAN mapping next to the kernel mapping") Signed-off-by: Alexandre Ghiti --- arch/riscv/include/asm/page.h | 2 +- arch/riscv/include/asm/pgtable.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 160e3a1e8f8b..004372f8da54 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -119,7 +119,7 @@ extern phys_addr_t phys_ram_base; ((x) >= kernel_map.virt_addr && (x) < (kernel_map.virt_addr + kernel_map.size)) #define is_linear_mapping(x) \ - ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < kernel_map.virt_addr)) + ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < PAGE_OFFSET + KERN_VIRT_SIZE)) #define linear_mapping_pa_to_va(x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset)) #define kernel_mapping_pa_to_va(y) ({ \ diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 7e949f25c933..e3549e50de95 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -13,6 +13,7 @@ #ifndef CONFIG_MMU #define KERNEL_LINK_ADDR PAGE_OFFSET +#define KERN_VIRT_SIZE (UL(-1)) #else #define ADDRESS_SPACE_END (UL(-1)) -- 2.32.0