From patchwork Mon Nov 20 10:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 167049 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2114161vqn; Mon, 20 Nov 2023 02:56:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdRCDcYgAYr26taAShMtxxSnJWQoMqF3GJZjWDi40aZjgC7gzZ+n8CcLEnVNGqIcBYT1WA X-Received: by 2002:a17:902:6acc:b0:1ce:61f4:590b with SMTP id i12-20020a1709026acc00b001ce61f4590bmr7353672plt.4.1700477791389; Mon, 20 Nov 2023 02:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477791; cv=none; d=google.com; s=arc-20160816; b=HiwYpoweKfvjkh6Oi2JctWaZBpnx5mlDLcX8YYOczY1il/M9qUZ8qq2dei+gP1K1xg mwpuMS5ilrUcjZl5XtedY4MbdJ6uaPjCagUMe1uxkdeozrH3DJLryQvL0TfJyW/2yYis 1DVQRu/bS6aWx0j9gz1jLMopXGNlc6rAwwDpoBjHGHwrpFKllSNHcaxPZnZMayTINQTt SjMV2+MiXeilbgmo3b9KqKWGk52vRtlQD3HC4Q/9o8Q0x5UHiHWEekIwJbuhw9TP3W3a 8dltGbLI33j0Uj/d3v/OcyKMDfpu2IZNeEFQTFCZ0cyOuvTnH0hnNuPjzRRh9bXH72Zv BFjg== 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 :dkim-signature; bh=hYWM4is6LVmFMNo5dpMFH0Wy9yxc8y0LNuURzC8Srcg=; fh=i0X96UA+DRFwxrkzVJLkkIx/77msyTucX1O/qlRL9hg=; b=F5GjT0KogJcznVx1V65MoEQEA+Z3JiAM3tRMrS6mes3iVMfd0cUU0t7ivUoJE7scPo 53vGRdIaJJed26mM+SMyVltg/NoHZJ1FpSIis+JFRb7hmkkZld06baL/O2UfdyDfgOLc tFiEKvMNQwNKf+1Is/4kJEjtP34mqZUxZHYHs+N/Bt4OjIbPB0FiLru1TbsZynTeSW+l IC1GGkSUSZyWSDKMWRbaoZNt4SOaS7ZlIKQmWt40grPWZIUq5ramoWPMm2sLrEZ+PZ8L Y9MTaohbkyvzN83h6SAZXMZ2e+ypRwjFDKkcXtqzn6ErF7+U+y+eFc92+7eDzxCBf6+V Fb3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TRXbUREp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c5-20020a170903234500b001cf5cb595c0si2452153plh.267.2023.11.20.02.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:56:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TRXbUREp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 949ED8044B4A; Mon, 20 Nov 2023 02:56:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233137AbjKTK4J (ORCPT + 27 others); Mon, 20 Nov 2023 05:56:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233110AbjKTK4B (ORCPT ); Mon, 20 Nov 2023 05:56:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB0785 for ; Mon, 20 Nov 2023 02:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700477756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hYWM4is6LVmFMNo5dpMFH0Wy9yxc8y0LNuURzC8Srcg=; b=TRXbUREpF24hnJ4/Mc4F4lMUdPbm+E6hxJBTrzxF1ADBCMmSeViKzLZBSkN39xzYowNrg2 NKCErmHElaYxIolgPwaEgYskODV+2I8YvkJ7L0SJ6uvGHmfnfLNMiHUUXVlXZVsObLMn4p rmMFquA1mp9/bYOtzXcz3cO3C3JLYbk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554--kwMc0T6P4mJ0OpNhhuLlA-1; Mon, 20 Nov 2023 05:55:53 -0500 X-MC-Unique: -kwMc0T6P4mJ0OpNhhuLlA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33059101A529; Mon, 20 Nov 2023 10:55:52 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B77642026D4C; Mon, 20 Nov 2023 10:55:46 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Peter Zijlstra , Thomas Gleixner , Borislav Petkov , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH 1/5] jump_label,module: Don't alloc static_key_mod for __ro_after_init keys Date: Mon, 20 Nov 2023 11:55:24 +0100 Message-ID: <20231120105528.760306-2-vschneid@redhat.com> In-Reply-To: <20231120105528.760306-1-vschneid@redhat.com> References: <20231120105528.760306-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:56:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783080200806446060 X-GMAIL-MSGID: 1783080200806446060 From: Peter Zijlstra When a static_key is marked ro_after_init, its state will never change (after init), therefore jump_label_update() will never need to iterate the entries, and thus module load won't actually need to track this -- avoiding the static_key::next write. Therefore, mark these keys such that jump_label_add_module() might recognise them and avoid the modification. Use the special state: 'static_key_linked(key) && !static_key_mod(key)' to denote such keys. Link: http://lore.kernel.org/r/20230705204142.GB2813335@hirez.programming.kicks-ass.net Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Valentin Schneider --- include/asm-generic/sections.h | 5 ++++ include/linux/jump_label.h | 1 + init/main.c | 1 + kernel/jump_label.c | 49 ++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index db13bb620f527..c768de6f19a9a 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -180,6 +180,11 @@ static inline bool is_kernel_rodata(unsigned long addr) addr < (unsigned long)__end_rodata; } +static inline bool is_kernel_ro_after_init(unsigned long addr) +{ + return addr >= (unsigned long)__start_ro_after_init && + addr < (unsigned long)__end_ro_after_init; +} /** * is_kernel_inittext - checks if the pointer address is located in the * .init.text section diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index f0a949b7c9733..88ef9e776af8d 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -216,6 +216,7 @@ extern struct jump_entry __start___jump_table[]; extern struct jump_entry __stop___jump_table[]; extern void jump_label_init(void); +extern void jump_label_ro(void); extern void jump_label_lock(void); extern void jump_label_unlock(void); extern void arch_jump_label_transform(struct jump_entry *entry, diff --git a/init/main.c b/init/main.c index e24b0780fdff7..5f51d8b910dc1 100644 --- a/init/main.c +++ b/init/main.c @@ -1407,6 +1407,7 @@ static void mark_readonly(void) * insecure pages which are W+X. */ rcu_barrier(); + jump_label_ro(); mark_rodata_ro(); rodata_test(); } else diff --git a/kernel/jump_label.c b/kernel/jump_label.c index d9c822bbffb8d..661ef74dee9b7 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -530,6 +530,45 @@ void __init jump_label_init(void) cpus_read_unlock(); } +static inline bool static_key_sealed(struct static_key *key) +{ + return (key->type & JUMP_TYPE_LINKED) && !(key->type & ~JUMP_TYPE_MASK); +} + +static inline void static_key_seal(struct static_key *key) +{ + unsigned long type = key->type & JUMP_TYPE_TRUE; + key->type = JUMP_TYPE_LINKED | type; +} + +void jump_label_ro(void) +{ + struct jump_entry *iter_start = __start___jump_table; + struct jump_entry *iter_stop = __stop___jump_table; + struct jump_entry *iter; + + if (WARN_ON_ONCE(!static_key_initialized)) + return; + + cpus_read_lock(); + jump_label_lock(); + + for (iter = iter_start; iter < iter_stop; iter++) { + struct static_key *iterk = jump_entry_key(iter); + + if (!is_kernel_ro_after_init((unsigned long)iterk)) + continue; + + if (static_key_sealed(iterk)) + continue; + + static_key_seal(iterk); + } + + jump_label_unlock(); + cpus_read_unlock(); +} + #ifdef CONFIG_MODULES enum jump_label_type jump_label_init_type(struct jump_entry *entry) @@ -650,6 +689,15 @@ static int jump_label_add_module(struct module *mod) static_key_set_entries(key, iter); continue; } + + /* + * If the key was sealed at init, then there's no need to keep a + * a reference to its module entries - just patch them now and + * be done with it. + */ + if (static_key_sealed(key)) + goto do_poke; + jlm = kzalloc(sizeof(struct static_key_mod), GFP_KERNEL); if (!jlm) return -ENOMEM; @@ -675,6 +723,7 @@ static int jump_label_add_module(struct module *mod) static_key_set_linked(key); /* Only update if we've changed from our initial state */ +do_poke: if (jump_label_type(iter) != jump_label_init_type(iter)) __jump_label_update(key, iter, iter_stop, true); } From patchwork Mon Nov 20 10:55:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 167052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2114557vqn; Mon, 20 Nov 2023 02:57:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSZC7NyFoNgBmhHoSITxOaPeyZHjjlK7Xbv0VN1Z6BzFkRj8UJB0sblK9yVKHHB4LQ0gjg X-Received: by 2002:a05:6a21:33a7:b0:187:517a:ff3f with SMTP id yy39-20020a056a2133a700b00187517aff3fmr5100545pzb.11.1700477851947; Mon, 20 Nov 2023 02:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477851; cv=none; d=google.com; s=arc-20160816; b=uUluM/rlHfvI8M8bg0h6IBMly/v+jqT+vs+kWHl92dyf/Ldod/mdHJSknL6EH50OX7 LaczGM0TWx/QK3xLbKIWbtSmVhG68fcu7PqHWC4dbazA0MZccrP7N3uUiS22AT8RzWf5 AcHdewhxjzhiFGabVA4JhENFw2Vb5/FA+/TLdQofeRv4fcbf0kWSp1csMjANcidw84hS GfLGNb7k9wHM8JTOjd87HbknjoDAAldb5DLaGLPq1ioVgnJcMC2VxLQdw2/zpEfPsMqS VR8OLWC4vWR1l1OmX/31CS1mBCUINilcUSQyoQ01giy+PtWadkSRApw/mSXvlImtHX+b 6tSw== 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 :dkim-signature; bh=kLzyis6PUviTtG453OISXCu8S+f029z0hO21me12mCo=; fh=bEaXtmS8lzRItYrE/RfaVyKNdc9i8y6GHBEJVBz/DUE=; b=EV/J72kCknGnMcGsoZgsGBiZW3uHM2RAIE3eTIx4OsvqqKsxx5cHDc9UJuF7Juf0g0 ArDcMVgJKB3X3z07duA8nBgMVDSKmYPaxqV8v9JSPG+z1Or6x6zRQ5tyFXY6THFKP8KA fJvl5Zlfb3b4BXO4j17h79hss7svh1x+pEKEU/HeH63mSBDvH6Ue5EuJaka+ERoXZeIp +mGiF6DlYQtrPqwpRMiT9U1wKwRUzqc7mF+Ed3YGXGdEJ1YyXue8ql5si+w5a4DVoQYF wrLqKyZiv8tcjvpV0IYeAoPUkAioU3OcV5b5h4HZa0p+eJJjsMOtwyHWf5MNqG2PT096 iGiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RqQ/rzKG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r12-20020a17090ad40c00b0027d22d5aa7esi8102265pju.46.2023.11.20.02.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:57:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RqQ/rzKG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 21815805FD73; Mon, 20 Nov 2023 02:57:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233185AbjKTK4W (ORCPT + 27 others); Mon, 20 Nov 2023 05:56:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233180AbjKTK4K (ORCPT ); Mon, 20 Nov 2023 05:56:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F323AF0 for ; Mon, 20 Nov 2023 02:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700477765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kLzyis6PUviTtG453OISXCu8S+f029z0hO21me12mCo=; b=RqQ/rzKGMZ1xhuwg+8G+PRWcRUCD4YijD4lKSZwvGwoWv5/b4sUjg/zYsfy2zhH+UhwehQ vuEoAQHlHMUnfxhROduNBK1lQtN9vHIqv4OeqQ4bINp+9xVQDfXYCi1VgniGoAVrM5Mc1V u84GmRPC/ZA3jKH4mJeJanLLzPtMMmM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-425-tGNqKUofPWSoGRXtkEN_5Q-1; Mon, 20 Nov 2023 05:55:58 -0500 X-MC-Unique: tGNqKUofPWSoGRXtkEN_5Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E407338157A4; Mon, 20 Nov 2023 10:55:56 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8846D2026D4C; Mon, 20 Nov 2023 10:55:52 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH 2/5] context_tracking: Make context_tracking_key __ro_after_init Date: Mon, 20 Nov 2023 11:55:25 +0100 Message-ID: <20231120105528.760306-3-vschneid@redhat.com> In-Reply-To: <20231120105528.760306-1-vschneid@redhat.com> References: <20231120105528.760306-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:57:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783080263789947507 X-GMAIL-MSGID: 1783080263789947507 context_tracking_key is only ever enabled in __init ct_cpu_tracker_user(), so mark it as __ro_after_init. Signed-off-by: Valentin Schneider --- kernel/context_tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 6ef0b35fc28c5..cc4f3a57f848c 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -432,7 +432,7 @@ static __always_inline void ct_kernel_enter(bool user, int offset) { } #define CREATE_TRACE_POINTS #include -DEFINE_STATIC_KEY_FALSE(context_tracking_key); +DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key); EXPORT_SYMBOL_GPL(context_tracking_key); static noinstr bool context_tracking_recursion_enter(void) From patchwork Mon Nov 20 10:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 167051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2114548vqn; Mon, 20 Nov 2023 02:57:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/+cIG7DVcyOGv5SuB68rCsAQupUjMXNHEvkxGJz30ghwB/6pXvGq9XZ3NSsBaWvSzx3wY X-Received: by 2002:a05:6870:7d89:b0:1eb:4805:30d9 with SMTP id oq9-20020a0568707d8900b001eb480530d9mr8975431oab.49.1700477849381; Mon, 20 Nov 2023 02:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477849; cv=none; d=google.com; s=arc-20160816; b=YAiUrdCe8O0VB9/C15ifGrEcSCPU3yOWtUUKYIcnRAtv2jXSVqtEKT+vVsjWDCIdCY vBKyoHFIYzMEtv3oc7wa8eHu26Ip5qeGf2h6ntVCzLO4k4NsPwifIawl9fiHa/QW9Nlr TzeZd8N3+CfRdT0MX6LPYJNcV0N1eJKtGscCqYnzexURwNOqzqGSYTFfl2hQxigR3JEM abjAiX0r6VrBEU42VGRwBsAwri6PjmZrD8BJPR//QrVT1DQMdbofK2w85yWX4adlXg73 MzetCOatp9yVLelvw4xpLqRo/D/z4LIizqF3MPWW+hqZibtTHwDNzdAkldFKhxlLwlxL GUoA== 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 :dkim-signature; bh=k68HwnJwcz4zoShTsfUk757+WGBllw5A6qnajgwYuQI=; fh=bEaXtmS8lzRItYrE/RfaVyKNdc9i8y6GHBEJVBz/DUE=; b=XHKMdtxKBtNvfRQ97o5l6rNDtEjo+PduFtCLWEDYlQEH/AIy/CrEyMt4rW7idUdMwD bexXVssIlCVb30gyE9y0lHHbctRDuDP2q8kphVoBlH7jBZkc9M7FWXalzNYpDl2caogS 6XBk6mmXZ0R7nyUzT8cI/r2Qr+G5ERFnYZIrT4pGJbXoWk9oMXrpUu8dmCyMwt34/J4F yLbAp2Qsn//p9SYnGcQWqOq+uhDNZxFTmJD0YfAvuOLXqdSFh8KtEQu7E4GGc7pPldLk iNH05zQo4XGSv8PUFSKYGGHrTonO6VwgEOxT7OyQZDg9F6fDikpvU9lgxtAB8jPwo03i Whcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T1e0LFnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bq3-20020a056a02044300b005b95fbd816esi7956258pgb.677.2023.11.20.02.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:57:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T1e0LFnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DC38780A439F; Mon, 20 Nov 2023 02:57:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbjKTK4c (ORCPT + 27 others); Mon, 20 Nov 2023 05:56:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233204AbjKTK4S (ORCPT ); Mon, 20 Nov 2023 05:56:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D4FE9C for ; Mon, 20 Nov 2023 02:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700477770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k68HwnJwcz4zoShTsfUk757+WGBllw5A6qnajgwYuQI=; b=T1e0LFntgh+O0GGeCaNDvGWW/LYc4C9ZWhOKVlWGGSKLXGzGoulSixZnfUGTkLjJadn0dS 6YSoar/qqugUQC91crIrWX3ATmLYQY2PsaVuwuiJA4IKg2nMjO4QlcWTmcibeGHnIaIlGR 2tzYr+vNFTGFMdQfsRbmL6HKq1UNU+Y= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-HElFptZqNS-CKEUV_FXkew-1; Mon, 20 Nov 2023 05:56:03 -0500 X-MC-Unique: HElFptZqNS-CKEUV_FXkew-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE7183C0E203; Mon, 20 Nov 2023 10:56:01 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FE2F2026D4C; Mon, 20 Nov 2023 10:55:57 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH 3/5] x86/kvm: Make kvm_async_pf_enabled __ro_after_init Date: Mon, 20 Nov 2023 11:55:26 +0100 Message-ID: <20231120105528.760306-4-vschneid@redhat.com> In-Reply-To: <20231120105528.760306-1-vschneid@redhat.com> References: <20231120105528.760306-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:57:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783080261375757534 X-GMAIL-MSGID: 1783080261375757534 kvm_async_pf_enabled is only ever enabled in __init kvm_guest_init(), so mark it as __ro_after_init. Signed-off-by: Valentin Schneider Reviewed-by: Sean Christopherson --- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 0ddb3bd0f1aac..146e16f420edf 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -44,7 +44,7 @@ #include #include -DEFINE_STATIC_KEY_FALSE(kvm_async_pf_enabled); +DEFINE_STATIC_KEY_FALSE_RO(kvm_async_pf_enabled); static int kvmapf = 1; From patchwork Mon Nov 20 10:55:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 167050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2114337vqn; Mon, 20 Nov 2023 02:57:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUkBfLYVMecuGBt4PfMWUc4lj7l7FtJfmUGRK6w19YN1R4MqsUSMOmd4uL+iTUy5Gj05H/ X-Received: by 2002:a17:903:50d:b0:1ca:dee1:4d1a with SMTP id jn13-20020a170903050d00b001cadee14d1amr5110928plb.25.1700477821746; Mon, 20 Nov 2023 02:57:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477821; cv=none; d=google.com; s=arc-20160816; b=fBF+IF9rj6q6IB7+puYYTucDv9ihLllCpjKeFVbv0TS2HCBbgptjDJkHcm1UeZzJEA VzdF3+sTe+7VaqoN//nuk/YVYay747nsoad6a3/ZAWuyG7KE2Bx0zLOgoaZAsbbQFXzy i9ZCeSdysjDu8OK7xSc5A8AtwCoESTUWPpQUVZZzlpUaUFtQ9FPiarGur9H3wEy4gFuS k8gVSZj+1IwmHrbPNZotslxvDllD+KDsYhgTo4ABVfKSlxFccAkyw5f67TfFCcXXBWF1 nnt+7fOvo5ktvEhWRcn9LvUIgyjNkwTIqmgVgb4NC+EXAUeQEDIZKwVsrQ4yJ8cuIddM OJIQ== 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 :dkim-signature; bh=qtn+6JJtdQbGCK4bL8AZ/8s8qyj6h0vNojls/57mTy0=; fh=bEaXtmS8lzRItYrE/RfaVyKNdc9i8y6GHBEJVBz/DUE=; b=zXtq6P/4cwPBzi9XyI5DwszqhWgwJmDW2+tf00FIn4gFgcZ7p3/QIcZPG2nCpfbnc9 8Z/o3xOpmNDwc+2v2UY8oRbc9jH4fBC60DS0zGqfoNFifgbl65LL5QzcW1NxnKX6Z5Y1 dV3Jzj70IAkAm5Rli2q+Je95lYtQQHFnUYEEDvkbP8ar8frR3NCVEc4dkHbH3HG6JlJC f6u9b757WfLHjaD3DZSuNeMa9jsHJtdD7N8XCEsxj8NMwSItNCj0vuq5wcnH45TirNUm pFgbLIW3r68GXVXJVk0LNhDpUaV9m0EtbPCDHbK9UyJtQp6y6XFLEHZVH08BXcOt+xP0 dpkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EedCQgO9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n10-20020a170902d2ca00b001cc407388a8si3901930plc.337.2023.11.20.02.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:57:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EedCQgO9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A5C708043ECC; Mon, 20 Nov 2023 02:56:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233144AbjKTK4v (ORCPT + 27 others); Mon, 20 Nov 2023 05:56:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233152AbjKTK43 (ORCPT ); Mon, 20 Nov 2023 05:56:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B42D5E for ; Mon, 20 Nov 2023 02:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700477776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qtn+6JJtdQbGCK4bL8AZ/8s8qyj6h0vNojls/57mTy0=; b=EedCQgO9sbv9zInDZaG1JMZO4B+aJ4uwLxYxmmy3xwJ7thzAsjQLcc2tOAR7k6As1/deiT H55UiLxJ2DW04uYvj+zlzlU6vqEo6ZmjaTf7akt+FQDa0BQWWB0H7yS+VvcBSUPComvWbB Mh01kE3rjKU8moj/D8hz5A4bTRsCHmw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-VLYCU4uwP9KHCgOT1Uc4aw-1; Mon, 20 Nov 2023 05:56:07 -0500 X-MC-Unique: VLYCU4uwP9KHCgOT1Uc4aw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DBF5811E91; Mon, 20 Nov 2023 10:56:06 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A89A2026D4C; Mon, 20 Nov 2023 10:56:02 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH 4/5] x86/speculation: Make mds_user_clear __ro_after_init Date: Mon, 20 Nov 2023 11:55:27 +0100 Message-ID: <20231120105528.760306-5-vschneid@redhat.com> In-Reply-To: <20231120105528.760306-1-vschneid@redhat.com> References: <20231120105528.760306-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:56:59 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783080232536363104 X-GMAIL-MSGID: 1783080232536363104 mds_user_clear is only ever enabled in: o __init mds_select_mitigation() o __init taa_select_mitigation() o __init mmio_select_mitigation() mark it as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index bb0ab8466b919..bab36096015d8 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -112,7 +112,7 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_ibpb); DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb); /* Control MDS CPU buffer clear before returning to user space */ -DEFINE_STATIC_KEY_FALSE(mds_user_clear); +DEFINE_STATIC_KEY_FALSE_RO(mds_user_clear); EXPORT_SYMBOL_GPL(mds_user_clear); /* Control MDS CPU buffer clear before idling (halt, mwait) */ DEFINE_STATIC_KEY_FALSE(mds_idle_clear); From patchwork Mon Nov 20 10:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 167054 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2115350vqn; Mon, 20 Nov 2023 02:59:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwzgTxmGD0RDjAR3OugDzQ8AUvAMe9RGdtmdfUzSFs7XlT5moc3fBfbbN005qujl8HZRC0 X-Received: by 2002:a05:6870:44d0:b0:1e9:cdad:4903 with SMTP id t16-20020a05687044d000b001e9cdad4903mr9186909oai.50.1700477994193; Mon, 20 Nov 2023 02:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477994; cv=none; d=google.com; s=arc-20160816; b=uFsr893HC11sY02QAY/WNxKS0LzKdWYDS72q2T+8fCXBG/yXsf5B4p7Hp+S6vyASPj /V4WKUY1pece/U91q/IcrcngfWLw3mJptJk+EbSpmv2j9zzmtgAjPhdm+c8IEza8/qc3 bE8TIY4i3NX8h/0TTq6WgjfwPr327nPiSXyqYDlzHpYcwiDuvJreLSZwfe2SbBmNboTt DYJmfu9YRAdVSM2Lx5XWCGw1yp0KCgBjXmRsDOGzzND/ooyh+Tm7epgkkzqAJkJE9oMR Y/dGuW/9iw5ND4yO2JIss70KBoGGwSS0gG1nhsDLUdOptmI8dh1ZERDpww7GPB/urAnU G2nQ== 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 :dkim-signature; bh=Fh5nWCS7m0i97fxRSND8fdK+nCY+MD6Me1hw+2UF/3c=; fh=bEaXtmS8lzRItYrE/RfaVyKNdc9i8y6GHBEJVBz/DUE=; b=GiARDmR3BkaHHnvTWVL2zOnOBwmo/WNKw2gEO27G0YKKgbSlsOG0LV/jC0OYbl+0wJ 8+pwHaTBx2CoX5Kf53aluOl77Mhil95wDtVdx/rvsGHSEcwHeSnCTKloGO1ooiNbWPPR QoqauaRRU6Gv417njmVULq45SOOhIKZuLJTrgNY0qVA4AB5P7bFInaZcucFmJ3rKY2l/ hELCh9lcucy10FBalKqh8J+K93nVmyg8V/d7utEq+PaZvpZp9Z8an4T69isNXqd2UmPF 964OHudIm2zuNncjFtwqqvF5N6zZ3RiablsMH1eBEpYF9QqWcJiwmQaBKX2bTz8rEye9 KwIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aL2R4fer; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r18-20020aa79892000000b006cb901a9883si2197262pfl.326.2023.11.20.02.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aL2R4fer; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 39F0B806CC36; Mon, 20 Nov 2023 02:56:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbjKTK4q (ORCPT + 27 others); Mon, 20 Nov 2023 05:56:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233115AbjKTK43 (ORCPT ); Mon, 20 Nov 2023 05:56:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3680BD4C for ; Mon, 20 Nov 2023 02:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700477776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fh5nWCS7m0i97fxRSND8fdK+nCY+MD6Me1hw+2UF/3c=; b=aL2R4ferCNTSW0/DM4wCLENT5BUyJ7WVaXa3M6x0ATKoxDUAXKkstGMplnZxLz1uyYE/FR xCCUnWiZdKVQqHQ8YL+9E/4f/M0K8jLsrYPQNiOrcOUKRJkFJvb99eKNc6xdMnhWmhePS1 58GVkehSPcacpMI+EvsbA2Qj0ZvHtfw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-Q63KOD7EPAGRzHG2NpasBw-1; Mon, 20 Nov 2023 05:56:12 -0500 X-MC-Unique: Q63KOD7EPAGRzHG2NpasBw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DB26811003; Mon, 20 Nov 2023 10:56:11 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAC3C2026D4C; Mon, 20 Nov 2023 10:56:06 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH 5/5] x86/tsc: Make __use_tsc __ro_after_init Date: Mon, 20 Nov 2023 11:55:28 +0100 Message-ID: <20231120105528.760306-6-vschneid@redhat.com> In-Reply-To: <20231120105528.760306-1-vschneid@redhat.com> References: <20231120105528.760306-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:56:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783080413135331773 X-GMAIL-MSGID: 1783080413135331773 __use_tsc is only ever enabled in __init tsc_enable_sched_clock(), so mark it as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/x86/kernel/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 15f97c0abc9d0..f19b42ea40573 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -44,7 +44,7 @@ EXPORT_SYMBOL(tsc_khz); static int __read_mostly tsc_unstable; static unsigned int __initdata tsc_early_khz; -static DEFINE_STATIC_KEY_FALSE(__use_tsc); +static DEFINE_STATIC_KEY_FALSE_RO(__use_tsc); int tsc_clocksource_reliable;