Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp686912pxp; Fri, 11 Mar 2022 12:25:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+Zpx72ohdMzM9Q9GBFhI3/C6BjO9Pkf2IoR2GpCI+ezAY7/bSfqt6wC6INsXpiz7vfjvq X-Received: by 2002:a17:902:b697:b0:151:4c2e:48be with SMTP id c23-20020a170902b69700b001514c2e48bemr11831596pls.70.1647030305193; Fri, 11 Mar 2022 12:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647030305; cv=none; d=google.com; s=arc-20160816; b=T/j51sqqmd/+VOrWcVTi4BhUbr9FvilPkifYmZIJMoRRnwhwU+awGB+Vs+5KpokOIT IfGlqxvLwbs2WjvIGTv9fRmWObncLuDOYj9Ukd/JtQN5QtHTpCgG9y99oJi1lAHcs/T3 RphU4G8SslZoBaJ8uehCv55bQbN2NpMBVWP4a3HgaeLhxRYFtRiiGtD+PNInyVyK8BST ZdclhmsfAGRD/9xniJQrLSJAaTi85ipJ0e2oujPjrtGBcVLKJtC3YiCsrV0x+RRfjHdO MZpdBgyDHeUEzRX0HduWHXArkV7Ozz/7LeEwuhHApjTTE8QqWUuliecV/xCOvIHBd/wI uSzA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MaJVSzdJuIcfBVwp6dGId2T1VQUv8Sog1CJFjGOqf0k=; b=Ti+DQLyhuWWdtuFUACRt2DnHi13NPR8/glK3qzhavPc4+RQivCEKKvfaC5WwoEki26 wnFfW3f6DhltKriB3I77mGLDs1XVmkunPyyDtKttbI2c8MtY7W6LBX4dCp6OM/7Abbu5 V3WGknQDZ1LNxPrAz+XeVRjL2O2WMQsmBUwaI8AO8LhpLGnMbE6PwexMh+gSxvMQg2Dr 6pospOhFa7qRffnKfANJtyiuSpdZBHVP/QIfoOXxgeqn8IGmu6x2oRNpzvavImg86jMp hGehjbB2vyaFo5xhwJwcC5kXu/2t92L3EolCFFU72XrkP9YSIs6f/zokdoWQu3ooFjFY h8eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=siZiiGip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a634d09000000b0036c8e54e2ebsi8569995pgb.147.2022.03.11.12.24.48; Fri, 11 Mar 2022 12:25:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=siZiiGip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244968AbiCJOik (ORCPT + 99 others); Thu, 10 Mar 2022 09:38:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343615AbiCJObF (ORCPT ); Thu, 10 Mar 2022 09:31:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 162929BACF; Thu, 10 Mar 2022 06:27:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6A681B82544; Thu, 10 Mar 2022 14:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C02E4C340EB; Thu, 10 Mar 2022 14:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922425; bh=UnvhIlQm44RU2lBhhosbmErjf2hqypuKRtKkNXHH5p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=siZiiGiph+NxmvSobdHyDHMBrcUyBv6jtDRSyBwD1ur1xRvSshIzKWglDuA+2kQ41 WJl4AGQi5XsSmUi3JDtcch9n1fzeku8ovkykhPXPzFQMjEVRvZlITQA3GMyR+dLTR7 sIBSQqtLqf8ocxjWeDixVfMGAhiHdbIsOsqC69Io= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , "Russell King (Oracle)" Subject: [PATCH 5.4 14/33] ARM: early traps initialisation Date: Thu, 10 Mar 2022 15:19:15 +0100 Message-Id: <20220310140809.163515443@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140808.741682643@linuxfoundation.org> References: <20220310140808.741682643@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Russell King (Oracle)" commit 04e91b7324760a377a725e218b5ee783826d30f5 upstream. Provide a couple of helpers to copy the vectors and stubs, and also to flush the copied vectors and stubs. Acked-by: Catalin Marinas Signed-off-by: Russell King (Oracle) Signed-off-by: Greg Kroah-Hartman --- arch/arm/kernel/traps.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -799,10 +799,22 @@ static inline void __init kuser_init(voi } #endif +#ifndef CONFIG_CPU_V7M +static void copy_from_lma(void *vma, void *lma_start, void *lma_end) +{ + memcpy(vma, lma_start, lma_end - lma_start); +} + +static void flush_vectors(void *vma, size_t offset, size_t size) +{ + unsigned long start = (unsigned long)vma + offset; + unsigned long end = start + size; + + flush_icache_range(start, end); +} + void __init early_trap_init(void *vectors_base) { -#ifndef CONFIG_CPU_V7M - unsigned long vectors = (unsigned long)vectors_base; extern char __stubs_start[], __stubs_end[]; extern char __vectors_start[], __vectors_end[]; unsigned i; @@ -823,17 +835,20 @@ void __init early_trap_init(void *vector * into the vector page, mapped at 0xffff0000, and ensure these * are visible to the instruction stream. */ - memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start); - memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start); + copy_from_lma(vectors_base, __vectors_start, __vectors_end); + copy_from_lma(vectors_base + 0x1000, __stubs_start, __stubs_end); kuser_init(vectors_base); - flush_icache_range(vectors, vectors + PAGE_SIZE * 2); + flush_vectors(vectors_base, 0, PAGE_SIZE * 2); +} #else /* ifndef CONFIG_CPU_V7M */ +void __init early_trap_init(void *vectors_base) +{ /* * on V7-M there is no need to copy the vector table to a dedicated * memory area. The address is configurable and so a table in the kernel * image can be used. */ -#endif } +#endif