From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A409023AB8D for ; Thu, 27 Nov 2025 01:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764208539; cv=none; b=lj96PycTm3WGrTdaeSHe5PJ0sG/J6Kdk6Yooe1bUiRqp9n85azrbafwWp9KN0mEZUwRFc+5DuvlkZllnjrcte58ZP+7FW1/UvAHxXwn68J50Q1C/7x86iewExAk+B5dBFOkkjB5u4APK4y7j2a8RGW1HRfuWnQi82QifCY4wCBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764208539; c=relaxed/simple; bh=atuhv8caJz4RoO7vMSluU+IZ+hIfMR/txzshM5V/7U0=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=G0Xa3KJAsOLvOQHHHLGJzwxiEJ8Jt4yqPV8897gIDfjOpxDdoK38s6UdHSthXRPLKA/Qcqedj3q8/UnCskMf1Te7HWGzkrShj+sKdOnr0f1rVSk0MKiqRbhQS1qJWLLwghxSjcLyLZCWFB4FU1jvb6unmBeEZeaR9Mq8sPbtaIA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.42.62]) by gateway (Coremail) with SMTP id _____8Dxvr+XrydphZIoAA--.19871S3; Thu, 27 Nov 2025 09:55:35 +0800 (CST) Received: from [10.20.42.62] (unknown [10.20.42.62]) by front1 (Coremail) with SMTP id qMiowJCxH8KUrydp3pBAAQ--.53414S3; Thu, 27 Nov 2025 09:55:34 +0800 (CST) Subject: Re: [PATCH v1] LoongArch: Handle special PC in unwind_next_frame() To: Tiezhu Yang , Jinyang He Cc: Huacai Chen , Xi Zhang , Xianglai Li , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org References: <20251125063327.31586-1-yangtiezhu@loongson.cn> <658bb477-b3f1-97c1-ab37-5dafcb6215f5@loongson.cn> <6cc59312-7cdc-19a5-4d18-e120ea9c7563@loongson.cn> <3c0602aa-a8bc-25b9-7d7a-467e04dbc519@loongson.cn> <45cf4a09-8895-73fb-c019-1b1f88501eed@loongson.cn> <87730f18-4ad7-2a21-f1bd-483074748b37@loongson.cn> From: Bibo Mao Message-ID: <7ddd6efc-e7ad-b2f8-9a4d-5ca1cad9e74d@loongson.cn> Date: Thu, 27 Nov 2025 09:53:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <87730f18-4ad7-2a21-f1bd-483074748b37@loongson.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID:qMiowJCxH8KUrydp3pBAAQ--.53414S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7ZFWxZF48JFWftFW3ZF45CFX_yoW8ZF1fpF yIyF45tF4kJFyI9r4kZwnY9ryYqrs7Kr4UGFn7tFyUJwn8XF1aqF10gasFvryqvw4kW3W0 va1Fvr9F9Fy5A3cCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0c Ia020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_ Jw1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrw CYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMxCIbckI1I0E14v26r1q6r43MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AK xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8uuWJUUUUU== On 2025/11/27 上午9:39, Tiezhu Yang wrote: > On 2025/11/26 下午5:56, Bibo Mao wrote: >> >> >> On 2025/11/26 下午5:09, Tiezhu Yang wrote: >>> Cc: Bibo Mao > ... >>> +#if IS_ENABLED(CONFIG_KVM) >>> +void (*get_kvm_entry_info)(unsigned long *old, unsigned long *new, >>> unsigned long *size); >>> +EXPORT_SYMBOL_GPL(get_kvm_entry_info); >>> +#endif >> this method mixes kvm and unwind components and it is obvious hack >> method. If there are other modules which have the similar problem, how >> to handle it? Add get_MODULE_1_entry_info/get_MODULE_2_entry_info API :) > > Currently, there is no other similar issue and something that should not > happen in the future, this is "concrete question concrete analysis" and > "handle special cases with special methods". If so, I can think LoongArch unwind method is nasty. If this method is special for KVM module. KVM prefer to compile the exception function with built-in method, rather than using this nasty method. Just be curious, it is the same orc unwind method. why is clean with file arch/x86/kernel/unwind_orc.c, however there is special handling bt_address() in file arch/loongarch/kernel/unwind_orc.c ? > >> KVM module copy exception function to allocated memory, it breaks >> unwind rules. KVM can compile exception function in kernel and do not >> copy the exception functions or LoongArch kernel provides unwind hint >> APIs to handle it. > > That is better if it is possible for KVM, no general API for kernel IMO. > >>>   static inline unsigned long bt_address(unsigned long ra) > ... >>> +       get_kvm_entry_info = kvm_entry_info; >> Is this API get_kvm_entry_info() general for all modules or kernel >> components? > > No, it is just to get the necessary exception info for this special KVM > case, we can use something like EXPORT_SYMBOL_FOR_KVM_INTERNAL to avoid > the potential misuse if possible (not tested yet). > > Thanks, > Tiezhu