From patchwork Thu Feb 1 15:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 195383 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp267979dyb; Thu, 1 Feb 2024 08:17:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3y9apzwW0Tu1L4pEgakeyQ0oS0ZCD+1GzXEBrGvQSkHYil6jr0Mwq8bsSNCnzBOWFHu9K X-Received: by 2002:a05:6870:40c1:b0:218:e4c3:e34 with SMTP id l1-20020a05687040c100b00218e4c30e34mr2859384oal.55.1706804272132; Thu, 01 Feb 2024 08:17:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706804272; cv=pass; d=google.com; s=arc-20160816; b=AraPsZjBXOjxQ+slrQ4b32rBby6kAuMXyjYw6hQsHU7fOgy0v03LQoQC3n8X9Pd/sj pVEtfDVuCfoScez7sgBSnDnYpNJw7M67fEtM1Y0J3b9VHo/Vxga+/+zN8MsWKDTfDzMB 7pjHSPOii+qgjMbruPmHvJ6Kj54SxS/GgfhQsXM7p6b3cvID0QGmpB3J1FgWevrVWcTq h9261jVeLONDiSXQuWNCtfOFsVCbvK0dnjechCUxmXZw3FNVZY3NXlWtcKy4LzJFu5ly Mp6qKeRhfVuCM/Z2ZIcwmSpG5oeHn56k2c/F9/bThri7WFoBTCakN8gpPcojl96KQ/5D afnA== 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=zM4ypLTsihhX4T85kzZYYbykGEdoiDtwYzxwA9PVkI8=; fh=c1T9Vha+ZBMhmfkevOZuT9wIIcVqEaNsfIvd16iRhXI=; b=lT3u0CaLMEFEcFlnF4ZreYtsR92ZgxSXHm64PeX2RF13dFV1pVGdACWYlRWprdvHon 3F6HPTaDbYXizDwGHOV9Js2exYbf5HxDzijXZDHA7CjLoawcijS37BRXdGbhiulrIslB r9FaDrv7PTx2HIdh3JCKtGQreAH4+lN4NS4ORAqXeMGcShG8WGsD+iuOgyTJjfU3wcSr 6dhRKBLBQuuuZ7DUYdyORkCqyvQhEA6Fx9vlx/5jJVOBEM/NOU5PqrRadWuTJFd0zIfN KBksCXoEpk0KBrmiu9VID7AB5r6gTNp8DGVtKaMlifq9SWNeYRy7DTZjnHuKkyaPUJoW aqXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=YxJn+2dF; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=TqSvgtZG; 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-48433-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com X-Forwarded-Encrypted: i=1; AJvYcCXIR/jUMpS83iw9qHii5OOgC53L4nt4ur0FYMjiHU5mPCZ0pm4sTQrS3UY/WiSnLgtNmFQJi+L69YDnisarqx0IOJS+bA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t63-20020a632d42000000b005d8c57281dfsi8954523pgt.410.2024.02.01.08.17.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 08:17:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48433-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=YxJn+2dF; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=TqSvgtZG; 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-48433-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48433-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 81C37B2E8D3 for ; Thu, 1 Feb 2024 15:47:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1DFB15CD5F; Thu, 1 Feb 2024 15:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="YxJn+2dF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TqSvgtZG" Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 5CC7E779E1; Thu, 1 Feb 2024 15:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802396; cv=none; b=jDks2SfgMzlhjrXE8MDkqgCQFL70NNvoPQUZaCPzUAI145rr01olsAM+hQtj0anizcMzghpc0J41Y12kglKvQ3WQqDhzf8EeGdA6H56byNH1OR7RjvmseuJHb3kv6nfyj5GISVjLDPm4ypSPz5Mlh86PcWDbit0t4gXbA7/CDFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802396; c=relaxed/simple; bh=To5vJPzytdUYzh0hXEDkOhoQVO7uNU4EWlR+7TGqcVA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F3INn0bv6eOFPQeWgA9Ely4IlptyGWsa+56jkDk4Z8MkvV5qFvGDo5Jh0CsXrFoOieMeSxAJBXRkvszaZJnk0T5wa5JU4xKVH/rw6KUEIXAyq6IEmUCdcTaFiXIBcyVn9r4sDcnt021b5swKedWvI6alfwXKCPH5rqVsnaTuqu4= 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=YxJn+2dF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TqSvgtZG; arc=none smtp.client-ip=66.111.4.25 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 4F6425C0197; Thu, 1 Feb 2024 10:46:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 01 Feb 2024 10:46:33 -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=1706802393; x=1706888793; bh=zM4ypLTsihhX4T85kzZYYbykGEdoiDtwYzxwA9PVkI8=; b= YxJn+2dFpph/Az50xTRg2kgNEk4jnjiA/7c50k8mKJEby/71UeM2LPcY/Y9fjjwf +LG/ieJnXn1YFyPj8okUh45Be+5bH69GxAxeYJMCpez5Pqt1FjPgjuzeu+CbuzQl qLiYVR/7s5CBpkSjys2xbYCd1HHZwKxwYmJk1jJ11jdJwMalcN0UT/3M3HUh3Qx8 U58lPT0el0EgxqIQgbM+aMzSVhYKokAkE1qEeXRt6YxKRigKDcruB6CUX2zts0Co FFHpmVJPKh7BTanZzeBn/sKc+coZX5KAwHf2ccCQarMzE8/yGjVsCIcFJyiI7Elz 5lLlFQo7hPAnlGbsVr8yjg== 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=1706802393; x= 1706888793; bh=zM4ypLTsihhX4T85kzZYYbykGEdoiDtwYzxwA9PVkI8=; b=T qSvgtZG3e5xUyV01ke2XtkIse8rzNIqZuMRHdi7J4XOZmbf+XbxygZgYx8T28jko CIQ1hiTtFx2NTSR8v97TSJLp6gZWC8m/c0Y1F9vsZ4KQSKx0bCh90uIWfWe3of6G fqO/ct9d7oZbtMsugZ8E+dCP4hhc748LAbC1//4ewM7w4elK0D00+4ohKU621a9j TPdByvTvjrpR6+C2/eF/o6BlpZTG+YNEsC3o9QF5i8nT+TJiFs3E7HLa0s9olxG8 f6ZFifklewNXyK1yxUqPI39bhj6R5ZNAxvirwqbHJXZ08Pp4dO1pIQuZmS7GncvK a9R+tTEFR8NQpKHMQ9p+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfeduuddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvedujefhfffhveekhfffkeetvefgteejkeeutdduieehieeg feejtdelveejtedunecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 10:46:31 -0500 (EST) From: Jiaxun Yang Date: Thu, 01 Feb 2024 15:46:27 +0000 Subject: [PATCH 1/3] ptrace: Introduce exception_ip arch hook Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240201-exception_ip-v1-1-aa26ab3ee0b5@flygoat.com> References: <20240201-exception_ip-v1-0-aa26ab3ee0b5@flygoat.com> In-Reply-To: <20240201-exception_ip-v1-0-aa26ab3ee0b5@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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=10340; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=To5vJPzytdUYzh0hXEDkOhoQVO7uNU4EWlR+7TGqcVA=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhtTde64K/ji8z21S7Jm/395wpbMFpN9JrrMJe8/mPdlSa 661+KHwjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZjIq1CGvzL8M++/aFUVlX+p X2j3i+m6VfjJZeeZOfZcy531ripikQgjw9NLv2c8uLhn4rS3Eoeq1u6aG7ZSR4DzlaWGXVL3KTW /YH4A X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789713995931529022 X-GMAIL-MSGID: 1789713995931529022 On architectures with delay slot, architecture level instruction pointer (or program counter) in pt_regs may differ from where exception was triggered. Introduce exception_ip hook to invoke architecture code and determine actual instruction pointer to the exception. Link: https://lore.kernel.org/lkml/00d1b813-c55f-4365-8d81-d70258e10b16@app.fastmail.com/ Signed-off-by: Jiaxun Yang --- arch/alpha/include/asm/ptrace.h | 1 + arch/arc/include/asm/ptrace.h | 1 + arch/arm/include/asm/ptrace.h | 1 + arch/csky/include/asm/ptrace.h | 1 + arch/hexagon/include/uapi/asm/ptrace.h | 1 + arch/loongarch/include/asm/ptrace.h | 1 + arch/m68k/include/asm/ptrace.h | 1 + arch/microblaze/include/asm/ptrace.h | 3 ++- arch/mips/include/asm/ptrace.h | 1 + arch/mips/kernel/ptrace.c | 7 +++++++ arch/nios2/include/asm/ptrace.h | 3 ++- arch/openrisc/include/asm/ptrace.h | 1 + arch/parisc/include/asm/ptrace.h | 1 + arch/s390/include/asm/ptrace.h | 1 + arch/sparc/include/asm/ptrace.h | 2 ++ arch/um/include/asm/ptrace-generic.h | 1 + 16 files changed, 25 insertions(+), 2 deletions(-) diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h index 3557ce64ed21..1ded3f2d09e9 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h @@ -8,6 +8,7 @@ #define arch_has_single_step() (1) #define user_mode(regs) (((regs)->ps & 8) != 0) #define instruction_pointer(regs) ((regs)->pc) +#define exception_ip(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs) #define current_user_stack_pointer() rdusp() diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index 00b9318e551e..94084f1048df 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -105,6 +105,7 @@ struct callee_regs { #endif #define instruction_pointer(regs) ((regs)->ret) +#define exception_ip(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs) /* return 1 if user mode or 0 if kernel mode */ diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h index 7f44e88d1f25..fb4dc23eba78 100644 --- a/arch/arm/include/asm/ptrace.h +++ b/arch/arm/include/asm/ptrace.h @@ -89,6 +89,7 @@ static inline long regs_return_value(struct pt_regs *regs) } #define instruction_pointer(regs) (regs)->ARM_pc +#define exception_ip(regs) instruction_pointer(regs) #ifdef CONFIG_THUMB2_KERNEL #define frame_pointer(regs) (regs)->ARM_r7 diff --git a/arch/csky/include/asm/ptrace.h b/arch/csky/include/asm/ptrace.h index 0634b7895d81..a738630e64b0 100644 --- a/arch/csky/include/asm/ptrace.h +++ b/arch/csky/include/asm/ptrace.h @@ -22,6 +22,7 @@ #define user_mode(regs) (!((regs)->sr & PS_S)) #define instruction_pointer(regs) ((regs)->pc) +#define exception_ip(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs) #define trap_no(regs) ((regs->sr >> 16) & 0xff) diff --git a/arch/hexagon/include/uapi/asm/ptrace.h b/arch/hexagon/include/uapi/asm/ptrace.h index 2a3ea14ad9b9..846471936237 100644 --- a/arch/hexagon/include/uapi/asm/ptrace.h +++ b/arch/hexagon/include/uapi/asm/ptrace.h @@ -25,6 +25,7 @@ #include #define instruction_pointer(regs) pt_elr(regs) +#define exception_ip(regs) instruction_pointer(regs) #define user_stack_pointer(regs) ((regs)->r29) #define profile_pc(regs) instruction_pointer(regs) diff --git a/arch/loongarch/include/asm/ptrace.h b/arch/loongarch/include/asm/ptrace.h index f3ddaed9ef7f..a34327f0e69d 100644 --- a/arch/loongarch/include/asm/ptrace.h +++ b/arch/loongarch/include/asm/ptrace.h @@ -160,6 +160,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long val } #define instruction_pointer(regs) ((regs)->csr_era) +#define exception_ip(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs) extern void die(const char *str, struct pt_regs *regs); diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h index ea5a80ca1ab3..cb553e2ec73a 100644 --- a/arch/m68k/include/asm/ptrace.h +++ b/arch/m68k/include/asm/ptrace.h @@ -13,6 +13,7 @@ #define user_mode(regs) (!((regs)->sr & PS_S)) #define instruction_pointer(regs) ((regs)->pc) +#define exception_ip(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs) #define current_pt_regs() \ (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1 diff --git a/arch/microblaze/include/asm/ptrace.h b/arch/microblaze/include/asm/ptrace.h index bfcb89df5e26..974c00fa7212 100644 --- a/arch/microblaze/include/asm/ptrace.h +++ b/arch/microblaze/include/asm/ptrace.h @@ -12,7 +12,8 @@ #define user_mode(regs) (!kernel_mode(regs)) #define instruction_pointer(regs) ((regs)->pc) -#define profile_pc(regs) instruction_pointer(regs) +#define exception_ip(regs) instruction_pointer(regs) +#define profile_pc(regs) instruction_pointer(regs) #define user_stack_pointer(regs) ((regs)->r1) static inline long regs_return_value(struct pt_regs *regs) diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h index daf3cf244ea9..97589731fd40 100644 --- a/arch/mips/include/asm/ptrace.h +++ b/arch/mips/include/asm/ptrace.h @@ -154,6 +154,7 @@ static inline long regs_return_value(struct pt_regs *regs) } #define instruction_pointer(regs) ((regs)->cp0_epc) +extern unsigned long exception_ip(struct pt_regs *regs); #define profile_pc(regs) instruction_pointer(regs) extern asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall); diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index d9df543f7e2c..59288c13b581 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,12 @@ #define CREATE_TRACE_POINTS #include +unsigned long exception_ip(struct pt_regs *regs) +{ + return exception_epc(regs); +} +EXPORT_SYMBOL(exception_ip); + /* * Called by kernel/ptrace.c when detaching.. * diff --git a/arch/nios2/include/asm/ptrace.h b/arch/nios2/include/asm/ptrace.h index 9da34c3022a2..136f5679ae79 100644 --- a/arch/nios2/include/asm/ptrace.h +++ b/arch/nios2/include/asm/ptrace.h @@ -66,7 +66,8 @@ struct switch_stack { #define user_mode(regs) (((regs)->estatus & ESTATUS_EU)) #define instruction_pointer(regs) ((regs)->ra) -#define profile_pc(regs) instruction_pointer(regs) +#define exception_ip(regs) instruction_pointer(regs) +#define profile_pc(regs) instruction_pointer(regs) #define user_stack_pointer(regs) ((regs)->sp) extern void show_regs(struct pt_regs *); diff --git a/arch/openrisc/include/asm/ptrace.h b/arch/openrisc/include/asm/ptrace.h index 375147ff71fc..67c28484d17e 100644 --- a/arch/openrisc/include/asm/ptrace.h +++ b/arch/openrisc/include/asm/ptrace.h @@ -67,6 +67,7 @@ struct pt_regs { #define STACK_FRAME_OVERHEAD 128 /* size of minimum stack frame */ #define instruction_pointer(regs) ((regs)->pc) +#define exception_ip(regs) instruction_pointer(regs) #define user_mode(regs) (((regs)->sr & SPR_SR_SM) == 0) #define user_stack_pointer(regs) ((unsigned long)(regs)->sp) #define profile_pc(regs) instruction_pointer(regs) diff --git a/arch/parisc/include/asm/ptrace.h b/arch/parisc/include/asm/ptrace.h index eea3f3df0823..d7e8dcf26582 100644 --- a/arch/parisc/include/asm/ptrace.h +++ b/arch/parisc/include/asm/ptrace.h @@ -17,6 +17,7 @@ #define user_mode(regs) (((regs)->iaoq[0] & 3) != PRIV_KERNEL) #define user_space(regs) ((regs)->iasq[1] != PRIV_KERNEL) #define instruction_pointer(regs) ((regs)->iaoq[0] & ~3) +#define exception_ip(regs) instruction_pointer(regs) #define user_stack_pointer(regs) ((regs)->gr[30]) unsigned long profile_pc(struct pt_regs *); diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h index d28bf8fb2799..a5255b2337af 100644 --- a/arch/s390/include/asm/ptrace.h +++ b/arch/s390/include/asm/ptrace.h @@ -211,6 +211,7 @@ static inline int test_and_clear_pt_regs_flag(struct pt_regs *regs, int flag) #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) #define instruction_pointer(regs) ((regs)->psw.addr) +#define exception_ip(regs) instruction_pointer(regs) #define user_stack_pointer(regs)((regs)->gprs[15]) #define profile_pc(regs) instruction_pointer(regs) diff --git a/arch/sparc/include/asm/ptrace.h b/arch/sparc/include/asm/ptrace.h index d1419e669027..41ae186f2245 100644 --- a/arch/sparc/include/asm/ptrace.h +++ b/arch/sparc/include/asm/ptrace.h @@ -63,6 +63,7 @@ extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS]; #define force_successful_syscall_return() set_thread_noerror(1) #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) #define instruction_pointer(regs) ((regs)->tpc) +#define exception_ip(regs) instruction_pointer(regs) #define instruction_pointer_set(regs, val) do { \ (regs)->tpc = (val); \ (regs)->tnpc = (val)+4; \ @@ -142,6 +143,7 @@ static inline bool pt_regs_clear_syscall(struct pt_regs *regs) #define user_mode(regs) (!((regs)->psr & PSR_PS)) #define instruction_pointer(regs) ((regs)->pc) +#define exception_ip(regs) instruction_pointer(regs) #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP]) unsigned long profile_pc(struct pt_regs *); #else /* (!__ASSEMBLY__) */ diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index adf91ef553ae..f9ada287ca12 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -26,6 +26,7 @@ struct pt_regs { #define PT_REGS_SYSCALL_NR(r) UPT_SYSCALL_NR(&(r)->regs) #define instruction_pointer(regs) PT_REGS_IP(regs) +#define exception_ip(regs) instruction_pointer(regs) #define PTRACE_OLDSETOPTIONS 21 From patchwork Thu Feb 1 15:46:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 195380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp267526dyb; Thu, 1 Feb 2024 08:17:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhpkk0hLXjYsg12rAG9j40Jwqx9wwOlsAGKk0gYRJg991BIiycuwmzHddYKTQD1HUiPQHO X-Received: by 2002:a05:6a00:93a1:b0:6da:c9e8:486f with SMTP id ka33-20020a056a0093a100b006dac9e8486fmr9991530pfb.3.1706804233459; Thu, 01 Feb 2024 08:17:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706804233; cv=pass; d=google.com; s=arc-20160816; b=sgENYS0LLbHfLKGw6rtECKAsHTk/BX6SnTFW2a3cghx/o1CWQkHIyg0kiwVesxB2b/ 2ghj0xDjQ7nEDV9mcomut8+4keSWxF0foRXG5pxeWolS0NAqQwmdEmP9qIohLjkmfezu 1RNICBPYxMFMBnIOQgNLB4ytFNAkCzgxBzuGEnKY/xSGP9ZthvLye+kIPhqF45lyTN+i 4D6kBLHXA2jRxSizeR4TTmeWPP0VSBx2EmqDfcbUWOYqMfP4pgrDo4wzDHIFlUwGCIRA j1zdgZoLSiWMqgFFQaJg0ECeNUQbHRVFEID09Nb6uURrwOFS787puFJRKhdOe1/sEqZ0 v7dw== 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=i1v7gjbWYtUmewWLy9Kvlb4tyH5uqfyNj8gU9rtRY70=; fh=8yDJeqhJCobAfsyyh38LGhwss/5Il4R5T0x9BzKfvdE=; b=Euw/He8vq2tsORQCnIhTQ+OMFgJBsekVo4QZXoIspDiQKXta0fv/we7WY5Jbs875Qy wnurD2bo2LYezVBpdDAH+KAHnKiSk7RNKaADz6wskJu/SCvW6BYuVDmnltxk2nFWyUl6 /oPn9d6L2DOr2Yg6Xau9TE5VG7v9VppTf1eW+aVN5A3J/PnzjQbPNHSbPFnouJUJIKKe EnasfQgDNkNknK7HXFz0zFo+drLYbLg3wusQRPQ4fId2nYpD3UMXqrIvwpJTTiCh/Uq1 HR4f70wNzoO7wq7wBlCpBtRIwinBNtgQU38fLSYjJM+VcWTz3dH1F9s3IfM+h8U203g3 ipCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=OcTC9QfL; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=uNT7zrOD; 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-48434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48434-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com X-Forwarded-Encrypted: i=1; AJvYcCXN4kjcr2rPA7c8kNwQx1Vh/joDCYHLBXQbl5wG2QKgPOF7uxY8SlIl7BJr6dVgMKH0Sr4zCCGpqhO2RBWviqgABfCyoQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p7-20020a056a000a0700b006dfe4c4ec20si2377584pfh.281.2024.02.01.08.17.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 08:17:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=OcTC9QfL; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=uNT7zrOD; 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-48434-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48434-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 74BD3B2EB2C for ; Thu, 1 Feb 2024 15:47:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00A5B626C1; Thu, 1 Feb 2024 15:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="OcTC9QfL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="uNT7zrOD" Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 C3DE3626AD; Thu, 1 Feb 2024 15:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802397; cv=none; b=qkaaKeF4AWai1LLUrejF2qnQezjg11WqhQqxmqWLwhUnFOD7NnIIQAcfGKhnKx9Fv+BWb+6KvNGgDlRAkhCV8KEU7SOo7fDTyiBPbQ7EvwnBZWF18UVUOK2OgBmgnaSa0jM6dLq80wsAsAtoCWK5ItJZ51HvKzYF7HgGrxSdb2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802397; c=relaxed/simple; bh=NiHFyPPrD5sK3tKmsstYY6GfrHgdKmJEsdk12grutnA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H3HHm1D9Gi4OiG64Nw9YtHpa2/Nz3c5IyJk12L5D5R4qvdQBKZxehQc9rliphiH9yi3vP2nZ6xwfmj12oisQJXnvMRUAhUNDDe4onrz/uucydraRO5Dzh4Hn3NYr3OmcW0A2svjLO0AhxzQkhEGJf3qk+Crb1MyEqA0e3hyywcc= 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=OcTC9QfL; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=uNT7zrOD; arc=none smtp.client-ip=66.111.4.25 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 compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id C35AC5C0080; Thu, 1 Feb 2024 10:46:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 01 Feb 2024 10:46:34 -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=1706802394; x=1706888794; bh=i1v7gjbWYtUmewWLy9Kvlb4tyH5uqfyNj8gU9rtRY70=; b= OcTC9QfL162gZptSWEDjPWdZnEazNy9ME14ocM4u4Hqg32ZxHXv86zGSpg1ANxrp y85+SHbIXplcptG1iu9QbpHDlIeWxrmmNxDtRWQRjB+GrMNAXbg0gjdoyiRkzveT RbPTIm1lL940KAuRgcszRYHYUjqyGaeWna6/r4ikauCbuoxp9SZueRiDIsUfUTbQ lLFeaRdYgU+Iful3+CVSJnsV+NbWTarlf/iXjvb66r48+k+fLozytYBianvvo6wf WS/vAa3CAsR+79V2NZvjF/LS1Gzt7DlyZZxQzBe+e+yuZKWGY1CKyNnRRwLbi3u5 QQB9Iw/7y92B4ZcU+gLr1A== 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=1706802394; x= 1706888794; bh=i1v7gjbWYtUmewWLy9Kvlb4tyH5uqfyNj8gU9rtRY70=; b=u NT7zrODxo1yyqBsfvZZE8jEgzkBEg4zm7mB0qJkNoo+cH7BOocaIMy8zJZoRIOhH 46YaWAexAN5A0SHU+Rfm3Ga+RIGesj+AvHsz0inE1ZD5zknUM5MiLnoiUKSo8hYW TSlSu33ESAm+VxKElQ7IBNKmzEtc526+wJgLUTACSRkGAgBoHG6zOgl0ejytcCzH XliM963BvsNuxXClnE1HOhNEuI7kq+NkGrTIcqD4pUBTuoKnr/481Z8m2mTTRrYD sbr9mvEU3osslGFafQqC+ckc6J64sgiPUeGYa6SkOzJAs13dXdKKbe3cxijujbUC dvaqenrCgk/Gub5tGP4wA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfeduuddgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 10:46:33 -0500 (EST) From: Jiaxun Yang Date: Thu, 01 Feb 2024 15:46:28 +0000 Subject: [PATCH 2/3] MIPS: Clear Cause.BD in instruction_pointer_set Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240201-exception_ip-v1-2-aa26ab3ee0b5@flygoat.com> References: <20240201-exception_ip-v1-0-aa26ab3ee0b5@flygoat.com> In-Reply-To: <20240201-exception_ip-v1-0-aa26ab3ee0b5@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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=860; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=NiHFyPPrD5sK3tKmsstYY6GfrHgdKmJEsdk12grutnA=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhtTde64yuL1SSV4UOF9DePOkzgsnGSd6LJDLjxSMtNtSb F0aeTKso5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDaEi1MAJmIdxMjwTTn6ttlZ/av+3xp3 Pe7ZFsP1s/eGc6bPToN79bsYuU7OY2Q45vFTKG7j7El89pddzOYxbdN/9LVUT2PVZknNzeInBAo 4AA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789713955990228367 X-GMAIL-MSGID: 1789713955990228367 Clear Cause.BD after we use instruction_pointer_set to override EPC. This can prevent exception_epc check against instruction code at new return address. It won't be considered as "in delay slot" after epc being overridden anyway. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/ptrace.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h index 97589731fd40..845508008e90 100644 --- a/arch/mips/include/asm/ptrace.h +++ b/arch/mips/include/asm/ptrace.h @@ -60,6 +60,7 @@ static inline void instruction_pointer_set(struct pt_regs *regs, unsigned long val) { regs->cp0_epc = val; + regs->cp0_cause &= ~CAUSEF_BD; } /* Query offset/name of register from its name/offset */ From patchwork Thu Feb 1 15:46:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 195371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp252345dyb; Thu, 1 Feb 2024 07:59:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYO5FYO0jvXSikSjA1C+CGBkQU7NKA+9MGZq0zUavFJonKVJh1MyjM9ZrJ5TeNwr207HCH X-Received: by 2002:a17:90b:30c1:b0:296:3240:470d with SMTP id hi1-20020a17090b30c100b002963240470dmr103982pjb.6.1706803190754; Thu, 01 Feb 2024 07:59:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706803190; cv=pass; d=google.com; s=arc-20160816; b=p6lNTn31BW646ygM+rHPPbM87ONN9DsSSufbv97D3Yxn6aVFR4o80VfvefjGSibNEI erj+XuCWV4hNUErtkzIjufYHKWj/Ftj1MSg1ijJ82IAMU2nJRYSV4LtRwuU4TBrhWNp/ AYzRsg9kTlderhtZIuBqP7atc9S9ACIkidh7zvlB4gn35wSxfI3L+xVahv2tR9Ze0J57 JmdeKD2J1gkvBhKOpujSZk4YTyKJaYQpNucUwDK0fqxP9UtzP11heeVpmF8TcBA6+D1Z fUvw9Oqh7f0RPinaKHzD7QTJdLkGH78XvhP4dzudotwzpD5Mk0ioaEO7Ao1wXEUbEaAW yOZw== 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=3l0xhk4kUdVtabXy41CVWUuZ8ezhjQ95fICEylwALwM=; b=Q7wN8PFhTx2hVza1itozhx4mkscU5EO079kHlfgx5kUnHzXKo0oewnjBeknuTn8Bsf 41wcFEXZZHZQuHmued0gQ5xrJZi/B3kutBLdDHyio53QM+sCQFBZ9JDTqFQUbfqIDWDv v0KKMvPWHruayupR/WGDrCbBN9qBR6C/s4BgsHURClBUy+6wfa4Iy2lJ2MZYGJE9xDTB rpNGxqJg2+LpARvJI9f/Kjd7jci7XXXgyarDepel6U5mDbMdzTrt2niLUUeOVk+g34ih 3WnyUi3+cvLzo50Z9yQE1vXYFzSshL0TrJchxzOcb3dSkrUVM2a5ISidQUrQQh9xBqL4 hKSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=ogNS4GpH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Zv7vFK8h; 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-48435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com X-Forwarded-Encrypted: i=1; AJvYcCW4k9G5+YRt0T38XayCEZISoKt1EIo118S2XXpWckfZRXa0+PkPsWFsgwUXdAbm+FCP/CHTMaEJRXds2lieiS/m4ao6MA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w6-20020a17090a1b8600b00295d9ec8e60si3842624pjc.123.2024.02.01.07.59.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 07:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=ogNS4GpH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Zv7vFK8h; 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-48435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48435-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 51C332997D8 for ; Thu, 1 Feb 2024 15:47:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99A9415D5BA; Thu, 1 Feb 2024 15:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="ogNS4GpH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Zv7vFK8h" Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 7509B779F0; Thu, 1 Feb 2024 15:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802399; cv=none; b=fJuAwlEkqOBb6YIzF51rrkpYw7r9xTxbO5iDAyXk6JL2gxVhsLN8VUoNPlEgMYdnZ72jQHRUBZ6tF5vA7i6+otdzZkGRZLTZRW5R0ucbVdfVHkGBfG9VjxpIt25dPH10jMcy5Aub//gf+ZGWqPJrHOZPOGDwlwEQ8a9mraCaHXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802399; c=relaxed/simple; bh=uKuLCoMYm7TN/5FDEmNqhpyC6JKJvRlQkX2qQKN8ZTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MIhRhE0FoY2P+q9zLoHm2mLv2bgHHhQffd2ZYNp+9ENU4LIYdc8IBaCvB9hDXXtmOfqL9BtBx1YubaeEuWfsMEwEeCxQ9fAtiYT/d+N+VPltNDdP8tHKo9th1SDjcCivFksJ30to78rKq4Q09vXNlzYMMQQ9fXK42dcXLUbLee4= 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=ogNS4GpH; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Zv7vFK8h; arc=none smtp.client-ip=66.111.4.25 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 compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 751975C0143; Thu, 1 Feb 2024 10:46:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 01 Feb 2024 10:46:36 -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=1706802396; x=1706888796; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b= ogNS4GpHLOaAi26YwvNGDn2O/lkVyJMCKH4ZLzdYBxvNF4Ghg+1pAS7N+7fe3PEQ F7U03j5yLZfBYr9bPyahFksuvY7GaYExKi0iBKAc8Hk6GqnizcaCLXyAFLCCEpXC AAX9DKxr/ZwxJ/FdNGr01oFM0sW6gRIyxhTkq99EulTm4pDloXDVGC1l89ZwZMfa F0CbBoftKcYqOXwCkLZwhPJ644yqZJelFRqgAxGz/uHR3IC9AFTai5ARHwqX/O6I u8HtBisIX2VLfLBtkDclhJkOx4RmpCqYQdmcoDHGINyWL/BIRP/bp98GL9AcfQmL IZvC9hNk77GCvSkpwET2KQ== 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=1706802396; x= 1706888796; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b=Z v7vFK8h6WyGCZO+fTEtv3JQhFyhoWTvILxwV2NRWBdSK1vdjFMCVXW2GwTXx/GZZ XBQSt1aqtTonHlvkFoOhTh6d+by+aReRfLMNARK8312ZdUbnzZyEGAOBjRIBuxU4 85NXS0HATkVvRpxYb1G0zp3NZ3ADGDRYaccdGeb+vffRs93pvjIqx6nUiTt1D8ny mGqzioXUePtDNS6HeWHnuUFkgFl6gJVgZVx4Xm2hSgDAQ73Bo/964MVd2/gTVo4Y FZD/yYJhMTAISTPGoUIid5krD4B4xst1ENOGPHMZ4I/j+rCYGPriAtVs9JD3RGG5 /I4/Hl8vvbpBKYCMxpSRA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfeduuddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvedujefhfffhveekhfffkeetvefgteejkeeutdduieehieeg feejtdelveejtedunecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 10:46:34 -0500 (EST) From: Jiaxun Yang Date: Thu, 01 Feb 2024 15:46:29 +0000 Subject: [PATCH 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 Message-Id: <20240201-exception_ip-v1-3-aa26ab3ee0b5@flygoat.com> References: <20240201-exception_ip-v1-0-aa26ab3ee0b5@flygoat.com> In-Reply-To: <20240201-exception_ip-v1-0-aa26ab3ee0b5@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=owGbwMvMwCXmXMhTe71c8zDjabUkhtTde672x4SsrfVewuR6t1Nnmlr5QtH+q/m1zqculPqee +n7amJERykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAEyk2oHhn8q3ba8O6dkcYv32 cfqJCbVLm8pE31xT/LY88sIrTq7Li2cw/Pdfnj5VT79IOtfx81mrjQXq64WdoqsvPp4d/UHlQPI XQx4A X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789712862198170301 X-GMAIL-MSGID: 1789712862198170301 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; }