From patchwork Wed Jul 5 18:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13302574 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 E1248EB64DA for ; Wed, 5 Jul 2023 18:16:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 806608D0001; Wed, 5 Jul 2023 14:16:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78F928E0003; Wed, 5 Jul 2023 14:16:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E2E98D0008; Wed, 5 Jul 2023 14:16:54 -0400 (EDT) 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 5002C8D0001 for ; Wed, 5 Jul 2023 14:16:54 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 16BE91C8EDB for ; Wed, 5 Jul 2023 18:16:54 +0000 (UTC) X-FDA: 80978364348.30.420024B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 1CF9C100007 for ; Wed, 5 Jul 2023 18:16:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AWK8d7z6; spf=pass (imf05.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=1688581012; 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=Rmsxmag8ZkUExVz48NdRE4bjGysGk4VVErYcJqwPIM4=; b=J4JxROWPJw4r6p9DQnh+ug30OIE/n6pshyBR+gdBJ5SdFK+tycSr+xW+xYKCOLivgO8Ci6 +Fh0Wm6DxwXsedtV0JMhLUFkfgM5E7XjDW4nXHTMm7Vq03yFsSUN4Nb0og9LQqS/+fsH5c AiNKOi+8AUHnIJLZ/jXpwAemlVo2alc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688581012; a=rsa-sha256; cv=none; b=kAGt8NzGSgTGXE5wQRR4aoLNWnTLJGhhflaIFWKYZpWDISuAc3NrVgkMMmRG7HLPZLMBOe hnzofPJS+JE+c+UUKnN/ioO1K4eMdHhDO1JEPJUq+HFOim0iyVJiYML0hpLabQ4Z7UA2QI HC5MxFW7po0y+qkNUmsdiqqaVRdxjxg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AWK8d7z6; spf=pass (imf05.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=1688581011; 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=Rmsxmag8ZkUExVz48NdRE4bjGysGk4VVErYcJqwPIM4=; b=AWK8d7z6mFMHw6US9ILqBYMeW/P9cE/bg421dFsnNLLYfHpPyR41npMqIZdhrx/oK8NH3j ZDJ8n3scitJulg2jApL5wOF9zJBcOuUWVNoKdfRH76gxW1DEUyYvCX4RpjWP/hFwFQRcxG tycUwOyjZC0gu+d/R57CvGtX6ZuqPvE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-K-_lME6ZNbOFxO4KCoVoVw-1; Wed, 05 Jul 2023 14:16:49 -0400 X-MC-Unique: K-_lME6ZNbOFxO4KCoVoVw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 980F53815EF4; Wed, 5 Jul 2023 18:16:46 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5B65F5CFA; Wed, 5 Jul 2023 18:16:41 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , Frederic Weisbecker , "Paul E. McKenney" , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: [RFC PATCH 08/14] BROKEN: context_tracking: Make context_tracking_key __ro_after_init Date: Wed, 5 Jul 2023 19:12:50 +0100 Message-Id: <20230705181256.3539027-9-vschneid@redhat.com> In-Reply-To: <20230705181256.3539027-1-vschneid@redhat.com> References: <20230705181256.3539027-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 1CF9C100007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fs1ktjxicn66zck9qurqd673r33pzwws X-HE-Tag: 1688581011-360338 X-HE-Meta: U2FsdGVkX1/O/Yva5D2Xyl40S2ZqYPsoeeWXemqQpYZB+gEms47Ar9rYu9zID5yHPPoqcWAskE9DXw3FUsgiyVefPU7rBaRspw1JfzBiYS9GF+b7mgLbFhgfpGu5yYmFjUSXkDjWUjeU/PnFnIUs7KCC87TuZ75u+slxVZTTh+YV6sXCwcrZpOIjgQ6JH+8iZSN4GDFbbs3Dw0qBSDv0LOwmD6zk058a+GooDpM2uFsEGQ0eodulo9yiXf+qaGBq5zrJGCpRS6NLzh7H1l32fsihYExWXKCCTpGyWa+J1GcJ1kMkgFMPAe6BhE+NSbRh4irtTxD7HYGpzG2x0mJKuN0zQlu7fNQ3svo7tXW0d1HE6zjjcwStAsb3HJjcRThM0fSi9qykCZ3YTxTWE/fSjVxfx+MRFaCQ9ar7CZlV4swq3JO+z9kjmDtE75g0qCHBjagc4Xv3k9ogM0FRdJm6jQ5FEx1Ix7spi9VGM/6Lr+TBsHtxvMvzFEbtIHIHeZZcT2oF5fcwtsLO6jgcveV+bs0uMnoKm8POmcLQoi/bTNnT1hjwVh68MLToRmVAvNf8GJY7nY7X//JhkRqNn1zLR2lYFyn2KC4UvUeBgE2hiTRTkUr0L2xXwoosSxIsZCXfmprZNMNsVKE82Gn8SiksA45PROLxzO6Hu3ZHOoxYkZzJk21txuh6QhXkA7Zw2boqlPGVi3Ve9M3dXm5sL8sKoBer5/7jSIoHjlPymqWJNk2nNsIsUqOJpRxikhVhIdMIBSXwYHcn2+4j2oq2FXy1qFiIFWI29MGhzaShtyNZNZmbrrkZYdA7qEmkR23T4K8VDM/D6S/HJsjOOFvGSDj8O0WeXcxiGXSbIXyqssbDVF9cX3MQMdMEwMpYGsybBkTwsL+5ya8GMIx24n3Gtb6xoyGXFl4ZbIHjiyK4eIDz2yBcs/T7kZEqN7pWZBCPba8bkSSYp9bKmuD+2PjMC5H Yc5hEkkv EXpMcAT3jBhMJ/nRvxLmrGioAx+gjP47xNVAm5na4hgi3yCcG8a4Zn6LD7jjn4HwqNhVs+5xFKx7VeBJgZmZEVxqOBR4I2CpkgBDRXziThtoq+AX4HJwkDYWdH6vwdESe+3GWCo0IB6d6FBSkDgrH659ez/tHKLfK/AlJlzoPjPzOzneYZ8mp29ShzueAuVkMs+PAu9x1uS1pWcwCvKEIqgnPcnXnmR1cO7dr 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: objtool now warns about it: vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: enter_from_user_mode+0x50: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x60: Non __ro_after_init static key "context_tracking_key" in .noinstr section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x62: Non __ro_after_init static key "context_tracking_key" in .noinstr section [...] The key can only be enabled (and not disabled) in the __init function ct_cpu_tracker_user(), so mark it as __ro_after_init. BROKEN: the struct static_key lives in a read-only mapping after mark_rodata_ro(), which falls apart when the KVM module is loaded after init and a write to the struct happens due to e.g. guest_state_exit_irqoff() relying on the static key: jump_label_add_module() `\ static_key_set_mod() static_key_set_linked() Signed-off-by: Valentin Schneider --- kernel/context_tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index a09f1c19336ae..4e6cb14272fcb 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -432,7 +432,7 @@ static __always_inline void ct_kernel_enter(bool user, int offset) { } #define CREATE_TRACE_POINTS #include -DEFINE_STATIC_KEY_FALSE(context_tracking_key); +DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key); EXPORT_SYMBOL_GPL(context_tracking_key); static noinstr bool context_tracking_recursion_enter(void)