Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp795921rdb; Fri, 2 Feb 2024 04:31:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzrVvUhZp9gjw2RG7P+x1RdQsIeeVSwBwQm72G2dKiLqTGiGGWnW0+NbfkRfieUZ4FFlfJ X-Received: by 2002:ac8:5a0b:0:b0:42c:c0:8299 with SMTP id n11-20020ac85a0b000000b0042c00c08299mr2188879qta.25.1706877087321; Fri, 02 Feb 2024 04:31:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706877087; cv=pass; d=google.com; s=arc-20160816; b=zEbDAyhJsQNQvcgZR4Nu2A+JKJkBoKh+41EuYg4AV+A21y4H7p1mj5oqNN893BlOXg GYI14qociQGoZEqTJ+luOkkx/btsY8rGizchr8/L4nDOXqBb60O61dBKGR4keCpo4uP+ PzmUWq9zo/XhpEn4SsSJmIWJ/ulv/kX6na8tJ9t7p1soYggcb6S81FZkkNHh0ID3daGn sz1CKk9p0z4TgvsnyXicEH6UZ6XQhWdPW3Q6k9R5nAalq4Gt6Qmk1/LDYc4v/vgkQHMl H86YKX+LlOi2y7A9ZTQGVmo5E3ldiVAzR8Gq3xL7gMjZyr4eWEDPirvTZGkCaoZWtm3m rkow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:feedback-id:dkim-signature:dkim-signature; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; fh=LOAwUppUy4kg/ljC13k4nGilkFTaA95tswje0kH7aRM=; b=yJTOMD5mjO/a+Y7TsJqrIMQmiOS7B9Hu7N0LVlD8gCNbCXRlINKgwkDi3ywvzGzICr 4rnC9crSbJt3a+wNdMRQblLGkd1FUWq1ZeI/PibqVdH0b1HasN8LXK7Xm4/xQxQeOzpq tabJpPldnvfe+/cCcB12uEYLvEhyQxyWzHrv1l639zRvat4QC7n1pFsTAqr5lnP3bMJl V5QPrVW/gq3y64xCKVKUqaRXFsfMD4WyCgsNVGyQQDlh/WIr+RaWsnCuMzZ5CZz0cyOM C9FKuWhav/HEL3WeybFw6RXGOyX7yQSdgSdQE9hxhS2rSRbTz0eLxESPwh6J4tzx+TM6 5iZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=mNL2+pa4; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Cq4Hswe3; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=flygoat.com); spf=pass (google.com: domain of linux-kernel+bounces-49842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com X-Forwarded-Encrypted: i=1; AJvYcCUqFdkKKBbsjSHcHGaPlrGF/MJ83DiemKkzOc/Jdo9r73cAzldR1S1N9fM1Jh3pcK7ZBJMSNGy/keKBK2mxutSvx2lldB+5Md7Z1+vBSw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d7-20020ac85d87000000b0042bff27081asi1901334qtx.120.2024.02.02.04.31.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 04:31:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=mNL2+pa4; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Cq4Hswe3; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=flygoat.com); spf=pass (google.com: domain of linux-kernel+bounces-49842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 16EE71C22277 for ; Fri, 2 Feb 2024 12:31:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2C68145B1F; Fri, 2 Feb 2024 12:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="mNL2+pa4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Cq4Hswe3" Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3076145345; Fri, 2 Feb 2024 12:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.28 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706877043; cv=none; b=MLSatz3zxBFOOTT8UkAeOakQakHpX1MeeKEJhS4ZTmmnYX+maD/1zwy2eaJRHm3TdApWOYURcj1HYBY4tVpByiWKVeFLaklKBekesNbIm4MZ8IQ1ohhuc7/9fIeH06UzywqO7Al8Tcfehv1KsZ0q0hObt8o1QNdecb+nFrRJZ0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706877043; c=relaxed/simple; bh=uKuLCoMYm7TN/5FDEmNqhpyC6JKJvRlQkX2qQKN8ZTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kL6WVmxf6wG6+IjQNhPZr1Gq1Cuc7CKUVcV9Kzl38G83DHlQL6kO6ni37pDmfn8w5jORzLewFiCJF8vvlOonhYy60wO7kHUC0BQiY18SLp1FAsihFC594aFGnSWn7IUzeeU2uU7IZhiwGIfDstx0USyiN5Pm/+hc/ShLw2Yf9sk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=mNL2+pa4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Cq4Hswe3; arc=none smtp.client-ip=66.111.4.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E94335C0180; Fri, 2 Feb 2024 07:30:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 02 Feb 2024 07:30:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1706877039; x=1706963439; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b= mNL2+pa4mBLckcf1YJNeLqeEfEkNIjSaMXoe0/FrLp02SzGJ1t3KLW7TQO9OrUXc gptTiPkf6xEJzcFsrJmmaP3fCsUyMqC7xRA+KTwybjnLjZRd0HzgwV0Hpw2bMevY DQ+bVp6Wcbe2sKmiK7UhkyRCrq1BPPCVpVdSbfPG+667OCbV20W7ydPsxLBgVJMH PVwxt+msm8xw2LScDcgmsw9zYJAtlnk2NZIT8KBu45qMK6XCj9Zu+luAq6INNCTz MKRctK4ygm6lXXS8eruWRjzvu8IRq6ynqU9WCHZjFBVUj/OjDLAgRPoGsOVl8MQv ymUfDDIqKWIrUCROGYDowQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1706877039; x= 1706963439; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b=C q4Hswe3VCvFGloX8BaUea0BX+Tdp6jIWtdo/NcLMOZ56e2czWHNGBPkiuQbNdzBb HBcnE/O0bfvlN2FqY6HlgqPif8XK2+JNKeADBQsfNLfGp3S7Sp88DXOuv7KROL1M qxYc/MyR+MFHX78qRaPRY1BTHlQgtAwnrxD4cVxCo6jpNlPMqWNmYWKx0HxbUh3V wtwSxtMqXbBHWYzIW6RDV58pXcBTsqQEVKXe3gt3wkwFWhOl69ipCtLw8ErunLPu rjLwCcAM/gYCPYwRX1+qpa/wHGqP1JVs4qH6fUfdd60GVpbNtxrx+5sCKB6OCqeW pPmUmusVQfxGge/Nohhaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedugedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvedujefhfffhveekhfffkeetvefgteejkeeutdduieehieeg feejtdelveejtedunecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Feb 2024 07:30:38 -0500 (EST) From: Jiaxun Yang Date: Fri, 02 Feb 2024 12:30:28 +0000 Subject: [PATCH v2 3/3] mm/memory: Use exception ip to search exception tables Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240202-exception_ip-v2-3-e6894d5ce705@flygoat.com> References: <20240202-exception_ip-v2-0-e6894d5ce705@flygoat.com> In-Reply-To: <20240202-exception_ip-v2-0-e6894d5ce705@flygoat.com> To: Oleg Nesterov , Thomas Bogendoerfer , Andrew Morton , Ben Hutchings Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, Jiaxun Yang , Xi Ruoyao , Linus Torvalds X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1379; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=uKuLCoMYm7TN/5FDEmNqhpyC6JKJvRlQkX2qQKN8ZTg=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhtQ9D9I5oxxuhtd5FaqYPUoS1m9SED32vzE+yratNz1t6 f17PZwdpSwMYlwMsmKKLCECSn0bGi8uuP4g6w/MHFYmkCEMXJwCMJGpQQx/xT/dPrVBSu154PLX /HJvTZJnd/7847ilbPm6i5kqQk9unmX4yVh5i+20gXjQviW/jx/ZZs6cUhVptrg1LabUvf/G1MP JLAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 On architectures with delay slot, instruction_pointer() may differ from where exception was triggered. Use exception_ip we just introduced to search exception tables to get rid of the problem. Fixes: 4bce37a68ff8 ("mips/mm: Convert to using lock_mm_and_find_vma()") Reported-by: Xi Ruoyao Link: https://lore.kernel.org/r/75e9fd7b08562ad9b456a5bdaacb7cc220311cc9.camel@xry111.site/ Suggested-by: Linus Torvalds Signed-off-by: Jiaxun Yang --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 8d14ba440929..49433612444a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5481,7 +5481,7 @@ static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt_regs return true; if (regs && !user_mode(regs)) { - unsigned long ip = instruction_pointer(regs); + unsigned long ip = exception_ip(regs); if (!search_exception_tables(ip)) return false; } @@ -5506,7 +5506,7 @@ static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struct pt_r { mmap_read_unlock(mm); if (regs && !user_mode(regs)) { - unsigned long ip = instruction_pointer(regs); + unsigned long ip = exception_ip(regs); if (!search_exception_tables(ip)) return false; } -- 2.43.0