Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp553203lfg; Fri, 11 Mar 2022 13:04:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7YOHHlTR6lJ3RrRgvR5jEPyja9cUFHc55OfdQKzwT7h7LNxwIKYTvnuD9H3XuJxPmeu+9 X-Received: by 2002:a17:902:a404:b0:14b:1100:aebc with SMTP id p4-20020a170902a40400b0014b1100aebcmr12418262plq.133.1647032642954; Fri, 11 Mar 2022 13:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647032642; cv=none; d=google.com; s=arc-20160816; b=oSDT7r47CCgfwnTiaPa/N4YKWxNp14SPE8YFQOPZaHfUl5MKvO3r91ojj2VhEMKfpd eB70V0fWK4Ka6oPdsGhD6r+ZBNzVJsb8Ct/hgIOSYDY4DK/ts/mWO0457z36oxroVtN7 tuUd6AHy5wNT8h7TvjOmZ8EyTeBHkmsEYviylve5ACSZdE6qiHxUj/PkskdDmXz4zLAV IdtIdQq3O8x2uS/R3OQR9Q9AzKmyPJmB3SRamEoAxyHSGe26LDttfrN9TKLZYtoiLnc0 AY9ZJcRTxNLaic3KBKoci0yiL2PS8R1OCfWZsCT4DUaZF9EJ1d2aaUGwwkzFyuLdo9Pz ewfg== 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=r4CKxroSzkfJCy1HnoC8XChjoEIfg11PhHNYrQniyJA=; b=lpACaDhmTN9i58ugJYm4OgDJaG2dZTGEnKWwzPRL0MmKpTTOIZgV9AbxukqBw8fQWu vfZ5rq3I/gep4KNZp4PX5hU3pY0p9In0rXwnBj6prR28u/GTtTtiQ3oGNaZH+ZLu+iMw HfUUWpnIhfreA6rsljyEcSMEXERXNgyOtaCda2horZu/bBhY3cMs0FyUUYmXbG8sT8IH EaHaXgpfp6kGEcNFyYkYRNpce/04WTPi7CMO06gEZ7r2SYdoIwzPncA+sBDYV0VU+WTF ZTQ7eImhvmc9Ul8ilqYJiyTqviDEIbrrO2rAU/Y9O6vVDZkWBFSG0XfCxLxHZjpMwPEg QHiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RNMSxsim; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v11-20020a056a00148b00b004f739ef5b88si9810946pfu.291.2022.03.11.13.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RNMSxsim; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FD9A15F62E; Fri, 11 Mar 2022 12:49:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244723AbiCJOds (ORCPT + 99 others); Thu, 10 Mar 2022 09:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244236AbiCJO2i (ORCPT ); Thu, 10 Mar 2022 09:28:38 -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 A78E2C7906; Thu, 10 Mar 2022 06:23:33 -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 E10D8B82615; Thu, 10 Mar 2022 14:23:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B513C340E8; Thu, 10 Mar 2022 14:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922210; bh=yxgoumT1YLDdhdq5IBgheUbGQSZm44o0PVleM4hr8QE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RNMSxsimwp70xhs4XctV+7JrHnmK7350zaDAD7ow74IEpdHSXxAIB7iN2jPrZrmRF Yai3lADtVOKUrhK2sd18CClbmvmn2tTd0ChFeLSwl0ZwlvP1GpCAa9+CiU0ahZC8AP GqDmisMsmtk4Wes8f71WbPFLtPcU2LBgCQzf+g1Q= 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 4.19 14/33] ARM: early traps initialisation Date: Thu, 10 Mar 2022 15:18:41 +0100 Message-Id: <20220310140808.166993548@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140807.749164737@linuxfoundation.org> References: <20220310140807.749164737@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=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 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 @@ -830,10 +830,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; @@ -854,17 +866,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