Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp427222lqo; Wed, 8 May 2024 04:21:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXebhVSjU3ispdBp7JLoM2smglhEXJmSGDTAz8FGFRyauORBslf4zWES6PJVvihc+27auZFpuZjFU/zPQTq9YCtkecrd0qdImL4x7LEQ== X-Google-Smtp-Source: AGHT+IEeey5UxmWasujEced/uB2P/lR6AWy0c7u7wSqDrC1LgdAyWKkuzUGjg4BNPSbz+mkeHa50 X-Received: by 2002:a17:906:368e:b0:a59:bfd6:bf2c with SMTP id a640c23a62f3a-a59fb91facfmr203427966b.7.1715167285758; Wed, 08 May 2024 04:21:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715167285; cv=pass; d=google.com; s=arc-20160816; b=E6oXkECqygNFR87fyRDqnKrL80uPkAC/8an5/lpPFiG/gquLC6QYRl2Xl9oAnUZ4VT mUSLlVpldHgdOGademuvWl1/tVoFi8Nnt+QET98rH/3Tk5LRuxZzLJSX2bX9v9VYiqPU ddBdazO3vPzlgHzs6gzAOF1rOe6iMI7g5oGgyPSKujqFvmoD/C23JFBeXsNs0Ow8bMaZ XUlPkxUfWljEdTonSaxgAixCd1+zsz0CIwYkw2uYgq4giJ/itpJMDL7KoePJEc7b2BLJ jk8cL9FkhtXz15EekQjRmxlh/j3wYxofzEWg4Oa+faiEWQEmemDBnxk/+Yg5ZrcrcYml 1h8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oM+WuwVvF178uIr+5Dc8IcJyYSbzDoUf3sQGwgQ7LEI=; fh=VXW+fKBN8Ix/N7XmWENc9T5mg2/Ou797nfpBfkppfYc=; b=pPUKb+FsU80kq3xGNkiLX2OgRPqP82Nttw/il+fV+fwBWiXKwGDaDrZCrW00hS5+KV sn/o57yvn7i7jCrFiIQzPHtJzbJ17iE8e9W2S6oaYdVpYGAGdfqMqglw0UIvVsGFDcAD r7bIWo0L01r4N8QGSh+5GH7dV8XVz7m/xhWhz336gRmsKoDlkRYaigz7K3rDafHaMEV8 k7OCOz6xXnS1idG2LqUnoGFMCYunoHBCd2GEcewUGuHTOf6HDf8SJ+zJt9k58eZSLJuk PIr97/hN7Hg9l4/G9HWTkc/LpYR75ffRU5SU+gU3CNuf5DSOEivaMZTJPjojQ5DAChiX RY2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=X6Azz6B7; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-173124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173124-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id di3-20020a170906730300b00a59a8e9c383si5538548ejc.950.2024.05.08.04.21.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:21:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=X6Azz6B7; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-173124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173124-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 683FC1F22F03 for ; Wed, 8 May 2024 11:21:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4008839FE; Wed, 8 May 2024 11:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="X6Azz6B7" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EE64839EA for ; Wed, 8 May 2024 11:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715167242; cv=none; b=k4wPt7IZSOqWTmHE5iMmyGNc5QVo9rsFIoru+GZ5Kl0fZo/TGmJQrx8/qkgbVFscpoJNcIT5Bl5TOlrM+e6ABYjYmuCar3b1or+VWaUOIQmkv2uIUM622Z4TygJZ1MgQ60tLC3XqrUzpB8S195cuYWjOO1Uu/9XtbnmfVwvv6+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715167242; c=relaxed/simple; bh=+Fl34XZCnTBozqKQN1RM+pVRa0O2c176ao71VrsxAaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SeoyS/uNS/Z92KgHNNBaYa4WykO8So2iQTyjVAJ8XOTbwTx0PD8290mRr4O2x3VkXHJS18ekIXei8qRbnE4J/oS2/TGVW6HV7HSZTjGcgHDjKmjoz+yudnabjaqBG1Vy17eJxz4lohzNPnNc1R9SBueItQ1WIYvFQJFe1AF/2PY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=X6Azz6B7; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-41b79450f78so28471275e9.2 for ; Wed, 08 May 2024 04:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715167239; x=1715772039; darn=vger.kernel.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=oM+WuwVvF178uIr+5Dc8IcJyYSbzDoUf3sQGwgQ7LEI=; b=X6Azz6B7EXXR8FLfABTsol2qyXf89hTxSlS8Lj/b89lP2GQN/C0Y/RtEO1OKuCzz7M Za+gbtmcI5FJvNl42sX4mFNafRj5yGYSyyqiAR9lATjvypNlcsIiW/0Che6FMXq4Jt3P XckR8webDgI3BoKmNjwPiNVsp1Xpz7rqIuQPjzELoG5DG0Dat9fLSXSzYUkaq9A+sOQD BXfPB3hiFG0nTRC5ScOm66JmHAiL4KeJaTEJXH7Io/kzVtvM99FDfl6smCar8egYf6vO 9fU/PsY4SzHNcM2uq+dE0wHqC4qrJ35zDrF5rNl9gYjgsreHBBxlgOreKVFYoGgzm+9u XaPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715167239; x=1715772039; 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=oM+WuwVvF178uIr+5Dc8IcJyYSbzDoUf3sQGwgQ7LEI=; b=mIxbUi+TqK4dIYEk5ooicFlEvySAbL8b56jbvvXQpesV/Ghnf7TtsAp9Hk/xgXO20Q dJGabMP95u0OZjGOY9Uy7NdC5Pms5gIQvqChlXYAMiZdcyLz4loWL+NIttzHa4TE0MnS tkJg24roFHhP/6Na2sx1AMqeaplz7+3LuIjotPTffrXaNJSQubobcEbQB4eTjwx78ER3 n3ssnI8X6YOax5CNX1pw+4Wyj5TM3R9ldfi10fn41aH3u7v+1DkMPyxeydB08wFgfs6o iDQfuOhmQs3j9VC2uqNq/IQN6pOifvGW5LbeC0ZZepZEV3S5QoA3o7OGYNNRB4I/JOKz SmcA== X-Forwarded-Encrypted: i=1; AJvYcCVpZPl6sUwaI8Sajjv2Sv6CAKvzZICQ4M2b0TZSWyhOeqD1XX+ZP/5OsigEqcL+denPCOIMTxhIEovgedZS1bmI8us72+xt/iMhaf8S X-Gm-Message-State: AOJu0YwokFrUeG4AorO3TbG7rLPiDr+l2SDlBEs7E7/Foo/7vWI9rloh fOjW8DQpLvDjdIcOjp2vYnH9XSxe3phvi/ZjXTiEIZBCL7n1mgkCfEGhZoFiFrlz33o83S/DhJ3 S X-Received: by 2002:a05:600c:1395:b0:41b:e201:eedb with SMTP id 5b1f17b1804b1-41f7269010amr20541325e9.41.1715167238957; Wed, 08 May 2024 04:20:38 -0700 (PDT) Received: from localhost.localdomain (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41f87c254f1sm19678785e9.14.2024.05.08.04.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:20:38 -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 v2 2/9] riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes Date: Wed, 8 May 2024 13:18:22 +0200 Message-Id: <20240508111829.16891-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240508111829.16891-1-alexghiti@rivosinc.com> References: <20240508111829.16891-1-alexghiti@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index fe8067ee71b4..f042f5c8bdb7 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -274,7 +274,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, return ptep_set_access_flags(vma, addr, ptep, pte, dirty); pte_num = arch_contpte_get_num_contig(ptep, 0, &pgsize); - ptep = huge_pte_offset(mm, addr, pte_num * pgsize); orig_pte = get_clear_contig_flush(mm, addr, ptep, pte_num); @@ -319,10 +318,8 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, } pte_num = arch_contpte_get_num_contig(ptep, 0, &pgsize); - ptep = huge_pte_offset(mm, addr, pte_num * pgsize); orig_pte = get_clear_contig_flush(mm, addr, ptep, pte_num); - orig_pte = pte_wrprotect(orig_pte); set_ptes(mm, addr, ptep, orig_pte, pte_num); -- 2.39.2