Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4761430rdb; Tue, 12 Dec 2023 08:36:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0TB33PwjzyRB9OmDkeFoI1EJ8Ki88T7A4lP775No4fqcKK00uhVSVppfOoHX6f5DbE7IJ X-Received: by 2002:a17:902:ce86:b0:1d0:cd9e:4276 with SMTP id f6-20020a170902ce8600b001d0cd9e4276mr2869707plg.72.1702398999720; Tue, 12 Dec 2023 08:36:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398999; cv=none; d=google.com; s=arc-20160816; b=M+vL6QBGNMS2+owYdDi/bvQWxCdbQOtAD4eytI6BEQPdu79aSvFbDN0OiPmWVL3C/8 7JggvFhjNkt3bv/kb9pFilGGcu1oT1gCxfDi8Cr/ajklL27fzPuJXtPfhhFM4rk9erKn BLubCwZKH5O/mthIK6WwVPBA9k01nnlWB/O8g64xwXtfP2YP02QhQqj9fYn4IJdHYb5u vi50ugxbERoFSL/hxShfSJTmcOGFfk+FpTlvH31k/jjrux1OIvEiG7+JkyAkvFcF4Erw yNp/CKvvGVyeFVlHwXlfBo0h0ojwpIm2I3S8DC2HSIIQdDm6nSG2XLJzJNvFMwzx1+AK j3UQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ktTTyr0RlfRgBEvWUnjy95sG7EHyWXVrxSqbNjLTqqU=; fh=t1bsw/gEI8w3DN7ouBpAewoQyybWh2yxEgAHixB9Iis=; b=Z4vvuzGW4LyIfCjlaTKbjKbqbQe8AoYUZO/X/sWxQGgQVN/9wUHpsBFg+tRB17ULOB Gw1h8iKAspGRPQ+llDcSP4163ARv2uKdl0hiM9VqNIkWbQ7im1boUPxohS8HhPxaDr15 4Awk1bYld7ka8YrOTyd23Vt0ZwDcTwSb7N2MMn+1LvyPiFme3W73LknesaP99ycvYWeC XkWkOmcTwSCTogHGK3fvutEDeAgbuy0jWi4hPIASISDxUBb7AtfTBonj4Qh6ZFj9T4MJ P8TNoj1n9BHrmMrMrE+/wk1dMM5O+INm36uzsFGBstw4/t3sL7i/a8MFtpR35SXu5hts 5vLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="j8SL/s+J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f4-20020a170902e98400b001cfc3f7392fsi8081809plb.252.2023.12.12.08.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="j8SL/s+J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7294A80AE51F; Tue, 12 Dec 2023 08:36:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376354AbjLLQgC (ORCPT + 99 others); Tue, 12 Dec 2023 11:36:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233112AbjLLQf2 (ORCPT ); Tue, 12 Dec 2023 11:35:28 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C6DA8; Tue, 12 Dec 2023 08:35:33 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D15CC000E; Tue, 12 Dec 2023 16:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702398932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ktTTyr0RlfRgBEvWUnjy95sG7EHyWXVrxSqbNjLTqqU=; b=j8SL/s+JKqdFRUq4rxjHbv1Z8aQfOG3Fdr9Qg4doJZaumc4gPtzMh1tBVHQbn00yFNV2i7 GR3B6rX16ranQs/MUIYpA1L4oT29ig96JQdIPyA5Jx8wwyYZNtMAWXAPERuGvUtPa+bWcp FjyamVci/1mfHZCxT7MKIKMK0CDzhdk9S6MO6QBGOvyYhe6c2j1wF4d1/EA7MVfWCAffcq B1fo0OTuTSaj+Fy0EdDlx5lppR/4q18dvBGWrNd3ogpopioHf4jBEX8W/cfjEuTeKuLSvN MQ7VcP0o9dwkgBRcuD8TUTDSfB60oHRAjSj2AU7fnBsJXyxPv9DreBjcAio+RA== From: Gregory CLEMENT To: Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Jiaxun Yang , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , Thomas Petazzoni Subject: [PATCH v5 10/22] MIPS: Avoid unnecessary reservation of exception space Date: Tue, 12 Dec 2023 17:34:42 +0100 Message-ID: <20231212163459.1923041-11-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231212163459.1923041-1-gregory.clement@bootlin.com> References: <20231212163459.1923041-1-gregory.clement@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:36:36 -0800 (PST) From: Jiaxun Yang Nowadays we allocate exception base from memblock for r2_r6, so we don't need to reverse exception space at the start of the memory for r2_r6 processors. For older processors the reservation is moved to traps_init where we have knowledge of exact size we need. We also add a sanity check to detect possible overlap with kernel. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/traps.h | 1 - arch/mips/kernel/cpu-probe.c | 5 ----- arch/mips/kernel/cpu-r3k-probe.c | 2 -- arch/mips/kernel/traps.c | 12 +++++++----- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/arch/mips/include/asm/traps.h b/arch/mips/include/asm/traps.h index 15cde638b4070..d3dddd1c083a9 100644 --- a/arch/mips/include/asm/traps.h +++ b/arch/mips/include/asm/traps.h @@ -24,7 +24,6 @@ extern void (*board_ebase_setup)(void); extern void (*board_cache_error_setup)(void); extern int register_nmi_notifier(struct notifier_block *nb); -extern void reserve_exception_space(phys_addr_t addr, unsigned long size); extern char except_vec_nmi[]; #define VECTORSPACING 0x100 /* for EI/VI mode */ diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index b406d8bfb15a3..54e8b0fd4a2ab 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1570,7 +1570,6 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) c->cputype = CPU_BMIPS3300; __cpu_name[cpu] = "Broadcom BMIPS3300"; set_elf_platform(cpu, "bmips3300"); - reserve_exception_space(0x400, VECTORSPACING * 64); break; case PRID_IMP_BMIPS43XX: { int rev = c->processor_id & PRID_REV_MASK; @@ -1581,7 +1580,6 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] = "Broadcom BMIPS4380"; set_elf_platform(cpu, "bmips4380"); c->options |= MIPS_CPU_RIXI; - reserve_exception_space(0x400, VECTORSPACING * 64); } else { c->cputype = CPU_BMIPS4350; __cpu_name[cpu] = "Broadcom BMIPS4350"; @@ -1598,7 +1596,6 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] = "Broadcom BMIPS5000"; set_elf_platform(cpu, "bmips5000"); c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI; - reserve_exception_space(0x1000, VECTORSPACING * 64); break; } } @@ -1996,8 +1993,6 @@ void cpu_probe(void) if (cpu == 0) __ua_limit = ~((1ull << cpu_vmbits) - 1); #endif - - reserve_exception_space(0, 0x1000); } void cpu_report(void) diff --git a/arch/mips/kernel/cpu-r3k-probe.c b/arch/mips/kernel/cpu-r3k-probe.c index be93469c0e0ec..05410b743e571 100644 --- a/arch/mips/kernel/cpu-r3k-probe.c +++ b/arch/mips/kernel/cpu-r3k-probe.c @@ -137,8 +137,6 @@ void cpu_probe(void) cpu_set_fpu_opts(c); else cpu_set_nofpu_opts(c); - - reserve_exception_space(0, 0x400); } void cpu_report(void) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 7e6e6df59e6d7..a6d0ae12b3c4c 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2007,10 +2007,6 @@ unsigned long exception_handlers[32]; static unsigned long vi_vecbase; unsigned long vi_handlers[64]; -void reserve_exception_space(phys_addr_t addr, unsigned long size) -{ - memblock_reserve(addr, size); -} void __init *set_except_vector(int n, void *addr) { @@ -2394,7 +2390,13 @@ void __init trap_init(void) } if (!cpu_has_mips_r2_r6) { - ebase = CAC_BASE; + ebase_pa = 0x0; + ebase = CKSEG0ADDR(ebase_pa); + + if (__pa_symbol(_stext) < (ebase_pa + vec_size)) + pr_err("Insufficient space for exception vectors\n"); + + memblock_reserve(ebase_pa, vec_size); } else { vec_size = max(vec_size, PAGE_SIZE); ebase_pa = memblock_phys_alloc(vec_size, 1 << fls(vec_size)); -- 2.42.0