Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2272225pxp; Mon, 21 Mar 2022 15:32:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNOBBInisW+p3UvYmICGr4EqIkHiLmL5oyH73uH0ZaPN1BOBnuwJDnriBAttuZSKVHKsuI X-Received: by 2002:a05:6a02:182:b0:374:5a57:cbf9 with SMTP id bj2-20020a056a02018200b003745a57cbf9mr19420615pgb.616.1647901920577; Mon, 21 Mar 2022 15:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901920; cv=none; d=google.com; s=arc-20160816; b=kRbAuckcJJLQA5nJCEublJqpNSh/jCSqWJ+Q22t41cpEbC6mon8bIJ6Cmxlxf9ka3g 5KEtbBgKK8Og/HrTwlub4PnWyv3TvRVPaEXtD96ryt6dHPCYQ+piyvac+LK/6VqLiYb2 ebbZNm+a+VqnmkZxICIGpmT3aG9ztqeVhuhAbsEZyiOAJ/ncQ+eLVkkM6IK3pqKk7W04 8GcCNxlhQAapF6fgk38ujbvRVFJh7jCcjYNrNjIgCQg9WQwTHIOhmxDYRZ+XQseZBpzQ /Vpn48bS8iqzhgHTGSE6kwDBmZI/HWN79XmqYJyj3a1VjH/1ayjxBHwv3BynNmjxZRAZ SeQw== 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=Pnj3YpYSMs3JUE69GtsNkTGlWclZT09Cm67jRW05SOo=; b=xf4UzQ0nCGVRxg8hkSzcqUTdojts/fsahANtHbm98vIIkIA5JOBtFGtS3fEcn1+4bU TrlaqsKQ87A2HViDhiweObC7fnq9vRtMMVKOWBaqiUG/LNaSALGCWaeZN/ZPCB7PspRZ YG6t0ER9n2xrzbLwA5QbrM2Op1ekGL7Bs5PekF1YLkjYidogDG7JTVrf2vuwNvhB9BFM LwAx49XPIVV0laNxEgS1dbeFSNzdgTWJ3dfltWAv1DxFTC6Nghg1r91E43zu1Wwfhx8c coDwR63NDEK39DMjZQlLzgHBg6Fp14v/SzjchhWo65HKn6vGvprnhy49U3CzwxxivD5B wm0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zCoSJLGs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c10-20020a056a00248a00b004fa3a8e00a6si6300182pfv.349.2022.03.21.15.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:32:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zCoSJLGs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E4AB3CCCC3; Mon, 21 Mar 2022 14:45:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348710AbiCUODt (ORCPT + 99 others); Mon, 21 Mar 2022 10:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348626AbiCUN6H (ORCPT ); Mon, 21 Mar 2022 09:58:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1083917869F; Mon, 21 Mar 2022 06:55:58 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 574D1B816D2; Mon, 21 Mar 2022 13:55:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 854B5C340E8; Mon, 21 Mar 2022 13:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647870948; bh=1cGeZM7lyVNRB7mTnf78tGm3xMRJ021aoldxZLHfTog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zCoSJLGsKDtOIrE5ZuWASGtgwkK3dcapgXRy4xUS7s+meaLcLgkBYe0Mz2eMgtHgz 7A/l8+uzGgn6F28EG44atnhqqKsagvnlLYAJQo0qxZrYwrcLRDyZWpGccmjizgn47v D7nurBGDjxj5AkuA+kOAguHmyYwsWz84nZ9MSItE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "Russell King (Oracle)" , Catalin Marinas , James Morse Subject: [PATCH 4.19 27/57] arm64: entry: Make the trampoline cleanup optional Date: Mon, 21 Mar 2022 14:52:08 +0100 Message-Id: <20220321133222.779722505@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: James Morse 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 Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -72,16 +72,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 @@ -983,7 +987,7 @@ alternative_insn isb, nop, ARM64_WORKARO #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?