Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211616pxb; Wed, 6 Apr 2022 11:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaRTAOIGamRsZreLQ++brkUbvlwzn3a8dCuqK+Xu4Y2GQTHTggo98o82unX4BkwtRorSML X-Received: by 2002:a17:902:d505:b0:154:76c2:f7bb with SMTP id b5-20020a170902d50500b0015476c2f7bbmr9837411plg.83.1649269577303; Wed, 06 Apr 2022 11:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269577; cv=none; d=google.com; s=arc-20160816; b=wwAbqc7bJ87qtbf2c9L7ta8nrGkaFgwiIXF0LdBKdv8m56bnBPjSS6sRg8LqKpHrQx 9zb9++llUwncR3HTWdLli9pgHmw1VYSoX6JuZ7FrfrpTUEO7fCxVjFxb+lRRkY62j0QP 12m8SOYiz6yBhoqzTmlu69hG8Ql/f/rabntRJURJkXAp3qnNya3oLsrvHsfgJSMngfqH 6A/6FUreRPvtmjEZmyteVussI1k3WBPKF8lQkV0qwgG0F+tG4XgTmgp3RNDFtf/uoj6t FPhLZeRsUgBnA3A7hszIukYJiriJUISUN4lOh3kaYqU9X4Z1EkaVEIJldbImPV8N2l5r Mdnw== 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=tmvz+l6C8zP/S9WtqLgTD9Qh3HYLA3/VsggPsLlACpQ=; b=Af1o7SoWjqZZJSm4uZtBwaiqQpZx4aerSlhuHbYt4viwboLagiWtMxLD6oqJZCt3KU sfDrOHcDvJ7C8R6rzayYjPKyQP2nSqIPaj94uDEXJf5DrGdxpaM/xHbAIsqEE2xF+tRz WoowxeYGA1B309+ZAowj18pvz2l1/tli3rjJVR77cjUCrB3THpVe8wEYZ8j8z3Bm1GKu 9sHdr01Nw+PYmfRMM7JsMPNLRYVaHVYuYzmCYA/mwrlH2IPwHveTi0nTq79DYvAUD+qN ZKObUj1+M0H9UujLUO/qMQkyaCxALaldHNGDgKUl+MliqjrhhFLkSmEVR8GexYOjh5Jn lJGg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u15-20020a170903124f00b00153b2d164fasi12450002plh.258.2022.04.06.11.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:26:17 -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; 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=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 7C95224B0B1; Wed, 6 Apr 2022 11:09:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240371AbiDFSKm (ORCPT + 99 others); Wed, 6 Apr 2022 14:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239824AbiDFSIK (ORCPT ); Wed, 6 Apr 2022 14:08:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C67C7197533; Wed, 6 Apr 2022 09:46:30 -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 AD52C23A; Wed, 6 Apr 2022 09:46:30 -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 0C2243F73B; Wed, 6 Apr 2022 09:46:29 -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 32/43] arm64: entry: Make the kpti trampoline's kpti sequence optional Date: Wed, 6 Apr 2022 17:45:35 +0100 Message-Id: <20220406164546.1888528-32-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 c47e4d04ba0f1ea17353d85d45f611277507e07a upstream. Spectre-BHB needs to add sequences to the vectors. Having one global set of vectors is a problem for big/little systems where the sequence is costly on cpus that are not vulnerable. Making the vectors per-cpu in the style of KVM's bh_harden_hyp_vecs requires the vectors to be generated by macros. Make the kpti re-mapping of the kernel optional, so the macros can be used without kpti. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 9132400d6a9d..6e1d02d87d45 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -921,9 +921,10 @@ __ni_sys_trace: sub \dst, \dst, PAGE_SIZE .endm - .macro tramp_ventry, vector_start, regsize + .macro tramp_ventry, vector_start, regsize, kpti .align 7 1: + .if \kpti == 1 .if \regsize == 64 msr tpidrro_el0, x30 // Restored in kernel_ventry .endif @@ -945,8 +946,12 @@ __ni_sys_trace: #endif prfm plil1strm, [x30, #(1b - \vector_start)] msr vbar_el1, x30 + isb + .else + ldr x30, =vectors + .endif // \kpti == 1 + add x30, x30, #(1b - \vector_start + 4) - isb ret .org 1b + 128 // Did we overflow the ventry slot? .endm @@ -963,15 +968,15 @@ __ni_sys_trace: eret .endm - .macro generate_tramp_vector + .macro generate_tramp_vector, kpti .Lvector_start\@: .space 0x400 .rept 4 - tramp_ventry .Lvector_start\@, 64 + tramp_ventry .Lvector_start\@, 64, \kpti .endr .rept 4 - tramp_ventry .Lvector_start\@, 32 + tramp_ventry .Lvector_start\@, 32, \kpti .endr .endm @@ -982,7 +987,7 @@ __ni_sys_trace: .pushsection ".entry.tramp.text", "ax" .align 11 ENTRY(tramp_vectors) - generate_tramp_vector + generate_tramp_vector kpti=1 END(tramp_vectors) ENTRY(tramp_exit_native) -- 2.30.2