Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5759285rwd; Wed, 24 May 2023 06:29:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fD024tH2rkW5XfPKX1ObzYUoKQ5DScJuYRgynJYCgJUHpKiDWX7N4P2Xtc0NSQe36+NNC X-Received: by 2002:a17:903:11cf:b0:1ae:10bc:4ae8 with SMTP id q15-20020a17090311cf00b001ae10bc4ae8mr20199723plh.26.1684934995684; Wed, 24 May 2023 06:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684934995; cv=none; d=google.com; s=arc-20160816; b=wEN8yiVyGguHQTus1m/Mx6RtsHksJSfI593TT7/WjfWaEunrrA0foyatfwk1TR0R5v 8rgtuvfl1V20AbmsXf5vS0fUWp4eAoHLEpuhF7vk8ZPADyZmQJKEtfmVCgRGUqsw/Mi1 BcVHbmth1MCA//H3+p2njy1lClK/gRhB/SDmWT/tJ5v8xdZLM48guSorByV509j4/qLY +uz+G0i8FnEiYM9qmONhIOZ1BofCgP9E+BZhuPtiOjC0u7cKXP1YJb9esM0joF7mdq0e 1gQ+PKqzblHvn9u23SK4LxfAIfOBmz9XqbTpUPnNvLpWIkZ5g5jTTE5AWUBsPZIJ0ZUX s2Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/Th1ctDRpxE0P7ABTcNoA1LkITiN+vWmEjWb5uTgEEU=; b=yLFeblx21BP0MU/9mRfZdNrpHr3ynOt6O1fl92FBanwwXdXcFEd+iOtwwMVIqjc0ou CRHOttZSAdXPSm0aIUfDAwUV2Jnr16+80xjOEiHsQaYJ675JcEl6dfqHZiiRz/Y6qdLp t1XYg7pHALGhsiYZM/CgrcHN8v5yzGW+q96RdMHQ5iGrOEBqX1UvcYb57YuZufe5rWg2 TDz3CkCcc/IJvapI6xRj8vm8Ugokm93sI+vE1RtNuy/HVNpWtJjxAE3OpyGKxj6f63L+ J9TZtLm82UF8+WKbPlPqAC82UusVUHN6SBNNG+m9V8LaCKvJtxIzPYFb46y7xjASRJm9 XLHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ReE/FBJx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a170902d2c400b001ac4027fa28si9041541plc.618.2023.05.24.06.29.41; Wed, 24 May 2023 06:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ReE/FBJx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbjEXNYN (ORCPT + 99 others); Wed, 24 May 2023 09:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233936AbjEXNXy (ORCPT ); Wed, 24 May 2023 09:23:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A26CAB6 for ; Wed, 24 May 2023 06:23:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1ADFA63351 for ; Wed, 24 May 2023 13:23:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69F55C4339B; Wed, 24 May 2023 13:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684934630; bh=X7w8UNBEZj68xoYR2+1fzYHN1lzC2y2GrI0EwehDjsk=; h=From:To:Cc:Subject:Date:From; b=ReE/FBJxbcHETmpMLAuM2/2+fMFJHxShGyb9I//gEdE3yoh1i66mXLpb+Tv8VyHEG gNbmYcVBfAtbSUsAkSCioYsC5k/GcC7C66aZh52EEvU0Fn9OB8ehms4oN5/XNhj2Tu T7D2mgDY+rvDwYZq7VVGB1ZjBDNCDmt7BHVvEZmmopNVUrp3K4tIiqHwH5+nbESsKv j7alRZUjfI8OKlopPSzj5I4KyFKOrdkBVio5ToZgvbPAQqO0NAlMxdqq7Dy0wttHVm x35sdP5Ih9qWPQAtlPy29CsFDuf55qH+VbK7dGXvwTu2AYMgiTBEL9x84iMM8MqznA rNABVyRoPWUKA== From: Jisheng Zhang To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: mm: pass original fault address to handle_mm_fault() in PER_VMA_LOCK block Date: Wed, 24 May 2023 21:12:38 +0800 Message-Id: <20230524131238.2791-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When reading the arm64's PER_VMA_LOCK support code, I found a bit difference between arm64 and other arch when calling handle_mm_fault() during VMA lock-based page fault handling: the fault address is masked before passing to handle_mm_fault(). This is also different from the usage in mmap_lock-based handling. I think we need to pass the original fault address to handle_mm_fault() as we did in commit 84c5e23edecd ("arm64: mm: Pass original fault address to handle_mm_fault()"). If we go through the code path further, we can find that the "masked" fault address can cause mismatched fault address between perf sw major/minor page fault sw event and perf page fault sw event: do_page_fault perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr) // orig addr handle_mm_fault mm_account_fault perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...) // masked addr Fixes: cd7f176aea5f ("arm64/mm: try VMA lock-based page fault handling first") Signed-off-by: Jisheng Zhang --- arch/arm64/mm/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index cb21ccd7940d..6045a5117ac1 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, vma_end_read(vma); goto lock_mmap; } - fault = handle_mm_fault(vma, addr & PAGE_MASK, - mm_flags | FAULT_FLAG_VMA_LOCK, regs); + fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); vma_end_read(vma); if (!(fault & VM_FAULT_RETRY)) { -- 2.40.1