Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2042996pxb; Sat, 2 Apr 2022 13:01:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUR7ADof0gup+VackvGRuzMwxHG8en2ZHFctmiMCI14bc56JZ25os3PYmlEEZPk7ya6e11 X-Received: by 2002:a17:906:6a0b:b0:6e0:c59:f387 with SMTP id qw11-20020a1709066a0b00b006e00c59f387mr4811748ejc.732.1648929713833; Sat, 02 Apr 2022 13:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648929713; cv=none; d=google.com; s=arc-20160816; b=0Xc8D2NCGlaaE0KWfCYAbZRgfJyywDpUmmGe2GVmxSIhNrhMp/DVc3ZUYhoTqdhCqV 3fymYDQjjU4l6TN83YQMZyiBeR8+URZwCqHx/QZwsOdB5RipT7JcStJ1/gsHuVEl/0bg Ur4yyaKgLEe9UvqWHUQw69rgBRikXpnQvK9bt27mja2c25E2gLsXBoe+7Eq3f0ox/6Am 16Idw7jivud1SCNvsXvSitdD3iU9OnqGeEVbh29TbJLD2a7QY7fzixnLBxSYXIZ1kYOi FbCXrHEkORMmhxeREbZvB0shM0QuPaYMtjUZ3f/SbLihADHUR0rlepdCi3aakb/WC+o8 /6IA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=h4ZLbuRsMJL+9lq2NzVXu579fmpQhYOMicBDJ5s0wgg=; b=CAjMKPsdczmEuzBB6tK+BHBfgtK22CK7IXrbmUurN2UfApC1kLDmj3v6KEOFvx6DQA 7XTr/pzUInfJnVKE5r+eucbG12WyNhREbqSH+ABKiK64ULr1zCxUa7JlptXDvlLwUC2a dmsq6SbhP7vAjNj0NL0Pg0YpYqgmvAHDzctl+0nJJF+CDYQ6regc2XG22SYnnWDStQmb y/kT1PubWlc6sfEQ7HCCOuDlSBS6j2BCHTBQXN7+jJejJM+4Q8se3s9ASrcufGy/dzrn /PEXdEbm9q9k8CjSWdBcgXEp9JXHCkYC1d1hGSiBy3fLtcHIKE/UH+qzwo+v+LcFt6Ui kJpw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kz11-20020a17090777cb00b006df76385ef4si3906249ejc.916.2022.04.02.13.01.28; Sat, 02 Apr 2022 13:01:53 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235540AbiCaSg4 (ORCPT + 99 others); Thu, 31 Mar 2022 14:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234895AbiCaSgZ (ORCPT ); Thu, 31 Mar 2022 14:36:25 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D7B61F0820; Thu, 31 Mar 2022 11:34:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10BB8139F; Thu, 31 Mar 2022 11:34:38 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 674FB3F718; Thu, 31 Mar 2022 11:34:37 -0700 (PDT) From: James Morse To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.14.274 10/27] arm64: entry: Make the trampoline cleanup optional Date: Thu, 31 Mar 2022 19:33:43 +0100 Message-Id: <20220331183400.73183-11-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331183400.73183-1-james.morse@arm.com> References: <20220331183400.73183-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,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 commit d739da1694a0eaef0358a42b76904b611539b77b upstream. Subsequent patches will add additional sets of vectors that use the same tricks as the kpti vectors to reach the full-fat vectors. The full-fat vectors contain some cleanup for kpti that is patched in by alternatives when kpti is in use. Once there are additional vectors, the cleanup will be needed in more cases. But on big/little systems, the cleanup would be harmful if no trampoline vector were in use. Instead of forcing CPUs that don't need a trampoline vector to use one, make the trampoline cleanup optional. Entry at the top of the vectors will skip the cleanup. The trampoline vectors can then skip the first instruction, triggering the cleanup to run. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 81069ad43a5e..1211e0da5476 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -76,16 +76,20 @@ .align 7 .Lventry_start\@: #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \el == 0 + /* + * This must be the first instruction of the EL0 vector entries. It is + * skipped by the trampoline vectors, to trigger the cleanup. + */ + b .Lskip_tramp_vectors_cleanup\@ .if \regsize == 64 mrs x30, tpidrro_el0 msr tpidrro_el0, xzr .else mov x30, xzr .endif +.Lskip_tramp_vectors_cleanup\@: .endif -alternative_else_nop_endif #endif sub sp, sp, #S_FRAME_SIZE @@ -1035,7 +1039,7 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 #endif prfm plil1strm, [x30, #(1b - tramp_vectors)] msr vbar_el1, x30 - add x30, x30, #(1b - tramp_vectors) + add x30, x30, #(1b - tramp_vectors + 4) isb ret .org 1b + 128 // Did we overflow the ventry slot? -- 2.30.2