From patchwork Tue Jan 14 17:51:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A785C02183 for ; Tue, 14 Jan 2025 17:53:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7E376B0083; Tue, 14 Jan 2025 12:53:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C0774280001; Tue, 14 Jan 2025 12:53:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0BEA6B0088; Tue, 14 Jan 2025 12:53:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7EF0B6B0083 for ; Tue, 14 Jan 2025 12:53:27 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2C432802DE for ; Tue, 14 Jan 2025 17:53:27 +0000 (UTC) X-FDA: 83006804454.22.8F14473 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 4A548A0011 for ; Tue, 14 Jan 2025 17:53:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QtqarhaW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877205; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fONXSYmqO3wil+TvuZe7xaKAIHytdle1lhLahiVcjdY=; b=FUp+6xjNyv862mvCTF66ZZBvxdl27vGBe3yy08RfDF76l6WLNVLut8q/bIS3sffQgSuiRi KbnyAISNItKMBOcP+durH5VsON1NpPOWDuHYljs6j69dCNoVL9yu6rjxbQAL5M7JYhR9dE +H2BP7xtTmoAtCqbSJwFWTWl32+oofY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877205; a=rsa-sha256; cv=none; b=aaR313RDKqepneseHUUCJ2DhDjpkqVqN1M+uYf+je37TtNWRavY3I2L7gD4ZON5cWBLjj2 tEPApEtkjKmmQVzuF0MMIbgClirg92RPVWa6YhcHUzETDYQGOh+4ANWghH4P0+dHRC1mnI gdmr51f5L+xAg/QTLljcdkg2c58fyRc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QtqarhaW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877204; 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=fONXSYmqO3wil+TvuZe7xaKAIHytdle1lhLahiVcjdY=; b=QtqarhaWXpimStjGdtAyj3/shNdqZFp1Gn/88V8S098PlCAyXd1blUZG0AQNRPSp8W9VhQ DQYvf12lbgZbbnxnOPYxuFc95ypGdlA4hpZ8UruJ6O5B+mKpW4PLaSc3ivX49sEA4n6XTN z5oVgDBXovnk+OUgiZMKdFFAL2UE4Gg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-EPzVHimUPgaLyL-8ZboJxw-1; Tue, 14 Jan 2025 12:53:20 -0500 X-MC-Unique: EPzVHimUPgaLyL-8ZboJxw-1 X-Mimecast-MFC-AGG-ID: EPzVHimUPgaLyL-8ZboJxw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B02F19560B2; Tue, 14 Jan 2025 17:53:14 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C28819560B7; Tue, 14 Jan 2025 17:52:48 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 01/30] objtool: Make validate_call() recognize indirect calls to pv_ops[] Date: Tue, 14 Jan 2025 18:51:14 +0100 Message-ID: <20250114175143.81438-2-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: crmqioxkt3xaeo9u4gt9wjk17y4wg7ti X-Rspamd-Queue-Id: 4A548A0011 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736877205-738397 X-HE-Meta: U2FsdGVkX1+4Hb50dPR/FMSWu4660RXMIV03AOluWKbEjZSe8Yf8A8GUW6xX4eHNIoPJ5Fhan1bVW2eGP5c/KNNAgvsgaGZqYwZ+K352WTJ3Ezi2PXGv+VHzfXYaPmw2P4sffLZRZCJhMrskT8mKsALNnuBf5J5d92gykumHxYRHDfnTOHgVYOmITZLOwQl+/1L7+MZi/Fq7Vl+qBdO+tpH8jR/DIUaX/vuJDzrZypF476DADhGqjgssYv9PB36tpKOb/vpjxklu9ayXx8vAzE/lee+h/XmLNZjKAIdncnUGAXmfO8nBC0LDhsWiYmJdDRtfrZ5eQZ6BxUhfWeeuR/F8Cc3OfMzcv4N46Hg3NkW1+Nifb6BUgnaKE/udMWoNtCUHaB7SyubI43r8dO9mRoyjg0RxHcFHgCA3jUKqE6g6CLuj+gwiiM7T5a9yCV4q/6YXuDg0fGMtnzzq1hEIdGK/IW/FO5QoHzeHY4/sj1RiU7xwMR2FpzkgRo/N7ZXN0rJ/z+WA4GSNer18rnpjo9OVIADC71kPKlw6GPBvPnmauAc2O7kTM6m0Bv9tVxkjMzle0KvB2tDTjMfngzcHoS9pWMD28iinhq4k5F2ACCHplGxA6+ya/Sk+21ETHbURsC55OkBMq5vopNLufmyKWZtL257U0lMXm/j8ljtifA0GIXx169FM9zHesyv5VYEp6+mC8kgG0j6j8XBhLnWbzVfoOGcEFB252AUim5E7wcmDlpyVD4LSAcnhy+RlIRl5wN8F45N2IECblsBfa9K8rUvak4gS7LImInNEFxiaZqTvk5kCp5OYaBF5qPty6ZA6wsUaeCNIqAYN1hscefQWSgQYm8whNlC9R/qzYymMR47c0XV2q6uErZh+Yalbyl2wdGj8qBbZMZ0NyBLlwghA8ZwOmKX/ZDQJCSqZaUs2E1rpUnFpEcdhYx87SeECTib0F0Zls7qqSTNLVoArtDk qJiaTCAe kXamRyRbz2dzzq0RoUDARraSCmHApt1iJyjDC7VKbHWHXsi3JBGkiyIclq1iHrTFPqahPuHaM4yu40hFLy1XVJft+vx6y6DQ4yuCJXeW1uT1YJYV9g/FHIzKO246NRr44JINTjSBZeZHNf5e+qfiVUYzypJ9BZXR//3TDsFsHxqzl4QYVKytw7jZv0dPfcEt43Yh8d8prey9ARWWMHSr4OcR7E2ZuNIW6AlttS5JeiEecfSlSQwQFiOL8lejOsS1HGK9WVlXxmOF5yWYg6/Qd3qIOTzMzZ5S7RW1xF8+6T3yb2Z9cqm8u3Jah5lXcMC5+kooDwVSMTb3zrcpxyYmk6Gb8MdNPVc/EQS3Eam7CFaXCFumnzecWsXoBweMaI0KqLnVtAJeZ8Mxb4EYnaVNfnU87fS06hE+cVy+7RGit9Fuzi9a8riCByzU992wdh1jwyuSKo7h8jMpMv6RSHLd471/HKBybEVyxreWIyzhfT4hL1uU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: call_dest_name() does not get passed the file pointer of validate_call(), which means its invocation of insn_reloc() will always return NULL. Make it take a file pointer. While at it, make sure call_dest_name() uses arch_dest_reloc_offset(), otherwise it gets the pv_ops[] offset wrong. Fabricating an intentional warning shows the change; previously: vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to {dynamic}() leaves .noinstr.text section now: vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to pv_ops[1]() leaves .noinstr.text section Signed-off-by: Valentin Schneider Acked-by: Josh Poimboeuf --- tools/objtool/check.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 76060da755b5c..b35763f05a548 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3448,7 +3448,7 @@ static inline bool func_uaccess_safe(struct symbol *func) return false; } -static inline const char *call_dest_name(struct instruction *insn) +static inline const char *call_dest_name(struct objtool_file *file, struct instruction *insn) { static char pvname[19]; struct reloc *reloc; @@ -3457,9 +3457,9 @@ static inline const char *call_dest_name(struct instruction *insn) if (insn_call_dest(insn)) return insn_call_dest(insn)->name; - reloc = insn_reloc(NULL, insn); + reloc = insn_reloc(file, insn); if (reloc && !strcmp(reloc->sym->name, "pv_ops")) { - idx = (reloc_addend(reloc) / sizeof(void *)); + idx = (arch_dest_reloc_offset(reloc_addend(reloc)) / sizeof(void *)); snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx); return pvname; } @@ -3538,17 +3538,19 @@ static int validate_call(struct objtool_file *file, { if (state->noinstr && state->instr <= 0 && !noinstr_call_dest(file, insn, insn_call_dest(insn))) { - WARN_INSN(insn, "call to %s() leaves .noinstr.text section", call_dest_name(insn)); + WARN_INSN(insn, "call to %s() leaves .noinstr.text section", call_dest_name(file, insn)); return 1; } if (state->uaccess && !func_uaccess_safe(insn_call_dest(insn))) { - WARN_INSN(insn, "call to %s() with UACCESS enabled", call_dest_name(insn)); + WARN_INSN(insn, "call to %s() with UACCESS enabled", + call_dest_name(file, insn)); return 1; } if (state->df) { - WARN_INSN(insn, "call to %s() with DF set", call_dest_name(insn)); + WARN_INSN(insn, "call to %s() with DF set", + call_dest_name(file, insn)); return 1; } From patchwork Tue Jan 14 17:51:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E19BE77188 for ; Tue, 14 Jan 2025 17:53:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E798B280002; Tue, 14 Jan 2025 12:53:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E2A1B280001; Tue, 14 Jan 2025 12:53:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7D07280002; Tue, 14 Jan 2025 12:53:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A5A34280001 for ; Tue, 14 Jan 2025 12:53:53 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 67A7D140BFC for ; Tue, 14 Jan 2025 17:53:53 +0000 (UTC) X-FDA: 83006805546.02.0F607A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id A25B2180009 for ; Tue, 14 Jan 2025 17:53:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TTxCdhd3; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877231; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BIPe4J+MPkclOG0fZ/T6Ew0fi09A38ofFGJkEjEgffw=; b=XWZiGsPcH2Iu1oGPAIbTP8MfEvvk270Xhdt4nAtENeQmmJ9k7ra9B9fk0slP48U2FWsp7a JGKLfu9mSIO+iChnOF3ewCzuBcuqWkwP5WISrjTZ2DEhhUvEQNJWLT8Q/NrgltymVM81s4 zWpuBptIjHfuvGOXY4NKji7H4gPLGn4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877231; a=rsa-sha256; cv=none; b=nFmSD4hJYz9w1hNV2tYrEpWeE37Zx3hTOlZSqPJfMmQ/37m+2C3aP382RXLmNpAC6lH0KS nlUMkEVlLsUJr2uwRD4u6sdRqy4U2ajrX2fV3wHQIiiRXtpr/cOqabCMmzrrsWSBWH5IOH NOLlMR7JyHVb/MZSQbFkf5kmuv9rrTY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TTxCdhd3; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877231; 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=BIPe4J+MPkclOG0fZ/T6Ew0fi09A38ofFGJkEjEgffw=; b=TTxCdhd37xrPsWen86mS+Tf/+zJ8fXbdeOfhXzKZx5/pBhBXRCQClbDLtgUVxXYa8OGn3L CXQq0JgcYPzdH+52ZusgNEIJVB5quQ/PvJY0VVMUq2KD7ACK+IN5Z5ref9Lhm9TxkHw5Lj pTGvmlt7a3HSAJ4XlOuu1oIpKVHHSzE= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-5yEXaqhRNsqIKNRsVS1Lsw-1; Tue, 14 Jan 2025 12:53:46 -0500 X-MC-Unique: 5yEXaqhRNsqIKNRsVS1Lsw-1 X-Mimecast-MFC-AGG-ID: 5yEXaqhRNsqIKNRsVS1Lsw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91E941955D80; Tue, 14 Jan 2025 17:53:42 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE4B5195608A; Tue, 14 Jan 2025 17:53:14 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 02/30] objtool: Flesh out warning related to pv_ops[] calls Date: Tue, 14 Jan 2025 18:51:15 +0100 Message-ID: <20250114175143.81438-3-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A25B2180009 X-Stat-Signature: pnerm3k3dcphy4gyutdwnn5fo7f1t7fa X-Rspam-User: X-HE-Tag: 1736877231-159100 X-HE-Meta: U2FsdGVkX1/icmGwiqnAEM/CCo4rYHTiZ7jwgxTJ9eVVYA/Ns5tmQA8qwRfMoDPNzuZx1vM/drFVKYznx2fHoKJfZyJMGfO+CvwoBKdEMmUiDQTH1o4/KqNJKh9DC2AFBawVIvmCr8dJXZ3S6cepooZfKsAEPfd9XNTVsdWbEX2OZsQTYdtj1aCSmhq7712wjGByRSvQkG554uJbdDYvxMPjLcyekdxKn1twPYs8js/62hdGX9Q/5vquIs0Xi1GeHmEeBFChG2cAlReGBX+icbVieM3kcmhyXet/6RjNIaLZFT+wyOgRYYRY5H8Y4oR0UCeDH79Kcb19IL5ZjNLI2PuVXgOF9f2APuWvnY6LqXpI7684A/SJM12iF8tIiZ70DKahn2MWCFFAqreUgRJZiKo0NlNXGqSt4ZjLaYNalFeB6FZxL/dAtVhjHAFXeevB+qjc7oYthdlSYxORWw9kPW7TayyEDJpmm3LrS95iyEFUhPhLokCaqUgKfZ8zyLIosQycKH7U5AHxG5cYDGJEh0d7Vztd7EPk/jolLFTGPf4bF10V8ulqozRoaEb2gMnrjT3H6YPQmW9aWefORoEoSWDecL5mc3xVnn+xO22pwvYXYW6VVLJMebjr77nFlW4PrRg3PVgvGR67bUuamMp5O6mSLjBLzcLF2XGnfEJjgbk1LMKbQxr3OhOpppp23eu0uKxmSMGDUC4/Z8pb+H7q3n6HzxLIrW5WnXsPvuBw79sTJEufLr5NL8R4pmquXwtyEnXOgMqCRJ+ca0HZelLQsMQWefG50Z9I3nq+hhKUBxw0bGCMSa+paj+zz/VM8LhhjR7aZQnzvZvtcphFq9yMf237Z9qP/1HWSHZvYk6w1FPVNZdxrqvolYehiCOlpW1EipvcfrutIvSqF0cR9ph8jkraqvDSEpn8EHG979yZzpjO9nmyOVmFOTWj+lgYywMi7n2yxISQCQv+e3Zyweq mch1fGoK kJZoQaJ+AOMNQaukWtrBcxsItmjU/dgo4e8IP9ILkTprYZUOGL7m9sDwMbJvi/Vr1IjWI8pSAqqkw0Xol/wIO/j6/PGOAAgDQiCR/E+zRMUkfthPTg4N5xdaV8NwmHdB1OJZ0vckbZ8v5NtmFG1DRcwLQRj7Fxp6mZpvxaC3XS138SVNED4qgWvPEbjlAwFgWT0U1ISp11gi9oXTwg4dfoLCz2KyHMS4POtS6ovUyflv2UFix3y14XhIGbU5tLXHB5/cc0uKDBnFQgmrMNB/BfJvfnvp9JRIQm8spNhpQZGu9KZ6ks+84czQL8BhY66tOSBVZ0Wc1HYJcT+MKqhijLcCTgBYwz7ffZBr9TFZ8jdEVTZW4gL/zbuflTZrxpQBpHf+/Uj1yTp0sP/cQ7SbhdqR5vdrBbsFO+K9VfVECMkIU8COlwFrMqDxO/JzyY5vvV6vGFVdIvzInAH4sdwkCLQ7o3hx5psXoyJy9Y8HxfhrTUMI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: I had to look into objtool itself to understand what this warning was about; make it more explicit. Signed-off-by: Valentin Schneider Acked-by: Josh Poimboeuf --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b35763f05a548..6aa9259fc9940 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3486,7 +3486,7 @@ static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { if (!target->sec->noinstr) { - WARN("pv_ops[%d]: %s", idx, target->name); + WARN("pv_ops[%d]: indirect call to %s() leaves .noinstr.text section", idx, target->name); file->pv_ops[idx].clean = false; } } From patchwork Tue Jan 14 17:51:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9680C02183 for ; Tue, 14 Jan 2025 17:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B3AC280003; Tue, 14 Jan 2025 12:54:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63AEE280001; Tue, 14 Jan 2025 12:54:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48E32280003; Tue, 14 Jan 2025 12:54:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 20E7C280001 for ; Tue, 14 Jan 2025 12:54:20 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A0B681A0BF7 for ; Tue, 14 Jan 2025 17:54:19 +0000 (UTC) X-FDA: 83006806638.21.5FFE719 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id A504118000F for ; Tue, 14 Jan 2025 17:54:17 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jVQiNTM1; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877257; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8uAN/SDgGjGVODi/Lh1/HC+8cnSPzXhphDSd8KqRTwQ=; b=YQ/W05eW484YdS9nd8ghHHmEUYMJYE77/7/TzTwNQyUQ5bpRwUTa4NWdRtq7sRibe4/yCu cR0Y027v6ZD+inuxZa96Y6Xb6utY98LmfRK/UQRWQEDPh4AJieQTMN8ML5axKkgCbkGVlJ ZxWqQOQ8msZDdGW44kDFox0rEuGEomk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jVQiNTM1; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877258; a=rsa-sha256; cv=none; b=sHWDBBIZNTgxKXNlS8ANwfgaEI8lpTQcb4yE0yaeWsZ96bN/4MFA9Sx5ytUEIwlbvq0wT8 JjPaMiY951RHBslm4guXTGuBT2YwmjSj6v2QRjGsX9sUn1jJhq95sWgs2TA5x+lHvWvV1B tzJlKLb+YsDYzQ8w1NPNC6ZKAAxu/mA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877257; 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=8uAN/SDgGjGVODi/Lh1/HC+8cnSPzXhphDSd8KqRTwQ=; b=jVQiNTM1RorR9GkQKxdfDKsqQCCqxBupmO0I+Et8fLTjR9pJk5wARJAOxkBCkz13iZNkrw javtQtfpfvOXN+bogkWKmTWWTfYrLgZGFAYjeKyqfkX8S/uQrPqYvhLGK/Vz/v6IVbLO8u 8+FIbtTDGPE4rFo9wlEj2UhJShODh4E= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-wEhSLQHTPt2u7JUQ3JJxhQ-1; Tue, 14 Jan 2025 12:54:13 -0500 X-MC-Unique: wEhSLQHTPt2u7JUQ3JJxhQ-1 X-Mimecast-MFC-AGG-ID: wEhSLQHTPt2u7JUQ3JJxhQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9298319560A1; Tue, 14 Jan 2025 17:54:09 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 10A8519560AB; Tue, 14 Jan 2025 17:53:42 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: "Paul E . McKenney" , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 03/30] rcu: Add a small-width RCU watching counter debug option Date: Tue, 14 Jan 2025 18:51:16 +0100 Message-ID: <20250114175143.81438-4-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam05 X-Stat-Signature: xqdzuw7eobst5qmpnub1gjqn6p39adyf X-Rspamd-Queue-Id: A504118000F X-Rspam-User: X-HE-Tag: 1736877257-447728 X-HE-Meta: U2FsdGVkX1/p8veJ+QxceMvenR2vBBAnNvrrY9s04xPaYzX7iO6SHXDa4gVNK9SMGNBDe78RyJL3aNZWT70XJhy/dYS+U4M63X+0B30+PQnkQZGoAXQBekyV/PXmDm9KlU9RhubdSOYhJRqHu78tYek6j8rareIFMo3K4ThqThUTsRTW8rwrjfeJFQiuViv8z4suu+KIO59K7XOFzMTKDKx4ZH2o2ygYMjgQ9Jrwc77zYu/Hkf4SmsbWeN76pO205xhs7kfWVusM46W//JD3lvAT9HTXeBQzwuOlu8g6CEDODjdXaQSilD+dlrv2NTXmTV4XwsDhBTwap/CsNPM8DNl806pA+Fyh5QYOidjCm/eRHDlS0aAyjQl0AyAmOCZ+m8nXZz06mtgHUz2GqMKx/eODD31Dm2mpO1DLrypK0PAiaO+wpkLUTxoCxAkEwkbd5n9QA2dLr0xB7DF8LSYw6F7WProJPGRcRV+F2ZAT8Gunzfxx68bqtIAsGkFKIN9CEB7SswF20h9oiBNfFexm04JzwqUryvynCykYmc+xJ6qzHHIDWlQ72kp2g1P+1zFb/CjtNx1WnQV9tTWm5Eiy64F2YQQChL6AcgJ9alQdsQJ8JaLY6z2pwh9rAraqYkzDhFCAcZZcf/eONLwiziepwl0yWWSUwe7ExQDWjjknhyFe0GN0GqeKBblCRnL/IQbQpPI6vYM6qCwEfxa7bXHCmPldTvYWTPD/FNNK/BQRdVdVA0N+ulkuOdmWEz6X7rXJzyz6omcw3j8ywCZvNbLG4Noomhqpuc81GZIUK7v0IKUN4Q7Hjkyf/n5YXL/AfmsFd2whPZgnFIXFAGtAgYW3Vyb5QNDm2ng5RYXFJgx2cdVMoG3LzcPvChSicm17cJOYGJvlIp6VPm+MSlU+QK0a00CcHP6SBe6X/NRRUmhCH19vT/poxl/Oj9x+eEVnlNsaVWh5mNCPmXl5PjuPONg kum7ucko uQH2EmR2Zz5cg7oDi0T0tmf+StgrXMXesSlyPJ8hidIdfhv1njbTAXIuVuzMpWp+sTGHyeNhgLZ1tO1paRzYM1mjDdOxIBaF2V42mgGpmJ62eTn0zhwSzbec1LrPP9f/HTVAU9hixYbn/+RT5Eu8i0oHr3EzPMVy0hSWYZysUQwUJUW8+CdV3MD/IzyL9xw5v6fQqb1uEEkd1WY/+hT9Q3jLee95f3rSdVLfoj5HowURiJNCetX5ZqaGvE7zxhxZDcnkEyWC9b0CT88+2KeW9sVydFuqaiPpWWbVMaBCMDCVjHoXw000+FcqUHj2qtEaXKj6mGdixhiJvmTnJr9uBp8Fe1ATpwgSxPQpcl9HJWkMDNygU1JJhRuwNEcgdUSK+wLFPCWzoUYXogwBfW70mwutwklsmSgjUomMfJv3QDGzJcIJZfeQdtYWUsaWs3MlV2wz0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: A later commit will reduce the size of the RCU watching counter to free up some bits for another purpose. Paul suggested adding a config option to test the extreme case where the counter is reduced to its minimum usable width for rcutorture to poke at, so do that. Make it only configurable under RCU_EXPERT. While at it, add a comment to explain the layout of context_tracking->state. Link: http://lore.kernel.org/r/4c2cb573-168f-4806-b1d9-164e8276e66a@paulmck-laptop Suggested-by: Paul E. McKenney Signed-off-by: Valentin Schneider Reviewed-by: Paul E. McKenney --- include/linux/context_tracking_state.h | 44 ++++++++++++++++++++++---- kernel/rcu/Kconfig.debug | 15 +++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 7b8433d5a8efe..0b81248aa03e2 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -18,12 +18,6 @@ enum ctx_state { CT_STATE_MAX = 4, }; -/* Odd value for watching, else even. */ -#define CT_RCU_WATCHING CT_STATE_MAX - -#define CT_STATE_MASK (CT_STATE_MAX - 1) -#define CT_RCU_WATCHING_MASK (~CT_STATE_MASK) - struct context_tracking { #ifdef CONFIG_CONTEXT_TRACKING_USER /* @@ -44,9 +38,45 @@ struct context_tracking { #endif }; +/* + * We cram two different things within the same atomic variable: + * + * CT_RCU_WATCHING_START CT_STATE_START + * | | + * v v + * MSB [ RCU watching counter ][ context_state ] LSB + * ^ ^ + * | | + * CT_RCU_WATCHING_END CT_STATE_END + * + * Bits are used from the LSB upwards, so unused bits (if any) will always be in + * upper bits of the variable. + */ #ifdef CONFIG_CONTEXT_TRACKING +#define CT_SIZE (sizeof(((struct context_tracking *)0)->state) * BITS_PER_BYTE) + +#define CT_STATE_WIDTH bits_per(CT_STATE_MAX - 1) +#define CT_STATE_START 0 +#define CT_STATE_END (CT_STATE_START + CT_STATE_WIDTH - 1) + +#define CT_RCU_WATCHING_MAX_WIDTH (CT_SIZE - CT_STATE_WIDTH) +#define CT_RCU_WATCHING_WIDTH (IS_ENABLED(CONFIG_RCU_DYNTICKS_TORTURE) ? 2 : CT_RCU_WATCHING_MAX_WIDTH) +#define CT_RCU_WATCHING_START (CT_STATE_END + 1) +#define CT_RCU_WATCHING_END (CT_RCU_WATCHING_START + CT_RCU_WATCHING_WIDTH - 1) +#define CT_RCU_WATCHING BIT(CT_RCU_WATCHING_START) + +#define CT_STATE_MASK GENMASK(CT_STATE_END, CT_STATE_START) +#define CT_RCU_WATCHING_MASK GENMASK(CT_RCU_WATCHING_END, CT_RCU_WATCHING_START) + +#define CT_UNUSED_WIDTH (CT_RCU_WATCHING_MAX_WIDTH - CT_RCU_WATCHING_WIDTH) + +static_assert(CT_STATE_WIDTH + + CT_RCU_WATCHING_WIDTH + + CT_UNUSED_WIDTH == + CT_SIZE); + DECLARE_PER_CPU(struct context_tracking, context_tracking); -#endif +#endif /* CONFIG_CONTEXT_TRACKING */ #ifdef CONFIG_CONTEXT_TRACKING_USER static __always_inline int __ct_state(void) diff --git a/kernel/rcu/Kconfig.debug b/kernel/rcu/Kconfig.debug index 9b0b52e1836fa..ea36953803a1e 100644 --- a/kernel/rcu/Kconfig.debug +++ b/kernel/rcu/Kconfig.debug @@ -168,4 +168,19 @@ config RCU_STRICT_GRACE_PERIOD when looking for certain types of RCU usage bugs, for example, too-short RCU read-side critical sections. + +config RCU_DYNTICKS_TORTURE + bool "Minimize RCU dynticks counter size" + depends on RCU_EXPERT && !COMPILE_TEST + default n + help + This option sets the width of the dynticks counter to its + minimum usable value. This minimum width greatly increases + the probability of flushing out bugs involving counter wrap, + but it also increases the probability of extending grace period + durations. This Kconfig option should therefore be avoided in + production due to the consequent increased probability of OOMs. + + This has no value for production and is only for testing. + endmenu # "RCU Debugging" From patchwork Tue Jan 14 17:51:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88882E77188 for ; Tue, 14 Jan 2025 17:54:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15BC56B0088; Tue, 14 Jan 2025 12:54:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10BC66B0089; Tue, 14 Jan 2025 12:54:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA0226B008A; Tue, 14 Jan 2025 12:54:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C9CA86B0088 for ; Tue, 14 Jan 2025 12:54:45 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8094280AFE for ; Tue, 14 Jan 2025 17:54:45 +0000 (UTC) X-FDA: 83006807730.03.15DB87C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id BAD568001B for ; Tue, 14 Jan 2025 17:54:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NcxdypVy; spf=pass (imf30.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877283; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sXsyWlIRHxUaG616jNoO6fTMagUzfNCGxp09271a4iI=; b=zdnIOzsHSiRd2gRmd9nnQsxLv/jMxEwCbFlSWihNzihDWz8tmzPlxxRCyrDTQMDfWG18UW qZDIGL2YKpdcYCE0U2WRbMneYGAz4Yy+Y4Y+vMmwn3ZS17xiim07b5o+w3gUxufkfcMxL7 s709+P3q7gMUuWXdb2ma6yf1CTj6Gw0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877283; a=rsa-sha256; cv=none; b=tOjsJak9demev8Y2bHP+eMzbwH9uWI9KFDGjt6IP/vW8rbqUG5t6RCarQIkwsZ94mbXmeS D/iAYJQW6PJqG3vSkq45bPQhxXr1bBPYT2dAZCtVjp3TF3GtZuz4cgQ89AyJGhTw9ciCPT luqNEMG1/ECwPCXjw40CsEMZ7gf3XbE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NcxdypVy; spf=pass (imf30.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877283; 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=sXsyWlIRHxUaG616jNoO6fTMagUzfNCGxp09271a4iI=; b=NcxdypVyNu+XipMn7CzdxJzN56AyGlzt0+tFUPAeXIZ5gdSYyHTTEt+A7euttxd6FeGaLX pni1Y3GrCi7XgWChDPuvNtYrACUZt2bTPzmb2DhkVSWY3hc1wYvZNyZ4U0K3RbwbpYtHpE 9QGoum5kzy/B7PYmktoX/w/yAfuVBCo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-NTn38snjMKqDKDXKnJ2usQ-1; Tue, 14 Jan 2025 12:54:39 -0500 X-MC-Unique: NTn38snjMKqDKDXKnJ2usQ-1 X-Mimecast-MFC-AGG-ID: NTn38snjMKqDKDXKnJ2usQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C835019560B8; Tue, 14 Jan 2025 17:54:35 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 151C7195608A; Tue, 14 Jan 2025 17:54:09 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: "Paul E . McKenney" , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 04/30] rcutorture: Make TREE04 use CONFIG_RCU_DYNTICKS_TORTURE Date: Tue, 14 Jan 2025 18:51:17 +0100 Message-ID: <20250114175143.81438-5-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BAD568001B X-Stat-Signature: 5ghyfoftzgtuxka8h3o16rinx6z5kdxr X-Rspam-User: X-HE-Tag: 1736877283-285689 X-HE-Meta: U2FsdGVkX1+oMsLtmwNNV3KgitVWvIsKoFgDZklykhTW7fbinDQmTPVEnbBKN89B6zN8Fd4gGIIDwQz5UjcatXzBI1NCxj2Y8LG1kg+EIc3m1+gn494zbfFZQaZ3w9XjPmi/RcFSs0MXGD2NSfm3bub2dpvf4PoAOkNHiXsFKGkHmz9JqB8JhNQ91vaF98WC2PE7L9r0MUV/iN8pwSZcmta/JhXPMdDuANugstW3GLPh4/6tfet33XO5CVoq6vAPaGvJ4HuN56d0/V2HC/qB91PUSYwabLLFEC4qiiRQCvs4/NCWrKmJX3slgteU7NkYpiCjigoUzl8h2xSAQum14U8ZC1sQ4U7ZAFloJskJkBQ1HKpBetp05T6YBLvcWL82Z6hai6Tvir8/1vXeEawmMZ88qAgmFLFNurTPn9nSw7Lbd9X+KQN6HXHtk0QNRZGeof1BTYRXszuDJoItH6Sil6+59bikGu+/hYXdBMyw1BQcg60ffi8Q2P6uZoYvyZFgXgiamScU5QUeVMI6B9VWoT207JwpjFntiQ3suMx4+mhdpiOWihSdWcmPPv2LbgqDACjBLspVxsjr4y3kGb9p4YzswlLWqdWZGFbaVJfB5gSRsH0+SlwWbD+1MLspLgtpplOCazqGfK4VQv7u7bKxn+JltcakEa+g5g+CDxSiRb8gnCLQD0R/9ml/w/gZPreWA1PyaNA5JttFMQZ4aQk1sgpgxMjACb3J3Iye4SDi/MUvOsx6WxsTW5Ma0Ica0zrXPfQF8Pz7IGnRfs27us7MeU7TyqTqAslzzfoKlVeLyhf/z2Vt4JtQEeagtglFdUvRYNTBe4kjnvvJTzrS3jLQ822Taw5zgcsiX/PDQ2+5XoWSL0qwa6VrBWuBabRH+wkR6Ss+GLC1a6k5AhLj38OZqvlvKMDpJgvlXo4YMspsvnbdfur+Xb7LklIz4mmOptoRTKFeN7GiTyDvzKRJ9F1 FIcrE/n8 f3bvBkXC/xnkn1kef3xBiqPBdi17IeqdxIH9qH71OZzRMD0nont/Myc0Xk5fOvIvfBhGO0MYnN/Htm20la5E37vFv9IVjTBpZr4kjmxKnZrkAhVCGFEITTpjCC+yPt5uorTQJ9kgzKbNtOCkjMjvEXP+MeNupCMBFpJkR3J0Lqh3A/ytrmkh55y11nWmsMvMOAjo1qyqIh0czYX8QSvrXFgaIT/ZXXpZhAgAZdHcRaPbL6oilhQ35i+7DdM5ZYEbsxqpPhO9KQdZmeKAhlJygvhXYuOYKhcw05Q/e8bZ9tjgSuUCqkb1qABeW+UJEq+6Y5F/KVCDELeU14DV6BAc9NnFLD4IOODmU7SSZbFQEbtsdsumbFdl6axr9OHSriqdaa9ONXJDWnU6e5r/G6lSOnxAnFG4GC1uKwml0C7YO28HRCwFoLK6hR6yaPe8te9dAzkV8s1AXYq8ZsErfeKuRKWCw2JXMiswz5hY7CgInYkRRbeU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We now have an RCU_EXPERT config for testing small-sized RCU dynticks counter: CONFIG_RCU_DYNTICKS_TORTURE. Modify scenario TREE04 to exercise to use this config in order to test a ridiculously small counter (2 bits). Link: http://lore.kernel.org/r/4c2cb573-168f-4806-b1d9-164e8276e66a@paulmck-laptop Suggested-by: Paul E. McKenney Signed-off-by: Valentin Schneider Reviewed-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/configs/rcu/TREE04 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE04 b/tools/testing/selftests/rcutorture/configs/rcu/TREE04 index dc4985064b3ad..67caf4276bb01 100644 --- a/tools/testing/selftests/rcutorture/configs/rcu/TREE04 +++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE04 @@ -16,3 +16,4 @@ CONFIG_DEBUG_OBJECTS_RCU_HEAD=n CONFIG_RCU_EXPERT=y CONFIG_RCU_EQS_DEBUG=y CONFIG_RCU_LAZY=y +CONFIG_RCU_DYNTICKS_TORTURE=y From patchwork Tue Jan 14 17:51:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A46C8C02183 for ; Tue, 14 Jan 2025 17:55:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A47E6B008A; Tue, 14 Jan 2025 12:55:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32E1E6B008C; Tue, 14 Jan 2025 12:55:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15A276B0092; Tue, 14 Jan 2025 12:55:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E68C76B008A for ; Tue, 14 Jan 2025 12:55:12 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B170280A00 for ; Tue, 14 Jan 2025 17:55:12 +0000 (UTC) X-FDA: 83006808864.13.04F2383 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id EB00E40011 for ; Tue, 14 Jan 2025 17:55:10 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jTcnElGV; spf=pass (imf07.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877311; a=rsa-sha256; cv=none; b=l6M+zw8KZS215ubVJW1az0NUwoPCHClJdYVb/RTWk7O+p8+g0DXooxcXUnz17gXonEW7jZ 6t0oJrBzl4xCqdhaQuO7WGvKFjVR6ho45MskQZDyP5IEGdYrAEHof8RjVokGixXEKuxvq0 zoOnyJeqtBSRjePGMJWYxzupieitv8I= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jTcnElGV; spf=pass (imf07.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877311; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tq2pU6+Sz+OC+aH2F2609vpzg9lrw/4sZVW/JKS6LBM=; b=sdxQzwJpqx7Yfq1iibk0ueBupps2jTf7rSQFiVpKPJqDc203lEQ5DQWYHOaz2K0lFaqUa+ jsQdGTg1EJntJITnKKc9saGbBnedqCJO4253LmxTjSY3in0Ihzg+H4qZa+CwQUep4YEmW3 xE3qMyqRQYONsDBBqTTTRWRrhg4Weho= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877310; 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=tq2pU6+Sz+OC+aH2F2609vpzg9lrw/4sZVW/JKS6LBM=; b=jTcnElGVl+HCTOWay4u9OobIOl315VUnU7YWfp2W4fp93e167H/VVl7AiMJFEmF0Wk8YWC w8H2nYT9gI+4L1/IH3K2PePx6WxozFP/IsPKhY4RlLqc+l5nojxmRsHU8HCZXF0j/TdL+I Vd5Q5wv1RbJXmjNF5hSuFt950CWNll0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-rasDThuXPT-KkBXykuo6Cg-1; Tue, 14 Jan 2025 12:55:06 -0500 X-MC-Unique: rasDThuXPT-KkBXykuo6Cg-1 X-Mimecast-MFC-AGG-ID: rasDThuXPT-KkBXykuo6Cg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F41581955F67; Tue, 14 Jan 2025 17:55:01 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 594CC19560AB; Tue, 14 Jan 2025 17:54:36 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 05/30] jump_label: Add annotations for validating noinstr usage Date: Tue, 14 Jan 2025 18:51:18 +0100 Message-ID: <20250114175143.81438-6-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: EB00E40011 X-Stat-Signature: z1dmi5xz73kc98ejhg8hgkkettcwgytu X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736877310-804938 X-HE-Meta: U2FsdGVkX1+fDnPPLXe3PTkL9fnC4CcAfK4//SNxIdNdx/RpPt+0tFMr3mVlvgbjKuiT0h13GSZM/wPJDRMYHpwqZU6xE6oIGxiC6+czSnoO2QjhC46Ax9cWJLP6g8rEVYvny0NmvIs9JIE5mkXAV1THLZn715Bn6ZmLKZLQrWPIqyLZ1Hc7cO2QuYOCkMAYCSotymwvnD5Qxa6hVHuwpKWY5QDzYjFEtDCAcPVaqgQNADSHzFXePisZd6CkpNUx0GRd78v28IpawaIDcmJlaTZyC6oPjpzfzjgde9FCcc4WJ6r/1D0fK5r/cd9d+uBaDUP+CU/0ksYqDTo9AU9ntt1+YKNDyn6eUgDgHSEDah2CVCrS6mNNsBNsptjs3SwDYEhsY7fpJDN+p1U1+AAF4u73GBPiFZeuo7UgoBUsMhmcXuzmUeuj3taprgWbvjUiby6rOKH9TEqu51/4NuRUx9ZrrmPsDRvG+vh/9Falh6saTgK+5EibLt/9e2YbotESoedAOHlN+N0gLLWFi5rl2LCCNnFb1hewOJAkJb4Pu96DjIo+ckeJRAjPMTGkc+0CBAl9ev2tb5LGINtELzLHrf1l3GXMI5CDDPxgK73VXuEOOJ+rSpWJzAN2b9cm5IYnnDB8woZnwUDuvDvrujUDBbqpQGo3LIUtPVrke2QC6c1T3+dcQ3j5L4Hmr4LIjD8WIPvl8WKaMGljbvv3NKRWJdMxK9ojA15JONIat4MGdH+m2q/+3UvsTnKRLkDjMpACm8UCqzShGSmyPT3iTSRqKmiucN/ODjOohjBsTn1JoWqmJugooKenYyI566sAWi9l6LHctP3Xxyd28MrQrqpOkXhSQy626My/0TV1fDgBiMsBVyLakzem6b4oPICXMJd3gqWdNelYMbvAYhY+wgVYtpWEnowtz0ZfO4Hwpc/HJv8NIxuQ0Ol4gFIT1GG4zffr4qy+ujEX0Vz+fg3ByMS yoX2V+1y nKmO1DWc3yuuh6275pGfyUQ6mP4dm1sSNIw1Jq1Ot9dTNDjTMKrzi2ioXNiZY7vaKdO4vES15WUk35dJj9F1gN0OroiutgVWDARTvB9o7Bsat1ho5ZsDOfOI8ibSLKCQvbkacz8apnnz1ceWQlSyJz2LVVhZTUojZDwAc6ZS+rdzHvh02tsYl90moaXjc4oNRWe6ggBqMtdF6Haj8GdeBgrIPvdMS8KSVic8VJTk/B5vODFexcjRTyH4mmJJb2SKouFjLD0XlM1NxDrEm8T3cHtnjSdHd2TmIcNKxFmLrk0vE47avofGl/rGk+d5D0RX3b6hg9XHIbAuGGXYzJvtKc34RTpH8eUDffMd447lIIumcerowjX6Au0qvSNB6nJ4C+kKtODlG5fMb4BafwwRks8NyO/sezfdfXNcBJpLP1U9toiHCkv489FFrC4bO6EK8V8ldFAB6jNfIBjjGSTUCFmwgmw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Josh Poimboeuf Deferring a code patching IPI is unsafe if the patched code is in a noinstr region. In that case the text poke code must trigger an immediate IPI to all CPUs, which can rudely interrupt an isolated NO_HZ CPU running in userspace. Some noinstr static branches may really need to be patched at runtime, despite the resulting disruption. Add DEFINE_STATIC_KEY_*_NOINSTR() variants for those. They don't do anything special yet; that will come later. Signed-off-by: Josh Poimboeuf --- include/linux/jump_label.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index f5a2727ca4a9a..88bb6e32fdcbc 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -385,6 +385,23 @@ struct static_key_false { #define DEFINE_STATIC_KEY_FALSE_RO(name) \ struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT +/* + * The _NOINSTR variants are used to tell objtool the static key is allowed to + * be used in noinstr code. + * + * They should almost never be used, as they prevent code patching IPIs from + * being deferred, which can be problematic for isolated NOHZ_FULL CPUs running + * in pure userspace. + * + * If using one of these _NOINSTR variants, please add a comment above the + * definition with the rationale. + */ +#define DEFINE_STATIC_KEY_TRUE_NOINSTR(name) \ + DEFINE_STATIC_KEY_TRUE(name) + +#define DEFINE_STATIC_KEY_FALSE_NOINSTR(name) \ + DEFINE_STATIC_KEY_FALSE(name) + #define DECLARE_STATIC_KEY_FALSE(name) \ extern struct static_key_false name From patchwork Tue Jan 14 17:51:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD656C02183 for ; Tue, 14 Jan 2025 17:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E159280004; Tue, 14 Jan 2025 12:55:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 26B05280001; Tue, 14 Jan 2025 12:55:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09692280004; Tue, 14 Jan 2025 12:55:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CCEF6280001 for ; Tue, 14 Jan 2025 12:55:38 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 79BA5AEE9F for ; Tue, 14 Jan 2025 17:55:38 +0000 (UTC) X-FDA: 83006809956.28.6C5B87D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 776D440003 for ; Tue, 14 Jan 2025 17:55:36 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Z3/AHxWy"; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877336; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yW4eDMpnPb09nDVWkM9p9gFnBpCcE/XnyyFFoIpXh9k=; b=rcQyDZLTtKFcIb0ImyDDBCE4F5syUI5631nkRMzyn5OnECnES8j8zBjJWWk7nwppHh0YgO ZDzhiQ7Ha0m0A/OStVQ7EToS7GOYPlUVVmqv+kJWzelirTfwC+W44zA8TPOoHwXIIHp0fq jMx8vAbM9Ghy2Pdc1qPoL1cmWYDH8oE= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Z3/AHxWy"; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877336; a=rsa-sha256; cv=none; b=PIYBKOyzgcg9dBc9UHz0bKXk4YkvbB4y8gZV5hBvjtUu7DutPAe1ue/YKUbQYsmrlTmFoW iNW/+KchK2Ylaj1KryGXviYI6Ln3gbKDKBw7KD0omg+YpKAG0BUylohtb8ZbP0jkVczMWl cggH4ZsiOCkPEF3Sw1xHjvKUHBqXOYU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877335; 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=yW4eDMpnPb09nDVWkM9p9gFnBpCcE/XnyyFFoIpXh9k=; b=Z3/AHxWyDTYIX1loh/q14XYJwkjSbc6315IzDO1Hz+BouHf1RlVU+sVYQckHFar4qPRi7W LRNxKmNvkv9il+ijRBf9wKpS+aE9I00zdzmbYk9C0gRuV9TW9i/QnBrSr6jBmKVdtrdNS9 pq6sImwx72yOvDGS4aX1Jrhzdv038Go= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-TCnp728BMva_I5fFAbpK4A-1; Tue, 14 Jan 2025 12:55:31 -0500 X-MC-Unique: TCnp728BMva_I5fFAbpK4A-1 X-Mimecast-MFC-AGG-ID: TCnp728BMva_I5fFAbpK4A Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC0371956053; Tue, 14 Jan 2025 17:55:27 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7D2BD195608A; Tue, 14 Jan 2025 17:55:02 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 06/30] static_call: Add read-only-after-init static calls Date: Tue, 14 Jan 2025 18:51:19 +0100 Message-ID: <20250114175143.81438-7-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 776D440003 X-Rspamd-Server: rspam12 X-Stat-Signature: npjuw5at84d9qbrr87deedoyzqnc9ykp X-Rspam-User: X-HE-Tag: 1736877336-219054 X-HE-Meta: U2FsdGVkX1+cpjUyEC+x7jjbj8afY5I1us9QoLCRDKthlqmeNU5FH3ldY2xbsyuDBlCGGAObj057S8pHma74hCrhy7xikquiCqFZXhkY2Jy6lhGgWw/up0ghvpSSuGHTeqWcnWp0LDr2og9rr3FdTKSk6oZOjOikQLlJYVjM2ivla8eyKZO0yeKt7bMOsggjVZzCx2bJZYt8E/zD5HLIv4Hhx1IGu2DD/kgDuwFx7uYUJ1fJJvg4gnEa/DeFjRB+9ousipXbyvY4gfLnHoSy2/ahveLPUGbTg6bUo4OJ21s3xeV3bONPIO4FfmGHp7RvlxUx6rtEPLrJzjuMWMpHWTqcdeL/13kKNjjO+X86WTDV4nAd2Oh5+xMeD91G3NLsffLAHC3VHP7ivTTNHWgwTb7ZkxheqvvZH486h6oq3fScphzuFyhUQXpx09t9yzx8DKKfNmtqbhBCZY3H9oG8Z+/SBfdPT6tzzwNvEIiJIrCYzkTN1U1Se/ghPga7nnrbU4AI33mwDWNQ3uiilhZLnrkFI6NZK30+oW8Y+s7FHKOPoxYnocMzZ/LZ7L2yp18LKlHXobTaeHSzglnmscUAo56l0Om6Oh1DdJa1reKEtWWE5TwCZTf3EHjcfvsAZwZekaAi3PS1BapWEl/0gqJOxa49GNXJKfag/NnCiUMO/BUzT0Vm1z85IcjMfSznlEVQJ0x6ShtEm74srAZKcOE+B//JchttRkLl9elA1olxLHHYb/8b8zMPAZM6EnDiaE07Al4G+Mh97tdNgTeXLPpmfwOQrXsI6Alt689uOMk9MvUoX4hE1aeE/oar/0ZMbEuOzhcIX/S8/eeJW3Ns7pFxGgNU0jfJVOhp+UIyHUV4D7Om+hmb9iIqx1vMbxULhe3q70bJNKPxeaeXHqiTSnM5JGsbt+FzOzteLdHkPWVyHHWcGDR8qtOM5Bq+tecldWwPhMILbBnx8O7Uk2u2pvE e6Ez4ca6 YhqebmvM6/tRzqdr1jSVsvkW7G0N7Sc5jo59F/ZQiiN5xGnPrfItFeEtJOkx6AULkxWTyOmBouHWAee16HinJ3GY6CikDpuaHNlAE0J0aEbTc988eSnaebQhuxx2q5KbiYg/TtMwjWbPrfM4kvlK+4IwhsQMpB4e22OwXxLnHdQbnfM6QTe5nf7pEBT7B1V9w8ZDJnaXNOvTFzcL8wUuk6GauKdhkAae/pPaLDHsq28XvvqzKcUwfl2jk7CLGydPjB3Cfyn+HgcleqRZuH+urM1pEn5Z34TgwNoXnDtqDw9P6M9rlIupCRK+dgKNCiQ0f8Y8xZqCH15YW8mimgKz8j8BsI53ssZFEJvlVye3hWI3mLLGc7K9SUlOVyTd58aSrdQH2v37ZH1scXQ0eMp6mT2Ccl8yTAVTSupLfpUR5K8PQ4azfThxLZ6oPtA2y0rAeCEMpnZqZ3Pc6OzB4IgvrfQUhPw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Josh Poimboeuf Deferring a code patching IPI is unsafe if the patched code is in a noinstr region. In that case the text poke code must trigger an immediate IPI to all CPUs, which can rudely interrupt an isolated NO_HZ CPU running in userspace. If a noinstr static call only needs to be patched during boot, its key can be made ro-after-init to ensure it will never be patched at runtime. Signed-off-by: Josh Poimboeuf --- include/linux/static_call.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/static_call.h b/include/linux/static_call.h index 78a77a4ae0ea8..ea6ca57e2a829 100644 --- a/include/linux/static_call.h +++ b/include/linux/static_call.h @@ -192,6 +192,14 @@ extern long __static_call_return0(void); }; \ ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func) +#define DEFINE_STATIC_CALL_RO(name, _func) \ + DECLARE_STATIC_CALL(name, _func); \ + struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\ + .func = _func, \ + .type = 1, \ + }; \ + ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func) + #define DEFINE_STATIC_CALL_NULL(name, _func) \ DECLARE_STATIC_CALL(name, _func); \ struct static_call_key STATIC_CALL_KEY(name) = { \ @@ -200,6 +208,14 @@ extern long __static_call_return0(void); }; \ ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) +#define DEFINE_STATIC_CALL_NULL_RO(name, _func) \ + DECLARE_STATIC_CALL(name, _func); \ + struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\ + .func = NULL, \ + .type = 1, \ + }; \ + ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) + #define DEFINE_STATIC_CALL_RET0(name, _func) \ DECLARE_STATIC_CALL(name, _func); \ struct static_call_key STATIC_CALL_KEY(name) = { \ From patchwork Tue Jan 14 17:51:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63CCCE77188 for ; Tue, 14 Jan 2025 17:56:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB789280005; Tue, 14 Jan 2025 12:56:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6837280001; Tue, 14 Jan 2025 12:56:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9328280005; Tue, 14 Jan 2025 12:56:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9B00A280001 for ; Tue, 14 Jan 2025 12:56:03 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 57E0A43F08 for ; Tue, 14 Jan 2025 17:56:03 +0000 (UTC) X-FDA: 83006811006.01.63567A7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 80012180002 for ; Tue, 14 Jan 2025 17:56:01 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hmrh2re3; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=P7DcLPe7N47ORcKkDkopF1lM4hKgrpRYFpILYCZNJJ8=; b=8lWUw9FxhY+fOjsuj+9atqe8WwedlzR1oUC/F9OySyyWLVZ/gBqz/li7arkbvznaaz3pSI ouxENXJRMwBDsR1eEiYY4Bk6WUfcMEa5GuqYpvqzr/pdmvdxFfLjM6ls9tg1HLP+FAc0qQ klXhoA1aXmHSmnuNCAW1meycMzY6oEU= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hmrh2re3; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877361; a=rsa-sha256; cv=none; b=CF66dmuNYAXz4bkAv60HTaGNqcKCl2m9bIIesHVo1gPUaavFLwb7yZXH4YjrevRyvdxsAG Cb1n4buhpU5wGc57lCJP8UwIAwRzplBvbKrc1luSlmLVpHbnLPKWtX/ddnH/MCo5+B/U71 WsS5XqKahxw4PHyIXaJ5FAMJNr8or+M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877360; 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=P7DcLPe7N47ORcKkDkopF1lM4hKgrpRYFpILYCZNJJ8=; b=Hmrh2re35pneF6+MKShEnpiJyIiZGE63kjrakzUNSGzl64C3jXoHC0meAYeMlkzigUBfZg deTOR+KBgQtFRd8psw2tMmOUJS+r6qGkuf9+xQRqGN9CaNCx9B4rXw6iGuMJDum6s6l8WM slG336zVaM3wwKuEfaCsls2EqQ3mrQM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-jE76dcsZPt-31fHWsIhMBg-1; Tue, 14 Jan 2025 12:55:57 -0500 X-MC-Unique: jE76dcsZPt-31fHWsIhMBg-1 X-Mimecast-MFC-AGG-ID: jE76dcsZPt-31fHWsIhMBg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47A70195609E; Tue, 14 Jan 2025 17:55:53 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6703A195608A; Tue, 14 Jan 2025 17:55:28 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 07/30] x86/paravirt: Mark pv_sched_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:20 +0100 Message-ID: <20250114175143.81438-8-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam05 X-Stat-Signature: dfe8m1yg6embzecqufpgq5rg9w7t8kzm X-Rspamd-Queue-Id: 80012180002 X-Rspam-User: X-HE-Tag: 1736877361-42139 X-HE-Meta: U2FsdGVkX19/Zk8XpxER4K0Rtam0tUa9DF3dxPDW8eVkrdi34BVIkMiksBk2DMFE4EfzRRC1GtdybiPM1udmrGN+yyhNk65qGS97ZjEnVZvzPPYJDShFllrkJzw2wo9gJu5qgqncMEbQp5ZPk34TaqH2e9jJAlVaI7t0g87L//8331IhIX8ApYA1K3upwkFcLxLudi457DY3RMEmAxamOlCuc0Wazkn5xP0zG438A7si+UFmwppf/+o5fieI0KXgj5/KuUxoxPcfno2w3/vpN2uqvtoOgEv+1nU6RGjgQ4Ir+NRvD5NZc7vnrcJLX5+GWmq0/nXvhgr6a/ZAFmMNw5phAe//MenTzfzWFZTuJvRsMuly80xz5rPi2j1igaqgPlKPSp1skWDBK3GhKfzaWUgNgXhFcBWtKS0MEQKVfAgV2QqdDNWhir/W9jIyb3E781G3xuGqp4dfm9vvZSfRtd87zCdbGtAZt2eaycUeYqshWOl1TNq/2iIC6jJU0FJsqMAPy4OBXgi0WkQaNev1IKfrbZ8N9kf2TWOmQ8cN+IZbdQDoo3nLdxhXQe15i35+/QmcJDhXDvi8kuWnELStIJp5lBNDHxtL8KpPrWmjnPhL3NlfuzP3KiNBpuzCIcaksiVSTcIAKa8mzll3knbkJ25K/fmqmzrkwMwsT2kXabG79qr5CRNZ8ybaT0gdtpMZCIztDcLX8NFfxx7084CvmO5thXpGZ9pgQTroGH35oz5Unu2ptfWOmY7KzzNg1TAJIDNL3zwS0Kt5GtcYSDj5deL719xf97cuEG7liJhgWy6zJ2hOu+W2Zer9wm+wod+tBklkL1KjHqzMhJMpJTD+tbw9+d0boai2U+B8ppIBeDi+bs1CkTQlBmvVk6D3jDol0z8ZoVL3GXEYLGaxOm2g67TR2tKKKevV7X4wRuZYqGhvJbkEK124epWzqgfWkbBren39Xcn4IxzmFhLqc7J QYnBBg// CMsVLDXiWaKYtmEQay33COjUh/If594qteuTty0VrzF/USGCZrjiPv7pPCILeFIIoJm18yE0rBRWMF0jwq0E7InG6PFi37JkFul8KNofsMUNhdTvWOL5am68ow4Vui7EFJeNq09WY0wp9JoUy6AAq4OSemO1uxtfFTjYxiN5ggLd2h82FvgDPOstyRl/FefGLCfHKSs3l6cynzv6RQzB1eUny+YiKDn9YgzBt7wzTRpPaKKPaKsVnZwDhzzDl6JVM4QVxnEBl6BcZX5107OUYZKx2g2QQMDFdO/2D1YhleJpchN74rYDFXdjZJsyfZND7wyB9UhhOm2gY8JhzCOrI2hMAZQHkhgCNL/2rYtmw9nVvpoWMceIZaePCDfNJu9/ePbLoA3ViXGMKeRFQogroTfuk5ODUoVSuQXZ/PegyP9Gw/iGxX2NmPXWqf05w4vE94cgZOeLr+JDk73FFMeIuN5imGIR37LGmW08MTKsCyigCjpU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static calls being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. pv_sched_clock is updated in: o __init vmware_paravirt_ops_setup() o __init xen_init_time_common() o kvm_sched_clock_init() <- __init kvmclock_init() o hv_setup_sched_clock() <- __init hv_init_tsc_clocksource() IOW purely init context, and can thus be marked as __ro_after_init. Reported-by: Josh Poimboeuf Signed-off-by: Valentin Schneider --- arch/x86/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index fec3815335558..ae6675167877b 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -73,7 +73,7 @@ static u64 native_steal_clock(int cpu) } DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); -DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock); +DEFINE_STATIC_CALL_RO(pv_sched_clock, native_sched_clock); void paravirt_set_sched_clock(u64 (*func)(void)) { From patchwork Tue Jan 14 17:51:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C46E7E77188 for ; Tue, 14 Jan 2025 17:56:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63DB0280007; Tue, 14 Jan 2025 12:56:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EDDD280001; Tue, 14 Jan 2025 12:56:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 440BD280007; Tue, 14 Jan 2025 12:56:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 21E18280001 for ; Tue, 14 Jan 2025 12:56:29 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D4F381C76F4 for ; Tue, 14 Jan 2025 17:56:28 +0000 (UTC) X-FDA: 83006812056.12.CD0B8AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 003A3180012 for ; Tue, 14 Jan 2025 17:56:26 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i5MYSo4r; spf=pass (imf24.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877387; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=upN6bWUdwddcYtCDglXcedCwjwFydQLGp2NkOO9id+w=; b=EUkGvlAoONp1of6y48Bs2frhFFQI00oRs9tg5czxfgN7p7LoEUxWKMJJYkS0t0YhtXUAw5 tu6q6KsFgPkj1jHyeMGA7sb/9I2RM4yTMG8cYgFkeOrZSKivv47mTwhDbPLwRx1V8KixUr E4pEH+kr4GNwHDSh7Fe9+6jVLM1FOGc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877387; a=rsa-sha256; cv=none; b=BaVcVZWng/PSnFe9/CeiquOUK5VMjm89EW/N27/k5Yc7PrrrwL7jRodzqYAVWiINSCnUH3 sZxnpPW+r2Ws3dHNMGkS0whflzGdUcfCEPpVIDcTJJa2gjXDvs/3eYacCssU7sW+VSJrmE tjSAQoZ4dspKfLDiitg0jTFZnGiZ4F8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i5MYSo4r; spf=pass (imf24.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877386; 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=upN6bWUdwddcYtCDglXcedCwjwFydQLGp2NkOO9id+w=; b=i5MYSo4rfZX0AdpyP0NiU5uKc8tWCXorgchkpXVMPyOEokRuMjJ2jpkCcyydDONdcT8Cdh eBIUEjVfHF11XPlulIJgPoWaN/rHgj8y3DJP9uFCUSCMqBTkpBolbCmLMqtIp9mbkxN9Kf s2BI2uVupTRVZN5obRUSuiKxLB0jT88= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-ULU7yixpNjKqcQQdXKvPwg-1; Tue, 14 Jan 2025 12:56:22 -0500 X-MC-Unique: ULU7yixpNjKqcQQdXKvPwg-1 X-Mimecast-MFC-AGG-ID: ULU7yixpNjKqcQQdXKvPwg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 83AA919560B4; Tue, 14 Jan 2025 17:56:18 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE8F1195608A; Tue, 14 Jan 2025 17:55:53 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 08/30] x86/idle: Mark x86_idle static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:21 +0100 Message-ID: <20250114175143.81438-9-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 003A3180012 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: dwt3zurwnqp74uan7iyj8nyduiydcpcp X-HE-Tag: 1736877386-830177 X-HE-Meta: U2FsdGVkX1/pM2QIayl/8hxHA1hXQyuqniMLxryGdScsEmxcGLqleNvwMfFJ4yAFVqPqDE4kBnuKicLTjEuH3t/0taYgrkXgsCk1+lqxFjG2bYQPK36Op3DCE1DXozu277zteqMgSbcI3rnLI1Mx/EnzQIxdALdvL517/S+qk9V1WgZSPE5Ut0j3RChgKiH4u9WQluOdWj51IOoE8dJAGZPmSUX3QbXnPU36LqM/wjjhbxW8EnFJFacsBH6D0oaNosdR8KBrcXav/n0P0rhn72/UtLbSkQiWZ8UZ5Ic4tK/isyV3B8ARak5Tce+waFEQQTGCQXZ3j+79RvSyW2NDtwcoVSZzwNTGLL3Y/DluRFMQFYHiejdxbjhw9QJqS0OXOU940hiUl9dPR3u30g00w6VJCAM+D1/p97Tcjo0LgcxriXIJECuPc+CBLvBpoBP3bP1QoYjBuyyjr+RNXhEyY1qc7hy9c2FIO4H7J+Sk55XEIT12vzTibl+J1DGthKtP94ANVnMoU84fxhmE9ga8m4DGO831AtuuuwKKz8Vw9AWJh+xwAg/Mj/Nm3O81L0EVQGfYgsfxC4xcd5hYtvIyCvXzIN47n5mKOT5CBPqRZYM1DbjUJxEqkyQ6SkbxyrjdoMYGuF+L+bPqbrIXpLHuXOgetM4DcTE/BR2H14TcYqwc4gRY1Ruk3zBxZz2WfjMs8P/E8y5lAQArdK620NCZ3nSHGIQif/5BdEwaZkVzjPz/4CY7EwVszp8fgktgLsvqgYVfEtJBvu4xj1MEx/xEYeILfWly1n51bkOoHECeGryQOtTbccelMmFF9+PzJwWJzpFBYh3IT3xLsPkH+7OgtNnJAwxqxxB6nz/8KNmWjDHolDU94PsQj8KrNM8HlcM2hiK56JqiolHuWdt1kpb/Nztac3FLDdA1Ng/mKQ6HBeT1/Z28lbhPEaKuGfjokxYRMCakhBES7YQmqg+zZux 3kC94Ei2 zAWuFsUwJ8ktZXpwZMlDoBHkU+2c8tkCbIBWeFFxMbUgyVaIK5tg5JRYrocADg2kT6beINCAK2NGfW32LoPIFGSlLVq5YOZHwYtGAmiB5tXV0aEnzp//grZ1A2yBKlM7lbdc7DkofVawBSStV5gzcmfzXXDVNpB9haI5pfNImfdERLEoujIxkArqDURQ10ACZZMm8qxDnY3DwNBmkILs8co/gMAMo2r1MiU8juPN1LyB0k2smPrv9bIgd7PilYWhZU5wLcZ1VAqknP7npZNy/Utu/EFkVfbUMHDJMNcYChKYySiRpOqTcaEuSC31WqiFuXIsxcJomkXBaNkeIdWAhy8XVWOoPEfqHRXO5xvdsgCir9eF7c56+ihZFRFXWk+i5JUDqfzCPqqmzXSRefheA0PMVBL96itHT8UWBW8jlY6INVnCwebmGDl7FR72HiI2+dt1VYFy0fJgX5h2VjBZV8Zc2QZMUS4jj08+wFxA+DzS2+d0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static calls being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. x86_idle is updated in: o xen_set_default_idle() <- __init xen_arch_setup() o __init select_idle_routine() IOW purely init context, and can thus be marked as __ro_after_init. Reported-by: Josh Poimboeuf Signed-off-by: Valentin Schneider --- arch/x86/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index f63f8fd00a91f..85cd62f61d633 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -746,7 +746,7 @@ void __cpuidle default_idle(void) EXPORT_SYMBOL(default_idle); #endif -DEFINE_STATIC_CALL_NULL(x86_idle, default_idle); +DEFINE_STATIC_CALL_NULL_RO(x86_idle, default_idle); static bool x86_idle_set(void) { From patchwork Tue Jan 14 17:51:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06606E77188 for ; Tue, 14 Jan 2025 17:56:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75009280008; Tue, 14 Jan 2025 12:56:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D7E5280001; Tue, 14 Jan 2025 12:56:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 503A1280008; Tue, 14 Jan 2025 12:56:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2F285280001 for ; Tue, 14 Jan 2025 12:56:56 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DCD9BAF7EE for ; Tue, 14 Jan 2025 17:56:55 +0000 (UTC) X-FDA: 83006813190.05.151B189 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id B9EA018000C for ; Tue, 14 Jan 2025 17:56:53 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iAqJgvqS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877414; a=rsa-sha256; cv=none; b=eNrjmgepCaNpgbGmRoFuOWoTVulqJjujHmebB0NeAKXpuBZLNdBf9OPQyodawSsuFlA037 EjqnOHpa7nsNlggQHtLj7yF0izOMi7S1n+giiBAaicVOQ9VQpzf2fWgvC+f1k4u+aJY8OD /kok2LLI92EMZmDyCMpwZZ69HuE6cmM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iAqJgvqS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877413; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=a7Wvwh2A2o47NLG/+LsYYIZxdlkCdbCUHu9ph/pgaME=; b=62cAorsoKTF2gaeVDKXBf+LyP5s1Pye4rth/GNeg0fn2jLMu+Ao11Nf5eAiFUwFtReGKpT HZuMOW9gp7ifO7IyceVs4VnV5osYkeIh47O0IsQP55bFwjDGWKNEynO7oDSU8QODfh5OKb s+ygGLatd5X4SXUwCK/3A67gbNlLdqM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877413; 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=a7Wvwh2A2o47NLG/+LsYYIZxdlkCdbCUHu9ph/pgaME=; b=iAqJgvqSyj3pWzMYYILkQQZaQXrSYtuhFJqnD0s2J43l+HoQlq4kKHP7OBLUHZ1cJGLBKy 7c704gBlj0xJ6pHdj+9+h3r+g3YaKlNNUIym4AOcfLd+7APSgjzFncqtGuh5w1WrhOgR/p o885UOOMuktmpPLguRRTeSGVxbxYZi4= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-83-lu3mCN1QPVqlwCLkY5ofog-1; Tue, 14 Jan 2025 12:56:48 -0500 X-MC-Unique: lu3mCN1QPVqlwCLkY5ofog-1 X-Mimecast-MFC-AGG-ID: lu3mCN1QPVqlwCLkY5ofog Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 03C901955DCC; Tue, 14 Jan 2025 17:56:45 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1AEB019560B7; Tue, 14 Jan 2025 17:56:18 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 09/30] x86/paravirt: Mark pv_steal_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:22 +0100 Message-ID: <20250114175143.81438-10-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: cp8b4obteii7x3r63xjdmh5jbp7r94xh X-Rspam-User: X-Rspamd-Queue-Id: B9EA018000C X-Rspamd-Server: rspam08 X-HE-Tag: 1736877413-131136 X-HE-Meta: U2FsdGVkX1+XCozWL/OK7m7ppnIuycpanHodXW4MkFFsfB9OwR927EYpaWBmkGsCFLjPWJTtVpBaD0G66485UILEfN8Fdzbo5ckkZNYMev3w/qCwTPKyg44g5YLVM41RsLTOfKovj8CTIDjvNb8Iojc8ZRk7SkeaMQaBTHhWbkSYdRh+GQdq3aZwIJNKUI3GCUwXLqgxmOgEEUU48oISnxSi/NKydXkEPo22xoOsvJ4gJ2klp1Hf601T1OuG1bZ8psGfmhRUgmnGxAaVqPDNi81/tyg057sMX7KO1jca6udC4wqJJxgEJbF5qMHnJxMD6ecIVvSLm6j0w+5lcAqBeSlZ4uVmFoKQ5mAbe53EGz9rK4k+vrp/+gUj2XdR+M4X6Ide5udKJVYJA/khIaq8K+9gdp73P1qBi3jVYLQ1DGqxfYyFVvGoAGZUvLG7MevCHJKWzNQl3wmZPRGYUxua8NDSrjQv1sXl8NvEi5wZVzEIMqQCfT513mQBEwYTOeYa4CJmSFeTYXvVwkteI0tL3lVdjEB9dqPk0vd2tUbeWa6VfEZ0N3BpYTlWhRIc3CWsClRrLheF225cYn9xzfDBi0Y/toB+p8M75YRdjJOF0DuEnppBHoCh3xAAu43eiCcSLhppNCLAMdOPVQjU34qTE8r9Imgf5bceYqJHf/K1q9qLZPO8xLPIphYsMPdiDzNOekxDRnZr0Rn2z9MxC8ZoB/QEi/kBvozOfkg2DUi6f3dgot4aylQ79A7Af1C0/dYCeVufNgWWhQdzO6LHzxw4Xv2fnavV4fkJ3IEDFaf5+ZWbDzgTtMIdnnzRFuMGe/JrclFGMGgwOifC+nJvRssMu5KqRgJgfQuH7V3UT4PLXe3gt414d+cxVQSnK36ISDN8k5b+NmUjA7im3CgRUJwEVlcj/TWSzEehp/oYBFNbZUfVqUO5dJjH3Bk6ghbGX4VgQGxYpfbS4X0B66Bxw7d 97QXXsY1 Qsa5v4uYd7qm5neOG7phVK7EWZFy8Ve8bA3cSC7LbpUs08sI6BGW547M7+vb4HiyT6nQ7PGQnq+80HpR/D3bynTEk3FMnPKBLENHEB/eDIfwgkqgUORRwHvB1LJ1xtmqqb3FBlTNHi9eg5rezgUdGUg8vVNhUnQVpzbOpKia/VUG9W3RzDNQOwfYhaBGeKHJg0HN3E9z7KrOsiMNrQ57TxsjQ7NmVtNaVtJ+sUuS4Gl/xKjZl6bcqYtt8ajwL+E1ix+U6Hy3/B/6qpdLO81dAatgiSJEECxurN9lz90lJEJHjpXbSZYkUlc+Z+wnaSRDo+ybCZFN0l/I/SI5pMZnR4SKYCOv+lG854krvspLc2sCfkZ2kFazXRkye763fftqqf83oXy1xpWZHBi59kMEZDCY4UfNO0c9RcR1IjG4MzYtGAOJ9NLgZ2rcduP/fUGVqCEWTB73gtxCKPTM0/ZnA6eTisg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static call is only ever updated in __init pv_time_init() __init xen_init_time_common() __init vmware_paravirt_ops_setup() __init xen_time_setup_guest( so mark it appropriately as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/x86/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index ae6675167877b..a19b0002b18d8 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -72,7 +72,7 @@ static u64 native_steal_clock(int cpu) return 0; } -DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); +DEFINE_STATIC_CALL_RO(pv_steal_clock, native_steal_clock); DEFINE_STATIC_CALL_RO(pv_sched_clock, native_sched_clock); void paravirt_set_sched_clock(u64 (*func)(void)) From patchwork Tue Jan 14 17:51:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C428E77188 for ; Tue, 14 Jan 2025 17:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC9B9280009; Tue, 14 Jan 2025 12:57:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E523B280001; Tue, 14 Jan 2025 12:57:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7DDD280009; Tue, 14 Jan 2025 12:57:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A6E53280001 for ; Tue, 14 Jan 2025 12:57:20 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6A9E1A0BC6 for ; Tue, 14 Jan 2025 17:57:20 +0000 (UTC) X-FDA: 83006814240.27.498B2C2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id B3C5914000C for ; Tue, 14 Jan 2025 17:57:18 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OAYPLUch; spf=pass (imf26.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877438; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IsiFsDssoC7X6eXx4w8a2ZnGZKlFjYm7iqHh1lVo3b0=; b=TWa3rHgFvMLHepGpCXzvcsB9mwttA+tTP6Qp9Q5x4aUj+IzWJCBsBPuKgjlnzsCM0G5XE0 ht5M/WruwzJzaSjNRWb9LIkvDgRB0zBjNTPVmk1Vfmt6QOsu9edqg0eWE/K6SjcCc6KnaS WZODJxOT7wlsd2A9/dlQQjAXIx2BF+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877438; a=rsa-sha256; cv=none; b=uPh8FVrPfDBSG1Zhq4B0ljuFQQ3GXstvQVdiuANc33Jzn39yhEn6axa9OZOIv/uMhR2jZc qbm+N+Jq4Uj06ishstS5oSX0iKdcY1aWat+KqOw8x04eEgNJuIOkNwlgm0YMO0vYhfwUrJ N9dHs3tIWsYVYzSOrx/TjETlVmAW880= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OAYPLUch; spf=pass (imf26.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877438; 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=IsiFsDssoC7X6eXx4w8a2ZnGZKlFjYm7iqHh1lVo3b0=; b=OAYPLUchG2aL5HbeU7MOeCgd9uAZinQff/iVy1iMYYHd9ntitVtYwiPzcNd78CsJt+aXlx FTIPcK7q/m+lAzQIc28JPyU7mOlybPccRWKsG7xIwFzQd4UA41+RdqwKbovf+LKbviBluk dY/hhKza1gJCsEALRHCq5OJQ87VMU5Q= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-EHMljfk1PzCiodKs1Rlu3g-1; Tue, 14 Jan 2025 12:57:14 -0500 X-MC-Unique: EHMljfk1PzCiodKs1Rlu3g-1 X-Mimecast-MFC-AGG-ID: EHMljfk1PzCiodKs1Rlu3g Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E80561955DC9; Tue, 14 Jan 2025 17:57:10 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 76727195608A; Tue, 14 Jan 2025 17:56:45 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 10/30] riscv/paravirt: Mark pv_steal_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:23 +0100 Message-ID: <20250114175143.81438-11-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B3C5914000C X-Stat-Signature: 6zt45eiqiknbfs8t53ok75uttiebkypp X-Rspam-User: X-HE-Tag: 1736877438-257959 X-HE-Meta: U2FsdGVkX185Y5flL2XMji8p3f+EeoIsoRAD8Qx7dr6GbZoCChJNsuuIyir2pGxhmDK8j80bvbXm1SU0SRHc79B3rOK+aPY49EzYAVmWQ9jJxxIa3Bwd6L0fh9UP09xlSkuFky7UAvKysjiCbNLYqZlPzaaqJFtUU7THxY0IdllWtdQUf6/jYgeOHD0bM57MoQuMDtj1FRu7rmY6sxWX21b6t9dR+lIsnAuDVUXM9P64dg+RC/vwSMkOx816+baQZwnuBhWP60UXuVJ8Ny8QfUQEqKF9jyF//+yEYxHR6nmXYmntMRSMSH12DVMoTjmsyQ/ltELC4AKRTIozNIYPjE6y1ORfHUP6lZs2gipGN8dwLExxoSDvqmo3rKl3tx9h8swrMMKOKwil5nED973NxLb8f6CZbjspAg7eIE8ACLzWRVth/jGpScFSQp3Pq73DUm0//bTKNFe+7MrTD9QvzsjsbBZXp82mWCO8PVu43Uut+bah7ryx03phVpZ/DJbxQmqarJJb3ziaTSaJ4yLxiZk3M54IvKZTHDW6ZfD2Kp7it9UeIY0UGlSllJZUdFqlOIsaG0xwG10aV5fjj5zt/w9mrcvNFDtRfs1JTBA+AhsoSzWrek+TfWsFowLs208tvn2+qcEVOiKBtGvPNDGzT7RdqbBQpu8/fFplLlPEbhjBpFp6BEOThss7ge1VwrU1mc6dedvcIfLj/57qH+GVNCNvRyRYsXN3jYORwwedJPmTNNcQ/BMVQ3+gwZvObsAbY5QEuFadv+7GkUqWOlILFHwyTKCSCxAkA2KkHGDEZRG1j0UFsBm4M4mVIRN5k/E8ptyIzg0gTSgsh6RUtRNxbu5XlYh3GfGn+NDLrU5JQAg2At0yAvNfBkuhDtiE3CdkuS4JbLnOciievsW0QuPw16ZEpZ2C+wrW02ZksP6xUBt1ai/53GAx1tdgcQfq8mYem2iJwwJtuq1qijUdYyV FDa8MI5W YdnHeZ0U/8N5lLAOg++vwN7G5lR9rC5XJBz2pFP7XlRrIE4B2sBJ40w1djA/sGDdzwc8MnGGIMYlqu91mz3ZPyCMasMxZkNe0SGY2amd7dhqBFdvMxA791dJJ2fmhZEdKE9QwyRRqd3XvQTrf0qfmQYcFrHIQqblnF2m5lTcpntCcr+P7aLjffCme8QYdrMYuKyM5T+EYlwVYQXmnde/jg0kRra6wI6Mt4akyM/hO79t3AzYun5HhL6vqI7gHjf36IZJh8AbIrJBAJ+JXotgdwxLcVqhE4x5+UTAVwiUfriMdITaJ6hn2pXJS2JnVa1lB2sKA/nXws1u30EVQcK5bA7G5B/zJ9JqFZTHtnpduGQ/5DP42lZFG/LswjEkLzpFii0cqsoDqANVOsUl//apmic7GIXeaN6DrJyXG8HX6jznyPFiTYGXOcYJW1gXY47i9NEHANTPe4lbK15J/oucgl8Ttdg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static call is only ever updated in: __init pv_time_init() __init xen_time_setup_guest() so mark it appropriately as __ro_after_init. Signed-off-by: Valentin Schneider Reviewed-by: Andrew Jones --- arch/riscv/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/paravirt.c b/arch/riscv/kernel/paravirt.c index fa6b0339a65de..dfe8808016fd8 100644 --- a/arch/riscv/kernel/paravirt.c +++ b/arch/riscv/kernel/paravirt.c @@ -30,7 +30,7 @@ static u64 native_steal_clock(int cpu) return 0; } -DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); +DEFINE_STATIC_CALL_RO(pv_steal_clock, native_steal_clock); static bool steal_acc = true; static int __init parse_no_stealacc(char *arg) From patchwork Tue Jan 14 17:51:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12874E77188 for ; Tue, 14 Jan 2025 17:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5DDC6B0085; Tue, 14 Jan 2025 12:57:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0CFD6B0089; Tue, 14 Jan 2025 12:57:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 886706B0092; Tue, 14 Jan 2025 12:57:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6933E6B0085 for ; Tue, 14 Jan 2025 12:57:48 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 08EAAA024E for ; Tue, 14 Jan 2025 17:57:48 +0000 (UTC) X-FDA: 83006815416.03.68D5E74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 4346840014 for ; Tue, 14 Jan 2025 17:57:46 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i9YCqHqH; spf=pass (imf04.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877466; a=rsa-sha256; cv=none; b=Bjasw4riQNKszwaPYp7js87fagPjsBqv5QldW55oBvdd0+KKilvJnpwVScpmaMSPQFnxf7 mijwwiGabZhqpNOI1LVNwfNV2JtlPyvApx/m7re4FoF0/CKplX3C6S1IByDAqoE4cDrcoW RoU0+fS2KyXpBhRYQtuIQvkVBPX7GkU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i9YCqHqH; spf=pass (imf04.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877466; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Gy6UStH5/TBRQ5eoVZhQAO0glKmQfzTIxzfOHtHv+oU=; b=vD1cA0F8M/8DXQbRE+xDcrssuwbxr4DkAkOVX7cR6L4psKJsT+AwmvqJZYjYHSo8vxSFJn 0NjhoMnxPlg2qiDl4Tn520cMRXiOrAddWcc1TIbCqc7gZIJ5m1zj+QdZb2Qxnfw5cRGWn5 ZhhjYmuyc2cvSsmJtQohI7cGPz8qlRc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877465; 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=Gy6UStH5/TBRQ5eoVZhQAO0glKmQfzTIxzfOHtHv+oU=; b=i9YCqHqHRbaEO7LbKGWwOZF8BeWjzgC/fqJzL8S0kTDO/wGpG2aBtrj/+jmum4McieHDlu KX38ONfSxWCh83SMxMXNH9dee1mxzZno5OkkUiiMGI2ywF6/pGRx4HxwS8Q+OYRzMzrTZv vZSI99Bing6cp6bHhhqZQyOyc16Cnzk= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-MPFxqqEtNGCUUE7KC7NLrg-1; Tue, 14 Jan 2025 12:57:42 -0500 X-MC-Unique: MPFxqqEtNGCUUE7KC7NLrg-1 X-Mimecast-MFC-AGG-ID: MPFxqqEtNGCUUE7KC7NLrg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2C9851955DC6; Tue, 14 Jan 2025 17:57:37 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 69120195608A; Tue, 14 Jan 2025 17:57:11 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 11/30] loongarch/paravirt: Mark pv_steal_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:24 +0100 Message-ID: <20250114175143.81438-12-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 4346840014 X-Stat-Signature: xxx9131jc56uxajejcufsyy8m8kgp9g4 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736877466-51634 X-HE-Meta: U2FsdGVkX1+6srnBWHyCRAQ0lwD4Sdcfud9W6EvBAK2BnfB8DIdnyTvsN8Ru0KJDD5arEUsHzAclKcoqM7/JhRrAwxpiCZaTAKY9YlUnXbO3fsDwP64F08je5KHGQnFjxq4AzkVFBngOvnEXbq6J9Bk39NUUj4sfKvD8LM31NWhbybDjYCiODscWngjzuoENzfOeFXvM0crSKXasM47BLZCqyB4L/aR9WJp4Z9uNmlTxXZbYmlF7r4YDpOGC0RBwFqaT2yVTMuaxBNQmmoPJfJP7WNjpkB0ao7JKtgV79d6ySABreoqWSRkALS4aqYFlizq2LchoSuhKRseznVUVeHU6DZiezqrU3onWXOJT9hwNAJq0JpASgbvwZm9L86AsVA52sMRx1F1hzeseJpK8mR+0m5yPARCH48CKMmUJiCAO8/fdZkybpzCkxZzSnUNO1EYQwKfMSSPYAjs89Hfa75GZkFoaHVZ5s+lxfKpgNJgtpP+mpXfE6WTmyi0IvICu1XAQb8ebFIf4IXsZi1kOcgr4BXRw4WjMm8eINfA6DHfj7yn9Mo22YW988HzEVLYFjpcwwrcBI66vCW6g2fCR0oNS5j+rKook8VBPlzMI91c9uCYbh0kWTKGDNEnm2LFXLl1ANH22C7XvTGOyMya3LZka6exfP1STgJ5hG7XbVpt3co0nFN0vRvkgNjSPRpCEPDh+INibdKk5GcshcqzICrOjO3xj1g2f4lnAYOKhutLwUkpyd+dCsbGHlT2Md3mrRo4R4kwmMeaCW7Mir7ErulEa7iLyVJpQP1w07t2xN9LbZ2EX3CZwZ1FdjSMWV4YjT8OOQdAp7XTrHwWEiItscpxAXAh7fjB+Q3WFjngmYVFNN1JET/nAupzaa+iRfn0vKpYvrNpf0u34gRka7uNGLscSqhmRg87qkM/vhE8vzCQyh9K/HMMb4lQopv6SPHEBwM1si78F949wvSMRi/3 6R0YEX/I kMmVz6wXM/75/DM5BSYruBsdjBlYYazJI4OUCntoABKpmeOpVlS4O5HZp/j+Dcn9J5rzFI1MfQwLNt1XGM4bBG4NvuCtW9iFksL/z+Ewmj5pdJYhtZs/fxWf8SO2r7h/RkWrtYAmCJpU71QuJy92Tjv3Rw9Ml3oDo010+kIAZ4UQFkAYXs8/fzvpiWlDVqgUy46CFb1JZn21ww6Vm4UOj6w2zxq/JQTB0OzTif8T8TzQZ4LA+t/h6qW7lrm2Exaung/Ep6nc1lQ4SB8EFS6zH3ppfChhLCzk0lZjRxOBPzw25J6irbUz3hOR1JJaRe24ffjBcjfe/T0voykBQC4+uNLdQEi9jdRv5n6gGlyi6tv1qWer/09ns+TbEcf6fFsgOjdvYrnDhuvWsjVSDDJALhq0/X+DuxPaT78xVSD3NAOQTbO2Ag425NNCqg2i30LD5kRKlcBom+WLYawTbziGJc/kVMw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static call is only ever updated in __init pv_time_init() __init xen_time_setup_guest() so mark it appropriately as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/loongarch/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c index e5a39bbad0780..b011578d3e931 100644 --- a/arch/loongarch/kernel/paravirt.c +++ b/arch/loongarch/kernel/paravirt.c @@ -20,7 +20,7 @@ static u64 native_steal_clock(int cpu) return 0; } -DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); +DEFINE_STATIC_CALL_RO(pv_steal_clock, native_steal_clock); static bool steal_acc = true; From patchwork Tue Jan 14 17:51:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F441E77188 for ; Tue, 14 Jan 2025 17:58:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5DE96B008C; Tue, 14 Jan 2025 12:58:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0FDB6B0092; Tue, 14 Jan 2025 12:58:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 860986B0093; Tue, 14 Jan 2025 12:58:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6807A6B008C for ; Tue, 14 Jan 2025 12:58:12 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2F6DEAEFD8 for ; Tue, 14 Jan 2025 17:58:12 +0000 (UTC) X-FDA: 83006816424.06.D9B807D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 4D7B140010 for ; Tue, 14 Jan 2025 17:58:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eK0D8wfn; spf=pass (imf01.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877490; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qXsyEmzNJ/sfD0UVcKoaU7D3OtZ64iLWu1bVWX+toF8=; b=UsSZkyqD98iqJxuk2sVdSgFZnz2gB22jQ14FtXWWRCliDe15AgxB3Q0qJDw25zp4Cdgtv3 7eQAIAYZB+D4wA0O4JfkDjvqjLBU2L1FOSh4l3t8nCh79etjBMB/fpqVB80dZ6HOKr3h5v GyP/WaUTDYb5XRK88CjoUqAvHTJQsp8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877490; a=rsa-sha256; cv=none; b=oZylOJMAhc4I+wiOH2iXNlsAiukZIpsQf2Y83PctrN7EMjdSfP4yzTcUvdnfPngQ1c1yc7 CRRDYnbFVLmX8n9TT76wl4D53OhuQxkZn7XCFHy+nVA43g5MsP0ouuHyu+j38AGUmiI2p5 i+j9odOnTuyvdFPUBeVKEctF2un4hgU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eK0D8wfn; spf=pass (imf01.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877489; 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=qXsyEmzNJ/sfD0UVcKoaU7D3OtZ64iLWu1bVWX+toF8=; b=eK0D8wfnzYbpE1qYLCne6Z/8z+5Veuhh55adJNFYKRbj4MFZ4jH2EUs+3BzXj9R51kdi73 FyM0ukk8l/VxhE4fBkEF07l+Trjv2Jy//GCLKrE1tIp7HYIn1bO3elRUjjjns2fTXcJf/S 5VxSX8mSkIgsxAwAtTHaujz3v3rdLuE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-MmrH9LTtO6KBV4tfRF2CNQ-1; Tue, 14 Jan 2025 12:58:06 -0500 X-MC-Unique: MmrH9LTtO6KBV4tfRF2CNQ-1 X-Mimecast-MFC-AGG-ID: MmrH9LTtO6KBV4tfRF2CNQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1F7F195608A; Tue, 14 Jan 2025 17:58:02 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E84C19560AB; Tue, 14 Jan 2025 17:57:37 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 12/30] arm64/paravirt: Mark pv_steal_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:25 +0100 Message-ID: <20250114175143.81438-13-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 4D7B140010 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: c1wctqgmnerskdi4dafrygiyabicrsmk X-HE-Tag: 1736877490-113854 X-HE-Meta: U2FsdGVkX19jxuT7n4UJNPC5ZXFJIsg+yPXWljjbjnRcPAyNCmZZmYyTXuOINkyRsHenIjvyktApV4L0iMNC5e2Bb9rlY6ZQJ0mQIxY6ZS9TafWfnpfEeexCT+QDtJshP2n/DCcMXCTjV5/I3b/S8Td7ITPS9bA9sK3jGa+vQ3FwtkGGrcIwqKwelxGzM6WdpBFhw6jYMXFCJTF4OoqwC0Xy/KzXRbpIvzjrSThn4Udd6SMozMxk8pg0SjCCpX6rJKok96RUrL37tRJ+B4ErHO4ZJypwTLQTImHfh1QJRChOPqA23b8hFMQXOBTy83t9NBPiIc7242rOah8N4fYS8r4qXIhHTNMMeK9wyO69U4AmAcl4WkwcOIemu3Th6SMCx761IW09nzPXkYzy4aL/ZvsbrV93JQPCxuJlQ7sGtKBJyprLmJUih/fyFzKHOICxqJTJrdUzHewFEGHn/Q5IeEQphLTcGFp/yWRm00wgngRJS+oF+tCt/KjKIo6t3DX9TPMXhESt3DKjS6GvTafacwL/zUsF8HlpE43803IpJgEfErUezmKOEJaJah3oH2l+CvUQTqHkcLNBriSbNMoyDrjbO5gYVLqhJw0jblGTL360eu/6lgDpl1N/CkxEUzWXJ4drNP+yqo1mPZMBgNU+Srk2dfT1AwHPVTKrC1rWmmrJZuneXRLVBiBd8qhEPuPPsIdLzUNS/FI561YyXzzJ1HdC15YXRtQLyirTCivZylnPsYJviwZSgKTB5mEjsVbv3VAypQRooovqVgJoaCNVfyz6LHon5tlb06LRrgnaMSRXmAyZFVHnbyq/oRA6j91dXr2Nd9TDBS5uiP3cDtseUs+l1nnA74q/cA/CNeBYTeMHdP1uS7aLSaNBcmSlgXehNT06IUS3ULTWJyNV7EWfRhRTWUWf2ryauNAuuPBID+sgT+SvRC1Rl08+IHRckmVZvaTn8CKT6zV9HdP98T8 rjy+4h15 QB6OHvJOl4iP+PSN80U2PeMQB0wJdpn4xjHe8xUlqKiuti3/RhOwDUOkmWioTOGRdlWFAaMOXvAR3A3qZmIuNun/F0sovcBMXOU2bOVG8GLlWbE2Gfk65Q7y3mlKV2g4APAphl44qUwHqEixFZtGtXMm7NkVRm9ON1M35WmV9LMREF7uFFOxc4nQnM3niB63n6xqqqSE/+tY6xV1eCwixSydBfGuhPZr3J82sosLOtDTt+1buyRfTrFzT0XDtib6qmYg7hxGer8Z6IjPbkmVxYSn9LgOVnsY1jss3YbWjyx+qrZvTfyk/mUpRnpPzin8BUq4uOCgWkAe+MnatZBDN1a5k93blfQvL3BEjkCAAIig9CM8X67QsfW/UwaWmfAKK8PLdvsqT56JY53/viZB2KnIEExmuIvslaHdGSUwImDWxGzlEpW+yW4ZWs1o/CsKKibhTdAFJVQyOtxQExPuyiVndTA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static call is only ever updated in __init pv_time_init() __init xen_time_setup_guest() so mark it appropriately as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/arm64/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c index aa718d6a9274a..ad28fa23c9228 100644 --- a/arch/arm64/kernel/paravirt.c +++ b/arch/arm64/kernel/paravirt.c @@ -32,7 +32,7 @@ static u64 native_steal_clock(int cpu) return 0; } -DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); +DEFINE_STATIC_CALL_RO(pv_steal_clock, native_steal_clock); struct pv_time_stolen_time_region { struct pvclock_vcpu_stolen_time __rcu *kaddr; From patchwork Tue Jan 14 17:51:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BED8C02183 for ; Tue, 14 Jan 2025 17:58:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2208D28000A; Tue, 14 Jan 2025 12:58:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A9A1280001; Tue, 14 Jan 2025 12:58:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3D9E28000A; Tue, 14 Jan 2025 12:58:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D5F0E280001 for ; Tue, 14 Jan 2025 12:58:38 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5FB9BA0BAB for ; Tue, 14 Jan 2025 17:58:38 +0000 (UTC) X-FDA: 83006817516.16.FD9F24B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 95E3712000D for ; Tue, 14 Jan 2025 17:58:36 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MxZzRxet; spf=pass (imf29.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877516; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Y5k5J5CPy2ktlmHvQwq2Ty9MVy4yNi4aG70MTyc3QHM=; b=YqLM+nIwQQ/R1t+WtgsWeFu+/tSAY2bjJ0AbdsbDW3ex5jl0QUpm5hpbWngyqJXZ4/JLx6 Y5248z2epa4eDRLtWC+gttCHlYMnnySWfKT6y+qZPK1ld39gY4MxEGRItAqJxGWkIPFHoB xhCL01PNEUF5leeaXCSeuyEx0pjG+OM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877516; a=rsa-sha256; cv=none; b=ANG63hbEOPC8OT9jCqWiV2/VYWvUhj9AEJmEq67mlt638B+5Xd2G26LG+OD0LOlzFM+rHt ZCVUGFBhyj+DQI/L/n1gBX0nvy5A7Cpo2Wc1oN344EcKq8H+OjbnugcA4YzkNTSU00R0cd 4eAXobOoqAND8ht2dgP8Ut2JEA0oS3k= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MxZzRxet; spf=pass (imf29.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877515; 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=Y5k5J5CPy2ktlmHvQwq2Ty9MVy4yNi4aG70MTyc3QHM=; b=MxZzRxetNrM/1EnrvWqFAuRVDvUP6yHC1GJIf9WrP7k2zZrCcvg716ithZITcowpoPGCLs FShrCHTS6u7NWEflj1hNjXlivU9F0IXzlUfK+iIjI9dEre5O7EONi6mIfWzruu0XrAte/m 6WmV1lKaBXV2TuF4Ii1kBSEI51renvc= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-297-eJ1DsfOqOJaNqmHoHG6xCQ-1; Tue, 14 Jan 2025 12:58:32 -0500 X-MC-Unique: eJ1DsfOqOJaNqmHoHG6xCQ-1 X-Mimecast-MFC-AGG-ID: eJ1DsfOqOJaNqmHoHG6xCQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F05721955DDE; Tue, 14 Jan 2025 17:58:28 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3D327195608A; Tue, 14 Jan 2025 17:58:02 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 13/30] arm/paravirt: Mark pv_steal_clock static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:26 +0100 Message-ID: <20250114175143.81438-14-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 95E3712000D X-Stat-Signature: e961dtxf41dkxxjticq1eswhqbt4fejp X-Rspam-User: X-HE-Tag: 1736877516-233076 X-HE-Meta: U2FsdGVkX1+/N3dMr3xWw0s/LKS1yhim403zSyChq50UfXczCs4A5ETMJOv0Cd0/9M/23EwHL1Wao+zbKTFRDOHsvKae6P+VMoUGYxdb+AF29OH+NJHlzfsUqDFRsPS+5myBbrCMZiQjlsLgzGxugfOe80q4VhZ52KDuF2szBGveKMY2QlcTIfTQLSCQ9/MzzGtetIOzMwZkJ4ZtzJenZGdZ51jrBYUtEz+qP1QbJVsRjQmyG6jJx7Oj3E21Z/MBt/kySunNJ9iDMy+do34vAuv7JuOM5L4huOGxsFNPJK9tD8YhbB9oTY8N/PeNVMeblNM8sqVdzMo64Hetbi5aBdjtoR3Pc5FAA9LQ9JnapQJGL2Rnt94NhLLo5ENGsUlVKhUqQnmUHIyD7KL0uMCrKxY4qf2V5fBmvPBbJ5C+mwTOwPqKqoq9MNKzAf8AZrpOTwo5j0fmLBorT+vBsmhQnwFAkDN5QrGB4zo+Q7V+x9x35EjIK62LYUWQYLThDMXPKtGPU9U9tlr7KJrMlcUHzq4Umi1R3YmOKgzdKJKyUoaQ1XJfpsrRegjMq+awAxsIVhDH3Lby2lFqvllsDG2KK5IE4jRdSnB4ZP1c3+D2pcp17A+a/cEnLqv+VHYRtyiqTLQ058aNvq6z8RiPYVC3qisaMeMTqcg1YZS4m0UywRfdLlYZZ5ThSkoyl85FN23vzpqOtp2meOPmD/b/Ljxz5D04EOwtxzZIIPiewy0dI6uo+2bHrJFgZqFeOoPQDg+KdhWIZrru1dNfZdvOlojiuiwKSA5Axe1RH4iVHQ4ca+gdBg5AnWdLH0VUdSX9ONlH/1B0xotkVgvw1QkfNXHQ40zXicXBLI/7HQr2/AnIOA5Js79Jk/y+4MjNTWUrMVBRMBs5cS3y8xpBE84gsMaiDUOOi+PsZZ1rY9Dt+N66hWVo7maMDwjU+oy41f/+s3AdKVjATmR+yIuSWa7VqQ+ HkNx3fjp V6dWewR5JlInKI4dhc5r9BBlAZdFawOkvIWhE7QQz/PrfBJu5HYefTRmYcg9rGWBbH8IRYIsM0q06gKNk7iZKWMW5AzJb8CQjIVMskcyERDyU97z6E82xNANYpLoYrxCLavNABpoJAtEaiQUtGa4qu++4Pd78LzI2dfZ8gdkcJZzwFKUA6u2fnefxblk3tb+wIWfsq9bAe1y7i8+D8T2ky50SK+NfMMotluQOMgnZnrT7Za3widC6S68DvI+YYfq74HTlJmgYpPDjGwNXV0fRzZDYuwRjDUKR5Fo4n4jIY2ewdDd/WHo2wdyejC8ANhhl4GXjk9l2CK0x3LbrQRoR4upwRt6cHR3saKEVdZzivLn7KoydmHZs43LbNaqm+ETkBdbEIZPlI75vRGJkIiDp6F7l+cPfhRFybp/B4OEyPO3S8U6I2umCCfC38RQu5k9Xs1uG9aSZ+hdyOFe9DLFlfgC+0Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The static call is only ever updated in __init xen_time_setup_guest() so mark it appropriately as __ro_after_init. Signed-off-by: Valentin Schneider --- arch/arm/kernel/paravirt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c index 7dd9806369fb0..632d8d5e06db3 100644 --- a/arch/arm/kernel/paravirt.c +++ b/arch/arm/kernel/paravirt.c @@ -20,4 +20,4 @@ static u64 native_steal_clock(int cpu) return 0; } -DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock); +DEFINE_STATIC_CALL_RO(pv_steal_clock, native_steal_clock); From patchwork Tue Jan 14 17:51:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5957C0218A for ; Tue, 14 Jan 2025 17:59:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41C8A28000B; Tue, 14 Jan 2025 12:59:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A56D280001; Tue, 14 Jan 2025 12:59:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D19D28000B; Tue, 14 Jan 2025 12:59:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EFC7B280001 for ; Tue, 14 Jan 2025 12:59:05 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AA1E8AFDCC for ; Tue, 14 Jan 2025 17:59:05 +0000 (UTC) X-FDA: 83006818650.21.DF104A2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id D4A36140010 for ; Tue, 14 Jan 2025 17:59:03 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UFOIhonS; spf=pass (imf23.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877543; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qMGrs2zO6mJ5O7oOgt8NAfFjs5VkJpcxP/Ef9nOpYpY=; b=dmqiwKLw+QVJ54Gd/w/UQb66lhiF/Z2k4FaraQFfYwYoil2/XLDx0TV+V09/D6U9q4xr+Z zMsMHQw5Z4jQUuwnwOFXc+Fr/PcNoAm6rX0Y3EobWWd5b0NZYItDy1ASDfFmYBhSzRcCRN kwSm34CCOExXQLUKllcHBAAQYNlzzFQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UFOIhonS; spf=pass (imf23.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877544; a=rsa-sha256; cv=none; b=ZMWdRK5EUY0fpVd+t43iOknZ6JnPXn7FjKllNDRwsQS17uZIJK0GkqFoEZZDGiaxVxeD9d NMeh7inmIrm9UCqGeZ2YQeJi16xd+ur4l42cjy82Eg7q7uvfh1mO8OFjQNtlPLN9+84/9b Z1pSfjRMCk3lpEeMFijVgXJa2cYigY4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877543; 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=qMGrs2zO6mJ5O7oOgt8NAfFjs5VkJpcxP/Ef9nOpYpY=; b=UFOIhonS50ocXH41lgLGbWKAjVZw+PsgcRhpegLJI75oDJcogmeuRkrGRvKW1dtyrgBvud KvYzeIviGEhIB5iC6w9cAECjGV6aBzgBBKycLNv4rNLfIX9s+6UDoj/5ws3fOENE+dvw+p +VfXplGkxmUefCN08/ECvWT2q4jbk5I= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-oI0zUiW-N3iwUtCDbN7ROA-1; Tue, 14 Jan 2025 12:58:58 -0500 X-MC-Unique: oI0zUiW-N3iwUtCDbN7ROA-1 X-Mimecast-MFC-AGG-ID: oI0zUiW-N3iwUtCDbN7ROA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BC5491956059; Tue, 14 Jan 2025 17:58:54 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8B17C195608A; Tue, 14 Jan 2025 17:58:29 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 14/30] perf/x86/amd: Mark perf_lopwr_cb static call as __ro_after_init Date: Tue, 14 Jan 2025 18:51:27 +0100 Message-ID: <20250114175143.81438-15-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D4A36140010 X-Rspam-User: X-Stat-Signature: 9hp99k9nx5u83mu9kjy4y51rxpg9ao3k X-HE-Tag: 1736877543-402964 X-HE-Meta: U2FsdGVkX1/tJAwFT8J3n2lQiXF5r2o5kjR70ZsQPZWOsE0B0ts64/4roKr0uivyOBos/v6BVQd7JktkpY64n1EkklkOO9Lq+SRmOL+rspQOOXPLkn/hadLs9aXpxlo85pgJd6ecBuZQ6stHG4Ibbn/uTsYLycJBa8J6R4mllyZGXUM0WsDzxG9Sw87c9pG0n+UrhYulqvH8zNLCgyas+KjSphHIsm1PCMZVdxwqvVMhG5wI1gt4dY6fvxB/PDGSM73nYZH7EP0un9oIEyrOUcA9JAof0Qd6eQ4oIqD68hV+k3SmqHizUywtYIdXobFOkuk+DU7i6NlDNXnZPW1biuplKhrijxhBSYtVAIqkH5Aul3/lqT946Mr3wpJ10JiKapEc9PEXoANS0jPbq8GYxZykXhKjxptW0uHdOXXjAu/LQwgOqnsQBIvnz5+ZU3q9plbD1AEJDLOmaggCRKlNVJgAv5UYXUAthtOw69mnMkIug9Qg2mNCkUIGbgBXCdnsMSUjMd0oQrZwVljfbAnwaWVvra3kcxWKw1J/hNDt3pT8rPmMviBLXM4j/JmSztL1zwpTXQcnHDLgIR7R1+Ngbh0GTCooLYDkxHvamDkZShxi7Li5dkd03+kJFg30or/6+YW21TpvoSTeKmHnUqTbFDGLR13svuPx8vAIPghv7Z1PGiP4ity/2jrcnkA6wuIz+z7XkpW4QRUpEfxp9PjbLMvxqUoltgsT+/sK5nXBM6TKVn0DQoj/Em+d6DbiTZE22n+SGdFKSqbG1JAhOyArTsCVCWCoqYiMGJS2COBOxOGuJ9zwnFjrd8RBlPTNfWngEk5U2Vf1dOUSDzdycxwVIZ3F3hcxR46Q4DPZovPcD9JsjCamOzKf3ELInkHsuveBfi9MuePBm053yNVBsxbMCzmwabKzcCHjv6qkP3wIdd9uvGIDWsS+qP8G3yLUxS7JjWMCd7wAZCp6yI9vZkA r8hZSKpl TIRjMSoE8Lz123d0hxOBuQn13Q6AgwRG1IbSkbeGq7yfK6WWySEykJI8NaP9ayJr9WbtGq1MLsNo6h5NugyHLAnRgvCId83E3xVw3aF0TFFEpMm74D9QrfTgfoBfDfdN2xX7tw2IWHqrc858fmy9e4TLXlu5w3H1kSPDs/+5tRjiTq9ftoBH5cheP6bMu4jM5I16MfkPG8d8eOqqzINeaYgM7AYQxavimnEsAymV/1rqgAOfbVO6a3cmuiIxZ9RK6GoHPC+7FojQrFN0FqIs4KDg91oA0NM9DSn9GY0+VrRReBGsS3tUIzkhR8S7ardzevjiZ2BzioI+HeCOpt+Qz+3ilOjiXPG9a1/BWYW9R3tTWqS/ixK/SwDVdG20Nfw+i5XbeYkDxo71rxV0Yrz0jcY6K5j6zAUkpAKgkq5OaiIfqx3uhrP3fxlMmRIl/hmNx9JtJji2qXrz4S/YiEy5I7TibTv8Em9orIORj9dctpoB4+gA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static calls being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. perf_lopwr_cb is used in .noinstr code, but is only ever updated in __init amd_brs_lopwr_init(), and can thus be marked as __ro_after_init. Reported-by: Josh Poimboeuf Signed-off-by: Valentin Schneider --- arch/x86/events/amd/brs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/amd/brs.c b/arch/x86/events/amd/brs.c index 780acd3dff22a..e2ff03af15d82 100644 --- a/arch/x86/events/amd/brs.c +++ b/arch/x86/events/amd/brs.c @@ -422,7 +422,7 @@ void noinstr perf_amd_brs_lopwr_cb(bool lopwr_in) } } -DEFINE_STATIC_CALL_NULL(perf_lopwr_cb, perf_amd_brs_lopwr_cb); +DEFINE_STATIC_CALL_NULL_RO(perf_lopwr_cb, perf_amd_brs_lopwr_cb); EXPORT_STATIC_CALL_TRAMP_GPL(perf_lopwr_cb); void __init amd_brs_lopwr_init(void) From patchwork Tue Jan 14 17:51:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939102 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 095C8E77188 for ; Tue, 14 Jan 2025 17:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9254B28000D; Tue, 14 Jan 2025 12:59:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AE1828000C; Tue, 14 Jan 2025 12:59:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7283128000D; Tue, 14 Jan 2025 12:59:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5426A28000C for ; Tue, 14 Jan 2025 12:59:29 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 104FAC09E3 for ; Tue, 14 Jan 2025 17:59:29 +0000 (UTC) X-FDA: 83006819658.06.F8F0E50 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 2BFB8A001C for ; Tue, 14 Jan 2025 17:59:27 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="iHxf/dIi"; spf=pass (imf15.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877567; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vzSk9ZzswXx0ijJl+1BL1pcjLYKU11Wq/W2Kyfj2Pb8=; b=CquWvBCUrQMcR9hmPJ77ulk3lVZOTAh+2TePVpa9ma+tyZ6m1j5rY9JtoAKqfUmB9Pja9E eRkZMaSsWw09uJoe2T/C9X6d17+8GN5f3xc1Di/qut7UHbIRt+X87JcNYGp2JNcs8Pjcuj EWctezyRc3RJAZxsiDrnjtF4ydB4EGo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="iHxf/dIi"; spf=pass (imf15.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877567; a=rsa-sha256; cv=none; b=C0ILvqiujP8HVWQ7hZfegqbJneL/bKHUk31DetxfqTCwHLKfhxg6uJauQHWiFGwVr8BvGz +3nVnwwHVT4BQ9t9LlwpegD9/+EFKQ90SkzE0RCtTosEZn970WMcygsJgCW/2BxinM2lOA dlrQDeufzx1qjOt63zuntfDlnCIBHDc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877566; 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=vzSk9ZzswXx0ijJl+1BL1pcjLYKU11Wq/W2Kyfj2Pb8=; b=iHxf/dIi55mPvEiN2Zs2NJNlVrAbi41lkr+hiDzpaKama2WELF4e5+/nchX8jPdrdfs9v7 IkbIa886dP0LuThAEz7kGPJsoIywwQTl+pzc3gJjoy68tkoc55mHEg9ylNjcC8GNslvi5a w0Pt/c+ZztZcu4M3/Mt+Z0b2qPJRWcI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317-domFoMd6N8WvyrMSzp1fqA-1; Tue, 14 Jan 2025 12:59:23 -0500 X-MC-Unique: domFoMd6N8WvyrMSzp1fqA-1 X-Mimecast-MFC-AGG-ID: domFoMd6N8WvyrMSzp1fqA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E586919560B7; Tue, 14 Jan 2025 17:59:19 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 21066195608A; Tue, 14 Jan 2025 17:58:54 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 15/30] sched/clock: Mark sched_clock_running key as __ro_after_init Date: Tue, 14 Jan 2025 18:51:28 +0100 Message-ID: <20250114175143.81438-16-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2BFB8A001C X-Rspam-User: X-Stat-Signature: ezohtfwf84snausjyki9z5dhyzwqc19s X-HE-Tag: 1736877566-1995 X-HE-Meta: U2FsdGVkX18R1PfYucEnfePyTjSkbucKoqjg2bZl9Mi1wnImcT90BYPb4c89DiYjHvFb0DEDeSZy5kD3MPn7dc7WZxMxERuPWE8I4lqzSafzC+npyjlEczLvYOO3hM4xPfDyx+tdb4TA62Z89UXI/jDjiDyAWhOcIvQi5+0tuJPm2E9dTtfIv809rAL3Py74PxCHuqsPoLn+vgMuIMXmjw18JxlkrNgN30H9IVqNhU7b4Vdj0njUqdg8MceELjFbobeLWxN4NZ1W3lPVFfOua9PZ2o87KR9cKiFQdk62BFHoQIa5we56CidxJ4bCK5giZwRdOLUkixhBdote2FmHGBI9+MAYgnu2N4X/4VhJV0wNKcj2yUV+2wXY0MnSLnCcOK19mt5q7aVIuEIUWKOSHRlzDYQKzO8133SGbvIdKIp/y3NROIbdsa8Aqiz+RRoBcpcGQ7Qo5CG9heYptP8ZuX9wgPR+jfO6u4+sg6T/9Bmuiz7RAqOxb9lnhXtpKMk7GT1D3R7n5j4r//j3cU/XB1FKroli1pSfahHmXeO8x7RViip6VozC/pOKXWqw5b+30V1Z1u06nX7sdhn0OA9qqeoRHDiu/0XlLUjq4+rzFxqn0///sKsL4jkJi7Fx75Iecycqk8pP3w44vjO9k0ovpoaSRcVZWM2pK37fF5h062CMvh1E53saAu65GP6OsDyrv2Webc58ohECymNUmuMmx0AXQaiQQiL4HBg4tRbZZvrhix6y510XVw8wr6sZgjyvamLDPvMFYHUPFvHuanghVcQZulJNuOvmo/nBnu9NC2PhEQKGdBhbHvcbGkebEE/wYa3BpqQdA4cDxyTsoipRTLH/yDVaQX7ryXUf62SoOwFs4Bw8n+BfVXH46J/pXBVtbBhYjHTvK4ubxLf/r1ymh/DCwRQhdPpJcm1J3mwBuP9ZpkR90666NDzkXIi7GhMjlRn+zCCblc2ICr06oOQ hQCA4S8v rYN6v0em/gcTpXomgripI0KNswEBzGi4FALKoZx27WIQBCLVCS+MPKnStLmL/iFErWzyV1rmcxCVQfKTFLEO2lLmMiFvXEwtTYBUS9FItZi1HZOBbSzH96QHqucQD0/hul6qEMbTwec1poQ4SwxKWSv3MFRsZ7lR83XOYWWeJoStgh+aVQGl331XPTKmzbbASjEV9Biuaz7Mpi2V2eBNmIEPqlfXkgqoe7h9a60g4GDJmdvcv8/5PncIWaDWcXS5F/oSdOtHpm27+LZwSay1pDIxu1WDt9y+EtZWLUMsUoeNhfQ2IslBZ5NLT9Jibia2Fm9eYjP9mM8QcXCUgPZyAsydCBMTZKwEcPRd7afEQMTHj8KP800UD7Q1oGxaI/SXMV3O0WyUS5cnlOEMkznYpzIlfe2Ro6VyZwDTaU1PC4DwAOS/eU1M8Hpov1qwSu3VlQUvBcH5x6oUT7204awmmCEAUWQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: sched_clock_running is only ever enabled in the __init functions sched_clock_init() and sched_clock_init_late(), and is never disabled. Mark it __ro_after_init. Signed-off-by: Valentin Schneider --- kernel/sched/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index a09655b481402..200e5568b9894 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -66,7 +66,7 @@ notrace unsigned long long __weak sched_clock(void) } EXPORT_SYMBOL_GPL(sched_clock); -static DEFINE_STATIC_KEY_FALSE(sched_clock_running); +static DEFINE_STATIC_KEY_FALSE_RO(sched_clock_running); #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK /* From patchwork Tue Jan 14 17:51:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2809DC02183 for ; Tue, 14 Jan 2025 17:59:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B95C628000E; Tue, 14 Jan 2025 12:59:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1F4C28000C; Tue, 14 Jan 2025 12:59:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9737F28000E; Tue, 14 Jan 2025 12:59:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 78B7D28000C for ; Tue, 14 Jan 2025 12:59:56 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 435671C7C00 for ; Tue, 14 Jan 2025 17:59:56 +0000 (UTC) X-FDA: 83006820792.09.6785C30 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 8C68FC0016 for ; Tue, 14 Jan 2025 17:59:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=amH3ApoI; spf=pass (imf28.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877594; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Fzzncw7C2q7Oj32JE4D69orayDnnAM5XMqXCZgIYhoQ=; b=OL3kJyxWvm65ParhrRnfGIQXowviy34RDf2yu/7wHJX2kUn/Ozkl4btJlTFyqERqsaZA+X iCxdGlgc1r2DPXZjTmDOxcuuktKk8+KKbsUC+iKiF5ZAj0no7UJHXT/Y/sGrNn2amK1Yp4 5BLtPUuYtHOOvBVypAO2tZ3YDXPjUt8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=amH3ApoI; spf=pass (imf28.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877594; a=rsa-sha256; cv=none; b=HzddBIn9mqr/pZJrekLl35ZVOPLfK9g0v0F4pO67oCEykCN11zPBbhDpCPYyRTl2IGpQg+ 56qDuHnD3G2vZBIrfzZc4x6IN4vO59yeSAAWVQcIYexMXtj9w3dH++wpMs6mKlMORK02MV YV1kW/Phh/wW3a7VZdAZkb8iYtZEkVs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877593; 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=Fzzncw7C2q7Oj32JE4D69orayDnnAM5XMqXCZgIYhoQ=; b=amH3ApoI0jhXc4/f2k7nzuM7kE8u5ef7+PeDa13YYw8AHtQ4Bzgu9mzle1fxVVOA/h52y2 GtFdV7u4aayWvhVYrtUGfjYt0WjoEX8JSh4FGVQbNK1rZ8fMEGuC+rHTh0vvfv/JQ2DAVC a3ROP2ONnIREVqUdOssn51e8aHuUxZw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-83-jmSM7AxOMj2WDdft3VwBHw-1; Tue, 14 Jan 2025 12:59:49 -0500 X-MC-Unique: jmSM7AxOMj2WDdft3VwBHw-1 X-Mimecast-MFC-AGG-ID: jmSM7AxOMj2WDdft3VwBHw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D8B751955F79; Tue, 14 Jan 2025 17:59:45 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6685F195608A; Tue, 14 Jan 2025 17:59:20 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 16/30] x86/speculation/mds: Mark mds_idle_clear key as allowed in .noinstr Date: Tue, 14 Jan 2025 18:51:29 +0100 Message-ID: <20250114175143.81438-17-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam05 X-Stat-Signature: 54xg6ci18rczgh5g3iu11y4oyef79rju X-Rspamd-Queue-Id: 8C68FC0016 X-Rspam-User: X-HE-Tag: 1736877594-840309 X-HE-Meta: U2FsdGVkX1/4ja/mzFjhz75DvhUwDW6t6t1yLlxGRNuqKdISaURREJKV46MAWWmwpSEAUEiWPqpCEPnQJUS0l2O32CHXPH/++nM3xxR4jx7m/tr4agpyujk/p+vCrmlq5n+5Nql2Z/aLJBysAVtiLG8n7FsoY9XY+o91DY5fZCp2rU+IbcGz0O1PLPKSq0eYluiPO0nYAEOEhAqaHqO0VQYD60JMahyMAyEhVTL7mUjGEWY+aNclpu4t+zZA6hVFmSdK24WfOp/B4i26EFHVXllYQmdxw8rd2S2ZvOix/nF/w/QYKY4ElJyk5dy7Shrg1BsAuMNT1m/80Hwlt+nMP+s9UTjPLqIHXvBpDcwMsntt2k3548/IrDU+8RzVC5migg4mMCv0HCR8dPmi0CYu8tlJ2t1s2WaAElY8IqjoaD26hgGyd1GzWoddkdyc1yOcukScel44sMU3/9TfcYGyQeI1ice3ZQmd6FuySP+9Jcr0xjK70TxWKBVo4XKkNRCxhXMJmTOLzZ9//oZVbKJAm/LdmKEC7bTgdFIwWN33PPDw/kWt72YgxRk9epSEITLaJSSUZXm96xi1oi++z23eiD6wApI7REHaGi2gifQu1rutskIu/oxcYHiaQfJ8DY7ZTfj8expA9oLit7zKw6uLI5pGlceDFIh0bMMwVIUBh3ZU2bmtog0yreSL1wbeRrSN/CjxEb35cy9+qv0UKJI1LLxHtzc1RICxCi5iyUtjYh/U7ttqkNHTo6QGWoMj3SwloLt8sUXDWROYBhNQWYy5ldPQmjqvjahd5rLmNtFSFcWgsGoDyFg5Ey6huSIRQQL1o5Odno4vgki1HyzueYHuumjetFUcaOI+jSQmvlzUHg9Au3y0buRCnrf3XvCNQQFLEYBj6duu5hpnRY2e31AmSPTmaEcIXvV1scWutMTF+6hk5I86SPeLxZUjoZBBKAl+7eyMLWTBHTkt+ut3Hh+ mCoY6suS guFSlB3M8XvpAQeZ7UEEbKLJ0NCtlGpTwn4ZyfM2IYdK2wTozUWlPPvKalFB5ziAvMSS0OmBdWIm7aNOZqhbI7h0Mhh+KQIIlUXB6527hbYsvJtWcrnbpEiqq6gFYApnzfLU67l0eiEJ1gUmMzqyKiRk9F3PQJgVJt9Dc1jelTIDtVcaNijRxfINvNj/59+Rj7w/8PP8KTE28XjxkZb/I+l+wEo6EU564cElFjHWgsuF+IwFm99cZdjTu8h6OPbVvaBwPD2Z59u+cKeQWM6rz8AumuyxadbvS/rMfNHBk7cmGh9VU2/U8amMN2vJ2plTVwNLEjZFaVBm8fzEh60OW1o+eAJm7yKCnQbKt8sD6u5cLpyVQRyGtIDeSvvhjFsc2jomVRltAnPfNtCXU+DO4+CwXLJusHm8BHADFhfJlY0jXEwYUJjEKg7e/gIysWC/6kn8B9wyhe0JOgyGRUXZMfftdrQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static keys being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. mds_idle_clear is used in .noinstr code, and can be modified at runtime (SMT hotplug). Suppressing the text_poke_sync() IPI has little benefits for this key, as hotplug implies eventually going through takedown_cpu() -> stop_machine_cpuslocked() which is going to cause interference on all online CPUs anyway. Mark it to let objtool know not to warn about it. Signed-off-by: Valentin Schneider --- arch/x86/kernel/cpu/bugs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 47a01d4028f60..acad84dcfc3cd 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -113,8 +113,13 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_ibpb); /* Control unconditional IBPB in switch_mm() */ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb); -/* Control MDS CPU buffer clear before idling (halt, mwait) */ -DEFINE_STATIC_KEY_FALSE(mds_idle_clear); +/* + * Control MDS CPU buffer clear before idling (halt, mwait) + * + * Allowed in .noinstr as this key is updated during hotplug which comes with + * more interference than just the text patching IPI. + */ +DEFINE_STATIC_KEY_FALSE_NOINSTR(mds_idle_clear); EXPORT_SYMBOL_GPL(mds_idle_clear); /* From patchwork Tue Jan 14 17:51:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB0A9C02183 for ; Tue, 14 Jan 2025 18:00:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41D496B009A; Tue, 14 Jan 2025 13:00:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC8B6B009B; Tue, 14 Jan 2025 13:00:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 246F46B009C; Tue, 14 Jan 2025 13:00:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 044666B009A for ; Tue, 14 Jan 2025 13:00:20 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ACF55120C0F for ; Tue, 14 Jan 2025 18:00:20 +0000 (UTC) X-FDA: 83006821800.17.DE154F0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id DB9E3160018 for ; Tue, 14 Jan 2025 18:00:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JppIlS87; spf=pass (imf08.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877618; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oEa6Jvbfjlidl4MXGQFSAZ9P76MqELccnrf7elTRMWU=; b=AIOu6OuSm9iLbt53JwHGNazMCTHTule55CSicSull3FhwtyJQpD2UBIUwqHHREvaeIZ8YA ulDnZ8e00mE0eZqqn/g2Ut8yVq92pv2TdvKrI5CvevHZX6K0sI7puMvSpH6TdGDB2mi0Xn 1V+iKB4hId+VUhL2335Qz4Jo8vQ1GsE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JppIlS87; spf=pass (imf08.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877619; a=rsa-sha256; cv=none; b=qsayvv44np+puB/ndSmUCKRMX5gk4r2cdLo6xgr/10jLgOMtFVtm6k4uH8eccoddLEG1oM 1/0Yr8KVbOm/JCylAZ7+MfzHoZ4MzlYgrcCe72akSzI7hhNQmLe2eK+0T/+LrrXI964uSA b19y2/hzLPWtCB/TxSTuFv34ACae6Oo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877618; 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=oEa6Jvbfjlidl4MXGQFSAZ9P76MqELccnrf7elTRMWU=; b=JppIlS876yk7+hztdTwy+MKgYWDkCR0o/FIvk/erKeqgT66+EIo5SwPFhX8g09Fcfoo6ru Ip3/C5Q0lm1g4SEWMS6r23VZ4lNqojmbsKUmHICqvFNpAhbbC7hJ5j2dceXq+08VOZ+n8r rYmgB0ZnmcgL5Y3pckDaXRTFmg3fL9U= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-k3wLyZ7iPkiQIoWyV-6PFw-1; Tue, 14 Jan 2025 13:00:14 -0500 X-MC-Unique: k3wLyZ7iPkiQIoWyV-6PFw-1 X-Mimecast-MFC-AGG-ID: k3wLyZ7iPkiQIoWyV-6PFw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD2A51955DE0; Tue, 14 Jan 2025 18:00:10 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79BA9195E3E0; Tue, 14 Jan 2025 17:59:46 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 17/30] sched/clock, x86: Mark __sched_clock_stable key as allowed in .noinstr Date: Tue, 14 Jan 2025 18:51:30 +0100 Message-ID: <20250114175143.81438-18-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: DB9E3160018 X-Stat-Signature: zagjhiuhgipgt9g194433efzo3oepn6p X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736877618-308858 X-HE-Meta: U2FsdGVkX194roztqKwt/vlCGegp5RmKVJVn9ZMG9Qx4QLUmSh6vuXZclB2LdXZCy3fe7H+6oWSyJIUqdEsb7wceDSjeku2F6RqmP6oSFmVqAgIer2XqQkk+HhvMyePpts8kudDHpllUZ6AaTsHDUrEwF8Fyx58HjJJO6hhxwFrtXi2BE2B7zMaBRQBDbU2wYXFPkiw6bDNSqV/Mkot64Q35ommJiXeeojHSeIaL/2oI40ceTJenKTBrnNJNnR0xfgcduPCgwa0C+oZHQj4J7aV8uspmS4vSGs6PZDpyHF3liCa/cLISzWrCTdT6HFgVyNEDoslwtsiVpTZDkyJ/9JMVUO7OXNbz8Xv1FIgkAQ147/H1/fbxTTm71D6rUksn1T9jXoZNexdRZGLC7mjkcYpvV+4U6Ps1dNrvsDSX+rMvMQPtNAW0GaC5N5pOjId9xgcSAIvbHTnwlrts9ZTvcnxzu4V+em0OxpSMfO369lUVliwWxul4kWAQzkTK6klSYRfyzrtcE2wLI9WQDeIRxqdGb8St8DGxQlu7t4hXIuuPJGxxPz1fQwmIwZajtNut/y+ZmC2rPcmUKqULapS8hZHpRU9eYZ8Cz9bpHRLgNVNmXyovbAKNjSQj5IByBhzeMWy2tNKSeZCsme8iHIcqEBvU0UMN3b2O79ZywN29h+s9IIH3vwg+RdhWJ+314/UtPH/IbfUuf6T+ThY7xbYcpDVAJShEE1LkPA7SjPC1sInamrPEKmF7ZdyhO8/H8+QyQ8rdKo0ELlFlK1MwZSeUSte9s5sDCujMrKCicZVbNoYw5ZNdS3Rq+QM1ALywkRq43cOhtpR4VUC7qgdoFXJsBdv7TICF61KEfBC7ewNyn9u5Lh63lECVojdvI0DkL0dG3ud2M+jy0UkIJRUcc1kn5LFHsaem/QH918FWLv4aLUW1MGy5nJc/ZTh9YnS0tqubu/EcDucU286eNeFtjaj k8szrR03 aZSXxt1kTT5PkRlFbUm/ODdflZzY0DMTWtEYilqgqSG9bB1mddH7pQjWEx3UX1X06pLVgK0Ve9Bb0t4uUjT9u+WqjX4q5cMEsMKHF/Cuqw/bsT9AUTKjVXiPt5+y5r8H3YBlvBJX6JSPTK7usWaPybvKdObdaaMQPxQGUSN6FjHi1ZpvaRC1kmAmakUnHdmlga2mKTF/azNVgDR7pQbyrDnNt1vt0te8e5hNLD3TGKrNMbFFK+Xja0gBTiDGEA+Z/nCrS11yxZ4lwdJpQYGYrM61WB6GerNGr38dcKfJ8D+amKS9bAI9JVe9F4KPKOujzvrcQzWWxilUL1NqhOkKYJMoeXXaLeqkd4c8a6o1LwyzQOYWQBwKiWNgj5+DMIq+in8CLm8Rrm768XViH5vECdhRY70wIk5TiQzrbuRRIz3YpaqozomvnifHvkzHFA4ZM/bHY3HbV/w4oc+PSJIiHwyQdEA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static keys being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. __sched_clock_stable is used in .noinstr code, and can be modified at runtime (e.g. time_cpufreq_notifier()). Suppressing the text_poke_sync() IPI has little benefits for this key, as NOHZ_FULL is incompatible with an unstable TSC anyway. Mark it to let objtool know not to warn about it. Signed-off-by: Valentin Schneider --- kernel/sched/clock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 200e5568b9894..e59986bc14a43 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -75,8 +75,11 @@ static DEFINE_STATIC_KEY_FALSE_RO(sched_clock_running); * * Similarly we start with __sched_clock_stable_early, thereby assuming we * will become stable, such that there's only a single 1 -> 0 transition. + * + * Allowed in .noinstr as an unstable TLC is incompatible with NOHZ_FULL, + * thus the text patching IPI would be the least of our concerns. */ -static DEFINE_STATIC_KEY_FALSE(__sched_clock_stable); +static DEFINE_STATIC_KEY_FALSE_NOINSTR(__sched_clock_stable); static int __sched_clock_stable_early = 1; /* From patchwork Tue Jan 14 17:51:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E37AFC02183 for ; Tue, 14 Jan 2025 18:00:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 752C5280010; Tue, 14 Jan 2025 13:00:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 701F028000C; Tue, 14 Jan 2025 13:00:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52CD1280010; Tue, 14 Jan 2025 13:00:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 32F9C28000C for ; Tue, 14 Jan 2025 13:00:47 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AF883140591 for ; Tue, 14 Jan 2025 18:00:46 +0000 (UTC) X-FDA: 83006822892.09.B0468BF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 64D0B18002C for ; Tue, 14 Jan 2025 18:00:41 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EcagOfMx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877643; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1xC4OsvuHAy+Ds3sLAPsZ084bYad84WLBsAT/g0G1RM=; b=pYMnj0HJprhhYn460tdEM2pStw7GVwz7bXULZIZrwqco4JfrSHqVkir1KFtwDE3wPgsOnh nYV0oMbdbU0vn3Lm8vPsQKjlrxrSdleI3lPdU6xIe5ZNN2RGEFMTz3ovsyUjILb5xn6xI4 yTlmVLRaYepkgtfxuKsaMHirkUtowbs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877643; a=rsa-sha256; cv=none; b=oxk4RQXtECuxIGq4D3vUTrQoD4hj8RTKLRcH7YjbC7+MtyWwkBGak6fGSzPHcIBhlrc2SM fHQ6x6Tlg/IZIlPaYEy6V8bKLLv8qYc027dtAKwHxhoZrMHY7nLCir2yqqoXjEwdoo+asy 0PLmvJr/NwEiwkv5i2L6QTev8esJGRs= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EcagOfMx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877641; 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=1xC4OsvuHAy+Ds3sLAPsZ084bYad84WLBsAT/g0G1RM=; b=EcagOfMx6kpBLs3yxfwJxIf81mF8We88FJUFWxcVBdWPTas5GJOsj05EID3hxJSTA+J1ss hM9SpR2GXnyiTh5/lt74rDKdlRF726tYTndYR5QXLPLqeXcKMEQ7htN0OS3GZGf3p8Oo2Z ZeMY6rgAQ+F5PrStuVndO6IzJGXxf0Q= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-15QLd5xpPJuBfkaI0jxIcg-1; Tue, 14 Jan 2025 13:00:36 -0500 X-MC-Unique: 15QLd5xpPJuBfkaI0jxIcg-1 X-Mimecast-MFC-AGG-ID: 15QLd5xpPJuBfkaI0jxIcg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7DD041954195; Tue, 14 Jan 2025 18:00:33 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3F89B195608A; Tue, 14 Jan 2025 18:00:11 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 18/30] x86/kvm/vmx: Mark vmx_l1d_should flush and vmx_l1d_flush_cond keys as allowed in .noinstr Date: Tue, 14 Jan 2025 18:51:31 +0100 Message-ID: <20250114175143.81438-19-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: x8xqywducaxuw95ktczha9mebzju3abp X-Rspamd-Queue-Id: 64D0B18002C X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736877641-270690 X-HE-Meta: U2FsdGVkX19Yx0qTpnoLzRbnATzSoHNq+gVqCQw09z8dJmkEi8Cx9c9IBqn9BnD5fQKkS39vuwW8suJ8s7IiE0oDIL9mZlDk3qOJHc7371jlv9w0YSGgCBke0MSfm1z9h8BTtca6IhMmDfJoyZFW1AKktNQRKtfEX58+gwoy7i7uTM47xg9Oj9ydQb6EYJHIZ8Kyi202NlQCR8333M9zQFWmLZsJYkNutEUeogk4vgJAoYyfY1tidbHnyXNHttaiDuvso2fYFMiT+sxSLkXpwbNxxghDfkGs0FJb6I3lMJACKgAe9itlsTCV9kVSAA7Tw2C1SYhdr6ttGv3oqvfm1qLaYt6Uwu8tUJalDDx2h+HGxc9NI6YI/d9gZTsAJ3G4Nz0bEkCNLKAQQQgXYayE4Alu72+7nGATUTkxIFwvHJrCcKUH19/e1z5tizXBFQD+onl9ZIdkXuz7efLhVdzEbVUEJ1Aab+ap37CoYMCXXAYTpzehfkQgWZIYjmQOlPVf2PltAXKgHNr0R+YJhAJ6sCJzkR8+PMXMPhT8scvtbM6DywQjX45MKdMribuMcpVnwhK35HN6vveKkCNdL+RDZVnIpJt9MU2RJUp9DgHN99BGBx6xf1Vbzr9PtOTEkc/g3lKogBFWNqp2tP43S7FfJYi/FJtnjE7xjowetLAOqNsxCDbZY3pH8GrGEHR9lve+miUkF1YRHJ6pJV392fXL1vwQ6++0llQA0YFETC7quVuyKFAW4CK6xUKLWL1xt20y3Llc1iRMNabq/SC94EweWYmBdpuAGso+ApBlegupKRORZXtJhsuaNyVeQ21zNvXt99O7zc0K/MAOfGVCIiiWm9SO3y3aL7lqJG09u0OL8ha8bnueQc44np6nNIK0KmqSrKH7BEk0gc0VdNldlLZlkykSLlyAAPogvtvMQ5YT287YO8Enj9eZmnNdQiP0LWtOiwW87Bl45A9R+zZhI8z IutE0dEP GkVhOUx0hKHkKIC79taXCbP+KX+3zVb8MUw8j530wDHv7KW1qvoYp2Nb+7cVbuqEJGN3X25GdepE4MmWEelhwa94O8a3tMduEhSPOqSCSc2IslxusuLljoZKbETwOeMhWdcIgkaMw4trE9jbk2GWotE1qmZw+iQsQwQazdN8MtdbJa8T5vguHgweuI1HyINGgtsSxyS7XU9U+nEFW7SSaahlZwGPHqsjpg2mUJ910iGG/PR3yubMLf5NMRPz2AHL70mLK54Vuz02t6Ng6d+YJ5c/IHLWmaDF5RXnak4z3iSbxtpIbI3ZGiQOX1+ydyyH8drEeuoTlbJ5b1VKYgQvKKldOkoCUo0onMu17yWhzLakBcfIjsgO4edXAPXncX029xbmAsudCL3V7+0LQso+y5bOoBDGZDjC84h6n+zotHbZ7LPseeQOKtTx+fl7FgZr5f1bNtwuPlmF5HisOXSEDgE7BxlFBkUaqWaLGmRwuqMrUP8Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static keys being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. These keys are used in .noinstr code, and can be modified at runtime (/proc/kernel/vmx* write). However it is not expected that they will be flipped during latency-sensitive operations, and thus shouldn't be a source of interference wrt the text patching IPI. Mark it to let objtool know not to warn about it. Reported-by: Josh Poimboeuf Signed-off-by: Valentin Schneider --- arch/x86/kvm/vmx/vmx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 893366e537322..a028c38f44e02 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -225,8 +225,15 @@ module_param(pt_mode, int, S_IRUGO); struct x86_pmu_lbr __ro_after_init vmx_lbr_caps; -static DEFINE_STATIC_KEY_FALSE(vmx_l1d_should_flush); -static DEFINE_STATIC_KEY_FALSE(vmx_l1d_flush_cond); +/* + * Both of these static keys end up being used in .noinstr sections, however + * they are only modified: + * - at init + * - from a /proc/kernel/vmx* write + * thus during latency-sensitive operations they should remain stable. + */ +static DEFINE_STATIC_KEY_FALSE_NOINSTR(vmx_l1d_should_flush); +static DEFINE_STATIC_KEY_FALSE_NOINSTR(vmx_l1d_flush_cond); static DEFINE_MUTEX(vmx_l1d_flush_mutex); /* Storage for pre module init parameter parsing */ From patchwork Tue Jan 14 17:51:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D16EFE77188 for ; Tue, 14 Jan 2025 18:01:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6686B280011; Tue, 14 Jan 2025 13:01:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6202728000C; Tue, 14 Jan 2025 13:01:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49096280011; Tue, 14 Jan 2025 13:01:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2B2B428000C for ; Tue, 14 Jan 2025 13:01:08 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E02DF120C17 for ; Tue, 14 Jan 2025 18:01:07 +0000 (UTC) X-FDA: 83006823774.29.46E07A5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 928351C0018 for ; Tue, 14 Jan 2025 18:01:05 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e4NdWv9X; spf=pass (imf18.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877665; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GQSPZLQ3FmvxIu57q6qI2psmX9IZ2horrf+PeQlNWuI=; b=Ag8ta76CLpjGy8hM5smk3dQG6GGRY/A4y2fRJdKvEk3MxxMj0jE1TdB6t45GT2QpwA86gl /dlBE7k7DPXPRcXvAoyHRoxIlmgxHEu33vBGIJUAETHJMyb9kPktJ5IG4fTPhKKcSxGSWM zh8adNOn9q290gJ/7sUHamhFBw2Nv/s= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e4NdWv9X; spf=pass (imf18.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877665; a=rsa-sha256; cv=none; b=AV0dVQ00Sk9rQR6i4bmzC+PGY6TUb5HUrdvoMFzyX3Mfl8I3WiTTgf9qHhTysfl61QQWFx RjK13Xz3qirTVY9jg8d6roSb9l/IttpaHOzGT40YqYwRc/iZmuyQuXVnXDiUvKAHQjZ7iy qDax9sfsSorradklA8+rXae9UoYCPV0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877664; 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=GQSPZLQ3FmvxIu57q6qI2psmX9IZ2horrf+PeQlNWuI=; b=e4NdWv9XiX5E0gif/3A0cDammbayQb384yeK+jDqJX7Fm+iR5mIfU4oNXGh751kYrGN/6G +RlFzgLqLw+7sA8EHiFYoZI6cGtBbtB4SZxLfdacgEmt8o2lFKeZ2J48Ik7k9X22YdZ5H5 SZgeUlKHzROY7cppUQUC0vkfTuXZOKU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-l9crDhjEN0CU5mOOpfPM-A-1; Tue, 14 Jan 2025 13:01:02 -0500 X-MC-Unique: l9crDhjEN0CU5mOOpfPM-A-1 X-Mimecast-MFC-AGG-ID: l9crDhjEN0CU5mOOpfPM-A Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 734481954190; Tue, 14 Jan 2025 18:00:56 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F38CE195608A; Tue, 14 Jan 2025 18:00:33 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 19/30] stackleack: Mark stack_erasing_bypass key as allowed in .noinstr Date: Tue, 14 Jan 2025 18:51:32 +0100 Message-ID: <20250114175143.81438-20-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 928351C0018 X-Rspamd-Server: rspam12 X-Stat-Signature: zyp8rhacs1esa76n5bqm97531xry6883 X-Rspam-User: X-HE-Tag: 1736877665-659324 X-HE-Meta: U2FsdGVkX19mPjH6goGpGA0lF6S0WGoC8sXExJr6kyjVHbsaysmFqErcNaDbwQx58RlVtmwaznmdlHqItjqT1bFvlubVmtSnrbMK/vdfGJBEGkE9DfwhsL/3AK2zPooV7gEQh91GT68O/7T0tK6xvc3LV9U55AsN/B1dWOtfdwC3+bKozT3Vme1goLy4ycfvQv9Sc2xN1RosnNSgsZQ72sSeZnAe5ia4bE0hxVF+7wgndoQt/ZyYdMw34Hx00x/QBebv2KueTl3zrO9gkYH+QiLNUMTIwa4PYMcvUhV1msiL6rWIkN9ZpKjmB/zkwQ9Blx2FHLrHxvrn4v2SEHdk44kjWe5GcKEewzFlMhaGefKioAik3Z4kroUtKgTlEcUDN36aMWLbjfnfZK4nAQvD4Iy6WLutRBKXB+us5FrL26FS8TI+btQOphEIJsntA+D5xqi6gNK6IaVh97WJxKcc7eXbSHVJgHo1ikp07t75FzmdfI2+ZGl3HNUadEPA8yMXai/I0tXFGUicYAGgcjH2Xt5iDfwzpEQGuzFprT4YzSubHSsainvIg4Rua0extej4Dpahgunjl0onAmEthtYPiYBex/jLMbgqP00fCRTGU59AIoyqmCAZqPdWWZI6c6WKVVad1PrjAwYNv29wewZnjvgRglc/KaXSMKAWFUiMN78Be1uv9OOXRO/c9jFaXrE8wAQL8F/EjWVO+q3LJ89aqwO6ZdrqDDvLTEsLNHruM4WD7UXti9kgQy5Qx87JaEXX6UEdW7oWpEYen5UUzwhvLDK2ztxfgliMeVVoHfyk9GMU1xinPL+7JuHs08kNycTTfu99edpaYHzuwCdVdiz2jUugq+vFDRZ6QCdSjcjpVjRmSL5E39ng/X3NNMLJvl7fL+RieVtdG56/ySizxeh9MWJAS+0er+qAQyo7fJ7UGtlDxV+Hmb5rAcXno+mWVn+YoRV1FTP0nT4HmuCfmaw tLM0tFrT cWqSf/Qsbsj7LQI5e60zzwZ8auI9Kk5KQSm27MBdLSgtoZq0en+giodxAZxx6u9EoZbxyc6ky+vRlZ6c3h60TDgQSBsCI5vQPgBHCFZQ//RIeeCzl4FiydvNlRIQE13IcOcUOrJperfnMTLWDfom+bWXywpwQDwy7u6qgtgxARB6CYWuOXSHgndX7+Y17pfv4LCL8ZeMdXt/y1JBdO7okdwXdiCLJecPv8WzVT49lZ/TIQjNIh/T6yW+hgDgb/x+ae0RgtjI0f+VFW8YNtSdPmresUUu0pVnzQ3JHIVatZZ8PbHEi+XPlw5bzEumhNILgiz8QKHmnmx7JDmIDZeENdMt9ueTYgMHseygS3/4wPwELeh26oQV59iMdkVig2/g1eEl/cNTgyNRNNk4B94ooX7RVQfLqCCBobj61TXs/TPHRyPp6ND2a6zv1JwTLo57nAaimes+si9M81pcUnu8nEMcwbjQmtdj2KEVQjXs8E1K5nOU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later commits will cause objtool to warn about static keys being used in .noinstr sections in order to safely defer instruction patching IPIs targeted at NOHZ_FULL CPUs. stack_erasing_bypass is used in .noinstr code, and can be modified at runtime (proc/sys/kernel/stack_erasing write). However it is not expected that it will be flipped during latency-sensitive operations, and thus shouldn't be a source of interference wrt the text patching IPI. Mark it to let objtool know not to warn about it. Reported-by: Josh Poimboeuf Signed-off-by: Valentin Schneider --- kernel/stackleak.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/stackleak.c b/kernel/stackleak.c index 39fd620a7db6f..a4f07fbc13f61 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -18,7 +18,11 @@ #include #include -static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass); +/* + * This static key can only be modified via its sysctl interface. It is + * expected it will remain stable during latency-senstive operations. + */ +static DEFINE_STATIC_KEY_FALSE_NOINSTR(stack_erasing_bypass); #ifdef CONFIG_SYSCTL static int stack_erasing_sysctl(const struct ctl_table *table, int write, From patchwork Tue Jan 14 17:51:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 124BCE77188 for ; Tue, 14 Jan 2025 18:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94E64280012; Tue, 14 Jan 2025 13:01:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FDFA28000C; Tue, 14 Jan 2025 13:01:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72A79280012; Tue, 14 Jan 2025 13:01:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4E36928000C for ; Tue, 14 Jan 2025 13:01:52 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F2372A0C13 for ; Tue, 14 Jan 2025 18:01:51 +0000 (UTC) X-FDA: 83006825622.01.8546887 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id BA2192000B for ; Tue, 14 Jan 2025 18:01:49 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IPdr9rXI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877710; a=rsa-sha256; cv=none; b=75bX21xDBjahMzLsQ7UrCnYFpwuCV24lHBDlaJCvjTl/iQpeLTrb+bwXhG3YV1Zc1yfRf0 78/mmQ79796hIS/GnkUGJRpdtGcLtdqGI2eqEpepwXEmgGCZDu79FujM54Q405Jjhg0Lw6 bFdxb2u5jVFN9pA4LlenzCtSaF/IN2o= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IPdr9rXI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877710; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e8MD/yxknvCsMYBCjJmdeKziBGiIOE307eysnVgCl2M=; b=YOzYtrF9meM2iGViT928dfF0L9U0wIYPjLII5GwlNvRnuWSJRkwkQGpqfhwjwdlkzarnHS nNzNzDoHP8gJbgRnJ+tHUcxiY1KgHI3EIUUauxQzwJoNc6VbhGSEEaa24/6zXLNcNpvEeh 0idxHlJQW0OtQGBy4cwGpjT0J5RxzB0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877709; 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=e8MD/yxknvCsMYBCjJmdeKziBGiIOE307eysnVgCl2M=; b=IPdr9rXIIszeZXdJDhy6x1ar1EM8ev/fQDgsQreEfTjPfplBHIAUDjxqBUvFOOISX2zoV4 3RYyY+ZXrqd+F6+1xfjucp5YU8b5d+Y3v8dIXfwszwUlyPOM1FgkHkizBMbAMktKCsDCb6 ruyC1BximInGE63JSSHxqoH2dJRcl08= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-yr-DHzXkMTap-bgFsYDaSw-1; Tue, 14 Jan 2025 13:01:44 -0500 X-MC-Unique: yr-DHzXkMTap-bgFsYDaSw-1 X-Mimecast-MFC-AGG-ID: yr-DHzXkMTap-bgFsYDaSw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A8ED1A445CE; Tue, 14 Jan 2025 18:01:23 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E8F64195608A; Tue, 14 Jan 2025 18:00:56 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Josh Poimboeuf , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 20/30] objtool: Add noinstr validation for static branches/calls Date: Tue, 14 Jan 2025 18:51:33 +0100 Message-ID: <20250114175143.81438-21-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: o8sry1jggncjsejc8t3i6yptczn5871u X-Rspam-User: X-Rspamd-Queue-Id: BA2192000B X-Rspamd-Server: rspam08 X-HE-Tag: 1736877709-287548 X-HE-Meta: U2FsdGVkX19Rt3XN/xUC+8gefLJG+VP9lzsy9pX9zAUWyZ7pcJd9ML/EqI8o4IQWKf9xdcF4cVsKwbw0UiIWocnD9j/kz//EZxbVlYDlDOXrJebuKbKtdYKB+TqPoNbcjfxhGyNLfTSXb8HRLTqo5AVY0v+rN8hEfO8Tm+iGzilyZlZPG2G2N+jrYcDsVpq0IfC/AC//zCjeX6CgF2mOkPnBWVic+X5jKewsuJzrgOf9lTlbo5HwMmpNxyj5Ekjr2xibfMw54xzAhDr6ozdLe7o23LeqErTYHJlPnpiIIWw0Ao3DOCnEUjNjflHYqRQd9470G7sdaQMhJKEe8/uDCRTTgArG0oELR3WGig9Yt2Fc8lc/7TteQx+z37SldpfumsMxHn9oIdS1Lc0LgrqPkWiH10RRzlXRjF24fmxsnIQDaPkha+J2JqfF2PBpHPYJ+p/F+QnigyaOyTfNJmRIzEdLD2IJpUf7kCuhOFA5Ui/TXPAUVO+2KeXYfcrs46oOheFq0WZQjLFo4aMz9oAkOAr4q7Xht4IOpQTHHUr5pW98/9bjkjHkdEwq7noi/nPlUEM+hXZQ/oWgLRy0XRhN3Z6yUzs89BH5sfgV3L+/n2EfTf+s1CFaxZMRUTIq5qZEF3bGKFIEJCkzE5lzt5h3+4u4OHK4nMJRfSt3fMI2d1gbLSNbaRvggsjgklpSAQn9aQAerD2Asy96Ny2hvSM4D55nADH3XDWZKBTv2+Z00bIXaHwt4LNqv5ERo8E8ECOZEb90QvWWTSJbYjLfy3uC5zz7TjmN9iQ5mBeL2nhpcK47DXv3p9a+csU4dbjJqqKtY6P/NLRIUwN/XhN9s5OcXGJjjTRZQZ6WSTjrEn3Pdhj02/5tYY2CMw0iJz2SIctdbCWX4Hp1SKVoBaqmCfQuLo60+0UBgpneSRmlHpOwJVRGVepR4My9EpaY58wNN7rIrQ8FsRkHNEGecuXSyLt jKI1bOG7 NQEW2x3tRcrJ14t9fQTgxaxWXim40FFhtlFxEHw7v7coFh5x9XTf60YoiXHGUTWpRu/Xqa51Q4xuVBnu54LnxteOYjeoeeG0zOrr0Z/U40D/zWf+VcTJER3Q+9fA+/HSnZPZo00Ekze6X9ds+QEJCC6FOynoEyV8qRlUE8IufSsrlpRqG5CNtbWy0g24hGI3ATW0sH4aLgj8SjYaUehxPinuvCjR3Qsajtl+CZFLgLxMxCcy99h11E0mnD2tb7gOuHZCcsTU5VXDcibGc10z1nDtOhjna++vaEPu71E0X4ygbhP+Xl+yCHMkHoleO9eRLe1JgjdaroObdPDyQMZuNC7E0KIhOu8w/7kJxXW869Sc8S61WJRSS1h13Mj5z7yWL+Jr+vZ2f1JM8Mi5uuFt8Txolc8Pm/y6vkOkv9xD1LjpANN/uxOMelOcki2SY7Pir4/fC X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Josh Poimboeuf Warn about static branches/calls in noinstr regions, unless the corresponding key is RO-after-init or has been manually whitelisted with DEFINE_STATIC_KEY_*_NOINSTR((). Signed-off-by: Josh Poimboeuf [Added NULL check for insn_call_dest() return value] Signed-off-by: Valentin Schneider --- include/linux/jump_label.h | 17 +++-- include/linux/objtool.h | 7 ++ include/linux/static_call.h | 3 + tools/objtool/Documentation/objtool.txt | 34 +++++++++ tools/objtool/check.c | 92 ++++++++++++++++++++++--- tools/objtool/include/objtool/check.h | 1 + tools/objtool/include/objtool/elf.h | 1 + tools/objtool/include/objtool/special.h | 1 + tools/objtool/special.c | 18 ++++- 9 files changed, 156 insertions(+), 18 deletions(-) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 88bb6e32fdcbc..dc8a82a62c109 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -75,6 +75,7 @@ #include #include +#include extern bool static_key_initialized; @@ -373,8 +374,9 @@ struct static_key_false { #define DEFINE_STATIC_KEY_TRUE(name) \ struct static_key_true name = STATIC_KEY_TRUE_INIT -#define DEFINE_STATIC_KEY_TRUE_RO(name) \ - struct static_key_true name __ro_after_init = STATIC_KEY_TRUE_INIT +#define DEFINE_STATIC_KEY_TRUE_RO(name) \ + struct static_key_true name __ro_after_init = STATIC_KEY_TRUE_INIT; \ + ANNOTATE_NOINSTR_ALLOWED(name) #define DECLARE_STATIC_KEY_TRUE(name) \ extern struct static_key_true name @@ -382,8 +384,9 @@ struct static_key_false { #define DEFINE_STATIC_KEY_FALSE(name) \ struct static_key_false name = STATIC_KEY_FALSE_INIT -#define DEFINE_STATIC_KEY_FALSE_RO(name) \ - struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT +#define DEFINE_STATIC_KEY_FALSE_RO(name) \ + struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT; \ + ANNOTATE_NOINSTR_ALLOWED(name) /* * The _NOINSTR variants are used to tell objtool the static key is allowed to @@ -397,10 +400,12 @@ struct static_key_false { * definition with the rationale. */ #define DEFINE_STATIC_KEY_TRUE_NOINSTR(name) \ - DEFINE_STATIC_KEY_TRUE(name) + DEFINE_STATIC_KEY_TRUE(name); \ + ANNOTATE_NOINSTR_ALLOWED(name) #define DEFINE_STATIC_KEY_FALSE_NOINSTR(name) \ - DEFINE_STATIC_KEY_FALSE(name) + DEFINE_STATIC_KEY_FALSE(name); \ + ANNOTATE_NOINSTR_ALLOWED(name) #define DECLARE_STATIC_KEY_FALSE(name) \ extern struct static_key_false name diff --git a/include/linux/objtool.h b/include/linux/objtool.h index b3b8d3dab52d5..1a7389f273063 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -34,6 +34,12 @@ static void __used __section(".discard.func_stack_frame_non_standard") \ *__func_stack_frame_non_standard_##func = func +#define __ANNOTATE_NOINSTR_ALLOWED(key) \ + static void __used __section(".discard.noinstr_allowed") \ + *__annotate_noinstr_allowed_##key = &key + +#define ANNOTATE_NOINSTR_ALLOWED(key) __ANNOTATE_NOINSTR_ALLOWED(key) + /* * STACK_FRAME_NON_STANDARD_FP() is a frame-pointer-specific function ignore * for the case where a function is intentionally missing frame pointer setup, @@ -157,6 +163,7 @@ #define STACK_FRAME_NON_STANDARD_FP(func) #define ANNOTATE_NOENDBR #define ASM_REACHABLE +#define ANNOTATE_NOINSTR_ALLOWED(key) #else #define ANNOTATE_INTRA_FUNCTION_CALL .macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0 diff --git a/include/linux/static_call.h b/include/linux/static_call.h index ea6ca57e2a829..0d4b16d348501 100644 --- a/include/linux/static_call.h +++ b/include/linux/static_call.h @@ -133,6 +133,7 @@ #include #include +#include #include #ifdef CONFIG_HAVE_STATIC_CALL @@ -198,6 +199,7 @@ extern long __static_call_return0(void); .func = _func, \ .type = 1, \ }; \ + ANNOTATE_NOINSTR_ALLOWED(STATIC_CALL_TRAMP(name)); \ ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func) #define DEFINE_STATIC_CALL_NULL(name, _func) \ @@ -214,6 +216,7 @@ extern long __static_call_return0(void); .func = NULL, \ .type = 1, \ }; \ + ANNOTATE_NOINSTR_ALLOWED(STATIC_CALL_TRAMP(name)); \ ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) #define DEFINE_STATIC_CALL_RET0(name, _func) \ diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt index 7c3ee959b63c7..922d3b41541d0 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -447,6 +447,40 @@ the objtool maintainers. names and does not use module_init() / module_exit() macros to create them. +13. file.o: warning: func()+0x2a: key: non-RO static key usage in noinstr code + file.o: warning: func()+0x2a: key: non-RO static call usage in noinstr code + + This means that noinstr function func() uses a static key or + static call named 'key' which can be modified at runtime. This is + discouraged because it prevents code patching IPIs from being + deferred. + + You have the following options: + + 1) Check whether the static key/call in question is only modified + during init. If so, define it as read-only-after-init with + DEFINE_STATIC_KEY_*_RO() or DEFINE_STATIC_CALL_RO(). + + 2) Avoid the runtime patching. For static keys this can be done by + using static_key_enabled() or by getting rid of the static key + altogether if performance is not a concern. + + For static calls, something like the following could be done: + + target = static_call_query(foo); + if (target == func1) + func1(); + else if (target == func2) + func2(); + ... + + 3) Silence the warning by defining the static key/call with + DEFINE_STATIC_*_NOINSTR(). This decision should not + be taken lightly as it may result in code patching IPIs getting + sent to isolated NOHZ_FULL CPUs running in pure userspace. A + comment should be added above the definition explaining the + rationale for the decision. + If the error doesn't seem to make sense, it could be a bug in objtool. Feel free to ask the objtool maintainer for help. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6aa9259fc9940..24219538c1587 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1068,6 +1068,45 @@ static int create_direct_call_sections(struct objtool_file *file) return 0; } +static int read_noinstr_allowed(struct objtool_file *file) +{ + struct section *rsec; + struct symbol *sym; + struct reloc *reloc; + + rsec = find_section_by_name(file->elf, ".rela.discard.noinstr_allowed"); + if (!rsec) + return 0; + + for_each_reloc(rsec, reloc) { + switch (reloc->sym->type) { + case STT_OBJECT: + case STT_FUNC: + sym = reloc->sym; + break; + + case STT_SECTION: + sym = find_symbol_by_offset(reloc->sym->sec, + reloc_addend(reloc)); + if (!sym) { + WARN_FUNC("can't find static key/call symbol", + reloc->sym->sec, reloc_addend(reloc)); + return -1; + } + break; + + default: + WARN("unexpected relocation symbol type in %s: %d", + rsec->name, reloc->sym->type); + return -1; + } + + sym->noinstr_allowed = 1; + } + + return 0; +} + /* * Warnings shouldn't be reported for ignored functions. */ @@ -1955,6 +1994,8 @@ static int handle_jump_alt(struct objtool_file *file, return -1; } + orig_insn->key = special_alt->key; + if (opts.hack_jump_label && special_alt->key_addend & 2) { struct reloc *reloc = insn_reloc(file, orig_insn); @@ -2731,6 +2772,10 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; + ret = read_noinstr_allowed(file); + if (ret) + return ret; + return 0; } @@ -3494,9 +3539,9 @@ static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) return file->pv_ops[idx].clean; } -static inline bool noinstr_call_dest(struct objtool_file *file, - struct instruction *insn, - struct symbol *func) +static inline bool noinstr_call_allowed(struct objtool_file *file, + struct instruction *insn, + struct symbol *func) { /* * We can't deal with indirect function calls at present; @@ -3516,10 +3561,10 @@ static inline bool noinstr_call_dest(struct objtool_file *file, return true; /* - * If the symbol is a static_call trampoline, we can't tell. + * Only DEFINE_STATIC_CALL_*_RO allowed. */ if (func->static_call_tramp) - return true; + return func->noinstr_allowed; /* * The __ubsan_handle_*() calls are like WARN(), they only happen when @@ -3532,14 +3577,29 @@ static inline bool noinstr_call_dest(struct objtool_file *file, return false; } +static char *static_call_name(struct symbol *func) +{ + return func->name + strlen("__SCT__"); +} + static int validate_call(struct objtool_file *file, struct instruction *insn, struct insn_state *state) { - if (state->noinstr && state->instr <= 0 && - !noinstr_call_dest(file, insn, insn_call_dest(insn))) { - WARN_INSN(insn, "call to %s() leaves .noinstr.text section", call_dest_name(file, insn)); - return 1; + if (state->noinstr && state->instr <= 0) { + struct symbol *dest = insn_call_dest(insn); + + if (dest && dest->static_call_tramp) { + if (!dest->noinstr_allowed) { + WARN_INSN(insn, "%s: non-RO static call usage in noinstr", + static_call_name(dest)); + } + + } else if (dest && !noinstr_call_allowed(file, insn, dest)) { + WARN_INSN(insn, "call to %s() leaves .noinstr.text section", + call_dest_name(file, insn)); + return 1; + } } if (state->uaccess && !func_uaccess_safe(insn_call_dest(insn))) { @@ -3604,6 +3664,17 @@ static int validate_return(struct symbol *func, struct instruction *insn, struct return 0; } +static int validate_static_key(struct instruction *insn, struct insn_state *state) +{ + if (state->noinstr && state->instr <= 0 && !insn->key->noinstr_allowed) { + WARN_INSN(insn, "%s: non-RO static key usage in noinstr", + insn->key->name); + return 1; + } + + return 0; +} + static struct instruction *next_insn_to_validate(struct objtool_file *file, struct instruction *insn) { @@ -3765,6 +3836,9 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, if (handle_insn_ops(insn, next_insn, &state)) return 1; + if (insn->key) + validate_static_key(insn, &state); + switch (insn->type) { case INSN_RETURN: diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index daa46f1f0965a..c0da7246eac7b 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -77,6 +77,7 @@ struct instruction { struct symbol *sym; struct stack_op *stack_ops; struct cfi_state *cfi; + struct symbol *key; }; static inline struct symbol *insn_func(struct instruction *insn) diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index d7e815c2fd156..0cb79931262bb 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -69,6 +69,7 @@ struct symbol { u8 embedded_insn : 1; u8 local_label : 1; u8 frame_pointer : 1; + u8 noinstr_allowed : 1; struct list_head pv_target; struct reloc *relocs; }; diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/include/objtool/special.h index 86d4af9c5aa9d..ce4759358ec48 100644 --- a/tools/objtool/include/objtool/special.h +++ b/tools/objtool/include/objtool/special.h @@ -20,6 +20,7 @@ struct special_alt { bool skip_alt; bool jump_or_nop; u8 key_addend; + struct symbol *key; struct section *orig_sec; unsigned long orig_off; diff --git a/tools/objtool/special.c b/tools/objtool/special.c index 097a69db82a0e..982d5cb55e1bb 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -119,14 +119,26 @@ static int get_alt_entry(struct elf *elf, const struct special_entry *entry, if (entry->key) { struct reloc *key_reloc; + struct symbol *key; + s64 key_addend; key_reloc = find_reloc_by_dest(elf, sec, offset + entry->key); if (!key_reloc) { - WARN_FUNC("can't find key reloc", - sec, offset + entry->key); + WARN_FUNC("can't find key reloc", sec, offset + entry->key); return -1; } - alt->key_addend = reloc_addend(key_reloc); + + key = key_reloc->sym; + key_addend = reloc_addend(key_reloc); + + if (key->type == STT_SECTION) + key = find_symbol_by_offset(key->sec, key_addend & ~3); + + /* embedded keys not supported */ + if (key) { + alt->key = key; + alt->key_addend = key_addend; + } } return 0; From patchwork Tue Jan 14 17:51:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41607E77188 for ; Tue, 14 Jan 2025 18:02:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5BB7280013; Tue, 14 Jan 2025 13:02:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C0A6828000C; Tue, 14 Jan 2025 13:02:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5CAF280013; Tue, 14 Jan 2025 13:02:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8771A28000C for ; Tue, 14 Jan 2025 13:02:07 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 30330120C02 for ; Tue, 14 Jan 2025 18:02:07 +0000 (UTC) X-FDA: 83006826294.22.962B879 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 63CB8180017 for ; Tue, 14 Jan 2025 18:02:05 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cMdqYwt4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877725; a=rsa-sha256; cv=none; b=WegrqoYU4TJQ6wZrlkGe4BHgfiYWwCQAZUZJZcUFi8z6obyA6FTF2l8fr40j59z8Pltvo9 hni2Gx/znA6nqMdyQ51+mYgJ/RvK6GsVbXzYPrc4AV7Fb2M9J8jVh2PsgArcFMmea3tgKC YRZ2+yp3IqyPzkwa20RuRbyBYJqjGY4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cMdqYwt4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877725; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KdPtt6PQsN+ylVvy58F0NcuUnOqkUWc+oSjD61c8P1k=; b=TYopI5gtdEUSi9vhSz65eX980wTRi6rSMJ6FHFcBNvje5wUwdiGbK7zERexRpoPhT0Ohzm NLCO/qZ9pGzv6Oxr2dHrWHMZFJftgZKrMDS8Hlq6O6F54adCZAtwgUTrG2nIkkHOEeZr+y UT7MDHXIufBvcer/pvJgp7EJgxWykv4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877724; 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=KdPtt6PQsN+ylVvy58F0NcuUnOqkUWc+oSjD61c8P1k=; b=cMdqYwt4pG7JtjxWcu40hBioQpioNdZv0ASsFz3bTteZMVEe6o1s4NSLZxdXGwyzvluzK4 wuM52AqqZ2MD/l+1mODWoz8NJNAbDsEf7JCRXW/2xFCuMgpFONs/IVEQAyhg6vpWT95ONO r0GE5T5BS1pL/6n59EscIxNdZFvW668= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-cs0jRgydMTW_3xbdYVeS2w-1; Tue, 14 Jan 2025 13:02:03 -0500 X-MC-Unique: cs0jRgydMTW_3xbdYVeS2w-1 X-Mimecast-MFC-AGG-ID: cs0jRgydMTW_3xbdYVeS2w Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E1CD319772CA; Tue, 14 Jan 2025 18:01:45 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F01A195E3EA; Tue, 14 Jan 2025 18:01:23 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 21/30] context_tracking: Explicitely use CT_STATE_KERNEL where it is missing Date: Tue, 14 Jan 2025 18:51:34 +0100 Message-ID: <20250114175143.81438-22-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: h94jozqnm33jz91538chuozwq41tee7u X-Rspam-User: X-Rspamd-Queue-Id: 63CB8180017 X-Rspamd-Server: rspam08 X-HE-Tag: 1736877725-368131 X-HE-Meta: U2FsdGVkX1+3TJ/lX8ONXAKZr+l528JsoB6+4MpunlbUyePVVMpNP7WNIUUqOd7Qy/zsPNslyXfj2/3EYcMIyORJWTAsnh2LuecdKKubykjw4NCtPncHLA2ZGeO7lawt/U2FXrT2Zanp9c3doIvn0F36taX5XjPSPL/PuI29XIf2SxKA8r5T6M+avOLKIb6i5JjV8U3HtIK4DHylUBXy0v7SugY9d3ubQ9/p1aXpBSgcNP0lxTCYoMSKZ1fKWOUXA2pXQii0IoL1UolY5Yu72igLwmPOb72GD8VKf5zLvvHs/CC7nprBCZzIwqK0fMHLDbLyW4cTfJQtsClC5MCBE4D9AsMFiLUd7/UdWH1mu32Pmi7jU/V7KLMjjlDu1wYoDSxUYD6XgPq5pSBKpcFZs4qc9E6Bi3FADxTRhZGe4OUMcCsGrzr46EUS34J+53ZJnC8BluRKBV/duLmCwR5iyrvkUgMKPW0hWZCgOMAFgGPD1yfFnQc4bUTFLUd/WDwe3zUq+ukzeQMRvJAJSIhPKl7e7inisyrdtZTgFeQKnGATwtOueI99Ib9YoOdQJjxWfzKE97tGvqwlkFrfv9uBJ7wQ6aacg3GAbGdTLjW6Y6xdogUe6VS5iXobszaEyFytY/mCUKMKTUl+hTiVpPeoB2mGm32M/AqziYOesRwxmnTBvGZsn61go5INTv3SBDIX0LxV9iH+vZAqFAG719QZaRL/v57JgbVdd6gX/oL3WNT6ChXD+dgbU++JSlhzY6M6KOPhhzGUQKaAWq3o0tA227xpMOAbR4r5a+UJqQ7SpvcFDAmiq4Aw8suPN8H4jWLQ/u710YwRzA3ZUF48oFez5/OeYe/dfu1npHLQKHjsOokU0TOgN4C02mUx3jPfSIzCJoHiMVFIbjomPJsx2v00MhW1bJ7hFAvwAZ75pWO2PIIfdNP+PYlHT9MsnlXp1pKRUKJPXgcybEHeZerIApP JWBZL+/v nrbTTIoY5pN1LAh6C8z0AQTrmUyJs59zHtzObdrlzpZYjeiGSs8cgOFeK/OK7dQIlS+KFTqNlcpLDR/b5jWpzExi6HHWAtw0AVgRPOoTFIGplg9BAIkavXmi6jvFbR7MSjIU6QKdvAidTPnpPTQ4CAWjFTnYL+ybKO36mns2dp8KV3vLPH5OQiUwTjI077i/FbGGytVHO8Hggd9iFKKW4QZV2shtnI96BJKLP0FyQzLbrPduMz3JnMQkol2bt3FMs5cwBEvqxZrE7cu4AtQGYykC/ox0kKcTTC9jHLDmiAKwzTR0NCc5mqaXbuPb7DtuV4534WqB1pBOdaNrBtiVyIn9CpvhNm2tXyrtkEQh36y46POjg5xg4Hbhio6KsjaIFi8ponxeEngM346P/Tglh2/ZSkZ/57Q/wKV8TvcIZj7gd/o9Jvmx3NYTiN3t5fEdAmsq8Bk/C60474ddVz8yoCw/czA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: CT_STATE_KERNEL being zero means it can be (and is) omitted in a handful of places. A later patch will change CT_STATE_KERNEL into a non-zero value, prepare that by using it where it should be: o In the initial CT state o At kernel entry / exit No change in functionality intended. Signed-off-by: Valentin Schneider --- kernel/context_tracking.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 938c48952d265..a61498a8425e2 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -31,7 +31,7 @@ DEFINE_PER_CPU(struct context_tracking, context_tracking) = { .nesting = 1, .nmi_nesting = CT_NESTING_IRQ_NONIDLE, #endif - .state = ATOMIC_INIT(CT_RCU_WATCHING), + .state = ATOMIC_INIT(CT_RCU_WATCHING | CT_STATE_KERNEL), }; EXPORT_SYMBOL_GPL(context_tracking); @@ -147,7 +147,7 @@ static void noinstr ct_kernel_exit(bool user, int offset) instrumentation_end(); WRITE_ONCE(ct->nesting, 0); /* Avoid irq-access tearing. */ // RCU is watching here ... - ct_kernel_exit_state(offset); + ct_kernel_exit_state(offset - CT_STATE_KERNEL); // ... but is no longer watching here. rcu_task_exit(); } @@ -175,7 +175,7 @@ static void noinstr ct_kernel_enter(bool user, int offset) } rcu_task_enter(); // RCU is not watching here ... - ct_kernel_enter_state(offset); + ct_kernel_enter_state(offset + CT_STATE_KERNEL); // ... but is watching here. instrumentation_begin(); @@ -537,7 +537,7 @@ void noinstr __ct_user_enter(enum ctx_state state) * RCU only requires CT_RCU_WATCHING increments to be fully * ordered. */ - raw_atomic_add(state, &ct->state); + raw_atomic_add(state - CT_STATE_KERNEL, &ct->state); } } } @@ -647,7 +647,7 @@ void noinstr __ct_user_exit(enum ctx_state state) * RCU only requires CT_RCU_WATCHING increments to be fully * ordered. */ - raw_atomic_sub(state, &ct->state); + raw_atomic_sub(state - CT_STATE_KERNEL, &ct->state); } } } From patchwork Tue Jan 14 17:51:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5388E77188 for ; Tue, 14 Jan 2025 18:02:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 334016B009B; Tue, 14 Jan 2025 13:02:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E3CD6B009C; Tue, 14 Jan 2025 13:02:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C1606B009D; Tue, 14 Jan 2025 13:02:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DF6E76B009B for ; Tue, 14 Jan 2025 13:02:20 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8CE77AFDCC for ; Tue, 14 Jan 2025 18:02:20 +0000 (UTC) X-FDA: 83006826840.05.A9B0CE8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id C47F54001A for ; Tue, 14 Jan 2025 18:02:18 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BGOeenbC; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877738; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cNwCh5fgGoJuTFO9fvGqFny78uJkIQRICFisC3zeCIo=; b=J52ZKRVXw5IUYRvc7oHYO+25udeXlEbkW5i+KakeRTxkxTxqVjKHcMshjY0gwfQkXu6PlJ wSiXcgHZxQW3QLGb71JY51HE7L/Klzq5aFJh2lToQ0PMy5FgOcnwLIa4n2ny6ajB9Crq+h xmrF62xcl00skzNS1hnSH6nkv9Za8rk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877738; a=rsa-sha256; cv=none; b=MwYPJIgKyPqK1dz0CCfjXbXB4BCCMCVYNMrMOp26tcIEpYSTCV+UStH0i9UsP44hJRKa61 0H9Nz0C0MWaFCEvnpAeq154r33wCz3JRaBtsjLg9ujwcPu2Gd8bMx5GTTKIDTZTjYUwhNc 4ZvqSUsAIWdJ9dvZsQdPJpTZXBJaqo8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BGOeenbC; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877738; 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=cNwCh5fgGoJuTFO9fvGqFny78uJkIQRICFisC3zeCIo=; b=BGOeenbCl4Bo7De8T06qW4qtr/8CJMr2RwTjJNamHkbavCVsM/fXm/8DxcNH8XcEJWJ/Bz 9Rgg0d5GHwLuOuwTUFF1EVKO6vXOXU7yV9eOo4hE8LZjGgN0Imyt8CV/+2qJ8woAH2TyYY 01A+BAzFzl1Z4TnFN9Zjj9vqDoriZ/s= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-RjarLQpsMFScdKhdOdyibw-1; Tue, 14 Jan 2025 13:02:13 -0500 X-MC-Unique: RjarLQpsMFScdKhdOdyibw-1 X-Mimecast-MFC-AGG-ID: RjarLQpsMFScdKhdOdyibw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E0C941955DBA; Tue, 14 Jan 2025 18:02:08 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 61C7C195608A; Tue, 14 Jan 2025 18:01:46 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 22/30] context_tracking: Exit CT_STATE_IDLE upon irq/nmi entry Date: Tue, 14 Jan 2025 18:51:35 +0100 Message-ID: <20250114175143.81438-23-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: C47F54001A X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: wehior6dagtrxd7rk1id5d4rekt64err X-HE-Tag: 1736877738-732833 X-HE-Meta: U2FsdGVkX1+Ug8d0FOnNYdiw82msDhg9+UNG4LOcUQm4UcsmyXxDlEL/zViKXEwV1HFypVioFjqHu3Z7wtPk01jb0FJOKC3MauEYg+jBW0VFpKrkoQOPUN6tohZg6Y+jOAePkpYAI1mp7HW/awJ33RfMKYOscUxo1HoE83JBQtMf0o9tHBhdhU9rloeuNMRKbJZPkqrQ+2b0C3jSMVXXDJ89j1jN/QeGVCob4WbJqP/T4ZgFwB90JLNlHvifGLPj5EAC/2fuoPtkwTK3sXW7t9XFeFwMxKXWaKN5bbMZdecpaQPZBcjSW1hutPHGumln+pVS3upwUzX+r+Ir3f/LEO1ejEGyLiR8HyYFTQ/p7hIwW59eJeh9HXU3qT0Rww6/C/TFeGKaRqsfWxbKBafKsORgfo9ApVGYMpfBFXsqBPxL5DfXc3kSW9RfCNDQlhpe2ffF/+JRWGMTZv4clm/z0jS9xpDY32nkTJx5nybVQJ5HYlGF6Xu9sce9VUJcfLfYGzNUWRblR2VexV9KGGlJs97J/OYDmcRzpHnA+fDKAmGbQTE07zhwF9uBs9NbIsr74vwEM2vcySLwL1cqjewF8VrSMtexYc+b+7dAujKi2cYFEg3X6qOyzl7tTc9jvegNYrXs9DcrcELbGE8ORQ2eC/VCqC3Q8y1pkVHcbF7eLBBg9NuzGSbf6komMrrHh03VcIXNML4JsP3C8PR1uS5SN3jCNiiHBq/Oaax5jFP1c3RxBpBtQwQqlVdfOIj4ckph0SxOz74Tw30qNaw0Y/MrXRmw729xTOO3hP3vkTGfwLc44NiINIEa5ERSSdQTZdBLH+5rYjBZKBgWel2Y2+eHwBB8CAOI6VmXk4PmtPnpw6Id/XGhNRzpaH6eGHjkkR0YumKNZ5FfR2aa/mZo3HU2LUpchwv3EZxmfzgf8J5g6ikJA+N16U7GNx4R1mfF+3l/n+2dUOHKBFNDFnKUVSI +u9HuAwU 6ItkZaiO1tRh0mSpdAahpZ1EvxkdJDxBRFFTCRlDRdH4al+dDIuFGnopZIo0FS3Wv3XtZm5TCnaWglcwB1ma9vq6/ELAL3xFX50cI59tuAy9wYQZJEqBbdkHFVJCJ8MRihc7fC7jKc8AD5xN5X6B+Jd0OaKgFxSIWmH0/EVVgaj9JNT1qcpdZEvJyb8/U+R69EtcrGkXL5psgYN+7omP17vRGrFh8ckRiEwfCXyHJp/QcojbYsXZxckDTzK1/azSxOXJccok7CswQAr7gBrmqJbgJDBqxY7SVOOexIFyAmHWp03V6q+ulaQvTOulb8oZz4h8mQUACfMvYh7frXxCctUasgzesiD7Bo4yuChK0lwm10tjgBAapK/q06cAeSfxxgqqNR/KMK+xoFBhkeUGKaeTxa2w6muTKv/OmNueVKPHMWDDuF79NO4d8WnF4G7gU4ujIwU7uTmKCU/lhtbgnv0eqxg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: ct_nmi_{enter, exit}() only touches the RCU watching counter and doesn't modify the actual CT state part context_tracking.state. This means that upon receiving an IRQ when idle, the CT_STATE_IDLE->CT_STATE_KERNEL transition only happens in ct_idle_exit(). One can note that ct_nmi_enter() can only ever be entered with the CT state as either CT_STATE_KERNEL or CT_STATE_IDLE, as an IRQ/NMI happenning in the CT_STATE_USER or CT_STATE_GUEST states will be routed down to ct_user_exit(). Add/remove CT_STATE_IDLE from the context tracking state as needed in ct_nmi_{enter, exit}(). Note that this leaves the following window where the CPU is executing code in kernelspace, but the context tracking state is CT_STATE_IDLE: ~> IRQ ct_nmi_enter() state = state + CT_STATE_KERNEL - CT_STATE_IDLE [...] ct_nmi_exit() state = state - CT_STATE_KERNEL + CT_STATE_IDLE [...] /!\ CT_STATE_IDLE here while we're really in kernelspace! /!\ ct_cpuidle_exit() state = state + CT_STATE_KERNEL - CT_STATE_IDLE Signed-off-by: Valentin Schneider --- kernel/context_tracking.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index a61498a8425e2..15f10ddec8cbe 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -236,7 +236,9 @@ void noinstr ct_nmi_exit(void) instrumentation_end(); // RCU is watching here ... - ct_kernel_exit_state(CT_RCU_WATCHING); + ct_kernel_exit_state(CT_RCU_WATCHING - + CT_STATE_KERNEL + + CT_STATE_IDLE); // ... but is no longer watching here. if (!in_nmi()) @@ -259,6 +261,7 @@ void noinstr ct_nmi_enter(void) { long incby = 2; struct context_tracking *ct = this_cpu_ptr(&context_tracking); + int curr_state; /* Complain about underflow. */ WARN_ON_ONCE(ct_nmi_nesting() < 0); @@ -271,13 +274,26 @@ void noinstr ct_nmi_enter(void) * to be in the outermost NMI handler that interrupted an RCU-idle * period (observation due to Andy Lutomirski). */ - if (!rcu_is_watching_curr_cpu()) { + curr_state = raw_atomic_read(this_cpu_ptr(&context_tracking.state)); + if (!(curr_state & CT_RCU_WATCHING)) { if (!in_nmi()) rcu_task_enter(); + /* + * RCU isn't watching, so we're one of + * CT_STATE_IDLE + * CT_STATE_USER + * CT_STATE_GUEST + * guest/user entry is handled by ct_user_enter(), so this has + * to be idle entry. + */ + WARN_ON_ONCE((curr_state & CT_STATE_MASK) != CT_STATE_IDLE); + // RCU is not watching here ... - ct_kernel_enter_state(CT_RCU_WATCHING); + ct_kernel_enter_state(CT_RCU_WATCHING + + CT_STATE_KERNEL - + CT_STATE_IDLE); // ... but is watching here. instrumentation_begin(); From patchwork Tue Jan 14 17:51:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAF1AC02183 for ; Tue, 14 Jan 2025 18:02:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52F2E280014; Tue, 14 Jan 2025 13:02:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DF3728000C; Tue, 14 Jan 2025 13:02:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3318A280014; Tue, 14 Jan 2025 13:02:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1422A28000C for ; Tue, 14 Jan 2025 13:02:42 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8C75A448CB for ; Tue, 14 Jan 2025 18:02:41 +0000 (UTC) X-FDA: 83006827722.10.5572476 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id C094A18001D for ; Tue, 14 Jan 2025 18:02:39 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IEhJktr9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877759; a=rsa-sha256; cv=none; b=SlSb1hyaK7ixSQq0S50PCN0ft3ZcVzF6BomUYOT6qkKOnIReNa8nHshAqmt3q4m0sfYK+y UyNZljISec/jv8eE7DRsWeJ090jUZ7BAOVp8YHaYGAUz8h/lJORDRsYmfyHhHgAPzKRz28 KtYqIhJ9hjzmuN9A/nVS6L0/2yf3qZQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IEhJktr9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877759; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vO7Dcae3S+ckJLBtr7bo/IIVyHg02LNyvWNatP3bxFA=; b=k6TXQXclWzWhpmgNnrIj0INYjXbrORfkp1vr4fBZ9jrUwV5XvOj55hn7ippf8mM2r9R2V9 uibNAcxfGg/9Fdjhefro3xdkVyjokTHIzsIiqX0Bgr/6Ehb/OKPT/4gwDIO78fpRLYJTav rIn1/lN3WLWtwU73S4MStbcZMzWBL9o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877759; 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=vO7Dcae3S+ckJLBtr7bo/IIVyHg02LNyvWNatP3bxFA=; b=IEhJktr9fqdLKFqJMquVWn6MDKEqrJJUSE4jWrbOfc3/Exew/vm6WiUFilFSlPOB7rDwkJ KCrlRTLgbxbgdilpu8ymB292Es4unf+ft402DlWHi1Jf20qR/0YwFRDn0eMH2t0G+O0M8P JzIXdM8Ss2UEamrN4JF2mcMrfuwqn6E= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-79n9fhnhPJ65-rfaOeT4Rg-1; Tue, 14 Jan 2025 13:02:34 -0500 X-MC-Unique: 79n9fhnhPJ65-rfaOeT4Rg-1 X-Mimecast-MFC-AGG-ID: 79n9fhnhPJ65-rfaOeT4Rg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 69EBE19560AA; Tue, 14 Jan 2025 18:02:31 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 60C94195608A; Tue, 14 Jan 2025 18:02:09 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 23/30] context_tracking: Turn CT_STATE_* into bits Date: Tue, 14 Jan 2025 18:51:36 +0100 Message-ID: <20250114175143.81438-24-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C094A18001D X-Stat-Signature: gep9yb885se8xcfdhxsn3qjq67ts7fxo X-Rspam-User: X-HE-Tag: 1736877759-804717 X-HE-Meta: U2FsdGVkX199uYlLZD1xXyIetEB1rNVydgy/3tYuNk/6GvpJe2qE/+Z54sv3cDJxInKLcylGjifJ/4sMiGU6Ofm7jmhwPwBUY9F7srGCfN6GVLn3+qFnOAYwcUw34LFPmAgMBED7MXqKo589690HkpaRohBf/u3AclLvoEgNkbtqhalf2O0pNLITVRq7nmUSlc+ggk2WIih21TQSsmrLqixJeOb18tmJVimKoHzoOrQTsQe/G+cfsJJH5WfIwS2YA3nwMiAeIwFUKXCgzVUrSlL4HhslNqGNINABaePmG6xjvyR0te7UkhAl91VKXvd5/yaUeSl+Sd/09Da1c9WAngnLFSPbVAINdLoQhoHWXBEbhWPEISe4gx944H09rEcbV92V/MBRRNQ57xiYiN0rJGOEPV4Hk3UykzuOcJNtzhJQYIRJvAfxaTx05qJ9ClV0eVzafy4iG9bDCH2aR29P/zH0W5pL3iqQTdrZ9criL1Dj5AaSfzHO1vXAUStzrDsoSywJElmf/nYOCS98Jjj2IK+sDKIeRFCM1J00/lrmWconUZUWO/+B5wr3tCAVPw2h3X7eUmYCcoAcaU6unKFIwbSrWLPd5v4z4ZfQQ8Uojhe4oQa43O0Xw5qNTwMftmtfXCOYUUmIgSn27WeJzxYkK1xpCSLwmmkSneDFAVIJ3EYWd07aWpfbpO/2+T42JJ/Uu/Y4E/1YYQgteEo69cwApxCsJijI0GKYD0ERDnhv9KTn4nlQDckCMKNC/fHqTU33q8pCmVB8wjRoYIdrIGWbsnmt+bC9DLelogDY9VbBN6eEyd+u6hXUilVCW0zuyauEmI7b44W87U4avgbIvk0UWuKijCs7DNAC3jvRJUg5JxQGxt8btsKmrQrVTu5Um9+kSBWwlByOfHIqWLuQyg5+f2+jouy/TunPgSctmRl0BP/uDVBukjKDZXvGb/OfOSXoONzJfgzH79luKFxeCUr 5ZXjDNoU mERS8s/6LqXSalgcNhYZfGQgUNkHdfyg5C2qshZODrEX2D/tm+pdfeWXfC+hN1lRGqyRci2udKmUNjROTHXDCTl7PeXHVz6W/TS9DsTlaDxtFeBYHoyQjFuUjLGkyG7lAN9ve9nvObQxqU2YNfBIYegtw8mFnqRw+MyXT0OucekDLjG9p/zl1TwZPcvPHJO3pentptf1BdW5lZ5zf5ZChkfcFbZ2hdIb2+rj+UBEuPYk7MHLchPXaUsMexbug8iCccEq0dpP1kKrQEofdKwvxu4YEU0dozuzJJrmkcshQjZ6Z0kPoNG8S0Q+kkjm/ymSrVPOQVnQdu0x2En2ZeweV+6uL16obHI1mA8sUMAP25E+SfmBllVLeRpUjsrl/5pkWj3dsdm9PXmVboI5KJEBbAm2Y+f8H4Xua3nbVaridIBhaBHJLX8LTKtxVJL1QeMe44ddYktWqaHZp3QPQFDh+x6vnGw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: A later patch will require to easily exclude CT_STATE_KERNEL from a genuine a ct->state read CT_STATE_KERNEL, which requires that value being non-zero and exclusive with the other CT_STATE_* values. This increases the size of the CT_STATE region of the ct->state variable by two bits. Signed-off-by: Valentin Schneider --- include/linux/context_tracking_state.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 0b81248aa03e2..eb2149b20baef 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -11,11 +11,11 @@ enum ctx_state { CT_STATE_DISABLED = -1, /* returned by ct_state() if unknown */ - CT_STATE_KERNEL = 0, - CT_STATE_IDLE = 1, - CT_STATE_USER = 2, - CT_STATE_GUEST = 3, - CT_STATE_MAX = 4, + CT_STATE_KERNEL = 1, + CT_STATE_IDLE = 2, + CT_STATE_USER = 4, + CT_STATE_GUEST = 8, + CT_STATE_MAX = 9, }; struct context_tracking { From patchwork Tue Jan 14 17:51:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A190C02183 for ; Tue, 14 Jan 2025 18:03:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B23C2280015; Tue, 14 Jan 2025 13:03:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAD2628000C; Tue, 14 Jan 2025 13:03:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D76F280015; Tue, 14 Jan 2025 13:03:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6C25D28000C for ; Tue, 14 Jan 2025 13:03:05 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0B83F120C0E for ; Tue, 14 Jan 2025 18:03:05 +0000 (UTC) X-FDA: 83006828730.17.069CE66 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 0943240012 for ; Tue, 14 Jan 2025 18:03:02 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A9aKzj9s; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877783; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cj0SVgwm0Gb22+xO5luDoQDcDRqoe4OsVd+MUCyw+y0=; b=7fwRYsT4hGlTqUcEBSMOHWZ1tq417dVdMAjAP9QhJZt04glsZggVYDgMRoKgpKEMDxsvbi Beg1ESI+pJCPCSzoYYiw8V3+FE1IjDEyv1IUSJOvzb4vhio2fXFh0Dmf898ZjNy3nedpX2 7pnAk+nyh/7b3F2UbDH8H8IjW2HWTOs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877783; a=rsa-sha256; cv=none; b=TFqlWr0DuEgFVtuQq9VLg3LtUF9M/agHNC5K+q5B0YDQimJjLosp17AWHaxacqgoen0alU BoDzn7Xhxio07jc2wNLSr9ytqphXGC2rTx39TpPlrlrlUiMH8KyPKzPw4glBJ+SArfjqHJ TkJeCK8V96aiOeEnDNdQYxLuusF6bks= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A9aKzj9s; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877780; 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=cj0SVgwm0Gb22+xO5luDoQDcDRqoe4OsVd+MUCyw+y0=; b=A9aKzj9su5q/kEbmiNGzCfqTNnwe+ZLkhX2F9kgxIb64B+9cAQVVzOAgVpF0uX3KzUElK6 FPPztQBI7tRL9etj6Wb2xrbSqsjavSk30Tdg3eWpfr+6/JUbMhtf76UjJScp5Hb8wptEgD qNIcI7bRc4mEsKztbZLcSpqYfRcD88g= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-hmcuI36TM9u3E6tRKSsWWQ-1; Tue, 14 Jan 2025 13:02:57 -0500 X-MC-Unique: hmcuI36TM9u3E6tRKSsWWQ-1 X-Mimecast-MFC-AGG-ID: hmcuI36TM9u3E6tRKSsWWQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD5C41955DD7; Tue, 14 Jan 2025 18:02:53 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE7CA19560AB; Tue, 14 Jan 2025 18:02:31 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Nicolas Saenz Julienne , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 24/30] context-tracking: Introduce work deferral infrastructure Date: Tue, 14 Jan 2025 18:51:37 +0100 Message-ID: <20250114175143.81438-25-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: ufkyknydfri586jso8t5squq9gm3ctx5 X-Rspamd-Queue-Id: 0943240012 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736877782-884119 X-HE-Meta: U2FsdGVkX1/0wLcydMYQevj1M/hrlJSOO4hNmc7rMHNG48hysD7b2kuch5AFPul9poSI85uzmTGrFFiaXw9SVlmJDJK13/ENtT1u9WwsJKeBnD8e87BgQtC9QKc/bu+2QphWvhIB14JK/JRB9gPKVSVxwJqjNN3+nvw8Z6cek4OeN/HUkyybefTttJk9PbOtqQ60sWK0CkyjOSzfrtFzM7h7kaUKJnIACh2+7ROF4rUPE733n3RU1NTlOnIwClxERG32cMFdBWzgYhgf0GB6W761S1kaujmeUNfIjEl3HS3ySVu8phQz4rQXtvqCS8G+iIJi+Pb7cosGD7iM2R5JPAyc0wctxJtqa1VL8meddgovse5lgdNFC7aU9bqAUUTemasp+ROguH7R2cXvi7kwiiswPiRidGFFmBYuNJZt1wB9qglCxW+ZLOMAYjEK50Ru8lQG2GOXcRW6Tm2xzRYNeogVC7+s0zqMm3wSaCqb6y7vj+1pzFIeAfDjyst4x14OxfKmSeYytq3WRLplKYpDw9ly6aN4tm/qx3gyzlSDWdboKgXJxARZmjD3Dz/w+73tc9tTWszLZ8veV17Aafn8u+NIGHcYZYeNgkNn5PojuLVQ6ZRLSlfvx01DD2cyo0CtVxaXiadu1Jwj70UiiZdnwk1ucBoddyI52Sc8LLLuIgvZJZ3kocdgJA8zzzzigMV24ARKMa1d1A2OdCMRzf3Yrgwbe0qO236hFIh1D3w4zc12R2GBH8JNUpu/aCntBP1U/p4HhIu1PTy3JlfasosNVz+hXlEq/hbBLNkqAsTCt6OKUcivrSgUCQUVkXJ4fslo0bhJrWFEAWcaVb2pqRBXlmM7giNpOQU/6X8U3u2SO77fFtO30Qk8dBWmIHd2bVHdcnAKnV8wt21rmgTvXJ7Ca9WUZWvcpQOUp7649PRwA7EMJs7BSB5oNgwJidCh03XhBNep82LVHQMWTlsLs+v 8QmFHasU sdxmZsVMnwRYqczLWVipPbQHV57omQe6oSH0RJ1ODAn01TSa5f5WoMnWNGFo1BqGALJkLQ/d3OA9ysmxUagZ9Do4uTyxKzKrHfPZuHYu4TsejP0gjUJLVeoVqqUQGotxI62hz9jeM0E7YQLj5JYfHyikzs8puDhYcM/RR6oJothgkDm4DxBgJMFb9/7/8CoylT78XXViwFkFS1NXHLsnfKfBrYFEojrnZ/ZffrCVtDR29/+lLtNbJhwN65D6TiQcuttFFhvvOL7LQDR4WydIQsZ5MsNw+OTR9ht88a/ZzlyuTyyneh3AXRje2KzlDWy3KtI9PFseHH0wu2RHuCkMOv/ogyjKDNxJ3LUa4MQG0AFuJNZM7qT/BjFAXdQ2RjapNTDGQQojHLUhMcmfde8Wuh7kWIspZgbwydxPq0jf7BjYVrDk1jeJ+neJ0BKXyhqiG7yWqPpX0CiXIbteX6Fw+NxVeBN+ZZgbJY3Tz7MrjP6gHuw7l0kY7gO6JjA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: smp_call_function() & friends have the unfortunate habit of sending IPIs to isolated, NOHZ_FULL, in-userspace CPUs, as they blindly target all online CPUs. Some callsites can be bent into doing the right, such as done by commit: cc9e303c91f5 ("x86/cpu: Disable frequency requests via aperfmperf IPI for nohz_full CPUs") Unfortunately, not all SMP callbacks can be omitted in this fashion. However, some of them only affect execution in kernelspace, which means they don't have to be executed *immediately* if the target CPU is in userspace: stashing the callback and executing it upon the next kernel entry would suffice. x86 kernel instruction patching or kernel TLB invalidation are prime examples of it. Reduce the RCU dynticks counter width to free up some bits to be used as a deferred callback bitmask. Add some build-time checks to validate that setup. Presence of CT_STATE_KERNEL in the ct_state prevents queuing deferred work. Later commits introduce the bit:callback mappings. Link: https://lore.kernel.org/all/20210929151723.162004989@infradead.org/ Signed-off-by: Nicolas Saenz Julienne Signed-off-by: Valentin Schneider --- arch/Kconfig | 9 +++ arch/x86/Kconfig | 1 + arch/x86/include/asm/context_tracking_work.h | 16 +++++ include/linux/context_tracking.h | 21 +++++++ include/linux/context_tracking_state.h | 30 ++++++--- include/linux/context_tracking_work.h | 26 ++++++++ kernel/context_tracking.c | 66 +++++++++++++++++++- kernel/time/Kconfig | 5 ++ 8 files changed, 162 insertions(+), 12 deletions(-) create mode 100644 arch/x86/include/asm/context_tracking_work.h create mode 100644 include/linux/context_tracking_work.h diff --git a/arch/Kconfig b/arch/Kconfig index 6682b2a53e342..b637f20f0fc68 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -952,6 +952,15 @@ config HAVE_CONTEXT_TRACKING_USER_OFFSTACK - No use of instrumentation, unless instrumentation_begin() got called. +config HAVE_CONTEXT_TRACKING_WORK + bool + help + Architecture supports deferring work while not in kernel context. + This is especially useful on setups with isolated CPUs that might + want to avoid being interrupted to perform housekeeping tasks (for + ex. TLB invalidation or icache invalidation). The housekeeping + operations are performed upon re-entering the kernel. + config HAVE_TIF_NOHZ bool help diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9d7bd0ae48c42..ca5dd4cfc354b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -216,6 +216,7 @@ config X86 select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING_USER if X86_64 select HAVE_CONTEXT_TRACKING_USER_OFFSTACK if HAVE_CONTEXT_TRACKING_USER + select HAVE_CONTEXT_TRACKING_WORK if X86_64 select HAVE_C_RECORDMCOUNT select HAVE_OBJTOOL_MCOUNT if HAVE_OBJTOOL select HAVE_OBJTOOL_NOP_MCOUNT if HAVE_OBJTOOL_MCOUNT diff --git a/arch/x86/include/asm/context_tracking_work.h b/arch/x86/include/asm/context_tracking_work.h new file mode 100644 index 0000000000000..5f3b2d0977235 --- /dev/null +++ b/arch/x86/include/asm/context_tracking_work.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_CONTEXT_TRACKING_WORK_H +#define _ASM_X86_CONTEXT_TRACKING_WORK_H + +static __always_inline void arch_context_tracking_work(enum ct_work work) +{ + switch (work) { + case CT_WORK_n: + // Do work... + break; + case CT_WORK_MAX: + WARN_ON_ONCE(true); + } +} + +#endif diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index af9fe87a09225..0b0faa040e9b5 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -137,6 +138,26 @@ static __always_inline unsigned long ct_state_inc(int incby) return raw_atomic_add_return(incby, this_cpu_ptr(&context_tracking.state)); } +#ifdef CONFIG_CONTEXT_TRACKING_WORK +static __always_inline unsigned long ct_state_inc_clear_work(int incby) +{ + struct context_tracking *ct = this_cpu_ptr(&context_tracking); + unsigned long new, old, state; + + state = arch_atomic_read(&ct->state); + do { + old = state; + new = old & ~CT_WORK_MASK; + new += incby; + state = arch_atomic_cmpxchg(&ct->state, old, new); + } while (old != state); + + return new; +} +#else +#define ct_state_inc_clear_work(x) ct_state_inc(x) +#endif + static __always_inline bool warn_rcu_enter(void) { bool ret = false; diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index eb2149b20baef..b6ddfccba9714 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -5,6 +5,7 @@ #include #include #include +#include /* Offset to allow distinguishing irq vs. task-based idle entry/exit. */ #define CT_NESTING_IRQ_NONIDLE ((LONG_MAX / 2) + 1) @@ -39,16 +40,19 @@ struct context_tracking { }; /* - * We cram two different things within the same atomic variable: + * We cram up to three different things within the same atomic variable: * - * CT_RCU_WATCHING_START CT_STATE_START - * | | - * v v - * MSB [ RCU watching counter ][ context_state ] LSB - * ^ ^ - * | | - * CT_RCU_WATCHING_END CT_STATE_END + * CT_RCU_WATCHING_START CT_STATE_START + * | CT_WORK_START | + * | | | + * v v v + * MSB [ RCU watching counter ][ context work ][ context_state ] LSB + * ^ ^ ^ + * | | | + * | CT_WORK_END | + * CT_RCU_WATCHING_END CT_STATE_END * + * The [ context work ] region spans 0 bits if CONFIG_CONTEXT_WORK=n * Bits are used from the LSB upwards, so unused bits (if any) will always be in * upper bits of the variable. */ @@ -59,18 +63,24 @@ struct context_tracking { #define CT_STATE_START 0 #define CT_STATE_END (CT_STATE_START + CT_STATE_WIDTH - 1) -#define CT_RCU_WATCHING_MAX_WIDTH (CT_SIZE - CT_STATE_WIDTH) +#define CT_WORK_WIDTH (IS_ENABLED(CONFIG_CONTEXT_TRACKING_WORK) ? CT_WORK_MAX_OFFSET : 0) +#define CT_WORK_START (CT_STATE_END + 1) +#define CT_WORK_END (CT_WORK_START + CT_WORK_WIDTH - 1) + +#define CT_RCU_WATCHING_MAX_WIDTH (CT_SIZE - CT_WORK_WIDTH - CT_STATE_WIDTH) #define CT_RCU_WATCHING_WIDTH (IS_ENABLED(CONFIG_RCU_DYNTICKS_TORTURE) ? 2 : CT_RCU_WATCHING_MAX_WIDTH) -#define CT_RCU_WATCHING_START (CT_STATE_END + 1) +#define CT_RCU_WATCHING_START (CT_WORK_END + 1) #define CT_RCU_WATCHING_END (CT_RCU_WATCHING_START + CT_RCU_WATCHING_WIDTH - 1) #define CT_RCU_WATCHING BIT(CT_RCU_WATCHING_START) #define CT_STATE_MASK GENMASK(CT_STATE_END, CT_STATE_START) +#define CT_WORK_MASK GENMASK(CT_WORK_END, CT_WORK_START) #define CT_RCU_WATCHING_MASK GENMASK(CT_RCU_WATCHING_END, CT_RCU_WATCHING_START) #define CT_UNUSED_WIDTH (CT_RCU_WATCHING_MAX_WIDTH - CT_RCU_WATCHING_WIDTH) static_assert(CT_STATE_WIDTH + + CT_WORK_WIDTH + CT_RCU_WATCHING_WIDTH + CT_UNUSED_WIDTH == CT_SIZE); diff --git a/include/linux/context_tracking_work.h b/include/linux/context_tracking_work.h new file mode 100644 index 0000000000000..c68245f8d77c5 --- /dev/null +++ b/include/linux/context_tracking_work.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CONTEXT_TRACKING_WORK_H +#define _LINUX_CONTEXT_TRACKING_WORK_H + +#include + +enum { + CT_WORK_n_OFFSET, + CT_WORK_MAX_OFFSET +}; + +enum ct_work { + CT_WORK_n = BIT(CT_WORK_n_OFFSET), + CT_WORK_MAX = BIT(CT_WORK_MAX_OFFSET) +}; + +#include + +#ifdef CONFIG_CONTEXT_TRACKING_WORK +extern bool ct_set_cpu_work(unsigned int cpu, enum ct_work work); +#else +static inline bool +ct_set_cpu_work(unsigned int cpu, unsigned int work) { return false; } +#endif + +#endif diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 15f10ddec8cbe..f7019c12269f9 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -72,6 +72,67 @@ static __always_inline void rcu_task_trace_heavyweight_exit(void) #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */ } +#ifdef CONFIG_CONTEXT_TRACKING_WORK +static noinstr void ct_work_flush(unsigned long seq) +{ + int bit; + + seq = (seq & CT_WORK_MASK) >> CT_WORK_START; + + /* + * arch_context_tracking_work() must be noinstr, non-blocking, + * and NMI safe. + */ + for_each_set_bit(bit, &seq, CT_WORK_MAX) + arch_context_tracking_work(BIT(bit)); +} + +/** + * ct_set_cpu_work - set work to be run at next kernel context entry + * + * If @cpu is not currently executing in kernelspace, it will execute the + * callback mapped to @work (see arch_context_tracking_work()) at its next + * transition to CT_KERNEL_STATE. + * + * If it is already in CT_KERNEL_STATE, this will be a no-op. + */ +bool ct_set_cpu_work(unsigned int cpu, enum ct_work work) +{ + struct context_tracking *ct = per_cpu_ptr(&context_tracking, cpu); + unsigned int old; + bool ret = false; + + if (!ct->active) + return false; + + preempt_disable(); + + old = atomic_read(&ct->state); + + /* + * We only want to set the work bit if the target CPU is not in + * kernelspace, so we clear the KERNEL bit here and let the cmpxchg do + * the check for us - the state could change between the atomic_read() and + * the cmpxchg(). + */ + old &= ~CT_STATE_KERNEL; + /* + * Try setting the work until either + * - the target CPU has entered kernelspace + * - the work has been set + */ + do { + ret = atomic_try_cmpxchg(&ct->state, &old, old | (work << CT_WORK_START)); + } while (!ret && ((old & CT_STATE_MASK) != CT_STATE_KERNEL)); + + preempt_enable(); + return ret; +} +#else +static __always_inline void ct_work_flush(unsigned long work) { } +static __always_inline void ct_work_clear(struct context_tracking *ct) { } +#endif + /* * Record entry into an extended quiescent state. This is only to be * called when not already in an extended quiescent state, that is, @@ -88,7 +149,7 @@ static noinstr void ct_kernel_exit_state(int offset) * next idle sojourn. */ rcu_task_trace_heavyweight_enter(); // Before CT state update! - seq = ct_state_inc(offset); + seq = ct_state_inc_clear_work(offset); // RCU is no longer watching. Better be in extended quiescent state! WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && (seq & CT_RCU_WATCHING)); } @@ -100,7 +161,7 @@ static noinstr void ct_kernel_exit_state(int offset) */ static noinstr void ct_kernel_enter_state(int offset) { - int seq; + unsigned long seq; /* * CPUs seeing atomic_add_return() must see prior idle sojourns, @@ -108,6 +169,7 @@ static noinstr void ct_kernel_enter_state(int offset) * critical section. */ seq = ct_state_inc(offset); + ct_work_flush(seq); // RCU is now watching. Better not be in an extended quiescent state! rcu_task_trace_heavyweight_exit(); // After CT state update! WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !(seq & CT_RCU_WATCHING)); diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index b0b97a60aaa6f..7e8106a0d981f 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -181,6 +181,11 @@ config CONTEXT_TRACKING_USER_FORCE Say N otherwise, this option brings an overhead that you don't want in production. +config CONTEXT_TRACKING_WORK + bool + depends on HAVE_CONTEXT_TRACKING_WORK && CONTEXT_TRACKING_USER + default y + config NO_HZ bool "Old Idle dynticks config" help From patchwork Tue Jan 14 17:51:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 841C0E77188 for ; Tue, 14 Jan 2025 18:03:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 185FB280016; Tue, 14 Jan 2025 13:03:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 136EA28000C; Tue, 14 Jan 2025 13:03:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF23D280016; Tue, 14 Jan 2025 13:03:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D1B2428000C for ; Tue, 14 Jan 2025 13:03:25 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7EE1580BFB for ; Tue, 14 Jan 2025 18:03:25 +0000 (UTC) X-FDA: 83006829570.29.BD388C3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id B60AFC002C for ; Tue, 14 Jan 2025 18:03:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPRLCqLS; spf=pass (imf28.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gOYbvMechf4Tk3QrOwIKHHFKhIz7g8W0C2CEkfk0nCI=; b=8pabCusXzAgCulgkePahhTCPXmuKRJ4/VlNcdgkIZkALzEu78NrPS/hjtUOQflp6nqCy17 NPaZgPbuKegqTf9jjqupBkECZcmjtORDI83M9cChP3TcMRM2/jfPEif87Ka2j4/GJXA/B8 DBhimS1T+lg+rWyaEPrA9R+QJ49UjJ0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPRLCqLS; spf=pass (imf28.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877803; a=rsa-sha256; cv=none; b=SUzoa2vq79iNxZAHlABmgaK+e1tJladwnZPg293cIy4rPjOYF0dOUDPg7Rs1uokM/5+aOR qS+OU/AzFATty+xvS2HZ88OgogRiOPKAqZ9BTM3qH0SM2Bb7qrKjCcZ82xYzRQyKYNuPlO ulXt/Ebp3TVcuSgMIG0o35/nTbNwlro= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877803; 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=gOYbvMechf4Tk3QrOwIKHHFKhIz7g8W0C2CEkfk0nCI=; b=iPRLCqLSu0gwLTG2PbeZW6wWPGfL9SXijsLXahy/pd/Ihdpp+e4FEPCAno+1sFXkoLWDeK 5ptJif2zh1KxqHJsWy+t4odxkVSq6o4XEM9o2op1nv+FzXzVFUsyAIKZ7IupNuRl1AkZ5c AszZmpTmJTkZGFQwoebbckMSNt7xT9A= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-Kq2Q4fXhOu2lJRR6wkpJZw-1; Tue, 14 Jan 2025 13:03:20 -0500 X-MC-Unique: Kq2Q4fXhOu2lJRR6wkpJZw-1 X-Mimecast-MFC-AGG-ID: Kq2Q4fXhOu2lJRR6wkpJZw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A57A91956054; Tue, 14 Jan 2025 18:03:16 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C6D619560B7; Tue, 14 Jan 2025 18:02:54 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Peter Zijlstra , Nicolas Saenz Julienne , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 25/30] context_tracking,x86: Defer kernel text patching IPIs Date: Tue, 14 Jan 2025 18:51:38 +0100 Message-ID: <20250114175143.81438-26-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B60AFC002C X-Rspam-User: X-Stat-Signature: pjxi16xckzi66643z6u6xg5gg3zeaifw X-HE-Tag: 1736877803-465884 X-HE-Meta: U2FsdGVkX1+2iQyqTKugW5KHYPI7R1BcfoxWVVVSBDPY1yJ/0qgTnMFw/XyaPeMDCd7l2/DL45IhKKWdswkJ/Auy1OrdeEp4nlIThP86T+FFBzPB6vqg7j2OpfBLsJsEBLMoGnFjrlOybJraeFaiwAQL2UxTr+8IbtozFUELveEIv6FazPrNkcC9Q0XneQiX1aJFeLPwL9KKuTDGcZ0iCIO8nItCJbU0GrOK5kKLhMheAVQPj1KvtWOfnT/Ox4ydcxWBE6HvpK7C6RXm2hFXU8qk+2DuNSdbetFHxexrc5+WU9HDDYC24949bBYt7zWgQi/19mtOgUQbRsze/5Ho1PRCMZv6K4pW62ei3+XlwSzPfdYpD/QQtPchN2uglMaV7qWJRaGna5msJ0tr/Jek0IfqU9mM9zMW8O23iOuq2pKGnDN6SPwoBltTU6bQ/PcVd3J5m4nHXrhHG3Um7rc/08dYOkWijV1hR/T+IsbZbtxH1nVzsM3c8QkOgJcNnWt3S2YKjBsqOGOba9GG4TTYI/0ds+nc1yL0QNrMdldbd1RcnLaZH8tPqvtfCFLNeNBbAjYKEtxQd2qrgS53jrV1necyGtOqxSazzPJAxKJQFFPXSha3zW9bzN+4I0HtXlbspneb6ElW0uGuak3f0CeXvqpCsEkxhNQO/Dj4JGBDa9yuO+/+15WkOiDqvCcGmR8RuE1SoM+CE4v0BO/SBczxCetWzzFiRvMVQ0lx8660Ddk6v9GwF8evJR8YDiFkQqR9nzRdlHk06Jz6dXy3Hlliyau9shhNQOgFHjrqA23QDXlTik0IS/fpSCckoBTExGtBXctqz1cMgr1j7z0+BjfUBneuK/nkjSZc3oEJkz5/0FQFtHfaLdsdOjOY5wCMguo2RjToAkhr6aVUTlYjcjyXp5MaJzruAHnUSiA6BavbHETNY6A0he48JQScEIsnIkOkd0/cA7VDc5jZqmGkPLG KMlisA/m u+LuJM3yjiRnXSv/xsNsDy8dacGmKfBEegEErKGNjv4/Mw1T4X2C5/vWwS6AUYC+strTw1EdaLn9BhxlJ/BPgKe0+0LncmqT8rCXm4BKhsZ/jaAJ0dc1a7KPMyToxi+eFRRE4TQojUU4KY6FQ0D5Pf21K9t0T4zh0JWrTd/BHY4IE5bJZ9p/iKtTIjbF0pg6KMXrwX4oXi2Ej9naUdGRSIE1R0taDWbLWVxgC3jXsBpnUwxiTFQIrHV8LhQTzsmyrnJiaZpk1TB9sV4ktjmOffyMa0Qz9nlcqqAyvyeCOBZOAL9ziQX09faftptsnC8Heu3rYJjXZav65kOidJzbPjE6MO518zfwU2all9MZtqqpYt9Br+Ke4o7qzgt2U2sJEgaX0OZFTADnZ6DRbEDyoWiR+7r6KqoGZf8X36cSMvqHvBCqPjyjwbc7au85J8nn7XOP87AZL+tpXLuOmfrT3WFqoW1ws1l7nE4eqzoE0vNYZPOXz5fnHM3W3adO9P8Kq7Xmc7x7tPRoIOOQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: text_poke_bp_batch() sends IPIs to all online CPUs to synchronize them vs the newly patched instruction. CPUs that are executing in userspace do not need this synchronization to happen immediately, and this is actually harmful interference for NOHZ_FULL CPUs. As the synchronization IPIs are sent using a blocking call, returning from text_poke_bp_batch() implies all CPUs will observe the patched instruction(s), and this should be preserved even if the IPI is deferred. In other words, to safely defer this synchronization, any kernel instruction leading to the execution of the deferred instruction sync (ct_work_flush()) must *not* be mutable (patchable) at runtime. This means we must pay attention to mutable instructions in the early entry code: - alternatives - static keys - static calls - all sorts of probes (kprobes/ftrace/bpf/???) The early entry code leading to ct_work_flush() is noinstr, which gets rid of the probes. Alternatives are safe, because it's boot-time patching (before SMP is even brought up) which is before any IPI deferral can happen. This leaves us with static keys and static calls. Any static key used in early entry code should be only forever-enabled at boot time, IOW __ro_after_init (pretty much like alternatives). Exceptions are explicitly marked as allowed in .noinstr and will always generate an IPI when flipped. The same applies to static calls - they should be only updated at boot time, or manually marked as an exception. Objtool is now able to point at static keys/calls that don't respect this, and all static keys/calls used in early entry code have now been verified as behaving appropriately. Leverage the new context_tracking infrastructure to defer sync_core() IPIs to a target CPU's next kernel entry. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Nicolas Saenz Julienne Signed-off-by: Valentin Schneider --- arch/x86/include/asm/context_tracking_work.h | 6 ++-- arch/x86/include/asm/text-patching.h | 1 + arch/x86/kernel/alternative.c | 38 ++++++++++++++++---- arch/x86/kernel/kprobes/core.c | 4 +-- arch/x86/kernel/kprobes/opt.c | 4 +-- arch/x86/kernel/module.c | 2 +- include/asm-generic/sections.h | 15 ++++++++ include/linux/context_tracking_work.h | 4 +-- 8 files changed, 59 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/context_tracking_work.h b/arch/x86/include/asm/context_tracking_work.h index 5f3b2d0977235..485b32881fde5 100644 --- a/arch/x86/include/asm/context_tracking_work.h +++ b/arch/x86/include/asm/context_tracking_work.h @@ -2,11 +2,13 @@ #ifndef _ASM_X86_CONTEXT_TRACKING_WORK_H #define _ASM_X86_CONTEXT_TRACKING_WORK_H +#include + static __always_inline void arch_context_tracking_work(enum ct_work work) { switch (work) { - case CT_WORK_n: - // Do work... + case CT_WORK_SYNC: + sync_core(); break; case CT_WORK_MAX: WARN_ON_ONCE(true); diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h index ab9e143ec9fea..9dfa46f721c1d 100644 --- a/arch/x86/include/asm/text-patching.h +++ b/arch/x86/include/asm/text-patching.h @@ -33,6 +33,7 @@ extern void apply_relocation(u8 *buf, const u8 * const instr, size_t instrlen, u */ extern void *text_poke(void *addr, const void *opcode, size_t len); extern void text_poke_sync(void); +extern void text_poke_sync_deferrable(void); extern void *text_poke_kgdb(void *addr, const void *opcode, size_t len); extern void *text_poke_copy(void *addr, const void *opcode, size_t len); #define text_poke_copy text_poke_copy diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 243843e44e89d..633deea8a89cb 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2109,9 +2110,24 @@ static void do_sync_core(void *info) sync_core(); } +static bool do_sync_core_defer_cond(int cpu, void *info) +{ + return !ct_set_cpu_work(cpu, CT_WORK_SYNC); +} + +static void __text_poke_sync(smp_cond_func_t cond_func) +{ + on_each_cpu_cond(cond_func, do_sync_core, NULL, 1); +} + void text_poke_sync(void) { - on_each_cpu(do_sync_core, NULL, 1); + __text_poke_sync(NULL); +} + +void text_poke_sync_deferrable(void) +{ + __text_poke_sync(do_sync_core_defer_cond); } /* @@ -2282,6 +2298,7 @@ static int tp_vec_nr; */ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries) { + smp_cond_func_t cond = do_sync_core_defer_cond; unsigned char int3 = INT3_INSN_OPCODE; unsigned int i; int do_sync; @@ -2317,11 +2334,20 @@ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries * First step: add a int3 trap to the address that will be patched. */ for (i = 0; i < nr_entries; i++) { - tp[i].old = *(u8 *)text_poke_addr(&tp[i]); - text_poke(text_poke_addr(&tp[i]), &int3, INT3_INSN_SIZE); + void *addr = text_poke_addr(&tp[i]); + + /* + * There's no safe way to defer IPIs for patching text in + * .noinstr, record whether there is at least one such poke. + */ + if (is_kernel_noinstr_text((unsigned long)addr)) + cond = NULL; + + tp[i].old = *((u8 *)addr); + text_poke(addr, &int3, INT3_INSN_SIZE); } - text_poke_sync(); + __text_poke_sync(cond); /* * Second step: update all but the first byte of the patched range. @@ -2383,7 +2409,7 @@ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries * not necessary and we'd be safe even without it. But * better safe than sorry (plus there's not only Intel). */ - text_poke_sync(); + __text_poke_sync(cond); } /* @@ -2404,7 +2430,7 @@ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries } if (do_sync) - text_poke_sync(); + __text_poke_sync(cond); /* * Remove and wait for refs to be zero. diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 72e6a45e7ec24..c2fd2578fd5fc 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -817,7 +817,7 @@ void arch_arm_kprobe(struct kprobe *p) u8 int3 = INT3_INSN_OPCODE; text_poke(p->addr, &int3, 1); - text_poke_sync(); + text_poke_sync_deferrable(); perf_event_text_poke(p->addr, &p->opcode, 1, &int3, 1); } @@ -827,7 +827,7 @@ void arch_disarm_kprobe(struct kprobe *p) perf_event_text_poke(p->addr, &int3, 1, &p->opcode, 1); text_poke(p->addr, &p->opcode, 1); - text_poke_sync(); + text_poke_sync_deferrable(); } void arch_remove_kprobe(struct kprobe *p) diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 36d6809c6c9e1..b2ce4d9c3ba56 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -513,11 +513,11 @@ void arch_unoptimize_kprobe(struct optimized_kprobe *op) JMP32_INSN_SIZE - INT3_INSN_SIZE); text_poke(addr, new, INT3_INSN_SIZE); - text_poke_sync(); + text_poke_sync_deferrable(); text_poke(addr + INT3_INSN_SIZE, new + INT3_INSN_SIZE, JMP32_INSN_SIZE - INT3_INSN_SIZE); - text_poke_sync(); + text_poke_sync_deferrable(); perf_event_text_poke(op->kp.addr, old, JMP32_INSN_SIZE, new, JMP32_INSN_SIZE); } diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index 8984abd91c001..acc810150b76c 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -194,7 +194,7 @@ static int write_relocate_add(Elf64_Shdr *sechdrs, write, apply); if (!early) { - text_poke_sync(); + text_poke_sync_deferrable(); mutex_unlock(&text_mutex); } diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index c768de6f19a9a..1b3ba3084fd2f 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -199,6 +199,21 @@ static inline bool is_kernel_inittext(unsigned long addr) addr < (unsigned long)_einittext; } + +/** + * is_kernel_noinstr_text - checks if the pointer address is located in the + * .noinstr section + * + * @addr: address to check + * + * Returns: true if the address is located in .noinstr, false otherwise. + */ +static inline bool is_kernel_noinstr_text(unsigned long addr) +{ + return addr >= (unsigned long)__noinstr_text_start && + addr < (unsigned long)__noinstr_text_end; +} + /** * __is_kernel_text - checks if the pointer address is located in the * .text section diff --git a/include/linux/context_tracking_work.h b/include/linux/context_tracking_work.h index c68245f8d77c5..931ade1dcbcc2 100644 --- a/include/linux/context_tracking_work.h +++ b/include/linux/context_tracking_work.h @@ -5,12 +5,12 @@ #include enum { - CT_WORK_n_OFFSET, + CT_WORK_SYNC, CT_WORK_MAX_OFFSET }; enum ct_work { - CT_WORK_n = BIT(CT_WORK_n_OFFSET), + CT_WORK_SYNC = BIT(CT_WORK_SYNC_OFFSET), CT_WORK_MAX = BIT(CT_WORK_MAX_OFFSET) }; From patchwork Tue Jan 14 17:51:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4040CE77188 for ; Tue, 14 Jan 2025 18:03:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C35E2280018; Tue, 14 Jan 2025 13:03:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE4B228000C; Tue, 14 Jan 2025 13:03:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1076280018; Tue, 14 Jan 2025 13:03:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8224828000C for ; Tue, 14 Jan 2025 13:03:47 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 40F461A0C59 for ; Tue, 14 Jan 2025 18:03:47 +0000 (UTC) X-FDA: 83006830494.06.37D7F34 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 642E116000A for ; Tue, 14 Jan 2025 18:03:45 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iA0m2w8u; spf=pass (imf08.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877825; a=rsa-sha256; cv=none; b=fhVu29J+pTwevk1IK6XBp/qjUyOtEuJuFuKY8vgEvmlJktgbyryvzvIyq4z1ljUoAY8i4I 5ViGl/jaG3Il4eYbc5jcbI/9MO7F984eKc5W9CrL2ekYN3otOw/64pBhAtTgsOvygL+TU0 38zlWit750fdYVwrKqjgDYPbA+ZBVFc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iA0m2w8u; spf=pass (imf08.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877825; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=le8UIdWvg/w/MVcf7PTpfkO3a8bfCjcr6cLgmw3M858=; b=fiTUZIIf22EwoPdvVVZvoh53KhU5qUNdhJby9GfgGnFIl9fLPHw/bP03P3n/wD+C194XZc 90XPyOSBwIGzU4/ET5e4AwVD2o3XE9lVT27qe4Dv6vCF/I1+Nh2G/lkLQm/Tt/DT9UAIrI ZuNawcoZJm8zC642sM2KnJw/Ge2JzyE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877824; 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=le8UIdWvg/w/MVcf7PTpfkO3a8bfCjcr6cLgmw3M858=; b=iA0m2w8uVUiLkLuqjHnVSkVYtKfW9iOo7Mz4eI5KIP7wys373umW5BJ+ZqY5QKMnopj4M9 OO9OkD8AqAfbNPWgr6zYkivH2RPSDzXBeB4L9XrX07G9dSLQwE2PFfsqwLxkZR/flM6fhi 75zM57YEiTRMXh5WLMBzaGVvYP+Ou/U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-RjogcdnCPlS1FV6yZ4Sprw-1; Tue, 14 Jan 2025 13:03:43 -0500 X-MC-Unique: RjogcdnCPlS1FV6yZ4Sprw-1 X-Mimecast-MFC-AGG-ID: RjogcdnCPlS1FV6yZ4Sprw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C8EC19560B3; Tue, 14 Jan 2025 18:03:39 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2905C195608A; Tue, 14 Jan 2025 18:03:16 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Peter Zijlstra , Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 26/30] x86,tlb: Make __flush_tlb_global() noinstr-compliant Date: Tue, 14 Jan 2025 18:51:39 +0100 Message-ID: <20250114175143.81438-27-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 642E116000A X-Stat-Signature: 4eypaquy97jsawrdw643nmedk5bh6a5g X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736877825-567977 X-HE-Meta: U2FsdGVkX19OOF0jonFOidWDu7nQQiwqxGxLGY501ng7y3cHL/2V1jiX+9C1lCo+WHBmAhKjPUyxlqPHgP+GRTvSxi+fs1KSDzvWuiM9pQaepYj/1VDEICTqyKXevWYUmx+T4L2skD4y9NkRhE0uBjDdOggSCeF0mtjmd/Fg9Y4uC7YsgU2OPhTGpLKMlwyO7+hYmE9s0Daou8nVBY72kqC9s7vI3a8EHEPRfoK/XLXmc8tYY5SldoAeces5BNwfU0gAA6BDN5yMVLqByubQK1hOZR7IWg7OUQMTh3T8X8Ul9xvIs5SApcFybkoDSd373DqyP1FbRvBzRAkX/jx10eQHpJmrA49qD1b/NOWs28gtHnwQfkUrUTaGW4HBUoKvdEVRlJs97cFhqQLP1ndaAMUztsUJBLgZNjFPZAQu6VG+G4CxbwMwjMJQbRLGQfXyEpVwAWnE63vN0lFgJSvKJemg4WVl5ocxKTCrAhbfm7X++lCPVPMACzsKvC9KPhf2OAKUr0Pe/wfaH3QRH2F2O9VJ+ziYgCIldzQ88lVIg8m4eUzboAbUc2qd8uw7H0JdjgFx0kPkZSOHAPky7zg/8sOWPnUlJrFzRsrsMmySMkc8ZnjJN7RPRwVxGb+VCOTfIbfnSdqRd2EJ0iW9PHWIAWXhrwlnvHZZSTJthYAVnAO0QLmPsoPbHVLs4u5Z1fVVXZOP87xLZ3kaI0NGLQSQ+PEaSQjli5Kl1oPj5KYbKCkqF7dVOWjSsoODj/GGdMF72HwHare4kfKitvyW4GUG3z4OCDPepBLRpjJWxYZKemHd+QLR/7/xr4rkgwCiPEn+dNqnEFWQT3IVsycbn8zw6VjFFChQC3VmrbfqFUqvgE58mW++mMQWGD+9Ku2sTi12j66ORoSU3JK9HdWAB1y1sIQ0YmP6fV7Q7asrJotJkdk0p/f9ardwRpLgp9gujzCb3b0sQIOWJIdP71LMQ4d oRWMuaCq Wn4MBfLZYbkXchgd3YriIywscTgJ3/3nTED3XZz5juwRwByO/CJ1bDwVsGOIJYE2os17RjNgJOCv8dOEpNjDI7gNYLoIG90TuF67nlR3HvDPu28LM+AKIKqAQUZAGViyv4C0zhMSYjBOnlGJsCLw0EOB3bEuGCkf46vPv3uFUUaT/D7yQzIAwrHx+0V2BQEqg5RrCgFJIBSsdbdULJ/6hSUAnJA4QTUc35SL6Nd1jCzMl85CU2dsqjsN43VbGDVlzHKHzd8hNmpMfOEXgX7t0keieV7P+RmzFCH3r4ONaCMH8IaP7hd6eRnSYx/OQsat13dsitJBCdwOy0fzt7g5RbypD4Ci+OL0w4fpscrT5Xn+ni4dcgiVomCiR8coAyNnfF7dzkZx2pp3m8MIegMG3dAPtPZs5yT3u2Os3J3f3nr7Q0Fy0czSqoG4tkthRQxBSRECGczS0S1S+i0iaY4IlQ6M2AzK0uzMswzm2d0ZNLaw0CuLZW9OE/yzWAEdBouYOeS0e1Z7IiqWJtio= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Peter Zijlstra Later patches will require issuing a __flush_tlb_all() from noinstr code. This requires making both __flush_tlb_local() and __flush_tlb_global() noinstr-compliant. For __flush_tlb_global(), both native_flush_tlb_global() and xen_flush_tlb() need to be made noinstr. Forgo using __native_flush_tlb_global() / native_write_cr4() and have the ASM directly inlined in the native function. For the Xen stuff, __always_inline a handful of helpers. Not-signed-off-by: Peter Zijlstra [Changelog faff] Signed-off-by: Valentin Schneider --- arch/x86/include/asm/invpcid.h | 13 ++++++------- arch/x86/include/asm/paravirt.h | 2 +- arch/x86/include/asm/xen/hypercall.h | 11 +++++++++-- arch/x86/mm/tlb.c | 15 +++++++++++---- arch/x86/xen/mmu_pv.c | 10 +++++----- arch/x86/xen/xen-ops.h | 12 ++++++++---- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/arch/x86/include/asm/invpcid.h b/arch/x86/include/asm/invpcid.h index 734482afbf81d..ff26136fcd9c6 100644 --- a/arch/x86/include/asm/invpcid.h +++ b/arch/x86/include/asm/invpcid.h @@ -2,7 +2,7 @@ #ifndef _ASM_X86_INVPCID #define _ASM_X86_INVPCID -static inline void __invpcid(unsigned long pcid, unsigned long addr, +static __always_inline void __invpcid(unsigned long pcid, unsigned long addr, unsigned long type) { struct { u64 d[2]; } desc = { { pcid, addr } }; @@ -13,7 +13,7 @@ static inline void __invpcid(unsigned long pcid, unsigned long addr, * mappings, we don't want the compiler to reorder any subsequent * memory accesses before the TLB flush. */ - asm volatile("invpcid %[desc], %[type]" + asm_inline volatile("invpcid %[desc], %[type]" :: [desc] "m" (desc), [type] "r" (type) : "memory"); } @@ -23,26 +23,25 @@ static inline void __invpcid(unsigned long pcid, unsigned long addr, #define INVPCID_TYPE_ALL_NON_GLOBAL 3 /* Flush all mappings for a given pcid and addr, not including globals. */ -static inline void invpcid_flush_one(unsigned long pcid, - unsigned long addr) +static __always_inline void invpcid_flush_one(unsigned long pcid, unsigned long addr) { __invpcid(pcid, addr, INVPCID_TYPE_INDIV_ADDR); } /* Flush all mappings for a given PCID, not including globals. */ -static inline void invpcid_flush_single_context(unsigned long pcid) +static __always_inline void invpcid_flush_single_context(unsigned long pcid) { __invpcid(pcid, 0, INVPCID_TYPE_SINGLE_CTXT); } /* Flush all mappings, including globals, for all PCIDs. */ -static inline void invpcid_flush_all(void) +static __always_inline void invpcid_flush_all(void) { __invpcid(0, 0, INVPCID_TYPE_ALL_INCL_GLOBAL); } /* Flush all mappings for all PCIDs except globals. */ -static inline void invpcid_flush_all_nonglobals(void) +static __always_inline void invpcid_flush_all_nonglobals(void) { __invpcid(0, 0, INVPCID_TYPE_ALL_NON_GLOBAL); } diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index d4eb9e1d61b8e..b3daee3d46677 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -75,7 +75,7 @@ static inline void __flush_tlb_local(void) PVOP_VCALL0(mmu.flush_tlb_user); } -static inline void __flush_tlb_global(void) +static __always_inline void __flush_tlb_global(void) { PVOP_VCALL0(mmu.flush_tlb_kernel); } diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h index 97771b9d33af3..291e9f8006f62 100644 --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -365,8 +365,8 @@ MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req, trace_xen_mc_entry(mcl, 4); } -static inline void -MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, +static __always_inline void +__MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, int *success_count, domid_t domid) { mcl->op = __HYPERVISOR_mmuext_op; @@ -374,6 +374,13 @@ MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, mcl->args[1] = count; mcl->args[2] = (unsigned long)success_count; mcl->args[3] = domid; +} + +static inline void +MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count, + int *success_count, domid_t domid) +{ + __MULTI_mmuext_op(mcl, op, count, success_count, domid); trace_xen_mc_entry(mcl, 4); } diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index a2becb85bea79..2d2ab3e221f0c 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1169,9 +1169,10 @@ void flush_tlb_one_user(unsigned long addr) /* * Flush everything */ -STATIC_NOPV void native_flush_tlb_global(void) +STATIC_NOPV noinstr void native_flush_tlb_global(void) { unsigned long flags; + unsigned long cr4; if (static_cpu_has(X86_FEATURE_INVPCID)) { /* @@ -1190,9 +1191,15 @@ STATIC_NOPV void native_flush_tlb_global(void) * be called from deep inside debugging code.) */ raw_local_irq_save(flags); - - __native_tlb_flush_global(this_cpu_read(cpu_tlbstate.cr4)); - + cr4 = this_cpu_read(cpu_tlbstate.cr4); + asm volatile("mov %0,%%cr4": : "r" (cr4 ^ X86_CR4_PGE) : "memory"); + asm volatile("mov %0,%%cr4": : "r" (cr4) : "memory"); + /* + * In lieu of not having the pinning crap, hard fail if CR4 doesn't + * match the expected value. This ensures that anybody doing dodgy gets + * the fallthrough check. + */ + BUG_ON(cr4 != this_cpu_read(cpu_tlbstate.cr4)); raw_local_irq_restore(flags); } diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 55a4996d0c04f..4eb265eb867af 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -1231,22 +1231,22 @@ static noinstr void xen_write_cr2(unsigned long cr2) this_cpu_read(xen_vcpu)->arch.cr2 = cr2; } -static noinline void xen_flush_tlb(void) +static noinline noinstr void xen_flush_tlb(void) { struct mmuext_op *op; struct multicall_space mcs; - preempt_disable(); + preempt_disable_notrace(); mcs = xen_mc_entry(sizeof(*op)); op = mcs.args; op->cmd = MMUEXT_TLB_FLUSH_LOCAL; - MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); + __MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); - xen_mc_issue(XEN_LAZY_MMU); + __xen_mc_issue(XEN_LAZY_MMU); - preempt_enable(); + preempt_enable_notrace(); } static void xen_flush_tlb_one_user(unsigned long addr) diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 63c13a2ccf556..effb1a54afbd1 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -235,15 +235,19 @@ static inline struct multicall_space xen_mc_entry(size_t args) void xen_mc_flush(void); /* Issue a multicall if we're not in a lazy mode */ -static inline void xen_mc_issue(unsigned mode) +static __always_inline void __xen_mc_issue(unsigned mode) { - trace_xen_mc_issue(mode); - if ((xen_get_lazy_mode() & mode) == 0) xen_mc_flush(); /* restore flags saved in xen_mc_batch */ - local_irq_restore(this_cpu_read(xen_mc_irq_flags)); + raw_local_irq_restore(this_cpu_read(xen_mc_irq_flags)); +} + +static inline void xen_mc_issue(unsigned mode) +{ + trace_xen_mc_issue(mode); + __xen_mc_issue(mode); } /* Set up a callback to be called when the current batch is flushed */ From patchwork Tue Jan 14 17:51:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52D00E77188 for ; Tue, 14 Jan 2025 18:04:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0B0C280019; Tue, 14 Jan 2025 13:04:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBA1928000C; Tue, 14 Jan 2025 13:04:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE814280019; Tue, 14 Jan 2025 13:04:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9E7D328000C for ; Tue, 14 Jan 2025 13:04:13 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4D8251A0A02 for ; Tue, 14 Jan 2025 18:04:13 +0000 (UTC) X-FDA: 83006831586.17.DE80228 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 67F3E8000A for ; Tue, 14 Jan 2025 18:04:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LTwCaDm0; spf=pass (imf30.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877851; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qfGcbREmcisg82Rx6e546I8mjQ8z9ythW/HTCaSXKy0=; b=4O7uv8yRxlcaqT8+R8juM6t/N45l5i1/uHz99/SRK7KJbShcxMSCSdMGcnJ9hL8Rrr1Asf J/yQoa0tugJehnGMmB687/icJqDX1kX73GVyfUIMLtcq8CnnUKI0TOlQzHfeQ2rVgDSBYZ BGjIgIxqYC9MrGCYyDJxiU6queY1/Rk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LTwCaDm0; spf=pass (imf30.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877851; a=rsa-sha256; cv=none; b=Y06zuhKXOFgRlaoOHtK1SNFPmAQ4/CC1r1QYCDrljksDbfzZCMGJMDD/JKK3vLN7yyhSwq DpLmP/b7fMWfMz+06SUWv+uQJ4yVCDLQJQKZW02U2aMkXKzWJPD/29LjE8G8U9US8AHFjO XGet8QRmelWtnXpyG3jTn8o6918oeSY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877850; 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=qfGcbREmcisg82Rx6e546I8mjQ8z9ythW/HTCaSXKy0=; b=LTwCaDm030pG9AOhBs6eYL8FVYf41aic18w4nWdPtuJyXsj0F+g2wRKOBptvmqUT9KwHse E1ebR9dyzX62LSQh03PMnfQle0oNgEUhCKpCmB4HLRiz5/qJdKcbJ+Bihyrlx+K6PtYAWe 0741DzGA8VzB661JDz+biSa82BUPVPg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-2bGxv9G8MbqEpONYIM0Pig-1; Tue, 14 Jan 2025 13:04:06 -0500 X-MC-Unique: 2bGxv9G8MbqEpONYIM0Pig-1 X-Mimecast-MFC-AGG-ID: 2bGxv9G8MbqEpONYIM0Pig Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EBCE81955D4F; Tue, 14 Jan 2025 18:04:02 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2065195608A; Tue, 14 Jan 2025 18:03:39 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 27/30] x86/tlb: Make __flush_tlb_local() noinstr-compliant Date: Tue, 14 Jan 2025 18:51:40 +0100 Message-ID: <20250114175143.81438-28-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 67F3E8000A X-Rspam-User: X-Stat-Signature: 8dhtwc7cxaa3z9so7ocaagsnjnc44qw9 X-HE-Tag: 1736877851-768702 X-HE-Meta: U2FsdGVkX18Q4x/1QIxaDcih18e+9EK9dFUeGHE9RYQ+OBThV7olVZNJ7FlFXZvZjTefd2HO58iRWY8i+6rPRjR71HyHJB5mnyegjri9DSRkTgy5rIkLMogjT/Yz4D4kai0Wef9cVGTR3Q/X+ODiOR6m4Qqu+wxy8ovrQ68a4U9Axip6tvIWHGdL+/HYpeMFwkvcpSmCmY/tKBTxQSkzFjOiCs8g31xIH0M/kVKVPdpdPRM/724w+xNL8uQJmoPESX7KXxYA6FN5VrxkS2DNUiwmeSLRnyJqIUPnbzwlYa6R/0DDBdGFS5RpMlsjgDvoIX3+JKDWfZqa9/lL0yKY3gWTo3U+szEFqScDx8oNAGrPbhCfoXVNlnSVEnTQXRm0TkkKpLGn+KwM9VZ3pUIMiuLwnIGvGQTZn+Ro/m2RpyGwjcaVqdxTV28gmMAf3rq3vgEbHImzY2A6iHe6Tx4megGUbp0NPzPJ4BuaygbZ5puVNP9WMw1L27mklTOy5FpuB3160CSkC1JKX6uCW3eB6RAbp5fXDCss2zEi29ySrZwIvR0EEm8TPFtx1Py3pn9oJQ2DBomTkj27RJWJZkVYoMoE4w/MxFScmnfo1mQ5Ff/4y/A2wles3Je5bnk8dfq4juWDHPsFJMdKLUs6PzqRnFPIXsAimr52ocVnSWpEhUgUyinR28ZbUj58E2jWUZpGhFHjrcwICcP61GEYxXuCVvTwImjoxWJ/D/wEmyqUPhN7feP7tD7gJiyFJivNJgL5Xa3Y39sRSD0QPjZDCjeiTc8M3LS3RTZJkl1USLxBvcpEV48JHZKKxFC5t0CIg9pcxRaJbuCtOe8x1/6GV7UNkyzRaa3eypyTuDQ5DNqYORnuwhSOfD1nmsrin9neHONolbSPxc43sZGutazVsJoCJ7op5DZ+OOPMv2Sv6qhwWWP522wr+B8BUXwcSJXfFZX0g3FOT4XyPvCpy9RHzvZ fsNOo82F UKyX+DyghpBOH2Q9T3scbv8FoSoRwPkkie10zxOHvyIzSKCJu6Q4w19LE/wMt0fMJW2+zSBFH2RLfrdTFH0O86oXF8skCVQwTgJmk3qAgExttJaGi8/79oTuNyffbt9IPKF7xpKhvlhwzVsvpJy7W7PpEOEqsq6HU2Z6YeHZ+R3gLwZUhoVJWeITEEmBhosmaXoE15CtNcP+cody1EcyH9hpDC35f5QMNbdRuEA1tC3xgNOdnGYO5ohzDIM/Fhye1kZrRiLfETujQKFZB0VRtY63slKqXKRdGwPLLBjemvPJgl1glvC9mPTq/t2E/fkdDVl8mJ5y/dRGryPns7lYYACWQExDapEedXXs7Pznrh3GX6uMLckjDm39dCc1g/bEtHTDS+D4H0VQw802OEgAGmvyI9VWv2ZOP9mw0vL9TTUarjzBAm9NBYV2yunHlcfBVc7sw/KEiFMxBIhJth0rfHK8XYg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later patches will require issuing a __flush_tlb_all() from noinstr code. This requires making both __flush_tlb_local() and __flush_tlb_global() noinstr-compliant. For __flush_tlb_local(), xen_flush_tlb() has already been made noinstr, so it's just native_flush_tlb_global(), and simply __always_inline'ing invalidate_user_asid() gets us there Signed-off-by: Valentin Schneider --- arch/x86/include/asm/paravirt.h | 2 +- arch/x86/mm/tlb.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index b3daee3d46677..0c0dd186c03e6 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -70,7 +70,7 @@ void native_flush_tlb_one_user(unsigned long addr); void native_flush_tlb_multi(const struct cpumask *cpumask, const struct flush_tlb_info *info); -static inline void __flush_tlb_local(void) +static __always_inline void __flush_tlb_local(void) { PVOP_VCALL0(mmu.flush_tlb_user); } diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 2d2ab3e221f0c..18b40bbc2fa15 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -257,7 +257,7 @@ static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, * * See SWITCH_TO_USER_CR3. */ -static inline void invalidate_user_asid(u16 asid) +static __always_inline void invalidate_user_asid(u16 asid) { /* There is no user ASID if address space separation is off */ if (!IS_ENABLED(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION)) @@ -1206,7 +1206,7 @@ STATIC_NOPV noinstr void native_flush_tlb_global(void) /* * Flush the entire current user mapping */ -STATIC_NOPV void native_flush_tlb_local(void) +STATIC_NOPV noinstr void native_flush_tlb_local(void) { /* * Preemption or interrupts must be disabled to protect the access From patchwork Tue Jan 14 17:51:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10877C02183 for ; Tue, 14 Jan 2025 18:04:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EB786B0096; Tue, 14 Jan 2025 13:04:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 99BC828001A; Tue, 14 Jan 2025 13:04:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE6A28000C; Tue, 14 Jan 2025 13:04:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 626C36B0096 for ; Tue, 14 Jan 2025 13:04:36 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 16744C0C3C for ; Tue, 14 Jan 2025 18:04:36 +0000 (UTC) X-FDA: 83006832552.29.AA7B6A7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 5E48F1C0021 for ; Tue, 14 Jan 2025 18:04:34 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dTN5U6o4; spf=pass (imf18.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877874; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uZZLtjs3Zw6jRIC16nznFhpiKaBBT8sXvDLj8C27htE=; b=C/Lca1UokIPhrk18A9GJLHf+F4kazT8nTtDOgtCKZXlyieyXKQ41SDg+CzXXn4U/SO1iud l/jHUpOnYw03w3RFGJ0h+hMzlhx+QiefP8Ec5JzcLpWU2ET1IEPcmIs+qYHhleoZvpw2rD efuSoGys1ki4BYFpk8Z+Jt8N97EHQMo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dTN5U6o4; spf=pass (imf18.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877874; a=rsa-sha256; cv=none; b=qVnhN69uBkX9vcOao7w4GNq0tGeidjDiiC6hz7Avd6mS2yv47bn0nz7GuIrNVEj4NXimax NkflUFJl0Wsi6hsvfpQ/GwI9CQGP5rK4zZErl0Vdp0/YKIBkD7VGFv4eRUw9dWUnx3oCu5 8A8GSJqdbUofMK3KAqAf/Y4hZA0noGI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877873; 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=uZZLtjs3Zw6jRIC16nznFhpiKaBBT8sXvDLj8C27htE=; b=dTN5U6o4wf67sy7YEmxWlenUbOZzHHePLrQ+e0ysRU+tCm/MY4O6sfCqPMuWfPUyhViSuR ixIjrOwyf0QKZEVPhwjff77MzqRMQG8EaQuKvlAQdOC6YqCaqU/WpMOkaDqU74ROICjPD1 1h2NdwIC+0PDBpM4wVAcqepBUGfEVK8= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-YsncyNivNYmsu48rkVhymA-1; Tue, 14 Jan 2025 13:04:29 -0500 X-MC-Unique: YsncyNivNYmsu48rkVhymA-1 X-Mimecast-MFC-AGG-ID: YsncyNivNYmsu48rkVhymA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A7D431955DCF; Tue, 14 Jan 2025 18:04:25 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6C14D195608A; Tue, 14 Jan 2025 18:04:03 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 28/30] x86/tlb: Make __flush_tlb_all() noinstr Date: Tue, 14 Jan 2025 18:51:41 +0100 Message-ID: <20250114175143.81438-29-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: 5E48F1C0021 X-Rspamd-Server: rspam12 X-Stat-Signature: mk9o5wno57jbwb6a36dtcsd6uce3197e X-Rspam-User: X-HE-Tag: 1736877874-844485 X-HE-Meta: U2FsdGVkX1/yJI19TsGXWgE5J2K3lSsA4774D+pGuUqz3X8cHHgqhOCFcHhcSc+i/+UGEw/SwBO5d/MIyFL2WOPJtkrnYdCu2dBCene5hzsUeXoYJx5a+I3RZKlMFWmPcfVCyGf1aT7uoVrJS18BYFFKJGh59sa9BuTilMC6GN52oN0Ksfxl8Zj/obilaBoY0TikJf+pyF4KFuOLr1LL/pSs/dJYuPl2KVpuS7s3kcq38NKzjbgdI4AAa7v+aTadaptxukOTRC7QwzG880nO0UiBbisqglg14mN6nf/SgIJW8SK+i/J+077pUzXeDRHxY03ag4VrJdcu8c4mFHWCVXKhYhKqLC/Kyl7N1A+J2PslyV7GV2TCYlzGZMcpqZ87NaVAUOaDzjSwM7AdEexil1uPG+6o893rs3rW1i9hsIAWuOvlDQeEWHc5TVCIRQRW4HOZmJO8X2egv7RLmq+eSxEWMPeREDBeH00KWblQmI3r4Q7Dqd/9dxKjH4BKrkSvyhp6v7X85O5T5m4RYFQfI/697hh2SVIYLQ94wS6jIMT8GMZXyuOeXFrHdJcVj1UsVg++j9L+B7MaN7RHuXCMoAjp/3Rvsf8Uo46FlGam0QPo95aez82skT9P8InRTWWOm+HpdDRivlWyylsAFrFH5KW/JvKtrjpRJVSImadCuzc2BTHcrPOZbsJ7OyqCToi3fbrHzrDOR6UMBBrC8IzJ2ZAa9B4v+lkT0Js/7aBgFQwK7ZiuYOViREdx5B3tUqsFWzcWtr78pIPzQjvPb3/AqRs/lE+08nhYna1EyossQDgSOIWlBtmn75hlDje7cQIHmRjj/YfLggEaLEYfKtu0higZI8jT404FTbI8ckAD7qAXdnp0LH2Nt1pYmsQt+Z9AJImBajENdYWHnDlrNeUpn0pkKpedJmJAv380Wr3RphviLITSLYaoxc6CwT/Re1ol5+AJ0fTQ4GoN5VZ//43 +sF77k1L TYdgdIhO/5zaKTMq5Shf4V/c1IQ/KiyulWt+3EjY8m/0mguldj5fUy8A3XBSIV1jcKyXDa7gCKpa5aym7YJfb3XLQoFxeVJIzBPkwnaQyMwlXlw5lCg1JgqSui7sCKYPYQvfIGsRD5o7dfEAW7PwtKYtfM8pQfTzmAndECcpUlPo2ACdPV9JbruATFBVXYKzkZbuote4g3JrSEGueYofqh2OCnthtL5FlBkXQatMfuOyxo3dLJAM1NvSCGNUfw6K+w3lSIMki7xxsiJIntWDp/WXA4Q9kQmpP5BW8C26PqpFv2wWZ0r5j9ah9MnAkPMEc2gcnIcJ+hKp6FGgPUjlroLL+bB4cyAIhxZeMWdPMrIp9JjsV0zQ8xYJVetGZbjzepPAIgGpbaANngj6IoSaRT5o6yoPI4U/dbW4k+BZo2go3s4fZPECtoMMRbcOIzS545Xka12/QUT3Xs1C8SR2a0nb98g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Later patches will require issuing a __flush_tlb_all() from noinstr code. Both __flush_tlb_local() and __flush_tlb_global() are now noinstr-compliant, so __flush_tlb_all() can be made noinstr itself. Signed-off-by: Valentin Schneider --- arch/x86/include/asm/tlbflush.h | 2 +- arch/x86/mm/tlb.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 69e79fff41b80..4d11396250999 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -17,7 +17,7 @@ DECLARE_PER_CPU(u64, tlbstate_untag_mask); -void __flush_tlb_all(void); +noinstr void __flush_tlb_all(void); #define TLB_FLUSH_ALL -1UL #define TLB_GENERATION_INVALID 0 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 18b40bbc2fa15..119765772ab11 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1229,7 +1229,7 @@ void flush_tlb_local(void) /* * Flush everything */ -void __flush_tlb_all(void) +noinstr void __flush_tlb_all(void) { /* * This is to catch users with enabled preemption and the PGE feature @@ -1243,7 +1243,7 @@ void __flush_tlb_all(void) /* * !PGE -> !PCID (setup_pcid()), thus every flush is total. */ - flush_tlb_local(); + __flush_tlb_local(); } } EXPORT_SYMBOL_GPL(__flush_tlb_all); From patchwork Tue Jan 14 17:51:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACAE6E77188 for ; Tue, 14 Jan 2025 18:04:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4470628001A; Tue, 14 Jan 2025 13:04:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F5F528000C; Tue, 14 Jan 2025 13:04:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 222B628001A; Tue, 14 Jan 2025 13:04:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0127F28000C for ; Tue, 14 Jan 2025 13:04:58 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A5315C0C6B for ; Tue, 14 Jan 2025 18:04:58 +0000 (UTC) X-FDA: 83006833476.16.D847881 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id D896640004 for ; Tue, 14 Jan 2025 18:04:56 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U3/4lIPS"; spf=pass (imf12.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877896; a=rsa-sha256; cv=none; b=2Hl4lnPDSzWlkS1NhaaphlxD6zA6UmCyYRILxVHEQMkYbJomazSlfvdBvuKQWEKu/Te7Et Yi/xGcVLSl9j5FmHESmmXU9VGJ+lC6u73KKfuR10mxsVdqR5bIEwiBh/+175PWaSFSzlWD My7QRy0trr5TzZLBCIvhKH6IYpaGBWc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U3/4lIPS"; spf=pass (imf12.hostedemail.com: domain of vschneid@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877896; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qclZNz9KUbrYZjVF2oHux5/JPahdxImvR1KpALrIQ34=; b=LBgDJSV3d5Wb6jNhl5qkLaURc9f8f6mqxYQ0X8k8Bar01enkJ9znGO7vWGFT6LCzW6F+iu 0nX7hT+XNSD7PVxhqMr6Ti6EdeDXL3iFKNhjm7PEx5G43c/C3VNICBlre49ab64J2gg+Qc SfwnqNaRbIz9uRs8wCgXOo3v9gMLqN0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877896; 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=qclZNz9KUbrYZjVF2oHux5/JPahdxImvR1KpALrIQ34=; b=U3/4lIPSpHv5yUv/D1OpO6sBQIbkc1hbS4mHYvWBFPlIzKmMsSg9jEZ56Vfx4H1CdGE3Ds zxnoTBaQiq48+MSEYiM6o9zxjIANJPtI5GFD8cTaV2ECsYgYNWbl8ZIRikcq+ctTNVjTZF c/w3TxEUB5SEuJMIdWcDQDPoUJy+AOU= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-qGEuL7tjNvSDQHBRs9YUmQ-1; Tue, 14 Jan 2025 13:04:52 -0500 X-MC-Unique: qGEuL7tjNvSDQHBRs9YUmQ-1 X-Mimecast-MFC-AGG-ID: qGEuL7tjNvSDQHBRs9YUmQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 69F741955D53; Tue, 14 Jan 2025 18:04:49 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A353195608A; Tue, 14 Jan 2025 18:04:25 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 29/30] x86/mm, mm/vmalloc: Defer flush_tlb_kernel_range() targeting NOHZ_FULL CPUs Date: Tue, 14 Jan 2025 18:51:42 +0100 Message-ID: <20250114175143.81438-30-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Queue-Id: D896640004 X-Stat-Signature: ejdfsaepywhkr8nw8fjn3pjcxgpq1o6r X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736877896-589922 X-HE-Meta: U2FsdGVkX18F5pQnsovY4q6oVt3YnR/1Tt3XGO5V9tUC98WdTdjS/yXnCZAAy0vjqdNsHvxjZwMHiMHsg+YoAdvC5svyKsF5DHds5UwSAPWdvw51HU09b7bHA/QclIyuHKEpJWl0xUGOIj4pmq4zzvl0fBqpyezTMu8Y3DFV1+vAFdCXUolqyRdy9+o+PC+Dy+xECGLb3zegGN9MWbtyzynK8PhljpE8IozWEdqoCkeA1kJxUBCGevRY2CRi4ZHOh1CpnEjReT+egUPb1cjEX7FtOn3bozZtnI6GS52AkNIzI4Cd3RGGWa9NEWO1MOu7b3jD98Zx5U+HMHUSnb/wb77I5Z0duHfwaZ07ajGvtjaOMSlb0gB4SZDjEbbzVb6u1RZ3QOLmj3vX0bLRCs1kDDxSoVDlkN4Go/LsdDbxN7k8anNmxJSUoWwcmPM9zdlRm4kP6W2Rcw+vPM5nRl05jfXmQ2k1gEhBjr0fWOuJmj9j5AXY8V0Nkb1ZLaxJvFSfFM7BhQWPSoL/buIjWh6i+IbGHey3yQN5lQyTDUlRdUeRnWirjq/n/XW5G7jpXBbGvma338Hnbzo0pamj/BhW8fHIjIRtHTfWPkOX/CQ7EdpI4Sk0Bl0bTiTwdp6BoFUSlnFZ3lKCNigAdlp0ruf2tklB4EkCkvFGacFW+MKGY56OTjOqlpjtu5mvMo6QcOKB3R7rvyMwRN2d+r9uMk1lrgzAsYHliXU2OaY1PwADq9M6vvtWlgtnERL4l3ZdarDzSsddoEAWQwjZUkr0qZSDMZ7gQDLzElfL2HGFxLgGgK//Tcx4Xey3NzTBX9+yN9n19gSZfC1fF8Lsyt+k20UzBiR8zLcXNRhuLS2hEBEB+4o5foJ04KBnPcgyhJOnG0pOORYcVNrDzU0twul0uwqvCeqtCg9VHvTslHRUwx3VNaHkhaDG6NQ8tefuFvR+WyK5p0AW3PhA4ROsqMm/rv6 ESx3uHbe mWAz/G8RJxvubCW8+0ufMoNy9JRb9Clf3J3WmnZknHwFwLcLmy+0PBUA8aWGSfhCq1+hTlcR3lDJfiLiH/UQK2CHRsZJyf74+jCUbJywpKOu67sdvcX7rASvGYW4u6YCVn26Q+vTRMvr9R3LOSvyXP0vIPZXUlwzJ0WFNz9uWYWlSLm1vEBx8bfI3jxedvBq70+AETbK3ztqaUcsKm6MMfDwD5al4dFFHHZwQR8UxGMBuIZ3YbYocJRecL84bpQn+DGVj90MzZu6jJytAWoTci02HZSRO5juk7527hlwKPXAV/L7l9qWK7CgPdiXl7upO1H/J2C768MQZrcMPd1GT5vrrigdEc7kPRXbTiNamkd6mSx47XVL3kkc2aplNW/9OtgEwSUfwihr54dG9Y+dHt5BDqVnvRaJrFO9qnZE6HbGVRgCg5LUF0nC0+Db94xeU0usji9vhkm6WOFZXCcCy6U7c9A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: vunmap()'s issued from housekeeping CPUs are a relatively common source of interference for isolated NOHZ_FULL CPUs, as they are hit by the flush_tlb_kernel_range() IPIs. Given that CPUs executing in userspace do not access data in the vmalloc range, these IPIs could be deferred until their next kernel entry. Deferral vs early entry danger zone =================================== This requires a guarantee that nothing in the vmalloc range can be vunmap'd and then accessed in early entry code. Vmalloc uses are, as reported by vmallocinfo: $ cat /proc/vmallocinfo | awk '{ print $3 }' | sort | uniq __pci_enable_msix_range+0x32b/0x560 acpi_os_map_iomem+0x22d/0x250 bpf_prog_alloc_no_stats+0x34/0x140 fork_idle+0x79/0x120 gen_pool_add_owner+0x3e/0xb0 ? hpet_enable+0xbf/0x470 irq_init_percpu_irqstack+0x129/0x160 kernel_clone+0xab/0x3b0 memremap+0x164/0x330 n_tty_open+0x18/0xa0 pcpu_create_chunk+0x4e/0x1b0 pcpu_create_chunk+0x75/0x1b0 pcpu_get_vm_areas+0x0/0x1100 unpurged vp_modern_map_capability+0x140/0x270 zisofs_init+0x16/0x30 I've categorized these as: a) Device or percpu mappings For these to be unmapped, the device (or CPU) has to be removed and an eventual IRQ freed. Even if the IRQ isn't freed, context tracking entry happens before handling the IRQ itself, per irqentry_enter() usage. __pci_enable_msix_range() acpi_os_map_iomem() irq_init_percpu_irqstack() (not even unmapped when CPU is hot-unplugged!) memremap() n_tty_open() pcpu_create_chunk() pcpu_get_vm_areas() vp_modern_map_capability() b) CONFIG_VMAP_STACK fork_idle() & kernel_clone() vmalloc'd kernel stacks are AFAICT a safe example, as a task running in userspace needs to enter kernelspace to execute do_exit() before its stack can be vfree'd. c) Non-issues bpf_prog_alloc_no_stats() - early entry is noinstr, no BPF! hpet_enable() - hpet_clear_mapping() is only called if __init function fails, no runtime worries zisofs_init () - used for zisofs block decompression, that's way past context tracking entry d) I'm not sure, have a look? gen_pool_add_owner() - AIUI this is mainly for PCI / DMA stuff, which again I wouldn't expect to be accessed before context tracking entry. Changes ====== Blindly deferring any and all flush of the kernel mappings is a risky move, so introduce a variant of flush_tlb_kernel_range() that explicitly allows deferral. Use it for vunmap flushes. Note that while flush_tlb_kernel_range() may end up issuing a full flush (including user mappings), this only happens when reaching a invalidation range threshold where it is cheaper to do a full flush than to individually invalidate each page in the range via INVLPG. IOW, it doesn't *require* invalidating user mappings, and thus remains safe to defer until a later kernel entry. Signed-off-by: Valentin Schneider --- arch/x86/include/asm/context_tracking_work.h | 4 +++ arch/x86/include/asm/tlbflush.h | 1 + arch/x86/mm/tlb.c | 23 +++++++++++-- include/linux/context_tracking_work.h | 4 ++- mm/vmalloc.c | 35 +++++++++++++++++--- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/context_tracking_work.h b/arch/x86/include/asm/context_tracking_work.h index 485b32881fde5..da3d270289836 100644 --- a/arch/x86/include/asm/context_tracking_work.h +++ b/arch/x86/include/asm/context_tracking_work.h @@ -3,6 +3,7 @@ #define _ASM_X86_CONTEXT_TRACKING_WORK_H #include +#include static __always_inline void arch_context_tracking_work(enum ct_work work) { @@ -10,6 +11,9 @@ static __always_inline void arch_context_tracking_work(enum ct_work work) case CT_WORK_SYNC: sync_core(); break; + case CT_WORK_TLBI: + __flush_tlb_all(); + break; case CT_WORK_MAX: WARN_ON_ONCE(true); } diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 4d11396250999..6e690acc35e53 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -248,6 +248,7 @@ extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned int stride_shift, bool freed_tables); extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); +extern void flush_tlb_kernel_range_deferrable(unsigned long start, unsigned long end); static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long a) { diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 119765772ab11..47fb437acf52a 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -1042,6 +1043,11 @@ static void do_flush_tlb_all(void *info) __flush_tlb_all(); } +static bool do_kernel_flush_defer_cond(int cpu, void *info) +{ + return !ct_set_cpu_work(cpu, CT_WORK_TLBI); +} + void flush_tlb_all(void) { count_vm_tlb_event(NR_TLB_REMOTE_FLUSH); @@ -1058,12 +1064,13 @@ static void do_kernel_range_flush(void *info) flush_tlb_one_kernel(addr); } -void flush_tlb_kernel_range(unsigned long start, unsigned long end) +static inline void +__flush_tlb_kernel_range(smp_cond_func_t cond_func, unsigned long start, unsigned long end) { /* Balance as user space task's flush, a bit conservative */ if (end == TLB_FLUSH_ALL || (end - start) > tlb_single_page_flush_ceiling << PAGE_SHIFT) { - on_each_cpu(do_flush_tlb_all, NULL, 1); + on_each_cpu_cond(cond_func, do_flush_tlb_all, NULL, 1); } else { struct flush_tlb_info *info; @@ -1071,13 +1078,23 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end) info = get_flush_tlb_info(NULL, start, end, 0, false, TLB_GENERATION_INVALID); - on_each_cpu(do_kernel_range_flush, info, 1); + on_each_cpu_cond(cond_func, do_kernel_range_flush, info, 1); put_flush_tlb_info(); preempt_enable(); } } +void flush_tlb_kernel_range(unsigned long start, unsigned long end) +{ + __flush_tlb_kernel_range(NULL, start, end); +} + +void flush_tlb_kernel_range_deferrable(unsigned long start, unsigned long end) +{ + __flush_tlb_kernel_range(do_kernel_flush_defer_cond, start, end); +} + /* * This can be used from process context to figure out what the value of * CR3 is without needing to do a (slow) __read_cr3(). diff --git a/include/linux/context_tracking_work.h b/include/linux/context_tracking_work.h index 931ade1dcbcc2..1be60c64cdeca 100644 --- a/include/linux/context_tracking_work.h +++ b/include/linux/context_tracking_work.h @@ -5,12 +5,14 @@ #include enum { - CT_WORK_SYNC, + CT_WORK_SYNC_OFFSET, + CT_WORK_TLBI_OFFSET, CT_WORK_MAX_OFFSET }; enum ct_work { CT_WORK_SYNC = BIT(CT_WORK_SYNC_OFFSET), + CT_WORK_TLBI = BIT(CT_WORK_TLBI_OFFSET), CT_WORK_MAX = BIT(CT_WORK_MAX_OFFSET) }; diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5c88d0e90c209..e8aad4d55e955 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -467,6 +467,31 @@ void vunmap_range_noflush(unsigned long start, unsigned long end) __vunmap_range_noflush(start, end); } +#ifdef CONFIG_CONTEXT_TRACKING_WORK +/* + * !!! BIG FAT WARNING !!! + * + * The CPU is free to cache any part of the paging hierarchy it wants at any + * time. It's also free to set accessed and dirty bits at any time, even for + * instructions that may never execute architecturally. + * + * This means that deferring a TLB flush affecting freed page-table-pages (IOW, + * keeping them in a CPU's paging hierarchy cache) is akin to dancing in a + * minefield. + * + * This isn't a problem for deferral of TLB flushes in vmalloc, because + * page-table-pages used for vmap() mappings are never freed - see how + * __vunmap_range_noflush() walks the whole mapping but only clears the leaf PTEs. + * If this ever changes, TLB flush deferral will cause misery. + */ +void __weak flush_tlb_kernel_range_deferrable(unsigned long start, unsigned long end) +{ + flush_tlb_kernel_range(start, end); +} +#else +#define flush_tlb_kernel_range_deferrable(start, end) flush_tlb_kernel_range(start, end) +#endif + /** * vunmap_range - unmap kernel virtual addresses * @addr: start of the VM area to unmap @@ -480,7 +505,7 @@ void vunmap_range(unsigned long addr, unsigned long end) { flush_cache_vunmap(addr, end); vunmap_range_noflush(addr, end); - flush_tlb_kernel_range(addr, end); + flush_tlb_kernel_range_deferrable(addr, end); } static int vmap_pages_pte_range(pmd_t *pmd, unsigned long addr, @@ -2281,7 +2306,7 @@ static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end, nr_purge_nodes = cpumask_weight(&purge_nodes); if (nr_purge_nodes > 0) { - flush_tlb_kernel_range(start, end); + flush_tlb_kernel_range_deferrable(start, end); /* One extra worker is per a lazy_max_pages() full set minus one. */ nr_purge_helpers = atomic_long_read(&vmap_lazy_nr) / lazy_max_pages(); @@ -2384,7 +2409,7 @@ static void free_unmap_vmap_area(struct vmap_area *va) flush_cache_vunmap(va->va_start, va->va_end); vunmap_range_noflush(va->va_start, va->va_end); if (debug_pagealloc_enabled_static()) - flush_tlb_kernel_range(va->va_start, va->va_end); + flush_tlb_kernel_range_deferrable(va->va_start, va->va_end); free_vmap_area_noflush(va); } @@ -2832,7 +2857,7 @@ static void vb_free(unsigned long addr, unsigned long size) vunmap_range_noflush(addr, addr + size); if (debug_pagealloc_enabled_static()) - flush_tlb_kernel_range(addr, addr + size); + flush_tlb_kernel_range_deferrable(addr, addr + size); spin_lock(&vb->lock); @@ -2897,7 +2922,7 @@ static void _vm_unmap_aliases(unsigned long start, unsigned long end, int flush) free_purged_blocks(&purge_list); if (!__purge_vmap_area_lazy(start, end, false) && flush) - flush_tlb_kernel_range(start, end); + flush_tlb_kernel_range_deferrable(start, end); mutex_unlock(&vmap_purge_lock); } From patchwork Tue Jan 14 17:51:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13939306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82B9BC02183 for ; Tue, 14 Jan 2025 18:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 161BD28001B; Tue, 14 Jan 2025 13:05:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 111EE28000F; Tue, 14 Jan 2025 13:05:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA62428001B; Tue, 14 Jan 2025 13:05:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C812D28000F for ; Tue, 14 Jan 2025 13:05:20 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 65721C0C6F for ; Tue, 14 Jan 2025 18:05:20 +0000 (UTC) X-FDA: 83006834400.27.F4A9FFA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 56132C001A for ; Tue, 14 Jan 2025 18:05:18 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RVJ4X7R4; spf=pass (imf10.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736877918; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hBnzPr+bF01eZ/FcGt3b6YBzs+ceSVKdSHsMFlRMR5E=; b=y9fE1V8XLxQwa6Xl1IcJprnGtCgMnIlB4flcB/Dx8NFHngBMBKo1QUrirkmrpqdbGTBJxQ 1sWsqiPJhWOdmGTUTSEZrvSZUodF0hOW7AP2YD5AJ5HP+QlVgLEyyinHr/GP5Bb1ANy56z Bo4m7VF4ISSQv8ExyvvUOEmSy6ByRRA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RVJ4X7R4; spf=pass (imf10.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736877918; a=rsa-sha256; cv=none; b=E2XWdlo1VD6Kod7EV8t8xL1pk6a4UXBstP/D3PqeK/KlrBqwGWfgxdaRoPVsNU1xqIWzg3 C8+tmU+jY2QuSKwq25unovVFxQUL9n4oYD6dfDMcHmYLBNIx0aRnVEFyY/ojczPfQRcZnH RUePytxF19jweh65U2YKdBObDd20n3M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736877917; 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=hBnzPr+bF01eZ/FcGt3b6YBzs+ceSVKdSHsMFlRMR5E=; b=RVJ4X7R4SqdG+DcOOY+b0viZ2SFXe5B/kaD55VE4xoIrPnyIzwVRC0D5mEfdYTMkxhAf1Z o//oMu+iVTVZFw+WVB66FkEnwroZZIEWGIiYBoabRfM0oYO+Y1p6vlXJnSlXJ8yUx1iI0d zcM7EMKBIi+TEZ4LvBVAwlka6uNhRyQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-8ogZguOiNnCawOG8JxolMw-1; Tue, 14 Jan 2025 13:05:15 -0500 X-MC-Unique: 8ogZguOiNnCawOG8JxolMw-1 X-Mimecast-MFC-AGG-ID: 8ogZguOiNnCawOG8JxolMw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F0F9F1956050; Tue, 14 Jan 2025 18:05:11 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.192.55]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DFA25195608A; Tue, 14 Jan 2025 18:04:49 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Boris Ostrovsky , Josh Poimboeuf , Pawan Gupta , Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Juri Lelli , Clark Williams , Yair Podemsky , Tomas Glozar , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Kees Cook , Andrew Morton , Christoph Hellwig , Shuah Khan , Sami Tolvanen , Miguel Ojeda , Alice Ryhl , "Mike Rapoport (Microsoft)" , Samuel Holland , Rong Xu , Nicolas Saenz Julienne , Geert Uytterhoeven , Yosry Ahmed , "Kirill A. Shutemov" , "Masami Hiramatsu (Google)" , Jinghao Jia , Luis Chamberlain , Randy Dunlap , Tiezhu Yang Subject: [PATCH v4 30/30] context-tracking: Add a Kconfig to enable IPI deferral for NO_HZ_IDLE Date: Tue, 14 Jan 2025 18:51:43 +0100 Message-ID: <20250114175143.81438-31-vschneid@redhat.com> In-Reply-To: <20250114175143.81438-1-vschneid@redhat.com> References: <20250114175143.81438-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 56132C001A X-Rspam-User: X-Stat-Signature: rofmi6444gtgapoutq5gbiokkby61j5o X-HE-Tag: 1736877918-402699 X-HE-Meta: U2FsdGVkX1+ozC9g1z5eRN4csnozfwM+I877UiWIeUCpXC3GlI406+U+1WWi3fj0SOiy/Fmip/E/r56Fd4EYryGDOSWiVOhpO7xpNgmO3zJhtEURs+0/w8HOXQtEZKuHjz0muOeZydoJX4UMwXm1nHwqm7QALSvs6p6j4RBaZ7rzIxGVh1ghHCHKP5Nu/IeGlnHlFXdedyIsR7/m2iq8eL8pDVSSH752AoFgt9PagnCd/6rNjEV5pKKu+bSsdrCNF8aIeFK9+I2UL1FvCc03sZV58HrepH2gyn4kI8vbWsAKmekkjDqq/6+6XJXlP4IxVePR0z+ypjzHAgK2PKysxJvgiQLjIu7P36ILThG2CtefUzvfVm8cwRKpa+R+KufL9Wt4T3gXk0BrSQ0LUtAVJYQZj61FLVOZY+rKLphcoAL4aU8BEyzR4ATpRuHctLvtEthdzWOH8xptDE6PQZo+sdOkWB72NLYh8O+rWxPZU5fUkAhYVRRHbOcOFbdPPs9GzXJcLe5DsO7ciOR7p0twizMVCiLquP1IV+uIw6juYGh3ZMVYz4t3ue6vTI3e+2WfWBYegaHA413DDAW1pWjbSVbJ5i+D4guLemxIVB/wsgNHVJVIbvH4z+Tuqg5aYv+d9r8nRIGcDNQqcaO7+uKLILkzW6yn8IwxK96xndZ18tZoJKuLfEgbHBDIQMGNi5808KgD6R+0rY5o6qgN/5nN3o9dMzfIPYkV0+20edhQqpqtcAD+Cfq9Kgtm/15IYgigLgxM6KzytJl0Xo28qJ17Dl9Vn0dcfyJm00vxagGmPHkRCA3Dv84KdRgFFV0KXEk/k3jEopwV34iG72tIWk/ClKnNuNiPQ4uzdBvMRk50QrGxjy4QZMSWNrpmP3cyrvMCPdlBqZKbKV31UJow5/4Xbbg9jE2Jk2IcBG18chfX0SZwKVNELCJj3WDwPjByG1uqI3PoKyO8ccNlLXVV2pj kyDe+g/c hQvU5nbiZMqZ8l9HC3wLTlZjcpJNGgdU1WRkIK83UnvjMsl89ZyOd2P7jRf3FZLwVfRDLOaeMqp/8rhCHcbvkopagDjaHHIvrJgWsvc3Kk8zU8KBsalYj8L/ZexgznwZ7rmF5bmfpSRwmrqsO51sIMasOmvgNdSXWbzfydcDs+plIleMCjPwHVc5v2YBIeOGdvQXdfJnCw1TUhk2AH9niLj/pCMtT9ioNeCozaznZBuWVfemCFAp8//eO5nY/szT215EvLQ1BmRHmH5u5xh4oXenqCehOk7U3nKUTmHzuk9UQkyTCbkfYfttEKvIv1FFzPOPI64Wq6t5pGIcI7HOcIj9n7llgG5YjTEiiMFebw1yF/RGIpAsFYMki59i3yvAHWjqbkLsjcX/alHfqPgUKc35qaDK7E2pO+P9EOWweQv4zJswqOEqoCfLurhMxjDQZl148599PPcx6q7nv5JzkRvPKnA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: With NO_HZ_IDLE, we get CONTEXT_TRACKING_IDLE, so we get these transitions: ct_idle_enter() ct_kernel_exit() ct_state_inc_clear_work() ct_idle_exit() ct_kernel_enter() ct_work_flush() With just CONTEXT_TRACKING_IDLE, ct_state_inc_clear_work() is just ct_state_inc() and ct_work_flush() is a no-op. However, making them be functional as if under CONTEXT_TRACKING_WORK would allow NO_HZ_IDLE to leverage IPI deferral to keep idle CPUs idle longer. Having this enabled for NO_HZ_IDLE is a different argument than for having it for NO_HZ_FULL (power savings vs latency/performance), but the backing mechanism is identical. Add a default-no option to enable IPI deferral with NO_HZ_IDLE. Signed-off-by: Valentin Schneider --- kernel/time/Kconfig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 7e8106a0d981f..c7398fe5382a0 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -183,9 +183,23 @@ config CONTEXT_TRACKING_USER_FORCE config CONTEXT_TRACKING_WORK bool - depends on HAVE_CONTEXT_TRACKING_WORK && CONTEXT_TRACKING_USER + depends on HAVE_CONTEXT_TRACKING_WORK && (CONTEXT_TRACKING_USER || CONTEXT_TRACKING_WORK_IDLE) default y +config CONTEXT_TRACKING_WORK_IDLE + bool + depends on HAVE_CONTEXT_TRACKING_WORK && CONTEXT_TRACKING_IDLE && !CONTEXT_TRACKING_USER + default n + help + This option enables deferral of some IPIs when they are targeted at CPUs + that are idle. This can help keep CPUs idle longer, but induces some + extra overhead to idle <-> kernel transitions and to IPI sending. + + Say Y if the power improvements are worth more to you than the added + overheads. + + Say N otherwise. + config NO_HZ bool "Old Idle dynticks config" help