Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp307664pxm; Fri, 25 Feb 2022 08:21:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMAFoEkHq5wSOuZ+TtS3re7eFoRomF03szDf3t7YIV3yLEUdY361ku8NH4PJHykxgJ1tVq X-Received: by 2002:a17:902:7d89:b0:14f:2fed:2461 with SMTP id a9-20020a1709027d8900b0014f2fed2461mr8038934plm.4.1645806109202; Fri, 25 Feb 2022 08:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645806109; cv=none; d=google.com; s=arc-20160816; b=AqbOv1HaGHE4O8xLO3PBW95FT3JY1skDvNBuJ66fm97LDPyeCvoGE8kZVDH1mxI233 z9TEd8ZGf83K+N4lCjsg+rDIUTkP9Tof/eNAcH9atzLcaJSSyWeBARpvAcRvbJL9QBia /9JEFxscDYZ8u14DaDVyJ+2Sfpsc+nmyWv74MOnHV2SCK1RNGI2hdR29+J/FO0JSzna0 dpHli0oqfXxWSntlzxFP6NrhYuV1xNvvTZ0WB36u8PhG9XJ376hUUVwiAPIzuddbk8ZB iGlbsKAedZp6X61GjVR+hpGcR/iueFIMAarf5ETmFN7FF1cNN+LRNxC+/oj3MnUJ8SLG PmwA== 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=IZZDTFAqzc8aGjWg1aZGEvUIk/RV0NTNXI1qwgw2jtM=; b=OqbWTjKu8adkOGqwzI4NsCqLBJJXq54brOeDEH+WtlxCUAk+Yak6NiT/QT2G8gAyfx ybT01qQeTDM2YtmPABZbhV6yZ5vBiQuAO8xgv2t3tpN3ZdvBXo0JoM3proV0Od17DCL6 Z469VrK/EmXfxEoSggJTdCDiGKWpXeVp7EpUjUNRl8kMAeG/5ToL2iPkNHxsknjl9gQw i4cKAnWSZNpbE7IV32c1Cz3o4o6+FjNpdt5nuOmRL8EUKqLNXgtFxufeNK9uXnEYr8Lk y6/O0H3W3FeO4mVuRcQsR9wdRWF4Ivf8esIc930p7ECWYezO8k1VL9oUMzsgcJETD8Rf wsxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=NbuplYwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a170902c94200b0014fc71ab2f6si2361686pla.511.2022.02.25.08.21.33; Fri, 25 Feb 2022 08:21:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=NbuplYwp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240700AbiBYMqi (ORCPT + 99 others); Fri, 25 Feb 2022 07:46:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbiBYMqg (ORCPT ); Fri, 25 Feb 2022 07:46:36 -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 C24A421CD12 for ; Fri, 25 Feb 2022 04:46:04 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (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 A602C3F1C9 for ; Fri, 25 Feb 2022 12:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645793163; bh=IZZDTFAqzc8aGjWg1aZGEvUIk/RV0NTNXI1qwgw2jtM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NbuplYwpZDA6vimglNGnb8sl8yD7+jhJ2oi2Ti0IUGF2J8G0s9m/GZ+8jhnFutli7 5Y/Ldq7Ixg47hG+FvmiBCry+Tp5sr26yKf4JRpOvFLrfi8/Lpl9dPIzsgq7lpu8Ozj KLe95HHy8+5oGLpMPcRsrSHu4fIr55Z47JvXsBPcnoUcgLNgqrigfjUQFk/tV88G7r t6vujrku7IlIqFQ/9Y6We8xM4uT8TJuQLRIOjs/R9lE0l4xg2bsUBtlv/FmKcYAHkU qiK3MXgm0a3NJakRdxbIAWeelxK8C3XhS53DBYDYoiePomfoUPJ6G03o+FWa3R4oA+ 0dx1/xoQYLzEw== Received: by mail-wm1-f69.google.com with SMTP id w3-20020a7bc743000000b0037c5168b3c4so1510781wmk.7 for ; Fri, 25 Feb 2022 04:46:03 -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=IZZDTFAqzc8aGjWg1aZGEvUIk/RV0NTNXI1qwgw2jtM=; b=5MFNklMRl4lPD1dBHw6iQRs6qpAfetCZZFL9EAFzXMsrN9fHIIUh1TnbEypkD6jVQW dtxokPL0gVgyMdqZP9CSj3bEByw5k6aC5aRUXHWXR5hAZDTTAPNn/jT9B5A8vi+oynwE 0RVNSzt3xYiCTiD92fAkuanttp0qONjLVPSU4tVubtUgHsJ1HXtJdCf5vRAWmHiBewHV ElRXMHHVjkPxl39lGdTh3VClILARJBNhY+k/RKPjIpf8xynKSsHvFe6liWMNDV73RMwF WzuXn9BhCdHo7M43okBU7vjCfAuavyIJ68LooQBmLoYihd66mponshpe5LhrGmuGM+Lm 42Qw== X-Gm-Message-State: AOAM531QnMq/ZcoBPoFYjqTrF+kB+M7wvz1Hon5AOe+Tzl/iRGRcW3qk lEsi0339dlKXI+ZK3vgjn+FySuKqCl6veRCc2N89zHMIS00MUoxJsBUTg07yD6k+X1/tP11LR5b DUKdPeYjpuHx90XYq1tb8h2/aRzZ38LbZ00LlCmYpZA== X-Received: by 2002:a5d:59af:0:b0:1e4:a027:ce3b with SMTP id p15-20020a5d59af000000b001e4a027ce3bmr5811393wrr.318.1645793163256; Fri, 25 Feb 2022 04:46:03 -0800 (PST) X-Received: by 2002:a5d:59af:0:b0:1e4:a027:ce3b with SMTP id p15-20020a5d59af000000b001e4a027ce3bmr5811384wrr.318.1645793163068; Fri, 25 Feb 2022 04:46:03 -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 e33-20020a05600c4ba100b003810c690ba2sm4741109wmp.3.2022.02.25.04.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 04:46:02 -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 6/6] riscv: Fix kasan pud population Date: Fri, 25 Feb 2022 13:39:53 +0100 Message-Id: <20220225123953.3251327-7-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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 In sv48, the kasan inner regions are not aligned on PGDIR_SIZE and then when we populate the kasan linear mapping region, we clear the kasan vmalloc region which is in the same PGD. Fix this by copying the content of the kasan early pud after allocating a new PGD for the first time. Fixes: e8a62cc26ddf ("riscv: Implement sv48 support") Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/kasan_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c index 85e849318389..cd1a145257b7 100644 --- a/arch/riscv/mm/kasan_init.c +++ b/arch/riscv/mm/kasan_init.c @@ -113,8 +113,11 @@ static void __init kasan_populate_pud(pgd_t *pgd, base_pud = pt_ops.get_pud_virt(pfn_to_phys(_pgd_pfn(*pgd))); } else { base_pud = (pud_t *)pgd_page_vaddr(*pgd); - if (base_pud == lm_alias(kasan_early_shadow_pud)) + if (base_pud == lm_alias(kasan_early_shadow_pud)) { base_pud = memblock_alloc(PTRS_PER_PUD * sizeof(pud_t), PAGE_SIZE); + memcpy(base_pud, (void *)kasan_early_shadow_pud, + sizeof(pud_t) * PTRS_PER_PUD); + } } pudp = base_pud + pud_index(vaddr); -- 2.32.0