Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2047693rdb; Tue, 3 Oct 2023 08:43:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2kMy6lx0ImnqoDXApyLikSbMVLoXeh945EsrNY6ppLZaThpcFrH+Wxf3xUhOLeem1ZYpW X-Received: by 2002:a05:6870:3101:b0:1c0:d0e8:8ff9 with SMTP id v1-20020a056870310100b001c0d0e88ff9mr15677245oaa.16.1696347804954; Tue, 03 Oct 2023 08:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696347804; cv=none; d=google.com; s=arc-20160816; b=yh8sdBxBTMxk0Ncy6uCF06M9p9OERp/EWS6NU91aVKpijkq1hEtcF3rE0517PxO9Am fKyAAGF70EnCN4ek0YY8is1A9rXHh4W01lwsYqtjuq0VOcl5K6tcnXzr8sUm8HCpgcK9 8jlmA4w/Kv0mjpeUsnYtdiJW8NU0cM+v14gd6oAeofC9FPaUyLhBuVerwRN7RRR4Xatm 1AH2cPKmJ7VTePSMAZiaE8EOzIUg4whUVHZYbGSR/Moz6xyW4ELB2IpCG7PM/HYTHcvh bIAkNS+Pj+g1kxjgcSYZezIoN5FZsff5+yb6QgELi+6ZKF5YnclS20FrEtSp9G3e1pYa HuVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=zxuAFqV4ZbVQEf+zZAz+sR6/gpOeH1Xr6c4kg01aGQ0=; fh=I5etRwHZ95ZwEK4qpyHRiFQyieknTunO5nbDqwUIdz8=; b=apy1owEtVVlV3QaatA6E9iPtrtIZtcClI/REMZEfYklwQaqM2++uzthHMIa9TsfYHz WJIuNebcuSDoufYyJMF+Mk5aqBpWeNDZsNEC1vR3EG5toADCeAL1X+2AGveq5ShVp78I 8752P6gTXvukONFsZqVi/MEOiN8kqZPqdv1CcVxw6FjlF9hPDyuh98ToRCUl1TGmRkIm yu5l8fmZ+j8ICafVfq9bWzhDP8Ju+O1Nn9SmWAvu98myFJOx7ydNllN4JemczNuZPG2Y o27XP/GoWhhiXzbZxU3Ao+7JMHN1QPx2dCJPQfz2zZziDPEjJ5XuJhK2M9tMUYGZfvuY WlOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t28-20020a63955c000000b00565f24af893si1626434pgn.22.2023.10.03.08.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:43:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7E7D982A399E; Tue, 3 Oct 2023 08:43:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbjJCPnX (ORCPT + 99 others); Tue, 3 Oct 2023 11:43:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbjJCPnW (ORCPT ); Tue, 3 Oct 2023 11:43:22 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC2E95 for ; Tue, 3 Oct 2023 08:43:18 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 24B891BF207; Tue, 3 Oct 2023 15:43:10 +0000 (UTC) Message-ID: <305b4dec-c99d-3cee-4563-8d7dcbae9384@ghiti.fr> Date: Tue, 3 Oct 2023 17:43:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH -fixes 0/2] Fix set_huge_pte_at() Content-Language: en-US To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Qinglin Pan , Ryan Roberts , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Andrew Morton References: <20230928151846.8229-1-alexghiti@rivosinc.com> From: Alexandre Ghiti In-Reply-To: <20230928151846.8229-1-alexghiti@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: alex@ghiti.fr X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:43:23 -0700 (PDT) +cc Andrew: Would  you mind taking this patchset in your tree for the next rc? This patchset depends on a previous fix for arm64 that you merged in rc4 which is not in the riscv -fixes branch yet. I saw with Palmer and he should ack this shortly. If I can do anything else to help, let me know. Thanks, Alex On 28/09/2023 17:18, Alexandre Ghiti wrote: > 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(-) >