Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3415860rdh; Thu, 28 Sep 2023 10:54:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErfwqo6hUPk3VAgT+K3rNHIkjcdFits8rIEZYxwhR7zfBOIkc0X6pXb285qBFkzk3/mQQi X-Received: by 2002:a0d:df8e:0:b0:59f:b0d1:9a60 with SMTP id i136-20020a0ddf8e000000b0059fb0d19a60mr2053920ywe.1.1695923677976; Thu, 28 Sep 2023 10:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923677; cv=none; d=google.com; s=arc-20160816; b=emU6h6vogSMW/r//OBxKLm/+SByypxuHfG9VTigvCWTuvcQ+ToTipc29SG1Mbx0MC2 qWUlbKfuALE6k3Z8fjniIqbeowpX/AgI+W4m4MdwoXfubKDNkosQPWKkmTYfeSRyb282 Noi1rI1ihvvVtdRs7HZY4+iowtreGsUKxIIxivdUOVUuR2GymthJCpBg1/yEa+r7D50G Iv3Bm0LXxk4Nh7/jNrcKYo8THLw+sg9FMP8QKCykEPs3aL/gyVwsOn3hf6mPJnORUDR1 xohPeBeTxELLguAobvaGcvxLiO5NZEOnrlsUIru3opyYePqZoFZID/Dfmq84um5PVwoX mh0g== 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:date:subject:cc:to:from:dkim-signature; bh=8XhINO5OKvYBbRtcmNNCbEmBFeMKEzNeQfLz10xju9g=; fh=70E37CH7MQytXhmqGdiWg7mOO5+EDfbVj5MS5OXKWoU=; b=Zhf1hhZ4yKzSR429wnn9u7mPU7iXdc+wHCjCBxt5XeWmyfhH5pLSrmhtTEh1pBwBoQ /Wy6gBIHd7EYDvgICadKH5iZFKBkGf5IZYUn+3PBRAQoDzOc9VNwudpsLSqZsr7XezLY sHoUGcVxv3XAdPyCgiuBpOdlGg1RfgDPaLx3NBcWIbiDZptgLfrZH8YxdbOwSG0DPDBb Mog5So6ZoswmJBUYm+GwhNzhv+kZXa34OBPx3gi8XtAtixwpvdsouhkYkoOX8+Xauo64 3nOn50wRwBzXdjkCV8F1W6HoBsJbUXfgHMQuhDvy24F9KEz4JktFakJrALiUW9RC0IVq fZ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=xw1bgQX1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bv9-20020a632e09000000b00578b93b1b26si19046773pgb.544.2023.09.28.10.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=xw1bgQX1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6013A8365F68; Thu, 28 Sep 2023 08:19:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjI1PS5 (ORCPT + 99 others); Thu, 28 Sep 2023 11:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbjI1PS4 (ORCPT ); Thu, 28 Sep 2023 11:18:56 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 287E399 for ; Thu, 28 Sep 2023 08:18:54 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3248ac76acbso549351f8f.1 for ; Thu, 28 Sep 2023 08:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1695914332; x=1696519132; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8XhINO5OKvYBbRtcmNNCbEmBFeMKEzNeQfLz10xju9g=; b=xw1bgQX1oDmBM/OY6Hw9WZPVrX3zkQYOTStxbmCuXhY8HuBco3dSDWgEgegkmRL74s arn17s54a9sSYWK7Xyeh3Juw8HMNVknAtGzN81kl9pY+IiELzS6nchLDrfUQq//GAly3 C8nIxz/b0A+bBQ2/QJmXYX1s8q/isCGvJR5rZ+SXwRS3dUaQ0UO6uGKL5rGEElwddK41 bgu02zop09OwM9lcY5H2zEVgVqYO7l/0Hy1HiCU3kTYhqrib3MsQen1NjS2lhJhFX71+ /CYNM77K9YA5H+2GQPjldbs3uGjiq19EsjdTMDIyB/jH2QzWGHFgdNsEV+VBVLvL/G72 o1BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695914332; x=1696519132; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8XhINO5OKvYBbRtcmNNCbEmBFeMKEzNeQfLz10xju9g=; b=Jnj7svyMQYjI7+sw/L/pTgkG4FKOnV93nmGwcC1HgyjVBVx8xFiOmGl2JCBp5e73B+ WP92zYUl6NE+KpH6DEcnodYGt1C8I6ShFgz8QHC0LEWT2v/0ij0RdMNoXA3LQWyXGj9y Nv1ZuCY7k7a9+1D0P6p59YbcZLNdLgscSoAvlWdps+rUw4HvXMBWsCDKVG+ytbdHk5hg I496fIdDIjY/RzvKQg8bvNxh0Vhav8YY7L2EYwWbXQIQ81KG4CbhBm+7GmwfOkvLKM6n +doMZ6Hd90BuK09jJ/ETmf4i70MBDvrAimuOsl2E2H93bpTJhTvqbxpSw8x+o30XcyZ4 sqGw== X-Gm-Message-State: AOJu0YytSmV9tyrjPYxDLsSqO3qb/ap3QHFwPh9ehvutjHcZuemW1Sw7 CmZFeMIPnxIxGDY6zBHqT5hKtA== X-Received: by 2002:a5d:4047:0:b0:324:84cd:5e67 with SMTP id w7-20020a5d4047000000b0032484cd5e67mr1401707wrp.6.1695914332582; Thu, 28 Sep 2023 08:18:52 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com ([2a02:8440:4541:1a11:c4e7:d9ee:586b:e201]) by smtp.gmail.com with ESMTPSA id a13-20020adff7cd000000b0031ad5fb5a0fsm4692046wrq.58.2023.09.28.08.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 08:18:49 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Qinglin Pan , Ryan Roberts , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH -fixes 0/2] Fix set_huge_pte_at() Date: Thu, 28 Sep 2023 17:18:44 +0200 Message-Id: <20230928151846.8229-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:19:15 -0700 (PDT) A recent report [1] from Ryan for arm64 revealed that we do not handle swap entries when setting a hugepage backed by a NAPOT region (the contpte riscv equivalent). As explained in [1], the issue was discovered by a new test in kselftest which uses poison entries, but the symptoms are different from arm64 though: - the riscv kernel bugs because we do not handle VM_FAULT_HWPOISON*, this is fixed by patch 1, - after that, the test passes because the first pte_napot() fails (the poison entry does not have the N bit set), and then we only set the first page table entry covering the NAPOT hugepage, which is enough for hugetlb_fault() to correctly raise a VM_FAULT_HWPOISON wherever we write in this mapping since only this first page table entry is checked (see https://elixir.bootlin.com/linux/v6.6-rc3/source/mm/hugetlb.c#L6071). But this seems fragile so patch 2 sets all page table entries of a NAPOT mapping. [1]: https://lore.kernel.org/linux-arm-kernel/20230922115804.2043771-1-ryan.roberts@arm.com/ Alexandre Ghiti (2): riscv: Handle VM_FAULT_[HWPOISON|HWPOISON_LARGE] faults instead of panicking riscv: Fix set_huge_pte_at() for NAPOT mappings when a swap entry is set arch/riscv/mm/fault.c | 2 +- arch/riscv/mm/hugetlbpage.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) -- 2.39.2