From patchwork Tue Feb 6 17:39:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 197571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1705845dyb; Tue, 6 Feb 2024 09:42:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAYki+161NQ2TZXN7e3uWOV8tXJhaVzzTiouLE54tYvTzo6Pb83nkAigyODXhqhztwJ01x X-Received: by 2002:aa7:84d4:0:b0:6e0:4e69:6ec4 with SMTP id x20-20020aa784d4000000b006e04e696ec4mr259417pfn.5.1707241362092; Tue, 06 Feb 2024 09:42:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241362; cv=pass; d=google.com; s=arc-20160816; b=gCtc1EjSZ82ATF62YhxDX8MwNU2R5BSJklM+ijTbX5v0Q/lLaT4JgnI6YGA/J5rkUx P2P4Gnds0jyeqllUgD8o8+2rMKURANj/ZiaATzCjiNRSGDCYdSeRP3RjfouT0hGDtEVU E2WTk8/5BHCYbYmkJCiaDJwLradhDAHC8ZI51KEbQWonKrGQeIYi0st5rymYoPuHm+3m eeYynBAtPQ206VSqNA6IHn/cAVvauahwYbs0WUDMdXscHaU5qyu0oOpZOm1xVSRPu1gu i6actXppaCWkNuBC+mANXkCw4R/2/qh7gJhJDc8xs8fVQXVqj6S/19zWxQ1PWadHBf5J vGOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zQJi5lVSKToVYNDb/xc3D9ULA1cJ8DD0UMSW58V8ctw=; fh=puFPKnmBhzRZ47zkfU5bcI9Jxbr1feLn7Ps2kJsZcEc=; b=rkyK8Rk4jCPK2WHhRtVjMuKRysJloVFZJY4X1hmn5IIXCvIsWx/wtVUGRnWvtIpma3 TCw5R4vUgYAlnSCrOQzu/5S9CRdVkDcw8DZD8aR7QZKYO1HG3X3zqHsrkPQfgr8ICO7A MDUHUcywyvIdLMFJdla7RuL7ok9/Y8PE4sk61rNGYiSglj5rC3BTyVA0BekpeWHFxhg4 26vzbQCfm4IAuSnOdn6XcM+RItJGT+KuVsBZj17DiWLkhHEUrMwsh9i7EIiyhDU9TtFX mnG3PsCafQG3P/IXcuqhtJToq+B2jBXPyMnI/RKEe0WV0cZzaZDf4AAzxv02ahzL5F5K d9xQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SQM2rshg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55411-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVo4IJlC9KA/IRCtqOE6gisuD0qaxDqRN+8kpOZmeCGS71QTJlJhPXrqqqwUuRhBILyDUH5tLgqOKJhiVMWOPKSEITThg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q14-20020a62ae0e000000b006e02fcbb817si1915232pff.201.2024.02.06.09.42.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:42:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55411-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SQM2rshg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55411-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC3E2284D5B for ; Tue, 6 Feb 2024 17:42:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA118134DB; Tue, 6 Feb 2024 17:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SQM2rshg" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 964CE19470 for ; Tue, 6 Feb 2024 17:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241198; cv=none; b=K2X0W9v1EnYTh7ptN7YxHiYj7wWj0KA+ggn1ZPOj1+s6UlCZtNtd1TvU4P2naaK2WX8F16YZyocOWIMKa2zvHtUJu+SOl+yLaWrem+ewdTg69GMfOfk0gO3+M4a7vJEL+oOYzHIQDtIAXKQs2RLE35E1ee6l5bklMQQGd30E8aQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241198; c=relaxed/simple; bh=ZMQTWbcCGrR/agcFVkVVEI05vXn0HszebfL8x+q/HRU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=adADQ9qIN8MFHAT8U8wxRWfo4UVni/O/DV+71gpnUQk04GsrmKrPScA3r91s8ZBrKZecrJLFOF9Xb2sqGlEGAJL3X1yDvQCBzYehAXl9YSAEnqxNn94wjfRblRnUoj/8rez4BmaZXcoW3/piUrDEdaSDeHtB7HuauFAY1/emZl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SQM2rshg; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241195; 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=zQJi5lVSKToVYNDb/xc3D9ULA1cJ8DD0UMSW58V8ctw=; b=SQM2rshgahd4zFYb7iSQWBd+XxXNgdCDmCkhxm0kep9pyL6d/VYwFVXNYRLgoqAGNYKS1p zLDfCKeOG2rPXUTHcZQ1VlvVANvWu3UW46qjcbxk819US/1DjYI65fb8EBhxM8b5/MGcg2 MedAjoyV2Hk0owHRm8m0Sd1idt0UoFY= 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-652-ZIz0_IVqNuCeGd0hcpWWmQ-1; Tue, 06 Feb 2024 12:39:52 -0500 X-MC-Unique: ZIz0_IVqNuCeGd0hcpWWmQ-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 613AD1C29EA3; Tue, 6 Feb 2024 17:39:51 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB6A02026D06; Tue, 6 Feb 2024 17:39: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 , Josh Poimboeuf , Thomas Gleixner , Borislav Petkov , 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 v2 1/5] jump_label,module: Don't alloc static_key_mod for __ro_after_init keys Date: Tue, 6 Feb 2024 18:39:07 +0100 Message-ID: <20240206173911.4131670-2-vschneid@redhat.com> In-Reply-To: <20240206173911.4131670-1-vschneid@redhat.com> References: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172318453176415 X-GMAIL-MSGID: 1790172318453176415 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. jump_label_add_module() does not exist under CONFIG_JUMP_LABEL=n, so the newly-introduced jump_label_ro() can be defined as a nop for that configuration. Link: http://lore.kernel.org/r/20230705204142.GB2813335@hirez.programming.kicks-ass.net Signed-off-by: Peter Zijlstra (Intel) [Added comments and build fix] Signed-off-by: Valentin Schneider Acked-by: Josh Poimboeuf --- include/asm-generic/sections.h | 5 ++++ include/linux/jump_label.h | 3 +++ init/main.c | 1 + kernel/jump_label.c | 49 ++++++++++++++++++++++++++++++++++ 4 files changed, 58 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..3b103d88c139e 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, @@ -265,6 +266,8 @@ static __always_inline void jump_label_init(void) static_key_initialized = true; } +static __always_inline void jump_label_ro(void) { } + static __always_inline bool static_key_false(struct static_key *key) { if (unlikely_notrace(static_key_count(key) > 0)) 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..25a5ed1147841 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 + * 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 Tue Feb 6 17:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 197573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1706142dyb; Tue, 6 Feb 2024 09:43:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaHQ1ZEWOyjO5QNJiCz6tLN+Xbvy9OCxy9L7uITtim6yIUirOf6OcsefGmKh6yKsABOR+c X-Received: by 2002:a17:90b:1096:b0:296:d466:71a1 with SMTP id gj22-20020a17090b109600b00296d46671a1mr226103pjb.41.1707241396700; Tue, 06 Feb 2024 09:43:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241396; cv=pass; d=google.com; s=arc-20160816; b=FFmwIAczR1lsKoC1MqmMjFw2Rvjsl8lvAxdAB7p/TnV0WTJdZqUXX4Kd1zMPvTTOLi bDr320tI4whZQp2UY6Xm+bL1a+o3Xqab660V19E3hzVVzlzuSy28hH256dGrt0i9oluD eRrzDcLRvHn9PTJvC5i3SXyOmQlD3I6/cAcM8/gGSenSPvTGMlUYsawdBwyR3naC+7XL 71cYFun+iXwPPXQYSEp4sQpznuTX2QnsYRoYJSQ9whzU3cITKJqslM0BG+IHGkUAjgjb tXDoa3qLGQ0WqtXYoyGia9ZvMBeBvCLSz0b7cidSfC3cZ9MvmJXyenPzAsVIubcVJiEF pIOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wAVeOMisjibwqonq5yPJYQ58Exx1w9fjDotka9U+BN4=; fh=SmvfVPr48tctl7s+0f+gZ7pGHqncCPVKbLhlxef2o9E=; b=Ox5fqd7yQkv7JSdVBX9643Q4iWctxJNEaF2FI6SNuA6SFak9lYwpY9T7wEX+Mli0/M sVJPNgjJ76pqd3HCehlccivdOY6B1FzYZ9Bkeog8NIVs6nF/23QUw1qAhtYDBhsUJvcQ RM5DQXoK6y7GudO7uTN6znLP04VutGnVW1g1JAXb4BM/L4/niQpR0bCAYVr+Tk6YOIXX tLAnOfwqeqKd8V8uMf8jYIvA7UiFBxOnjhQjPQRRM+xCoopswFsqhVIlDEjAwJJ/aOqt iMtY+vvyCbMOpXNJkC8aTGfoNvpS1lPlAx0fjCTfyerAlLvd13qYSEb9JDwgW03iRe5y 5zyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DV5sd2AR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55413-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55413-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCXVIn/orVTqMIxVMum+k/DbuUUyELQ1aR97A+DLwzSjcq9lrdufk2Fjy9Kbu4s9kXB1FSXKb4wPcRfMeRMRakiYj36iaA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v21-20020a17090a899500b002962fe3cd22si1470595pjn.142.2024.02.06.09.43.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:43:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55413-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DV5sd2AR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55413-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55413-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0F14628B377 for ; Tue, 6 Feb 2024 17:42:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 875071B811; Tue, 6 Feb 2024 17:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DV5sd2AR" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E2DC17997 for ; Tue, 6 Feb 2024 17:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241206; cv=none; b=Cx22cv3tjJeXhJdGtMMEuH/LEke9U2UqQ+EgSiMzI/mzug1wZpkzGStSzHDayxq5EfDM1wXT1LAE0kNdBnJXrwXpbm0Tfb1Z5jQ4kmd+JETeyntvTSUSYscLusEkPhFcf0CfF81ipuuZH7HmJ6m8x20oqJtixpGxtt+JRWhJmK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241206; c=relaxed/simple; bh=DFZQ/EilDH1t8WOKFPKN8p7KM/uu/NEDA8dWflqpPdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajLeOhAiEtyQHE0LxLljBrOGK3zaXBzIJJUTZYtiV90JCiwV4z6b4Vq0pKV+/T9jy+Gr/EPIzEfPirQsoDK1f2QIv2UeLUS32QGgf8ZJkct5maRFQA7RkZlW0gXY3LAbONWGpyJ+3aezj86NjW3RfF73cYBTAf9tszseyt+NpKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DV5sd2AR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241203; 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=wAVeOMisjibwqonq5yPJYQ58Exx1w9fjDotka9U+BN4=; b=DV5sd2AREkV5t5Omvvp14xpIt2ecI2cA1tRmmhOFwrfxHWbaRyGC0LNWgvEqzd+iwL+s8o N4xcOLld8xm0MHUAPPeUlN0B15KjtXIY6F6LwyBz4rPKUt1QdNGym3crdGyWhsMpoTp6im 2AW9tHASi1UdfgY0sIvnE22wBG2EpOM= 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-680-X4XQR69UNdyvfJZ65mDaVw-1; Tue, 06 Feb 2024 12:39:57 -0500 X-MC-Unique: X4XQR69UNdyvfJZ65mDaVw-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 2041E101FA2C; Tue, 6 Feb 2024 17:39:56 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A881D2026D06; Tue, 6 Feb 2024 17:39:51 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Josh Poimboeuf , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , 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 v2 2/5] context_tracking: Make context_tracking_key __ro_after_init Date: Tue, 6 Feb 2024 18:39:08 +0100 Message-ID: <20240206173911.4131670-3-vschneid@redhat.com> In-Reply-To: <20240206173911.4131670-1-vschneid@redhat.com> References: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172354385629174 X-GMAIL-MSGID: 1790172354385629174 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 Acked-by: Josh Poimboeuf --- 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 Tue Feb 6 17:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 197572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1705995dyb; Tue, 6 Feb 2024 09:43:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzUUxd/Y5tF3X4SMy22I/LP8qzfvC/MvSVyNr3QqJ/lWBkKBt27kKztjFVJa8RawAF9BjG X-Received: by 2002:a05:620a:4489:b0:785:6411:344 with SMTP id x9-20020a05620a448900b0078564110344mr4108793qkp.7.1707241381616; Tue, 06 Feb 2024 09:43:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241381; cv=pass; d=google.com; s=arc-20160816; b=ZZq0CVmFHo51NOB9OL+Xa/ngkVTeUfD1pcn6HH/xFA2tTIALMbxRrkCcTyWX0WBAbB k+CWpYEcXShvQTe9P2SPAjAzUT3SJR49DdUPwzW2ZbRD+v+mSLRJdsDwV+3OmT6GYT3I Vfp8HV9gpuJTdjSVqPmFXuDuTiTkjlJrefJkLSrnTvHKpKg7cIBerV8O9HR3Qc3/zifN POaQg46ZX8j4dd2T+j4QDbMTtdzVoJJv+QAnlcw6pPo1woI10pzafplNHiUUIaL/PRyU XoVVpTzUdmh7DL35BYnd57NcM+xOzJcukazmdPQ4Y16rCFtXH0aplW3T3QBgekzhXIM3 uyQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DiAeFErACPu2Qq/VSwmzn5NIHI5rZO8DYF37cTAxg+8=; fh=RaLc3JvvDpbvBfK1lrocTZelB7+xr0VHiebZ8C1vpaQ=; b=DOMXUJtMV4ep3exX0NtpExDelQ9zBBoCFAWq609O3DTGOyLqVnMsjHgfPpam/vK+Tm I0ImqRGeL4bR1ZCRAiPZpya4jUrsV0FDYut0awwOzyXgaDtWQmFxnCg2l+KZXTrrzLc2 tgfKOhtzEDXX9i0zpfli8gACxFbdFhf7UDXSPFBfgtcyxXurG5V6c4QgaEux3RuUT/EK xuZVDgjtmAwF9Sno5GC4zSytmP9ShVHV2XV7Op5RbIEaXp+xxY6pPUI9PgWv5DWC4fDR f9L6nn4f0q7LKEu73nquvfu9SCrS3GrD6jO6sG9Pg/6LoFJtOTv9XfA2DlhVz/pPkzys ltlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C1MOs9an; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55414-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55414-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXQf/Sof95CYBkkcYqXwqKj4VxDeARimlc7QukGPGHuLCKRsFU51H6761B4c3NiCP3iur5tRFBLfuOllBgdtu2tCq6D0Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z10-20020ae9e60a000000b0078596a6f587si508049qkf.47.2024.02.06.09.43.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:43:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55414-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C1MOs9an; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55414-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55414-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 673FA1C25151 for ; Tue, 6 Feb 2024 17:43:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 080561B94F; Tue, 6 Feb 2024 17:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C1MOs9an" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B827719470 for ; Tue, 6 Feb 2024 17:40:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241210; cv=none; b=PVv2Mwlou2Sake20O3YiOZg8KEehnFewvIcDbYx7pPfdev+IGnQCrvxuTJlKMzLTodYMIBhx6vR+Axx1ofOp43vXFmuDFJqvG8n/IS61f1RCD84iWybIYKDnFN6g2V0lq7Nqb5SB2JacfhEssGBTNJTZYUO0RxiFScMOWDVY0Fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241210; c=relaxed/simple; bh=OqaVifQS+nxzCD21b4s8rJ7JH6j5ozOv9bSA598QaaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E4F16/X6nsCTgjLFe2US3IMvjQn+ff97o0P9u4nwyCgTJhxXgkI4X80w7LPEOT/y0okvl9w7s3XKKbyhpr7/+U7g7MnRYOBQHb6NE9Vs5sYJWjxqIkxKR0+isp2B36hMmEUylKjnBYbUOkY0KHJz0Z1kMZbEL93+MgBNNisVlQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=C1MOs9an; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241207; 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=DiAeFErACPu2Qq/VSwmzn5NIHI5rZO8DYF37cTAxg+8=; b=C1MOs9anrQSsXFRlV/Bfj8OEba6wS8eDNuYaWzmIl1sgnBKiP0vlspln4ajXN1NOo6n6EY 0IQIhLuNXcGk/NS9oBZB0dPTqR+KxsUpwUdN1oqJ1+5YNAgIwk1HbpyMIpAy8Im9xZp/PS y7rSrHgzDmgmOXTf+cY0oVL8yRoClfQ= 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-527-Leok8IbMPaWMhJaxElOyGA-1; Tue, 06 Feb 2024 12:40:02 -0500 X-MC-Unique: Leok8IbMPaWMhJaxElOyGA-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 98959879843; Tue, 6 Feb 2024 17:40:00 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B9882026D06; Tue, 6 Feb 2024 17:39:56 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Sean Christopherson , Josh Poimboeuf , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , 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 v2 3/5] x86/kvm: Make kvm_async_pf_enabled __ro_after_init Date: Tue, 6 Feb 2024 18:39:09 +0100 Message-ID: <20240206173911.4131670-4-vschneid@redhat.com> In-Reply-To: <20240206173911.4131670-1-vschneid@redhat.com> References: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172338960865827 X-GMAIL-MSGID: 1790172338960865827 kvm_async_pf_enabled is only ever enabled in __init kvm_guest_init(), so mark it as __ro_after_init. Reviewed-by: Sean Christopherson Signed-off-by: Valentin Schneider Acked-by: Josh Poimboeuf --- 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 dfe9945b9bece..8f48ce7adfb28 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 Tue Feb 6 17:39:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 197574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1706186dyb; Tue, 6 Feb 2024 09:43:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn9mNUE1FK5C8DgidtObVIZJ7x91OYPuZLotdbHInAp9CwSLhcFGqFme+R8WuEQSJ8Mj/3 X-Received: by 2002:a17:907:96a5:b0:a36:2df:5ded with SMTP id hd37-20020a17090796a500b00a3602df5dedmr2669325ejc.72.1707241401429; Tue, 06 Feb 2024 09:43:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241401; cv=pass; d=google.com; s=arc-20160816; b=Gw6UZiMbLfsYnsWKsPCqYmSF8fZ3QX26SVg07kI0xADmMvnEnGji3eriebC7gjG7vp U7UyaCaf5tbzZv/P+YXVQE/V46II2URhG4Iq8r9CG1dcAvdrp6gN1dxSzUnpq+/zQZtn 0FkFXDhA4RH5G0Piw/WPPaIyNZV9gs+PQQlDIm9YEmnXjCg/tAy2rblL2Djy5bDrYJ0Y LY/WEGeoIf7RKy/vdUb1B1CFA49CF5M2uvYf9wOuwQZKq+y25hXUvZF2qqVoN0l1Xist 8XUyl0yt1Z161MOI0RlCRhyzO5krx7dVuFCBzr4j54dSzbjip9ElJISfkah1r38Bzc83 lzaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=e9TbiIW7v7P2/Ue8wq2AyQZ0xtrZV7cRznu5SFXHEEQ=; fh=wPpqlsHVLieyl5/8RKyk+a14ZkybqPiCLRP1bAm83vY=; b=zz5x2G5fXN68iPE68yws/dF/cGACOr7pNBlbvndKjRGO09dyZP7rT6MfrR5wTqKO6e afFyDR/gx/cNMvzFU0emkvPtQeoMFO0/si5fQFmIa4KgY4Jvu/sCttqt8LrS+RaDoU1G b+8StyZSiw71q1BfCg0uF1tq4XSX4/CLCjGZ97Pt5fngYgIPpPPG6xO1LBX2w1ifg4Y2 advc/eobMr/8SUg2XaLnZjDt02vFSLGRewk6ztSiEcJ43yMuDGJF7fclGGLGS5kbQQbt ayB+kYoIkmW4odPbYLu2IRcdB6EpQExW4xhgH46FCsQMJsNPOssdZreOqvQrqvPGQW46 FToQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V99u+Uce; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXj2it/PEFKlfl09s3cZep99TlGJEWf30KF53zRj0V9V2I38KekWxhTdtY7N1+TVt81Zp7jCyCwwPYYuUbtBvi8ussrtg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gs23-20020a170906f19700b00a385d11fcc5si11612ejb.199.2024.02.06.09.43.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V99u+Uce; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E28191F27952 for ; Tue, 6 Feb 2024 17:43:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 167C81BF2B; Tue, 6 Feb 2024 17:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V99u+Uce" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF31914003 for ; Tue, 6 Feb 2024 17:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241213; cv=none; b=qftxBwEKTQzPiTkvAQ3GB256b/00M9jRP04FOBh7zhOePjt5uJYiGkHGr75hy6ExIYV7Tlm9yNGP0WgReUUcLVUhFCw9s4Kppge7f10HJwWm3P5sQBrtbw55Lh+p2Q+Sd8NrYeK4n1HqhZ056Od7oVhbCY0FZlx4nDPCQAcIc/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241213; c=relaxed/simple; bh=S1tCYMcNXkihabDiqpDnmfHcIQO8CZnjsn5bQsn7UME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eQSzH9F2YykDf9weK8PLn3vFQmtDFhYZkMWoTZi6SI+qDHRaLvBuIfz23/8bL1OSwTuCeD+T1K0zBRuCCjW6ByNl5jaF4mxtKeMgl1JWelbtZQZO+vNC2vWjdl4p/oIfI8vxIiQyxFSpdR+IE8RLQDC6V+AzVzuNIq7A+56S0JA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=V99u+Uce; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241210; 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=e9TbiIW7v7P2/Ue8wq2AyQZ0xtrZV7cRznu5SFXHEEQ=; b=V99u+UceR2Jpq/vJH/CA10p2Ua53l1j3dJTD3AYNgn53PORQ4SfDQU/tBMhhGaACZpcYk8 8qQESLy8CdKhpZZGvcG3jLexeyteBVyfjvCL/0NkBWidXcOwEbfkCuTqXcoaAsE7/fTVDG 1KCEGZtjKf6Uu+8Q/R6LUcaIbEGZrj8= 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-488-3Nw8cN53NgCVyR-ABxYhyA-1; Tue, 06 Feb 2024 12:40:06 -0500 X-MC-Unique: 3Nw8cN53NgCVyR-ABxYhyA-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 CC028101FA2E; Tue, 6 Feb 2024 17:40:04 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D20342026D06; Tue, 6 Feb 2024 17:40:00 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Josh Poimboeuf , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , 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 v2 4/5] x86/speculation: Make mds_user_clear __ro_after_init Date: Tue, 6 Feb 2024 18:39:10 +0100 Message-ID: <20240206173911.4131670-5-vschneid@redhat.com> In-Reply-To: <20240206173911.4131670-1-vschneid@redhat.com> References: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172359714974787 X-GMAIL-MSGID: 1790172359714974787 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 Acked-by: Josh Poimboeuf --- 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 Tue Feb 6 17:39:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 197575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1706337dyb; Tue, 6 Feb 2024 09:43:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5wnzP5LHtXqpfE25SWXfMqCx523QWXMMgI+V8++G9tQyjimKI/J0dhtd+Sw05vtFs7D79 X-Received: by 2002:a05:6830:410c:b0:6e2:78eb:667b with SMTP id w12-20020a056830410c00b006e278eb667bmr4310541ott.12.1707241417759; Tue, 06 Feb 2024 09:43:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241417; cv=pass; d=google.com; s=arc-20160816; b=AVjPFUAUuEUeXyG3/0OU9xYB9gpJ3lSiD/VolvzUJmysMfkYWZ9bxMk2AUm9k5cpXF VFmp/7epJVbvRw/POv3NLUs8P6mUAEIwEz2F3mTconZAb2ywticAxCr9I4oIpGIqx//6 R7TI2uzDPgyhIjsVzFUvcNMCuv3oilvXWwvgNis4qfT1iP7LDggBlXR+OvXAU59RZm6m VzBh1KIykvycTyB5ETDpdH45kebI8XoR9g8FMwAgmwE9jzvION/g1deGviCXKUwbhF4W bVafJ3hxsrpfBLbCRri2dM82/Fx9D5mN8Y+633pSn2gMKevlESaQKMFnDRn97p1DaTXm rlSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0DIKSVQAHIC80NxjvBA7Hf0Rcwayb35T2JV1uGe0svE=; fh=ipfzO2r/euidb9OGc9gwrS2v4OPXHgqIs3ZBGbUK3iA=; b=LqZ/0h3CntdE7N8uk2qCtg9sSRLyRopiAUscCrY+7eDHgPTi3HVnYIbyuzYFXg/Yb4 LAXtZlaEOj8DGdXQeKmhCgiij1gtge8DSd3pRy8cEGLkEkjuGq3LELaRTKFYHBWcUnc1 Ac6BbwMLAKtYREW9J8XNWGdSFM4wOzRnMcW1T6zDFs3topTbgRK7bHTEGCXavBJN8hB3 eN6QOojwmDIR5Cka8Tx+uzXK1Yjm2T71XbE+AFbgWsfN+jdz9EcxwvdKTc+mbbqxS/2T Pi1nOF0QkQSaleEOUIkaiIi1zymhElRydLPlRVzxCjztrdKGrvnDS055eHecHgS1DzXr a0DQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hbBEgWvg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUHKvxrAOqDFqTsOsixc6k6GiiSKg00TyQh8IIJ5wHJH0THLY4qJkzuc58vq0V7cy8dHQOv9NoxmuKDTg5iXeVX/6XORA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u18-20020ac858d2000000b0042c06c69168si2789709qta.622.2024.02.06.09.43.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:43:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hbBEgWvg; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55416-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 89E151C251BB for ; Tue, 6 Feb 2024 17:43:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B2BC1C294; Tue, 6 Feb 2024 17:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hbBEgWvg" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F11A1BDE6 for ; Tue, 6 Feb 2024 17:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241217; cv=none; b=F/xgr62nrKPodjlw7WsWbWmXekLkkkkN0ohGxwU5IPAb6CxQJe5GPPYqf3do7B1HSMUpyfxNI743VWt869KEP7RTSbacHFEXXatMHbOdwQ0JBlVxCsFsJDSh7uzH1Nt3cvkEZNTxV24O3CCxKpPK/h/gOxLZe/AaAg9mNIFU8Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241217; c=relaxed/simple; bh=Pj/Lvr3RhnSeb3N65sWQi1MGfOlxf0VpQWQY8/5A14E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Thu0xPpHSCGqqH+GdGMR4/DdNGV50b+4FvUmNfD9eE+UH3PSfUwap5DL1IKNJw12mZddFLAamAt1IRvrdeW4gLgnghHjix9o5D5q4ImWbagQ0yt46bpLUBs1jks7nUH/28M2k21LeJ6vS4a7KxKvFAzARw7Pm9ggzo+Pnew4/UY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hbBEgWvg; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241214; 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=0DIKSVQAHIC80NxjvBA7Hf0Rcwayb35T2JV1uGe0svE=; b=hbBEgWvgl0H+uf92GdKA2xkba7MWfqNY5KTmg1/IzCeDQuBvfU7wtIUNjPprRDbKbsRKKJ 4qXeaqfA5aB0cBdXXcn9rnCk09rJ4Ydy4IGiMZTLsRQ1ZgOCddq5Vz1mDrNjyB3HS3OZHk xXhBCyUl6fjJUDzS3TPy3fUI65yrfrA= 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-21-YsH3nB9OOKS4VDnNf5PLTQ-1; Tue, 06 Feb 2024 12:40:10 -0500 X-MC-Unique: YsH3nB9OOKS4VDnNf5PLTQ-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 51ACC1C29EA3; Tue, 6 Feb 2024 17:40:09 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 241C62026D06; Tue, 6 Feb 2024 17:40:05 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Josh Poimboeuf , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , 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 v2 5/5] x86/tsc: Make __use_tsc __ro_after_init Date: Tue, 6 Feb 2024 18:39:11 +0100 Message-ID: <20240206173911.4131670-6-vschneid@redhat.com> In-Reply-To: <20240206173911.4131670-1-vschneid@redhat.com> References: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172377317877233 X-GMAIL-MSGID: 1790172377317877233 __use_tsc is only ever enabled in __init tsc_enable_sched_clock(), so mark it as __ro_after_init. Signed-off-by: Valentin Schneider Acked-by: Josh Poimboeuf --- 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;