Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp581027pxp; Wed, 9 Mar 2022 08:32:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw044OWiBOOtMgMDLHhENuBc80CRxjd49sBiBE5Ot+uxRRnTNdWTJnIoYxm4ojgYNPAPaEQ X-Received: by 2002:a17:907:7685:b0:6db:67:7218 with SMTP id jv5-20020a170907768500b006db00677218mr522744ejc.461.1646843546404; Wed, 09 Mar 2022 08:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646843546; cv=none; d=google.com; s=arc-20160816; b=sqvDnCGyX84jPvpVIfa1OPIkSCaeQkKeO5cKeaT6ZkOtNRcbXHumANRszXXKpYSymV ZSHBS16hUPTspLJns+nVK7mnt5sq2tCP7epI++GrokU8h0yiqKspPXhaw23n44RNCjNC c9ZcpGcjuVTd1RehjeK9rqmczcLimH/a09CqkJ1Lq6IuzBt7JN2yOy+iJM4sXxpqjVXk xXvRZvsga7yhT4XS7iF2HMSLcb9Lki4fiKuXxVlFMQEZim3LGwz0Mnowvcw0alC4yzjW kLJ7PgdGufOtp46fU0zs+Mi2QtToinRGJK9hhIFYI6E4RAkZuG2hOjO+0f02RmVOEi4Y pjbA== 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=ShdwNqRch8tBliBLysDq1wlBgWHEMPj8qkDeF021oJrLuwzmY3k9+i/Dpb7XowK87o ayYFHSIBo7+p/S5ycNFE8BwQGsDjyYP6MN9rUrpfxQhdDLXn5pAaQ5wmnzmc+wDVKJaZ sLT/El0Im3pdx1I5SoVNqZ7PoevGkUh5q/ZcSOJbdti1NfJq0Vrvm17NvAbjBReY/WQY 49P7kL4PaUtalsg8ht+yoOAMmu53DJAw7E6D5K0DDK277ghtDUx2tJkBwdiUz56yd6qz hgQNnDFTGd6athpwIe28N/qh0G2GsYEmWwlaNf3bwWaMXy+PKxQl8j9/uO4Dtt/vHuTq 4msA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d9LQhLPB; 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 nd32-20020a17090762a000b006d887ed13fcsi1591495ejc.296.2022.03.09.08.31.45; Wed, 09 Mar 2022 08:32: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=d9LQhLPB; 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 S234300AbiCIQEE (ORCPT + 99 others); Wed, 9 Mar 2022 11:04:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234289AbiCIQC6 (ORCPT ); Wed, 9 Mar 2022 11:02:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F874175865; Wed, 9 Mar 2022 08:01:58 -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 0EAC461486; Wed, 9 Mar 2022 16:01:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E3BAC340E8; Wed, 9 Mar 2022 16:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646841717; bh=MXzJc6tTNRtXvc8e7ywF9mKWYhF9eLEQl9GE1I8MWLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9LQhLPBLQJZI/0skyU71JOecA/Zz9XRs/N/nA4HqqweNH7zXfdarkvU0/kQOznwd 8ht9rnqWUhoo865oPA6wVLvI8HSH5xB22kNAH+ayvi+ROSjJtJNfG/s3F3CpvlStdl wNq0CcK+9KnrwXohZYi04ZCg0IfbD+8v1KlG0AgM= 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/24] ARM: early traps initialisation Date: Wed, 9 Mar 2022 16:59:33 +0100 Message-Id: <20220309155856.894814595@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220309155856.295480966@linuxfoundation.org> References: <20220309155856.295480966@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