From patchwork Fri Aug 2 15:14:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13751616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A029C52D6F for ; Fri, 2 Aug 2024 15:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YlgUGAmuTWGVKaOGr6DQU8bhY7gyR7CYcPHPJxmYPTE=; b=lTYZeh2b5D+hD6BZLqcf5ATdKx fsVuGNuKEEHBrk3m+r8S/te8RRB2RjDksqJbStK1cJxBNysU5uhPe3DyNnie1xR5Pc5elQ6RuwQFX 9CAQ2H+dzUydzfiihytsfnSy8udafmDzSuubWh50aynUr06i8NnfPbD425osiTj2Yn94lLd4aSyXR SYgHMIUk+tR09orcsQr1IxVRSOhr7p/x/IBWpE1OBYw1ST6Vk1zzofN9an9ogGR65o6CWw6y91JeX +bCMJslIcvjUWk+rFDcdQWtkil7kk301nMJo/SUlIokI2OFJ8HHsBjQJk9BpQg+qc2JuBlxTgA77p LEuJGGSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZu0m-00000009CtX-3Dgx; Fri, 02 Aug 2024 15:16:08 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZu0H-00000009ChF-1kr0 for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 15:15:38 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42803bbf842so73475855e9.1 for ; Fri, 02 Aug 2024 08:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1722611735; x=1723216535; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YlgUGAmuTWGVKaOGr6DQU8bhY7gyR7CYcPHPJxmYPTE=; b=lpNPL9YbZ6FHKRz84ETmrKbs8sKXBtkUkFIZsvnrcZ9TnaDqbgD4C9uypSMeoWkm3A nVHIlWFyANK1NZa4K4GLJTzt7KIsQrS9Etn69O8XAt4jN0FvDbhvejve4Yrl/m30BHCp mmBinTbjHvmTKAR1i2A3ktvRuF9OEOO0VeKt6XO8+spVndNbYE5Zf6JZjsVtoi1i1yJO qJg4UBiv77vF/+1GKmAIcNRS1aq5E7gOk2Q1q1TmeageLbVqpG4Qpk6qr+mRjwXNlQ8b tXSfZqVbXbCbgjt6lp3Yrij6Ynzf+OQhQIkaSFWB3BeYBl7g09xnl0tYJBdWDFIrN0W7 s58w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722611735; x=1723216535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YlgUGAmuTWGVKaOGr6DQU8bhY7gyR7CYcPHPJxmYPTE=; b=sOYopWflRzurTTZKo78uX5XDX/RAK4xARp1Wd8WiTXMSRgLSwB832F6w2xm7JwRWe1 GDMn8V7awS1VP7tpVLX0whIWh8YOtk1LD1l3FPVnxCd+wFLFkvH4v0obrXl41s3U5ciC VwlsmmY1ia3W6nSbrv4p4W9CRjRVDfa7Pe3YtDTHHGfLGbFMGBbPNMbjjh0/SzpaclKZ FL3FM/IREESTvpSUkK7KfepkV6cHZQuqJjuPZk0z/r0jj97bHqFIdZMTKgS4RrcBbLqk PcuKmLvKWMzY9DFDgmveBtv48Pj7Qx/rku2ET3Q3hHI6S/F+5ahM0BZat1C7EJey4HSU j9oA== X-Forwarded-Encrypted: i=1; AJvYcCWdjyCa0xufVDdEbHPMp0SnPf638HWVXln5zHdQWtQ7LX7vclZxJghJ9OOUkeB8emXH/31kmwDqLCWRghocHhhzXB37G+LSmbMAetaZOJM1FT3JTUI= X-Gm-Message-State: AOJu0YxsdgngjrjilmVk9m69jG/r2cXUTZHFLKwvI0ej3ARSRNMAU4H3 xHeQCP3NZ9PF1AA1tWeRGhWJSwkfvHoaHj47gtnirLIZ8b1ts7JppDvhwStAJZA= X-Google-Smtp-Source: AGHT+IH4Zu+tW3v1CbjrzMX8UC2ElJa1MqCyLtpkk5dkYfGnqCXlVjQZLgHhH8VhTadf1xkkn6UFcw== X-Received: by 2002:a05:600c:4713:b0:426:593c:9359 with SMTP id 5b1f17b1804b1-428e6b954cfmr36381225e9.32.1722611734897; Fri, 02 Aug 2024 08:15:34 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbd06d078sm2168897f8f.94.2024.08.02.08.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 08:15:34 -0700 (PDT) From: Alexandre Ghiti To: Catalin Marinas , Will Deacon , Ryan Roberts , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH v3 1/9] riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes Date: Fri, 2 Aug 2024 17:14:22 +0200 Message-Id: <20240802151430.99114-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240802151430.99114-1-alexghiti@rivosinc.com> References: <20240802151430.99114-1-alexghiti@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_081537_482913_137C994B X-CRM114-Status: GOOD ( 11.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pte_t pointer is expected to point to the first entry of the NAPOT mapping so no need to use huge_pte_offset(), similarly to what is done in arm64. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/hugetlbpage.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 42314f093922..6b09cd1ef41c 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -276,7 +276,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, order = napot_cont_order(pte); pte_num = napot_pte_num(order); - ptep = huge_pte_offset(mm, addr, napot_cont_size(order)); orig_pte = get_clear_contig_flush(mm, addr, ptep, pte_num); if (pte_dirty(orig_pte)) @@ -322,7 +321,6 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, order = napot_cont_order(pte); pte_num = napot_pte_num(order); - ptep = huge_pte_offset(mm, addr, napot_cont_size(order)); orig_pte = get_clear_contig_flush(mm, addr, ptep, pte_num); orig_pte = pte_wrprotect(orig_pte);