From patchwork Fri Mar 1 09:14:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13578191 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 79460C5478C for ; Fri, 1 Mar 2024 09:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WX3Q6lFI7kCR999RhGMiHKTcBCf2JFq+G/y3JKsgYkY=; b=irOajB7fZF5+9y 8E9zA7ibYOSIC/0IGBzWD3KPDhkulDSngS+DVKXRDlpJhGgcucUioHv+KlKJ+5fCwmegH7qMN3VVs f81vDiMnnuj0+2yxV/8XMc3FW3QAkyCyp2iSC/rCVUk0+KMl/5XoRzIcYNf/sCTL2RPopr+6d6NhC UG9sCem71wYMK28oiqm+w3wsegsbDVXfsz5TAEKtYqBXliJHtgrmv5WJa7jdRDaK5mpwm8T6oBi8j EQtQKQ0Pd+Jr9gNMCQJMlhzX0AcH9ogNNY8nHaK5Jh3g5gQMoo4oVMaYXZtMjffLzb+GDjFGhamek a6WQkYy1Pstpj5slkedw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfz16-0000000H5uB-33xf; Fri, 01 Mar 2024 09:17:20 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfz12-0000000H5s9-3a09 for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2024 09:17:18 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412a3371133so13602325e9.2 for ; Fri, 01 Mar 2024 01:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709284634; x=1709889434; 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=celeezlUFfnCgdabriQL+vY9x87nEUlib9jbsT9nzg0=; b=3bJaS0ryaL9sbB9ktQti0IYObfKb0u5BFSdgqq4ilx+WQDz7DslhrfnFAkRnCwR2Yg PRWOqE4+WccSUBvVj3+metU2BlVcQu1QtvI9VTcq/JDyvaENZkiYBW6Cy2CWJyB+red0 ygHXlG3KCQCuFMau++ecDfJewDpnbcaqsFSuBzUT7bQ1DW1BK4/5ZsJLLiMq7n3oFGZU X6hnY3eJHYlPZStQ1OE8khZIAJM2EO8ApDV6pdVs2L5uGk3ACwHUcEywhKpu4i0ebJfb +7g0hBIXg3O2Ay6J3YUf7FrVk3fpznZ0Qoqnhh6o9Cn+eo+eV5HiCPzzajkEvzkzf4fU qYKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709284634; x=1709889434; 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=celeezlUFfnCgdabriQL+vY9x87nEUlib9jbsT9nzg0=; b=pSiNbO+yP+/l7fx/D86I/AN9TK9bdGJVub8mhasNCbKqIKBOQ4LUiAaT/nburW86wJ NrdcihDVxWgo64RcBTJsEebC2kT1wBKrBVQ5XonCeJcFmYBM/sOdHM+OBQoMTMLBz6hc T9RHyafTIY/7hOdnUAFBpul9vzUQ8wircNfQoeoWIPsjdS2meVUEpPT+NFGBDBPciT2Q 6GP0JYhYtb+uJv3LUQSHz2LyTnG4s8q2brwFAS7ixPgDyps7qEmTm+6i2WL3GjQYIF1l wHsvcmKR9o9XUWLgP8OccV8Vr+i8HVe1k72l+SWQR7bSvw7y+2gqYsPf6Jtyc8kvqq2U 4hbA== X-Forwarded-Encrypted: i=1; AJvYcCUYPw5i/ou+tvNwds9oewA9bj7zG9Sq2KiKkN6dzdaoG8jcnFslCn1ZBxovop7nVWxuaE2eBGEd22e7MbVtpzj6oAC5/E6Kzcn56wT7g7tdgRDL22U= X-Gm-Message-State: AOJu0Ywy/uz7fUf9OEwLOonE3+UEvnJGFZpqQGaaGMrgWwDY1jZnubyu 1MBFWLv4dDqCvU0Q0wRIvzj+MJX0pnTkr8/VX8g0TA59mC13MckFKQ5rkbQqn+k= X-Google-Smtp-Source: AGHT+IFB0pFFxU/+IPg3Lb+DpLxmFSKXoGv4IrPSAZpcxiUzICaAY8iLg+9vVvkiiGxUNIP5Ue4QKg== X-Received: by 2002:a05:600c:3b26:b0:412:c810:fd18 with SMTP id m38-20020a05600c3b2600b00412c810fd18mr995837wms.18.1709284634158; Fri, 01 Mar 2024 01:17:14 -0800 (PST) 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 l33-20020a05600c1d2100b00412ca88537dsm358022wms.0.2024.03.01.01.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 01:17:13 -0800 (PST) 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 2/9] riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes Date: Fri, 1 Mar 2024 10:14:48 +0100 Message-Id: <20240301091455.246686-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301091455.246686-1-alexghiti@rivosinc.com> References: <20240301091455.246686-1-alexghiti@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_011716_939892_E58D6CCF X-CRM114-Status: GOOD ( 10.43 ) 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 | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 3d84fbc5c572..2477d20c1497 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);