From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BD3AC6FA82 for ; Tue, 13 Sep 2022 13:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6x0+xOo07ZYMV6K5zgTC8zqByg2KTeTZ9rrn/VBcf8c=; b=oOBcEEVRhuxEcO 2x7xOlrYm7zqmI3hiuEat+nRXzcPFd3+I7byy28d7hizzMIGZNdCew0OmkYW3TCVFDq78477QzQfH dVnaBcigzXMG9LCZgG9x2MkSmziSpy6dS/Ujm0D67JkCCWAqoF+bchZWuVpaIj4Oo2GJmG1JVaxLv nOrgoloa2v15aaXSHZI1ht6mII7lUzYUH8howfr8/ru3bi31VP2FcQrYArtz4/IPTBWnxhT4S/omp G4glmeMNwQ7sUOXf7eFDnHadjqkDM0OY1PXoG0IUiB4QQKVTJIs+G3xzaq0Byve5qKTCE3m0KdgfJ 6PwlGTob+Tp7NTaoZ0DA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY65x-00Akd7-Ao; Tue, 13 Sep 2022 13:36:57 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY65s-00AkZJ-4f for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2022 13:36:53 +0000 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 F1F6D6147A for ; Tue, 13 Sep 2022 13:36:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E29AC433D7 for ; Tue, 13 Sep 2022 13:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663076209; bh=IRm/CTKkV7TQkeEp72IdW34aXEqPxZaA668L55CoiWE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M0wL1b60LNIlCzah/44W3Vkdgm8DQo8E4qPX5QF+UROl2Fks9j0IKShbqaC+XSbe8 weZ0fMlgsvdxj32MV6oB0kxOtPQq/cSVA6moWHMz6CTjN3iyyuNoI5H9JysS123rrZ Kk+D3P1w1prMO4qO1CPV4c3G0SzSGNOFvJV3uqbPBSmIHMsPpKT0ATOvGAiizHJqGg 2Qt6Z0LN2RmqihECGywbD4fssmsV8TgxDZr7mepssoFdulcz41x0EvGEwl4kaK0chj TVee3dUZOZZmAIjL5vMaUtfPSVJP8Zcw+jsR1nyNFmwGs7SlXZn0m+48tAQEAsEgpf +QL8dH2NJLx0g== Received: by mail-lf1-f53.google.com with SMTP id s6so8930057lfo.7 for ; Tue, 13 Sep 2022 06:36:49 -0700 (PDT) X-Gm-Message-State: ACgBeo08WvnPNQgDB5EJuuEzXP1fx/vF0dOZLykH1NyU9f9r1H3+MpuD 5ZbIIg4g9j+eKs5j6gn/rSkw0upS8e1XL6rheNw= X-Google-Smtp-Source: AA6agR5vKDrvHOd8+bwGD3TQo0h3EszIdjsq+Wv25O0fb4PLcrsPWGVVkkQNkjaezfS9NhOpW6nNaiXwHfoVCSjT8t4= X-Received: by 2002:a05:6512:4024:b0:497:4db:6ad0 with SMTP id br36-20020a056512402400b0049704db6ad0mr11088190lfb.637.1663076207347; Tue, 13 Sep 2022 06:36:47 -0700 (PDT) MIME-Version: 1.0 References: <20220912162210.3626215-1-mark.rutland@arm.com> In-Reply-To: <20220912162210.3626215-1-mark.rutland@arm.com> From: Ard Biesheuvel Date: Tue, 13 Sep 2022 14:36:35 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/8] arm64: alternatives: improvements To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , james.morse@arm.com, joey.gouly@arm.com, maz@kernel.org, will@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_063652_305631_7CF42678 X-CRM114-Status: GOOD ( 31.53 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 12 Sept 2022 at 17:22, Mark Rutland wrote: > > This series reworks the arm64 alternatives code. The major aim is to > make the patching code more consistent and robust, and as a benefit we > can also make the kernel Image smaller. > > Largely, the series makes two structural changes: > > 1) Replacing cpucap static branches with equivalent alternatives. > > This helps with a number of existing pain points: > > * Each static branch has metadata in the __jump_table section, which > is not discarded after features are finalized. This wastes some > space, and slows down the patching of other static branches. > > * The static branches are patched at a different point in time from > the alternatives, so changes are not atomic. This leaves a > transient period where there could be a mismatch between the > behaviour of alternatives and static branches, which could be > problematic for some features (e.g. pseudo-NMI). > > * More (instrumentable) kernel code is executed to patch each static > branch, which can be risky when patching certain features (e.g. > irqflags management for pseudo-NMI). > > * When CONFIG_JUMP_LABEL=n, static branches are turned into a load of > a flag and a conditional branch. This means it isn't safe to use > such static branches in an alternative address space (e.g. the > NVHE/PKVM hyp code), where the generated address isn't safe to > acccess. > > Note that all supported toolchains have asm goto support, and since > commit: > > a0a12c3ed057af57 ("asm goto: eradicate CC_HAS_ASM_GOTO)" > > ... the CC_HAS_ASM_GOTO Kconfig symbol has been removed, so no > feature check is necessary, and we can always make use of asm goto. > > 2) Associating callback alternatives with a cpucap. > > This removes the need to special-case alternatives with callbacks, > making it clearer when the callbacks will be invoked, and making it > possible to add boot-time callbacks in future. > > This also makes it possible to add shared callbacks for common > operations (e.g. where the replacement consists purely of NOPs), > saving space. > > With this series applied, the resulting vmlinux is ~364KiB smaller, and > the resulting Image is 64KiB smaller (due to padding and alignment): > > | % ls -al vmlinux-* > | -rwxr-xr-x 1 mark mark 134644592 Sep 1 15:25 vmlinux-after > | -rwxr-xr-x 1 mark mark 135018072 Sep 1 15:23 vmlinux-v6.0-rc3 > | % ls -al Image-* > | -rw-r--r-- 1 mark mark 37108224 Sep 1 15:25 Image-after > | -rw-r--r-- 1 mark mark 37173760 Sep 1 15:23 Image-v6.0-rc3 > > Note: this patch does *NOT* address latent issues with noinstr safety in > the existing alternatives callbacks, which will be addressed in a > separate patch series. > > Since v1 [1]: > * Expand commit message for making alt_region const > * Remove unused macro > * Fix typos and phrasing > * Add R-b from Joey > > [1] https://lore.kernel.org/r/20220901151403.1735836-1-mark.rutland@arm.com > > Mark. > > Mark Rutland (8): > arm64: cpufeature: make cpus_have_cap() noinstr-safe > arm64: alternatives: kvm: prepare for cap changes > arm64: alternatives: proton-pack: prepare for cap changes > arm64: alternatives: hoist print out of __apply_alternatives() > arm64: alternatives: make alt_region const > arm64: alternatives: have callbacks take a cap > arm64: alternatives: add alternative_has_feature_*() > arm64: alternatives: add shared NOP callback > Reviewed-by: Ard Biesheuvel > arch/arm64/include/asm/alternative-macros.h | 59 ++++++++++++++++-- > arch/arm64/include/asm/assembler.h | 10 ++-- > arch/arm64/include/asm/cpufeature.h | 15 ++--- > arch/arm64/include/asm/kvm_mmu.h | 5 +- > arch/arm64/include/asm/lse.h | 5 +- > arch/arm64/kernel/alternative.c | 66 ++++++++++++--------- > arch/arm64/kernel/cpufeature.c | 44 ++++++-------- > arch/arm64/kernel/entry.S | 8 +-- > arch/arm64/kernel/image-vars.h | 5 +- > arch/arm64/kernel/proton-pack.c | 2 +- > arch/arm64/kvm/hyp/hyp-entry.S | 4 +- > arch/arm64/kvm/va_layout.c | 5 +- > arch/arm64/tools/cpucaps | 2 + > 13 files changed, 137 insertions(+), 93 deletions(-) > > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel