Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp582954pxp; Wed, 9 Mar 2022 08:34:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPHATPLg3YGSqaQIeBABjCBvZt0l0HnrwhfAHf4rupDlvqveZl7FIwEFx/70nSoctBDHip X-Received: by 2002:a17:907:2d22:b0:6da:91fe:15a5 with SMTP id gs34-20020a1709072d2200b006da91fe15a5mr568923ejc.448.1646843547543; Wed, 09 Mar 2022 08:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646843547; cv=none; d=google.com; s=arc-20160816; b=NEGmS8/rwm9TpPM4VMOEELEnc0Utinh+vvG1XVD8ZkXKTUZB9B65Qs86Vd7qc+LqRX 8RYB1bbM0805WKvW1Zmns3qbLKyZGJxYx3DmfsB8bx9LcE/89N9XKCoM8sF9/vaxwsB+ aRwNux/np5NbGX1WdbtbJbnhyK5ERN9FDS8FyncQ1KBfg3PFpe8R/8wyd3HHYgM4e+BZ WFdSbnTe7BD1ogT6mlK1/MQ/pKLICBNQj4HuaNAUGHrVFRYFVOfGmpQgFUz9s7PhdObE 8Mdk/jDIJjshAOXL12tG/VNbK4Tdd2plBwXaaD5DY8rafkvHj/vCKn4HzfdmaJ8gKh3l rQAQ== 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=0FNAbYoST0gNY5tp169w4WK/wUORvvYVpnV5ah9Vkrg=; b=vXescKN3jYKPWnWKyCWVHAbWsg3TN0HZSsvaiQ4CCPPJdCzTneKIupwCIpjYLnLdjr UQlKQW5LUeahwY6Xuv1YgB31trypZGLEAiDn2d336NmTXZ7zFDTnxnC1bU8ZegSPOtZN ENA9HPqmpd9nw3VZ34J/WuOjGxBQU9fv9/49IIU0pUaTG0C/fv77bw+AR5f81Zoz5enJ QRCbxNhRKgjshjti50/jId1S4Tch85YCaevLaQ1ALiQBM7yvCC2lV4jtc1zsEZt6qB93 ezzj60TwW6e6w+xABvgFWhJwCh/OoCO6HBdLw2SA68yVX3s24RbHDU5XXvGfj1Ydmfeo /pUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U9AxVsFI; 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 bu26-20020a170906a15a00b006d09dc2b438si1536776ejb.268.2022.03.09.08.31.46; Wed, 09 Mar 2022 08:32:27 -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=U9AxVsFI; 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 S234402AbiCIQEw (ORCPT + 99 others); Wed, 9 Mar 2022 11:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233372AbiCIQDQ (ORCPT ); Wed, 9 Mar 2022 11:03:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC50E17AEC5; Wed, 9 Mar 2022 08:02:17 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3170961049; Wed, 9 Mar 2022 16:02:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41A98C340E8; Wed, 9 Mar 2022 16:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646841736; bh=Yry5MStUl6kJVX6ddF24JcfhvBWe69QvcUTxAvEtDK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9AxVsFI+bbEitxPATfrk67viUhgiumWoDhRwoH5oNcs7AeVu82N2edqt+SeyjfUQ TJq7RFd7D8DzeD4p68wzRB20iOkcNDQKgVAEtympxqjHiF4t1G5tdDNeXy8NiJbtob kp4KP1yUKSVCj51JF09Nc9BazLbzuLhm7qjZFEOc= 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.14 14/18] ARM: early traps initialisation Date: Wed, 9 Mar 2022 16:59:44 +0100 Message-Id: <20220309155856.515293861@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220309155856.090281301@linuxfoundation.org> References: <20220309155856.090281301@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 @@ -820,10 +820,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; @@ -844,17 +856,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