Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3043895pxb; Tue, 12 Jan 2021 05:07:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8sriF/cC2ZGZQKkPUrLyEl1t2T9J5hUZ2me71Cucjog4tHbN89KOjS6ZrSdQzj6PPAict X-Received: by 2002:a50:fd18:: with SMTP id i24mr3469647eds.146.1610456847328; Tue, 12 Jan 2021 05:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610456847; cv=none; d=google.com; s=arc-20160816; b=Uy7bEDqEHWh5KRICmT/yXmfIdEsDCeX+C98C0r8XAcdSRppS09NVSR6XU5ySLyQV9P xLDqIicfvs8jtUHe7rfAu7k1Baiv2JgKP2T20qtPJjxikzerIOAdYkvPPHjAFHeVpCKP 7aSec497vLK9kkSSoGwvRwCxov6/QwzhyMO/RAHHxHEQ/UHbUN9OlX5pd8hG4tEpvBEo cUpvcUqnO6oLYwbr/yLD1CpHaBV/hPQwIUzqnfYtZ22CC/AhOINQOifrb0O140Mz5MiB 2nPlGbBENnnMrYJ2BR5DpKrz3zZXI6rh39lNY8kvxqtN4fvjeq9hhot67gUcpL0LO2C+ QcDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=+T4qeqZGEPG2yjX6LOTwS1rx/29rq3oZxdcIaIcFzmE=; b=qeyeupz9CXusvcW1YLrQWvY2VBvGs5XVtKP3aU6HSTci1ueDbC/5vccINWuKMKSTd7 40e97CaUDykVWbPVyNpQGoo0lV0Jld2duvpmb+sEI1ijt350xQYCVXUMdnEvfYsR2aGA 6yriPl/rIhZ7FhXl4Z3eHTcTJm84laEvHlLIo8ZTaDBuFs2ljdlw3bSfoWm46roXOxPV TF/3BPZhN6K8Q0vFJxoT+4FpjbEWNQTh7DGaeG5WXZ4uaYaJHA5iPVt69KaB3FyD+FkT +o2CbmKBt+v1og7M76RPIJumEQrRxewJATz+6DlgS3eWvvF+1YQm0P21KrmOJR4oHwDb lYPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga11si252730ejb.301.2021.01.12.05.07.01; Tue, 12 Jan 2021 05:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387804AbhALMaI (ORCPT + 99 others); Tue, 12 Jan 2021 07:30:08 -0500 Received: from mail.loongson.cn ([114.242.206.163]:34330 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730630AbhALMaH (ORCPT ); Tue, 12 Jan 2021 07:30:07 -0500 Received: from loongson.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx6L0dlv1fsycDAA--.5569S5; Tue, 12 Jan 2021 20:29:19 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Burton , Jun-Ru Chang Subject: [PATCH 3/4] MIPS: Fix get_frame_info() handing of function size Date: Tue, 12 Jan 2021 20:29:16 +0800 Message-Id: <1610454557-25867-4-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1610454557-25867-1-git-send-email-hejinyang@loongson.cn> References: <1610454557-25867-1-git-send-email-hejinyang@loongson.cn> X-CM-TRANSID: AQAAf9Dx6L0dlv1fsycDAA--.5569S5 X-Coremail-Ant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IUYeVbPUUUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [1]: Commit b6c7a324df37b ("MIPS: Fix get_frame_info() handling of microMIPS function size") [2]: Commit 2b424cfc69728 ("MIPS: Remove function size check in get_frame_info()") First patch added a constant to check the number of iterations against. Second patch fixed the situation that info->func_size is zero. However, func_size member became useless after the second commit. Without ip_end, the get frame_size operation may be out of range although KALLSYMS enabled. Thus, check func_size first. Then make ip_end be the sum of ip and a constant (512) if func_size is equal to 0. Otherwise make ip_end be the sum of ip and func_size. Signed-off-by: Jinyang He --- arch/mips/kernel/process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 94dfdf4..bef8f8d 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -390,10 +390,8 @@ static inline int is_sp_move_ins(union mips_instruction *ip, int *frame_size) static int get_frame_info(struct mips_frame_info *info) { bool is_mmips = IS_ENABLED(CONFIG_CPU_MICROMIPS); - union mips_instruction insn, *ip; - const unsigned int max_insns = 128; + union mips_instruction insn, *ip, *ip_end; unsigned int last_insn_size = 0; - unsigned int i; bool saw_jump = false; info->pc_offset = -1; @@ -403,7 +401,9 @@ static int get_frame_info(struct mips_frame_info *info) if (!ip) goto err; - for (i = 0; i < max_insns; i++) { + ip_end = (void *)ip + (info->func_size ? info->func_size : 512); + + while(ip < ip_end) { ip = (void *)ip + last_insn_size; if (is_mmips && mm_insn_16bit(ip->halfword[0])) { -- 2.1.0