From patchwork Thu May 20 12:43:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 12270133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAA7CC43461 for ; Thu, 20 May 2021 12:46:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7AED8611AD for ; Thu, 20 May 2021 12:46:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AED8611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=KUMDjHx6bGsFD5q2ziqvzS0GDUpDhDZjum+3vuTfKEo=; b=T7bLfthEJ2yFOmjDeQxMjxV5GM f5/D8XyPVl3hKHd9MOD+2GvSaupdGth5TnA246hSnJn/fiE92ofQvWak/N/gPCuVwyfETgqUXuMJG EF4DipyYhei0R693+/luUiss42X1PNJfyM6U/PlVca20v9xyOrjLlihBiuAF7rs1U2KDOoVeG/o8T y93hyav6xQdZgOwxehdtyYw5QnP1O6/SvtqkO6C68ymc6O947eIMbP5XwnNS1WyRrXuPbfQWpN7LL 3/XcWNbpSk6Llw5cqioziudv/7mOYh5wINy4WgNwIFVgWpCahk6MpI4zeRlUYsXy1KF5CI3IW5n/j OD4ceomA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lji2r-000uA2-Sc; Thu, 20 May 2021 12:44:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lji2B-000txz-3T for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 12:44:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:From:Subject: Mime-Version:Message-Id:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=CTkce2NnUBAYxtLvxeH/nsW78Xn1d+UZtwvdyKO4rhc=; b=isiezhS7iVXLx1UISTOujkO+TM Q+XJi8romxNzZSsxZ1sMZrnjifWpMxRkGi/WX3Xu3wNZzzPU8NB4Lbiyk+LxgAJsU+7WlBAlvLpd6 yXzPOlAGsEu+1TRtGEv94A6xBLM3S3Shv/WMZOeWsEAZUTTSLSDgYeQM9B9I9ma+Z8mKVQLw18yNT sFWqbb93jtnhPe9FiZPDsEYnrpYVa1cDHLAHRteLLQJeZt0B/QlPIdsD/1tswxG724C2m/I5c59K8 RkIbnx75MVJ0til2LfxLvFgiXahoIndPkdf0tG2dffX2QwpkfLYc175o6nX9BQUHyQHTYpfQIb0Fq zgr96t5g==; Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lji28-00GKbf-76 for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 12:44:13 +0000 Received: by mail-qt1-x84a.google.com with SMTP id d7-20020ac811870000b02901e65f85117bso12160250qtj.18 for ; Thu, 20 May 2021 05:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=CTkce2NnUBAYxtLvxeH/nsW78Xn1d+UZtwvdyKO4rhc=; b=JcETK2+PlwFcf8MHWSGdtMhMmpgursCoG5VLKEt0VEoeeAMiyuc0zFmMHhDJ1snRbx drEP+j2OF6AGo4HBVqwU5UsNmgIC2GJpnY+/tMLuc8ZWZP1DGBjS2ABjmJPNH9pvIu4z +A9SPIROLy4FhBdO+1lHeRRABHpZJqEVk0b/3l0FYwwmTgeXa6OcuCLvbXsIltIi1cdH TyNKwCH+oGTlCWUTwgpt6Xj+9sSUxtrO0L5qqiTYMKm7BP72AUvTQO4qAI4LSqXKW+5i Jx4vY4e6VGkxg3lkO3tJsQJmDiYC1Q80YdbJnPKui21b9ev/n7TysbMN2um84LyYJmr+ 1zyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=CTkce2NnUBAYxtLvxeH/nsW78Xn1d+UZtwvdyKO4rhc=; b=Gjx9nhhVLaZ6Uqg/j3KkpSTM3KqdXyoekb7hbW4ejvRaES7mfI7HWHp26EuyJbazs5 h9C8jzX/4g+o8FiCJYt5MHdkLidlELNBO92K/U7GWPc2CKvWf5wxcErbn1x1U2VBNCx4 9KXLa0eKdwGNVW2giKnprXdMTiP9pbKPfZMKQUu33oWC/7XBRXNNuX5HgTEuWktUetRB Li9AWP8eWLOqEOm88h2PDPXQXR5p3Dtu5rLA6i6Trt8yL2xMUbZxt2rj5S9709JMYBmV bqEeuk1ezIj7pKNlHGVdi1w13CRijaQCD9fpnsrgGPM6qTSkbVhajyfrYN7OvgcWN5rf 1unQ== X-Gm-Message-State: AOAM533JIW5J5Jda325MZzCKCcZF73NlZcvL3NaT9SRWfurcmme5IuDI RS3Fh5+gqr31vT0Jq/IiJKGNudGMRDkSlrn1uh+R7NiKcAXBiu3qsNso5o3aPE75Q1VFMgv1SPC 4FJUC7cufwUzXKSyUoiwIs9lmUq1Z6h3Fm+HREi4ZqAmneGq3b0MVRoRaOp2mxbaBk0tv1QaN5X Eh+A== X-Google-Smtp-Source: ABdhPJyfBlEM5zHfxHq7DAKUrSLVKAk8Iqv5xZMyCMZCi+/2+NiJRgd2+UYj3IKvSH8MPigEvwyhG7vC4A== X-Received: from tabba.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:482]) (user=tabba job=sendgmr) by 2002:a05:6214:288:: with SMTP id l8mr5220656qvv.21.1621514648179; Thu, 20 May 2021 05:44:08 -0700 (PDT) Date: Thu, 20 May 2021 13:43:48 +0100 Message-Id: <20210520124406.2731873-1-tabba@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog Subject: [PATCH v3 00/18] Tidy up cache.S From: Fuad Tabba To: linux-arm-kernel@lists.infradead.org Cc: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, maz@kernel.org, ardb@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, robin.murphy@arm.com, tabba@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_054412_281789_7417E01A X-CRM114-Status: GOOD ( 17.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Changes since v2 [1]: - Brought in Mark's patches that add conditional cache fixups, only generating an extable entry if a label is provided [2]. NOTE: The patches missed some of the code comments to reflect the changes. I took the liberty of fixing the comments in Mark's patch. - Modified the user_alt macro to make the fixup label optional, in the same way as Mark's patches [2], to avoid code duplication later in the series. - Tidied up the new cache flush (clean/invalidate) macro by removing code duplication, conditional variables/labels. Moved the ttbr manipulation, fixup handler, and rets inline in __flush_cache_user_range. (Mark) - Fixed comments and commit messages. (Mark) Changes since v1 [3]: - Apply ARM64_WORKAROUND_CLEAN_CACHE errata to swsusp_arch_suspend_exit (Mark) - Remove toggling of uaccess from the newly created cache flush (clean/invalidate) macro and leave it up to the caller (Robin) - Fix renaming of cache maintenance functions (Ard, Mark) - Fix comment on maintenance operations in machine_kexec_post_load (Ard) - Fix commit msg comments to clarify some of the changes and outline potential performance impact (Mark) - Fix code comments that refer to flush_icache_range when the intended function is __flush_icache_range As has been noted before [4], the code in cache.S isn't very tidy. Some of its functions accept address ranges by start and size, whereas others with similar names do so by start and end. This has resulted in at least one bug [5]. Moreover, invalidate_icache_range and __flush_icache_range toggle uaccess, which isn't necessary because they work on the kernel linear map [6]. This patch series attempts to fix these issues, as well as tidy up the code in general to reduce ambiguity and make it consistent with Arm terminology and with the functions' actual operations. No functional change intended in this series. However, there might be a performance impact due to the reduced number of instructions in general. This series is based on v5.13-rc1. You can find the applied series here [7]. Cheers, /fuad [1] https://lore.kernel.org/linux-arm-kernel/20210517075124.152151-1-tabba@google.com/ [2] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=arm64/cleanups/cache [3] https://lore.kernel.org/linux-arm-kernel/20210511144252.3779113-1-tabba@google.com/T/ [4] https://lore.kernel.org/linux-arch/20200511075115.GA16134@willie-the-truck/ [5] https://lore.kernel.org/linux-arch/20200510075510.987823-3-hch@lst.de/ [6] https://lore.kernel.org/linux-arch/20200511110014.lb9PEahJ4hVOYrbwIb_qUHXyNy9KQzNFdb_I3YlzY6A@z/ [7] https://android-kvm.googlesource.com/linux/+/refs/heads/tabba/fixcache-5.13 Fuad Tabba (16): arm64: Apply errata to swsusp_arch_suspend_exit arm64: assembler: user_alt label optional arm64: Do not enable uaccess for flush_icache_range arm64: Do not enable uaccess for invalidate_icache_range arm64: Downgrade flush_icache_range to invalidate arm64: Move documentation of dcache_by_line_op arm64: Fix comments to refer to correct function __flush_icache_range arm64: __inval_dcache_area to take end parameter instead of size arm64: dcache_by_line_op to take end parameter instead of size arm64: __flush_dcache_area to take end parameter instead of size arm64: __clean_dcache_area_poc to take end parameter instead of size arm64: __clean_dcache_area_pop to take end parameter instead of size arm64: __clean_dcache_area_pou to take end parameter instead of size arm64: sync_icache_aliases to take end parameter instead of size arm64: Fix cache maintenance function comments arm64: Rename arm64-internal cache maintenance functions Mark Rutland (2): arm64: assembler: replace `kaddr` with `addr` arm64: assembler: add conditional cache fixups arch/arm64/include/asm/alternative-macros.h | 9 +- arch/arm64/include/asm/arch_gicv3.h | 3 +- arch/arm64/include/asm/assembler.h | 80 ++++++---- arch/arm64/include/asm/cacheflush.h | 69 +++++---- arch/arm64/include/asm/efi.h | 2 +- arch/arm64/include/asm/kvm_mmu.h | 7 +- arch/arm64/kernel/alternative.c | 2 +- arch/arm64/kernel/efi-entry.S | 9 +- arch/arm64/kernel/head.S | 13 +- arch/arm64/kernel/hibernate-asm.S | 7 +- arch/arm64/kernel/hibernate.c | 20 ++- arch/arm64/kernel/idreg-override.c | 3 +- arch/arm64/kernel/image-vars.h | 2 +- arch/arm64/kernel/insn.c | 2 +- arch/arm64/kernel/kaslr.c | 12 +- arch/arm64/kernel/machine_kexec.c | 30 ++-- arch/arm64/kernel/probes/uprobes.c | 2 +- arch/arm64/kernel/smp.c | 8 +- arch/arm64/kernel/smp_spin_table.c | 7 +- arch/arm64/kernel/sys_compat.c | 2 +- arch/arm64/kvm/arm.c | 2 +- arch/arm64/kvm/hyp/nvhe/cache.S | 4 +- arch/arm64/kvm/hyp/nvhe/setup.c | 3 +- arch/arm64/kvm/hyp/nvhe/tlb.c | 2 +- arch/arm64/kvm/hyp/pgtable.c | 13 +- arch/arm64/lib/uaccess_flushcache.c | 4 +- arch/arm64/mm/cache.S | 163 +++++++++++--------- arch/arm64/mm/flush.c | 29 ++-- 28 files changed, 294 insertions(+), 215 deletions(-) base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5