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: 13751614 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4F08C52D6F for ; Fri, 2 Aug 2024 15:15:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63FFC6B0089; Fri, 2 Aug 2024 11:15:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F01F6B008A; Fri, 2 Aug 2024 11:15:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B7D66B008C; Fri, 2 Aug 2024 11:15:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2B1236B0089 for ; Fri, 2 Aug 2024 11:15:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CD005141306 for ; Fri, 2 Aug 2024 15:15:38 +0000 (UTC) X-FDA: 82407654756.07.E85D13C Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf17.hostedemail.com (Postfix) with ESMTP id C9FE740016 for ; Fri, 2 Aug 2024 15:15:36 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uCkr1dcM; dmarc=none; spf=pass (imf17.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722611693; a=rsa-sha256; cv=none; b=8NH/megg646Mh/0ycL2RuQbFLFN68GoogzrV3bvq6ReRk+8DG0yTZTIcASi72idE9DFpN9 CQGVq00O8Q6JvVch1puVB7ykGpSfIvmHFdrddfGy77SqXh4mHj6wy7uJrOlVo80mSa6pLi k8LK9YYDed9p0lA7jw2wtw6ROJ73sOw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uCkr1dcM; dmarc=none; spf=pass (imf17.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722611693; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YlgUGAmuTWGVKaOGr6DQU8bhY7gyR7CYcPHPJxmYPTE=; b=JdFvc0qE1lIsKmK9w/C85Q+BUiFcNXw3/7AQoGB1GAC+Q7KzX9e7j+BvMPKWMhRq21nh/f DTlkFnJdNtu9SWpN5yp0G2BpsrBye4l8yMMLd5OeCHIqcnm74A0MErsDqU+RPQWydaRxGE hypd9oV7sn6ziETfq18KnVHh49swSJ8= Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42803bbf842so73475835e9.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=kvack.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=uCkr1dcMEfeDI6vBZjjV2YJSbxGI9I+Ve0vrWLwb+tAyfAxD/KYkNFYVjjmr963elk ORWpFgrkwr9CXp4s2Jsnk22MdpWRrx34o+hJKgYNCSZaXcxdwBX6+DEniRFJ1br1FT7+ G+Yf31F8div+TnXL9LjRkssvdriplvWnLewi14/aWmIeqcsOP05ztpFb48kHAUfShmat gBJ7pXSojn3WuEMnqpXZaP7knuJgLe27CI9lQUM+ERf20xeC09KywypzcNbTLagD9ze0 ZjJRzRfAOvRxpG/5O4fniXf9ndZzIAL7/lBmUGhpAOcRqaO/ovmTtYtBwgzuYSwCtrGS FNWQ== 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=rPA1SMbbp9DVWp5aYGkVLrcilh7IKMECrN+x1pMv2yfEEri8fwelhWvujSC40u+Bm/ srR3ugv65KIpWMAmCU/0JNU0G3NrXwTsTU3X3ZTDwF70aaJC2fOmv/Ueb9X5Xcp+++Ui dLVyLgkcCubH5WZWsvs2gp1Nipe+L/TIRvsORjV3s02Rlc4M8wJDMvCNStWNCWnJ4tbK EALob/j9pFtLLjCSRn9/xchdVEtlrIIZCxp738qWAzEZx0W9sU21yTIqaFU10OT5PjVi HjyN8P0gfA1BUQC3tDUL/X4okmetZMfRWUEUNJV3beXvrz9fPu8en/PuBOdWC3ivXboz DNdQ== X-Forwarded-Encrypted: i=1; AJvYcCXyN9wqI+BSb1qn3yRaHfDF+Wieuk0k2fCz62IEwSRYKCU7JfmJcsvBTp8omfaRzrP+/nTJCr3BLnHM64bal8/RpMo= X-Gm-Message-State: AOJu0YwLBGNc5fcR3PkC4X1S+xYqbGfVkaie1LxPV1dsnJtT4JtkcBrv P0+l0fPlBgcocwHZK+re3mvVDqanYNw9Pdq00gYznhym9IQK0vQ/8CBmHN4MQEXNO25a1b92vhh 7 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-Rspamd-Queue-Id: C9FE740016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1gro8zg3k3bamncsx7sxpi9oeahy5g5r X-HE-Tag: 1722611736-712412 X-HE-Meta: U2FsdGVkX197PEfo+c4i4vOKFg06/fjfs42Wh2ieemKHh1EcOpg9BNiJT/5BwjQUHkiQjjHGwsNlFdzCT7fgLAEsg7A5HzTsmH+j4p2TxOet0+HToTsC/AdNzLtZf3fBh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gU51muU01Y9brPMqgPwvzGxFyL2emTqpDTaqgY8G8P9Ey/0848frGBVKokge5fi8XgjsYwMVklc9uSjKS2auadUbmk2IHt6EuoWWdixKQJta3p0woSTvlhYJ/42i0ZSFj9JqEOYi3xaS/OdzV3I3kCTbzkqpF7iImD98jFZVBWprrE/YCbhihY7+w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);