From patchwork Mon Oct 17 14:53:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 3506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1493384wrs; Mon, 17 Oct 2022 07:56:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ctTPWyxVAjX8mmC1b01x6GB8T2KAp8pErSfMKEf8OH/60lq4GQfhFk+56ag814wSMf+3F X-Received: by 2002:a05:6402:220e:b0:458:b857:85b3 with SMTP id cq14-20020a056402220e00b00458b85785b3mr10910442edb.379.1666018575348; Mon, 17 Oct 2022 07:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666018575; cv=none; d=google.com; s=arc-20160816; b=kMLZDKULpk3Rq/aBRmYrH8jxG7vE/WbfPRFVav9ge9xD6XQswaDGs73mevhebURCXG K4+eeaFy4S0j8D+pcRVwYXAf26uN/141hRT7x9qvf8f/690NAwUXN5LYqZXmithwVy8V XMVR10zwmx36MQXY0kalNwkAKZMSsDG8qYfeVp9Rm1X4o0uJkUsl9RgEHF9rPrQZ/lPH x0ElQHcs6AWTNGYTfprUu5AbA+5oGULHUOXOTV6CHaJRZcNtaHBaOjx9ZQFA1xBMoaQ1 BVryL/ybikzX9DHQfmtNRoUTDV8MmK1LFpyM2e+ac7xK7EL1cjmR5U+9U+pLSEaZJFqH cACA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Ubd/DIoeJ/OIwn9O60Fds2i+sO91FJSLSaxfilo2cTM=; b=YhDQh9pMi37nKe7bpRV/qHG5qqtR2zqU6a8mnsc1819b6dqgXG60t8wIDpCocPGMV5 fr7DekEtjrzxyteoWVUs6PnihlQwxtNDp8gLN8tKXpD6pV0UJ6HiCXtmaxQqI0o9GYN/ gz0U9HytvyPythJ6K8xT5E2DwIgrlQfpQNbPK1NSingygn4SXedycLAt0Nak5EFCWRwD x32QvkzyhpNmy01GUOHDFZs5N5TVcjralfjSIWXuW+vUGGOSOgnas7liWSW/UKRaCJMi NWkElBE9eQEQMdSutHBh1Ais28BIUvNT+zqQDNt7oxM1Lce8ASSn/fASVBum7jWLXj8d rBiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HdhJaKzY; dkim=neutral (no key) header.i=@linutronix.de; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a05640205cb00b00452697eda4csi10979977edx.58.2022.10.17.07.55.50; Mon, 17 Oct 2022 07:56:15 -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=HdhJaKzY; dkim=neutral (no key) header.i=@linutronix.de; 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 S231247AbiJQOy7 (ORCPT + 99 others); Mon, 17 Oct 2022 10:54:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiJQOyB (ORCPT ); Mon, 17 Oct 2022 10:54:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31B0691AD; Mon, 17 Oct 2022 07:53:45 -0700 (PDT) Date: Mon, 17 Oct 2022 14:53:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666018419; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ubd/DIoeJ/OIwn9O60Fds2i+sO91FJSLSaxfilo2cTM=; b=HdhJaKzYXh2Rqs34vC4yW5xhBCJcc0LOm3NYR9CI+ivNdaXEWmflJpZdIkv9RecT1huLc1 8croHnrPqIMsjQTaetb6HwKus7JQzZPwe/JYbXQd2tQW1LcGHwZ8Zm+le7fJ3Mg6V8hR+c 5AjQxBnDXMfCATPpR5FaqK4eN+VFB+0aqOzcC0smgm9ne3uI0qAnjSRUggn/nB0/vcfZjV P9K3IRrDzEZiqgl9bquDeH3p5lZpQmh0Vf+AIwLKwjnRh+0zAy/3bVTSSH9+5elK54zBml DkaHawnf3igybgowqfHuJkw9co3mXan3fBEmyFjMJgyoBhUN0fV90Wlt1XqF2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666018419; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ubd/DIoeJ/OIwn9O60Fds2i+sO91FJSLSaxfilo2cTM=; b=b3m9bV/m3mA5pAXPgOvsi8WFi2pf1fgZM9bgpmTXZ9N6v+M3u4goRtwDFMvWkdt8hyTjJ/ VZSgBJV6TpyyYNDw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86/retbleed: Add SKL call thunk Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220915111148.101125588@infradead.org> References: <20220915111148.101125588@infradead.org> MIME-Version: 1.0 Message-ID: <166601841845.401.850662909719524117.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746947093160331432?= X-GMAIL-MSGID: =?utf-8?q?1746947093160331432?= The following commit has been merged into the x86/core branch of tip: Commit-ID: bbaceb189a21d7245e8063701fe10985396028f9 Gitweb: https://git.kernel.org/tip/bbaceb189a21d7245e8063701fe10985396028f9 Author: Thomas Gleixner AuthorDate: Thu, 15 Sep 2022 13:11:29 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 17 Oct 2022 16:41:15 +02:00 x86/retbleed: Add SKL call thunk Add the actual SKL call thunk for call depth accounting. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220915111148.101125588@infradead.org --- arch/x86/kernel/callthunks.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c index 7b9d998..01f6f6b 100644 --- a/arch/x86/kernel/callthunks.c +++ b/arch/x86/kernel/callthunks.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -55,7 +56,21 @@ static const struct core_text builtin_coretext = { .name = "builtin", }; -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)) extern void error_entry(void); extern void xen_error_entry(void); @@ -157,11 +172,11 @@ static const u8 nops[] = { static __init_or_module void *patch_dest(void *dest, bool direct) { - unsigned int tsize = callthunk_desc.template_size; + unsigned int tsize = SKL_TMPL_SIZE; u8 *pad = dest - tsize; /* Already patched? */ - if (!bcmp(pad, callthunk_desc.template, tsize)) + if (!bcmp(pad, skl_call_thunk_template, tsize)) return pad; /* Ensure there are nops */ @@ -171,9 +186,9 @@ static __init_or_module void *patch_dest(void *dest, bool direct) } if (direct) - memcpy(pad, callthunk_desc.template, tsize); + memcpy(pad, skl_call_thunk_template, tsize); else - text_poke_copy_locked(pad, callthunk_desc.template, tsize, true); + text_poke_copy_locked(pad, skl_call_thunk_template, tsize, true); return pad; }