Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1455563rdh; Fri, 27 Oct 2023 15:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPDDKCEzdg1ZPqtdS7eqXeGlXz1yBhRo7zfPdtKXq33xG1DzhECaTE3AROS/h0ZeavRX2G X-Received: by 2002:a17:902:d489:b0:1cc:f8:51d0 with SMTP id c9-20020a170902d48900b001cc00f851d0mr4297816plg.42.1698444769826; Fri, 27 Oct 2023 15:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698444769; cv=none; d=google.com; s=arc-20160816; b=IJ+CXsHIHcAiUonnMK1J8OX5+w6eYb4QCRCOC75Kv8qsR80tJDRsl9gKR4bTqUmDoD cLTldiS1vkuuq6XZardBbH8FWImj9tXsgAC1PipmJxbKWkZ7fDuFGxW9dneSMOvzoafl wngAnLEUwQc0zQqhQ6Gam4guHGzu4bj8ijBVno32w7u+qX6k/o5k/nL0D0RGnK1ZzRMu Xzd40qyb9qB5hQKAXznrDk4lEX2SmpERvymAmZZoz+lokB+6uhXzxi3nqGwf8CeTqiXe yj+uyvZ6o5yLY9Xdm+oDH0q5AqkRNpWZRWg8fbfe+V7Bb4cf2W7GT3BKU8lRwIOiUIvD wWzw== 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 :feedback-id:dkim-signature:dkim-signature; bh=GfLwAORI6DxI0P9SZsCprbtQo1SdXn/VrLRSxzuwQR4=; fh=34VXqKbbbRVUWYKB0XlF9D4jmhXxe51P2+smd1zcTfU=; b=LhPZZa4RcwP1/dbKF+v/cU9MCAhDsloMeqE73jKykZZiXDCPqDBIc17erMRpjAb+S2 bGiF0ENPNU4wkpIaG/XTOTJ6t19vwPs7dORnFEnD6kZs5BSTpPhnRES28zOkPNCpSzYN npChaRCBB4KyfpagMyKa4HoBb+vRm+LIoSFs2+j6dCo7tXI5Q5voQwEDsFgFhBmOaey2 Xmi7r+Ncyk5lCCeXT1/uWBRbt2Sji3/Eg8t/Bjyb1r7TyaVBwXb31wxTxbwBI1GGDFL6 0j+OnqLFXPEebNnay2YRBYdDE/rDpl1h8CXQO6OFnmwAtmONfYPeCqxpN+Qf3ibadBPm BpfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=nYG6TLE9; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=MEdwpHWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m6-20020a170902db0600b001cae5779ed1si1688085plx.543.2023.10.27.15.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 15:12:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=nYG6TLE9; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=MEdwpHWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6F60483EE9ED; Fri, 27 Oct 2023 15:12:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235163AbjJ0WML (ORCPT + 99 others); Fri, 27 Oct 2023 18:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346695AbjJ0WLv (ORCPT ); Fri, 27 Oct 2023 18:11:51 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D72FC10FD; Fri, 27 Oct 2023 15:11:33 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 743653200930; Fri, 27 Oct 2023 18:11:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 27 Oct 2023 18:11:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1698444690; x= 1698531090; bh=GfLwAORI6DxI0P9SZsCprbtQo1SdXn/VrLRSxzuwQR4=; b=n YG6TLE93W20ZgxBA9/Dos/YhIY0YVVd8oVDdwWSEA7ZjYAJKv6+F741kEGJNM7cu gLwWSDNZ/UKNcv99cnU01CpJW0/xottYJIMzJsJ/oMAiQO/IwZvOEDu9xAryc10+ iqHtWEcvUMqMHVqXzWzDPT0GV7LsEJXUfs2vOnbd7vEL/Ys7H1Bcxz60b7SQqMcY P4yBl+plaV+y0dsckCzB9k4yeLxKuJ6GF9LkCFfQmIcpT590lDw4hZH+J8Pn4651 GdBxLFM634rAPCD2FSgTtyfpvpN6fjkZjGsZfGx/p53AfbGNZJzakSSr22Yw7GUL xp9JsD03HeTw3BYGOATyA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698444690; x= 1698531090; bh=GfLwAORI6DxI0P9SZsCprbtQo1SdXn/VrLRSxzuwQR4=; b=M EdwpHWMA7reyomXBT6TJojaPnVxpChevCW3Gzk6MqX1OxezkX1jMWly9yaLymdao SNMVk7xMOeM/pYrmmg9Yxj+qARw6ahUn0wdYmuXhjD+ePukz2akoDWSoJONMNLo1 2kmQ9wClXRB91T8b8Mj4Al36SoEJRNJ3DKTr8ByWfcL6e5f4QMWNEm5UdQAycII1 urJ4c3Lx92LEMoLBSsVaCoThrhZeVwkpYf+kq5hmOsRK6LlfFf6Tf1ObAeBVZraC M0XkTy/90xAd/sXWRigBvXPDzPsB5fj7FJFGamBHc24PEAKqy0q8T1Fm6lK+UEju W+FX/O39Pfb50UkayReZA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleehgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefledufeehgedvuedvvd egkefgvddttedtleeiiefhgeetudegkefhvdfhjeeftdenucevlhhushhtvghrufhiiigv peefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihgh horghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Oct 2023 18:11:29 -0400 (EDT) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, gregory.clement@bootlin.com, vladimir.kondratiev@intel.com, Jiaxun Yang Subject: [PATCH v2 08/10] MIPS: Avoid unnecessary reservation of exception space Date: Fri, 27 Oct 2023 23:11:04 +0100 Message-Id: <20231027221106.405666-9-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027221106.405666-1-jiaxun.yang@flygoat.com> References: <20231027221106.405666-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 15:12:46 -0700 (PDT) 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 15cde638b407..d3dddd1c083a 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 b406d8bfb15a..54e8b0fd4a2a 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 be93469c0e0e..05410b743e57 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 651c9ec6265a..b6e94654f621 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.34.1