Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2271725pxp; Mon, 21 Mar 2022 15:31:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAeipkQF6uf4XHfDXaQndxQCl+paMMcJ/VP1MI2fshap0M9zasEDq3JBlJ4ekXdqVPElDh X-Received: by 2002:a17:90b:1801:b0:1bf:a1ab:7fec with SMTP id lw1-20020a17090b180100b001bfa1ab7fecmr1380446pjb.201.1647901875677; Mon, 21 Mar 2022 15:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901875; cv=none; d=google.com; s=arc-20160816; b=GKZBJ0hczaPJIAzNq1WTyaPP1h1iLnRUDHhIgRGPdhwlLialenH06f+PmUNP6LKVso 5zXEtW5kDT5DtTF5tL/zQqXg0C3b5f+l4fHZyy2ylqlhMNQsXlOh+q9dvqg1/gdhtk7H cPGhOTKo81g/nDKaXR6QtuHXHJlMdCZIrl1ls3H8RCDPxpBV1aHL7aI38C1X8DhwDeIX 5PPDUaerJoPrK8ZAroSQUK5OjZlEKYxxWwZlh4TqgvOtA9j5Lcn9BbTL74rMGRln3q9T WCEl2GLFXwGglZKUsdvZEli2twHtYSLdQ+82NNp4V4OgCxcpRTUwzEVOFb8PTiUJiyGe Ro2Q== 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=v629oZ5vYUgUoy/iK7blR38ujSNj7ays2rsQ/ZCYw7c=; b=Asl757kLVQv6qObOZKSwg2swCMdTtKMToUQd5Z/LV1mmJSSVnrYxXe62ilPE28AYBH Qh0Vmyo/Flb0Y11QcgcJy7lg4P3n8aTI/99tsvLo6Pp0Gh7tohPYyFusBH2tcztAkeWN 6tty5ryPP2E8rYyv4cK06XpqxNdVw2remxakU15rGfyXJQrtZuIqqDh3F4tQEaVIwFSU uNFMu8PuuwQCLpLoACpz2mTfYJ5nMX+Jp+LyHIu3gZ9VLy1uxYoGhtohBg7WEALJ7W35 mo4OjWRMPfsDLk8gyQim5AUX1gpiFLy0zoAwDpMacFBCOavmh2Nn3G0A+q0/zEkIgutm gwYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G8yBhR6o; 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 a1-20020a656041000000b003822d7cda53si11246410pgp.519.2022.03.21.15.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:31:15 -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=G8yBhR6o; 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 6254492329; Mon, 21 Mar 2022 14:45:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348777AbiCUOC5 (ORCPT + 99 others); Mon, 21 Mar 2022 10:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348978AbiCUN6p (ORCPT ); Mon, 21 Mar 2022 09:58:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 814582251A; Mon, 21 Mar 2022 06:56:56 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 0BE2C6126A; Mon, 21 Mar 2022 13:56:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F813C340E8; Mon, 21 Mar 2022 13:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871015; bh=ZTei38FhRF4iI1M4iWEEN8aEVK/yf7EhkkEDNtbJyZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8yBhR6oCFLsq1fxXFCy6VvD/KMREc5NCLSNxX6khq8F15XPg451bPvrqkDTzkXhO AHpTi/StkPBSIix1gZJTjRb077gaH2c8Sujaxc0lacBcW37NPPe69ryhlfQtTWUl3v uSKvnfR+w8YrNWxF9ESI8XXx0FV8tbilhwB7OpfQ= 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 33/57] arm64: entry: Make the kpti trampolines kpti sequence optional Date: Mon, 21 Mar 2022 14:52:14 +0100 Message-Id: <20220321133222.954903592@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 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 Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -970,9 +970,10 @@ alternative_else_nop_endif 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 @@ -994,8 +995,12 @@ alternative_insn isb, nop, ARM64_WORKARO #endif prfm plil1strm, [x30, #(1b - \vector_start)] msr vbar_el1, x30 - add x30, x30, #(1b - \vector_start + 4) isb + .else + ldr x30, =vectors + .endif // \kpti == 1 + + add x30, x30, #(1b - \vector_start + 4) ret .org 1b + 128 // Did we overflow the ventry slot? .endm @@ -1012,15 +1017,15 @@ alternative_insn isb, nop, ARM64_WORKARO 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 @@ -1031,7 +1036,7 @@ alternative_insn isb, nop, ARM64_WORKARO .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)