Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211009pxb; Wed, 6 Apr 2022 11:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFHtQMtzvS5QalEEUhbgTQcCMdTkhGVcjVmw1oukOgO2TfF2Qh0rQCtTpYQFMUvG5v4Q3p X-Received: by 2002:a17:903:2d1:b0:156:7ceb:b56f with SMTP id s17-20020a17090302d100b001567cebb56fmr10101372plk.11.1649269529191; Wed, 06 Apr 2022 11:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269529; cv=none; d=google.com; s=arc-20160816; b=AtTktb5SXvsxn7JYkWXa32ou7czMkAB/yW+MNFKmgOj8qpMlBUcd+F69oahZW03mgt Wzpt4qxau8w3FwOGpBpLJBPiSYbLf3H+NdElOIZt+HBZ4ImQxfLD1PNr3rIPMZpTQlPJ nX5B7Fl8BMta4b3Y48J7maI0x9Pae7Um0W4dEaQ9cLU6YKIavQwRnkm42eZq/jW71NFI sftZTJ+eLNR2iTD3oGIEJ8FW9kgLHx1OhQSJEoHyrXkHVuYmWuHdv1upJMSSnIgytK7T tHaeSMH9QnAp0hVPBHLEmGELnIRRNFYXpFRTxM7hAxVblpQCHqjQ0XHN884FLzdUW/c6 EP9g== 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=ff4DJ3lVL3WYE584Glbs7+/mkZJAInzaqQfKlPsgD58=; b=k9htDP9vjosBphNg8j6MDCT8hZ6r+GnYSLiM1j3aySPzvfB2WsRnoaCED6B6FZ7fBD tOYl3Wn/qHDaUs26Kw3zYarnmCMf2ZRt2Id2xa5k33s07sQKzOLoNfusNXruyz3NVaLC VWaTdpyqiQe/IHT+gyk8g/aZA71llmsmK3Gpqxhu8edXatpwPSKRbfwRpxDVGjsdaRch SfmX0INyZLg7cZoIDzeTgqUSlFMmJ7IPIx3VapICn0HEJ20S+zgAM+K7mNZaP7/unbIt MqvnIuYYey5c2EU68vbqB12GHfKdZh5uwUz0KKTAw/fNxDyZj6tSuC7OE069B98+yCXS xMlQ== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t18-20020a656092000000b003823f33cdd2si17384424pgu.209.2022.04.06.11.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D29921B418; Wed, 6 Apr 2022 11:08:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233917AbiDFSKN (ORCPT + 99 others); Wed, 6 Apr 2022 14:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240526AbiDFSIF (ORCPT ); Wed, 6 Apr 2022 14:08:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8718517008E; Wed, 6 Apr 2022 09:46:25 -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 6E55012FC; Wed, 6 Apr 2022 09:46:25 -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 C14313F73B; Wed, 6 Apr 2022 09:46:24 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Morse , Catalin Marinas Subject: [stable:PATCH v4.9.309 26/43] arm64: entry: Make the trampoline cleanup optional Date: Wed, 6 Apr 2022 17:45:29 +0100 Message-Id: <20220406164546.1888528-26-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406164546.1888528-1-james.morse@arm.com> References: <0220406164217.1888053-1-james.morse@arm.com> <20220406164546.1888528-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 0414b0494dd3..160a3131a190 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 @@ -934,7 +938,7 @@ __ni_sys_trace: #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