From patchwork Sat Aug 31 08:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13785975 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 363C0CA101D for ; Sat, 31 Aug 2024 08:37:00 +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: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:In-Reply-To:References:List-Owner; bh=cu4q1q4MiGODhcwED+miwpta2OvmryUYkLRInznLuoE=; b=W4qaOg/lkN+KeJ2sgoYWOpX7o+ ALaQIgo2Czs9hAb9zkbNsmQ0/ZQov7dgCmki0MVOds4iI8ZIFXoX+15FTCV1BlO1y20NCIlLB0q+Z mAczIdb4t2svgQ6rg//1TzLYOd+yk/isztmph9tmIDmrkzMa6PbR8xpx1v6SVf/Y8rnb4s1gd2sY3 +dOiOPMkD8Emr+BZlu/WqjDKsyb5pZa5ZARHikVSMZMfniggBwRBBqvn9cglWZ/R1JOtVkqG3m6qI VA4k3CsxQWcwNYBLJti6mYC2folvp4AbdRKi1kTeNALng4acLVoYky7arDXb4dKVB5omlzqAIrKRD NQNaETuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skJbA-00000008xbM-0crq; Sat, 31 Aug 2024 08:36:44 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skJaH-00000008xWW-0iIN for linux-arm-kernel@lists.infradead.org; Sat, 31 Aug 2024 08:35:51 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-714226888dfso2147734b3a.1 for ; Sat, 31 Aug 2024 01:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725093348; x=1725698148; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cu4q1q4MiGODhcwED+miwpta2OvmryUYkLRInznLuoE=; b=fnXCXw1WC22gOLaFm2HnHq7oQo5xCMDAW6NDAvY39rfq2f1ID4WEK9QA/K1b5d4MP7 BavMWBlSJJnldvKpha3SRoeYn9JNdex3OtIzQ6J4EtXVWDzF8u2tMtDXIpa3I/kuzIGe LdtIRj3zuC4CdJNGO4/pLVCTKFsT+KA8v03Lm3DET7pUyj6TnIBkirE14COty9IDjGgm mVObiq1Qw1VUQSxRM1eRGbo/z8QcKRDFLyQM/ZG3NS6HmE0V3/jD+lS4WMANb76a5xXF rWSlTVRWGXUnkjHor4bnzAVivH5nxcet8bNxo8zmPOwZopTjfftPB4qA7W+KxNOeUI7+ jqLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725093348; x=1725698148; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cu4q1q4MiGODhcwED+miwpta2OvmryUYkLRInznLuoE=; b=FsG3SvgZQr21kEQ7qBSv0nSWCMeVTdbPem5PjpAeqN34C1AohhdzG2B+hBzJgr/yo0 oQqwjfVJho3ZrGqf3c680NzbmFrYeaFLFMPS3pmvRbI0wWs5wEjBOP3ckN+0+EG3t1On FsxgwpduE+b8xP2Q9RNQBfY7o1/3YDioZIf62rJUFORLR67QWRjKImbWmmERO8ADCuLV dGl/GaL8G3tminKQSX9yCT57EObtTU+Nt7ODoIrwkSw8ZJKEmGccBUkNEUiu82UOTu0H CL3cwRnt0sErL+jkq7JInUBxAhrbkCE7MchEpHDYpRuXtI1aFYM9ujKiNX40nqx4nrP+ kKQg== X-Gm-Message-State: AOJu0YydjPdhYUNOBim3om2h5R4Rr0g9VFhfGAnla9pLBjjeAErXiVpc 3T+dbXZsp8K2sKNL+W/+mT4eEfhPAVjIiB/geevt1rwiybq26Jnh X-Google-Smtp-Source: AGHT+IEMHaZ3sQpvZFZ7T4UQGmAN17dCVvRs3tLzFPAhiVHrYvkEFJYzOU5+X32z60SLU6h8v/AhIg== X-Received: by 2002:a05:6a00:198d:b0:714:21f0:c799 with SMTP id d2e1a72fcca58-715dfb26b96mr9710736b3a.12.1725093347760; Sat, 31 Aug 2024 01:35:47 -0700 (PDT) Received: from Barrys-MBP.hub ([2407:7000:8942:5500:198b:37cd:b0d:f4fa]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e569e767sm3845680b3a.107.2024.08.31.01.35.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 31 Aug 2024 01:35:47 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Barry Song , Ard Biesheuvel , John Hubbard , Mark Rutland , Catalin Marinas , David Hildenbrand , Will Deacon Subject: [PATCH RFC] mm: arm64: advance pte for contpte_ptep_set_access_flags Date: Sat, 31 Aug 2024 20:35:37 +1200 Message-Id: <20240831083537.62111-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240831_013549_374701_405936D1 X-CRM114-Status: GOOD ( 12.35 ) 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 From: Barry Song Hi Ryan, David, it seems contpte_ptep_set_access_flags() has never advanced pte pfn, and it is setting all entries' pfn to the first subpage. But I feel quite strange we never have a bug reported. Am I missing something? Fixes: 4602e5757bcc ("arm64/mm: wire up PTE_CONT for user mappings") Cc: Ard Biesheuvel Cc: John Hubbard Cc: Mark Rutland Cc: Catalin Marinas Cc: David Hildenbrand Cc: Will Deacon Signed-off-by: Barry Song Reviewed-by: Ryan Roberts Acked-by: David Hildenbrand --- arch/arm64/mm/contpte.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c index a3edced29ac1..10dcd2641184 100644 --- a/arch/arm64/mm/contpte.c +++ b/arch/arm64/mm/contpte.c @@ -421,8 +421,10 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma, ptep = contpte_align_down(ptep); start_addr = addr = ALIGN_DOWN(addr, CONT_PTE_SIZE); - for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE) + for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE) { __ptep_set_access_flags(vma, addr, ptep, entry, 0); + entry = pte_advance_pfn(entry, 1); + } if (dirty) __flush_tlb_range(vma, start_addr, addr,