Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1835143imw; Sat, 16 Jul 2022 16:24:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1skU2tCW+PeERoqSboa/wcXFmSLpiRUgxSdCGkOJrsEGoE2N3y9OZUJA/g9v8xFcUINiTSK X-Received: by 2002:a17:907:60d1:b0:726:a049:7740 with SMTP id hv17-20020a17090760d100b00726a0497740mr20180152ejc.215.1658013891430; Sat, 16 Jul 2022 16:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658013891; cv=none; d=google.com; s=arc-20160816; b=YCH+CrG1/wJ2fJPOkpZeORFKppLnBKinghSLY0MJMgkUOMfofbBAbnZLSK/uNbLmwY IuJAVZmry08fwYF9nIvz0gyCuaUdn4X9k326g/9W2or1vOlttdXEMq8iOYC64Fjx1K08 1ZmAklyh5rHo38hlVI53ht8mI9NE1/fm+wQCq9f8Eh8+rPr+xr3Y/kLHqIJrJlYqus3q HzF6MQKbX15j/79c80YEKUWMg/emliwqtyhkEAVEdtBIsoL1B0f48oTsANOpmMQ8Yf1d WGnFMVUCnGOZpJniOn2EbNhk2qZlHroyc/KBmIFoD9RbtFZATrsBbcaain7jTxMk+Cli 2biQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=QMc5vSkp40P2d+jY5LFr071gTHJY7fEdf/VlKzlHVVI=; b=ighhOy8oTyI1FBW8oBapAOg43Xtd2Avp6wDQI28Ao4hd5l04r0klJsWqBAAxr3wFMB gK6Apos8imqWLe6GFBhfPdtwQwYQF715wDtySQ/MgAe6IDWPnrQjmlLnsNj+yfRQh/5t 9DB+zL+9GcX/zSOEUYJublE2qOz8RFCo46GcVfUuTjc6ydHwgyzCH127hz33MzekV0Jt 4fYlXaNOJQrAoGA6wVk6zZgpiLz90BIpS2mbfPrO6iR0ESrVU6ziT+7kxHBWDf7D0vxV hiLEW3PxIYleL8XvVEhWzx69klb4p2LiUbyIfxAb+ugLidt7+aGKAMDTJ0YPNsWuhpYa fNMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4IQkCHfH; dkim=neutral (no key) header.i=@linutronix.de header.b=XidcQsbk; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a50ef15000000b00436d3f2d36esi5050151eds.318.2022.07.16.16.24.26; Sat, 16 Jul 2022 16:24:51 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4IQkCHfH; dkim=neutral (no key) header.i=@linutronix.de header.b=XidcQsbk; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbiGPXTf (ORCPT + 99 others); Sat, 16 Jul 2022 19:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233206AbiGPXSf (ORCPT ); Sat, 16 Jul 2022 19:18:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2791023BD3 for ; Sat, 16 Jul 2022 16:18:05 -0700 (PDT) Message-ID: <20220716230954.470918864@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1658013479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QMc5vSkp40P2d+jY5LFr071gTHJY7fEdf/VlKzlHVVI=; b=4IQkCHfHf1/mvq1CUwZOV29fe86HDSfLQZ37SslVG18eluh8arFjSxoTnb+67JsQMGTeUE KGWIWof9HQ39phxWZnGnw2NQyOxYBzQ2NHjKfSuyo8umK2clI/NVdzRmL2I1MqQBiOPrzU EupHbjkDsrwgWL9Vfxui9R0d5Ho6xFsLirL56eUQ9NSAgN61MlzEJ/VNA40J6mySlfWNbp pULWGP1xlBMIk+kcNWy/3fGoSYlBfyDDCiDBaJyohgxynyi2+KhdfbZwjhY4vJA/rsH3PB 7DJb4CXVG3YZ0ISGjCzd9p6L7zsKoWtgprylHb/t/VOecwnteS8lXPrQNMtKhA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1658013479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QMc5vSkp40P2d+jY5LFr071gTHJY7fEdf/VlKzlHVVI=; b=XidcQsbkLQgs93ZB2oKlm16rt5MV1bnkdHJyGP+ENcy5BQohTo3yPonBQfZJP9LapjLZRh ZqlBqe7f36ewhfAw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt Subject: [patch 30/38] x86/retbleed: Add SKL call thunk References: <20220716230344.239749011@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Sun, 17 Jul 2022 01:17:58 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 Add the actual SKL call thunk for call depth accounting. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/callthunks.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- a/arch/x86/kernel/callthunks.c +++ b/arch/x86/kernel/callthunks.c @@ -52,6 +52,24 @@ struct thunk_desc { static struct thunk_desc callthunk_desc __ro_after_init; +asm ( + ".pushsection .rodata \n" + ".global skl_call_thunk_template \n" + "skl_call_thunk_template: \n" + __stringify(INCREMENT_CALL_DEPTH)" \n" + ".global skl_call_thunk_tail \n" + "skl_call_thunk_tail: \n" + ".popsection \n" +); + +extern u8 skl_call_thunk_template[]; +extern u8 skl_call_thunk_tail[]; + +#define SKL_TMPL_SIZE \ + ((unsigned int)(skl_call_thunk_tail - skl_call_thunk_template)) +#define SKL_CALLTHUNK_CODE_SIZE (SKL_TMPL_SIZE + JMP32_INSN_SIZE + INT3_INSN_SIZE) +#define SKL_CALLTHUNK_SIZE roundup_pow_of_two(SKL_CALLTHUNK_CODE_SIZE) + struct thunk_mem { void *base; unsigned int size; @@ -447,6 +465,12 @@ static __init noinline void callthunks_i { int ret; + if (cpu_feature_enabled(X86_FEATURE_CALL_DEPTH)) { + callthunk_desc.template = skl_call_thunk_template; + callthunk_desc.template_size = SKL_TMPL_SIZE; + callthunk_desc.thunk_size = SKL_CALLTHUNK_SIZE; + } + if (!callthunk_desc.template) return;