Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp132565pxp; Fri, 11 Mar 2022 00:40:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNmf6h6lV18Y43P/a99vt13C5XP2Y51EpgZMP6+7o8y5XpCfzGaHWDH0w/XCsifNFNTn3+ X-Received: by 2002:a17:907:60d0:b0:6db:9e12:7e9c with SMTP id hv16-20020a17090760d000b006db9e127e9cmr2580182ejc.156.1646988026665; Fri, 11 Mar 2022 00:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646988026; cv=none; d=google.com; s=arc-20160816; b=a1ZttWi8gdPxTEjUEeqBfrLe/7OpE2seQbK/A8QGvWFZUsOfzqzaInxdxd6Q5Ynpns KHw4lS/DQmCmXcOEK49eV6S7ofHxdYehlVBSJ87g+11ivwq7TT3vl8O2s8B1Ie6v/fbM 0aGyrt8B6mPFOX0ACi7DlaRP/zzd7tSaBoLDLK8KdWCmXL3CHbp4ZCLAai3OATjqKpA2 /ZY3AnXIoZw7iOyTrk/Zqxtbw7ktu5DqzXdwSH8Vw17Ki2yK4JKyVNRCwLledmPXva7t BFo2i1GhwQqfJYGeCH/s8odP2SaVEUmH8HvtnSGgRlBtTZW2O6PpD/HAyMWorfqtYHP3 ZgeA== 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=0uRZdQqGyfMzOyFxwjDbbt7X+G7L7qi1fZR20AAZ1MU=; b=MxoPUDwfH6fpiF6Mdt97BJyuxZEWEJs5SEXe6KHWh5J3NFs4Tz05fdpDHb8kzpaz6y Ei+5WeO3xO42bx8MSzszGKiisL1cFnZO0yHiBBgoqg9tlBSJNAfkMLPYisDQAlBDN8ew eZdhoftEjl5cJhwTWXVG3ntS8DV7l81ksVN5MY3LEtwvU/6lrZpRTq/G6EhTLKsOz87N DHrP1h15+wOvt/ZygEqDw8SbOVg36WtsA9Z7xeBq34Jnd9udcrFUmxggXPwAbBe+Twk9 NKf108bxj1oY5Ix3IjjaRNxMc9oO9/jDkCoORU2d5YbgQJUq9XWLb/vUE8GEgJtsLmfk wDsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eq8HXcPF; 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 hh8-20020a170906a94800b006b29d8e3865si4524291ejb.215.2022.03.11.00.40.01; Fri, 11 Mar 2022 00:40:26 -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=eq8HXcPF; 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 S243303AbiCJOV6 (ORCPT + 99 others); Thu, 10 Mar 2022 09:21:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243841AbiCJOSZ (ORCPT ); Thu, 10 Mar 2022 09:18:25 -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 D37F6158DA5; Thu, 10 Mar 2022 06:14:56 -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 97626B8267F; Thu, 10 Mar 2022 14:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDF44C340E8; Thu, 10 Mar 2022 14:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921688; bh=MXzJc6tTNRtXvc8e7ywF9mKWYhF9eLEQl9GE1I8MWLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eq8HXcPFHUT8A1hLKG4555UVTkqzGECbxSjiPVm5NkcNQnF5LEWuRoycvcSE8QqQa 8hHY+MNol3fp06SnPYSE9Bz1Vorgcp4ArEvgbGq3TpNmiq71WlSPnf3UcKCx9VshCK gZs+sk/9yCgiuCfliPKsf2d0z954PPLQYeuQhVt8= 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.9 20/38] ARM: early traps initialisation Date: Thu, 10 Mar 2022 15:13:33 +0100 Message-Id: <20220310140808.728100502@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140808.136149678@linuxfoundation.org> References: <20220310140808.136149678@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 @@ -819,10 +819,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; @@ -843,17 +855,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