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: 13785974 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 B4300CA101D for ; Sat, 31 Aug 2024 08:35:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C39768D0017; Sat, 31 Aug 2024 04:35:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE8F98D0013; Sat, 31 Aug 2024 04:35:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB07D8D0017; Sat, 31 Aug 2024 04:35:51 -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 8E8C78D0013 for ; Sat, 31 Aug 2024 04:35:51 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 07BDF120A85 for ; Sat, 31 Aug 2024 08:35:51 +0000 (UTC) X-FDA: 82511882502.08.EA488E5 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf30.hostedemail.com (Postfix) with ESMTP id 4612680003 for ; Sat, 31 Aug 2024 08:35:49 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UkkfPrpo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725093327; a=rsa-sha256; cv=none; b=yD1f1IbRrAB29U9zB3YTLNswSaS+DSD5UQojmniaLoKjl7n1DHE1bPUPbcJ3Y9YrNGH5o4 CqB/hJrBle+kqKay1QR2VsP+n/NHtMeUPJhOsTMKX00YTkI/HpRvSRZrXQnYKH/5nqs+V2 pu4LKnPqi2MGWCy2XZHFAD33Ie1Bc5s= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UkkfPrpo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725093327; 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:references:dkim-signature; bh=cu4q1q4MiGODhcwED+miwpta2OvmryUYkLRInznLuoE=; b=MfdF8GMkT6PrSjAkotlPGrbGEJ7o0GowSat2xE1M5I6c1UN74yfv+xNeuao10J3iyc4CHm FzaJhrzr0RHNAL6PyR/8xZaMGjS+ckeyrY/npkhcv1oQ4VM4jzFhp7sVaP5cQvCZdcC18o 0drGsqrwVHBZUmuysPg0EsPF8iFmT5A= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71456acebe8so2079011b3a.3 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=kvack.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=UkkfPrpovlfE7NTUuNFrpL9iUX9OKXw3DOAO4hnvzw63vLbODhOMjHKOQ5xRNAAjut QTM7zD4SjEvUfudQqldHhN2SEB4KSbVmY1ffnwwmDzCMwAeaa516ks7NKhNm+e3tUuBB qN00QHySN4WxAPZIdUwaL063hOqDYO0W+9o3Nnu1xp4V2HEb0WLcBtyk8Orz8XApOD04 yzmO1wKYI62AYWhESPQEcUvLI8ur1H7cYZ990Ip2NpQuhMpl6g57ngmHfTo6+cTV1L8/ 9ALuVcX1mDlYFSZ7HGhzhEYbbmNAjs1d13m4cO58cGfTrJfKjM+SKjFW5Nazixjo/k0k yLjA== 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=eYN0xkKH3I+bj6s+pbIV13gJBs579zTVoA6tR1uLO5t/lkCtyVqCPrFrY/VuaFoV3F 9H6iS9gOFTHUed/k8F2sji89XVtXgHaZYXIZ3z2/R3xe87mWkNtL5NJWh4jMtO07rCw7 7EJ9IxNNYHPhTNC1eCaJkFm9qpfhGld7cdiIgg3xGet4nxw5lXtyXLuAQHaNCTGgnQd8 7uARR8jIvVILQwB6GnDyoPXJ9YGP38YsgsKIjctSRMiBOkDMMctZqA9fbvdiBbapNR9t fJoqMgsYcLkiio9xudQK7alYje0ChWhZ0EzvuYG9y+SYgdhkJzagmzhRL29HarZrvIz9 EXMw== X-Forwarded-Encrypted: i=1; AJvYcCVrodK5+fvJuKqKw67/xyYbrHtKigK9NZJwbUYgRg0GY5NICEPE5KdHvzJLwVbvyJQxBunChMoqtg==@kvack.org X-Gm-Message-State: AOJu0YxAcnjEzDw9ItPvdygBEqkWZtSc3w3tJJ2fx2oFHj37309gZNyU ADmfyC0Zj22uBHHE1/Z2vOCFTZX3ysFi8aDeH5LGXG/wW4sVIAGA 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-Rspam-User: X-Rspamd-Queue-Id: 4612680003 X-Rspamd-Server: rspam01 X-Stat-Signature: y5hd68seoaayees4gru45trjk3tz1e67 X-HE-Tag: 1725093349-32890 X-HE-Meta: U2FsdGVkX1+UzLol1Sh/9gVBecWFL5+4xA4sUiVbZ+DE+mKGENaiHEoS/Mz9ZS/OGI6riWvlY83kPu0vx+GkL+aArTnGlWj9wLltUqL5YfEpC7WxfdcFrRa1bfNi/40BwuQcd4xPsxcDSRYojP86YrJIOHrRK3EzeV6hvjC6/LTAqK0Cz5coK8pCZPsnPd+v2RndHBh1K3k+bmdxtYGRWNUhHJhF8JgOoNZHIM5uUwtoRWKC1jx0NDwBUIy23BY7YOnR7mayrAyUtHSBWHeUlhpxCWoV/uY5P3UQG5VJAujRZmMR1XrtRredaN7D+IgVesZo+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fhzbfQo9iVt8O7atjV3C4clPK4+oZPvV/w3oFfPPcJQtFDYLLfnGlwxW3N9kvNITNJXgiK87Hb1+s6TRuefHduYj0sGqoGhaiaSjqFKsWtKpD328fnlus6PLGsm0LFZQttael3uRnSZLrWfOKaP0QYv6dMKJMGwClVRtjrq0xMLU7Qw== 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: 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,