From patchwork Tue Feb 6 17:39:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 20022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1705343dyb; Tue, 6 Feb 2024 09:41:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9MhkeWiArSYrRXfmJ+LCrQtXYe7blC+zipkFbWBT7dSk50D4kY2crLzC9VqGJ404Aj4QI X-Received: by 2002:a05:6122:788:b0:4c0:3cb3:446f with SMTP id k8-20020a056122078800b004c03cb3446fmr293207vkr.4.1707241305755; Tue, 06 Feb 2024 09:41:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241305; cv=pass; d=google.com; s=arc-20160816; b=A3jxe6nPMWFJptkZttJgdYHji8njj8knQaNjZIvDxlZ9Rv6Ug3M/qSKSrYNHBMQclI xFDahO237YtKZwg18YXcg8XnqIc7mYxxofm0NjCNDmATo45iDG7102OStoIwx48lEtso /h9XgIM3R9fSjtmrY1jg2N/NriTZ6Pc1goG4EccYcxX7N0zktZxtd31ErPBblAr+Czj8 p3Rk26Gtkma8/tt3uGcfCppotGFSy5aBlw9wUI3cVF1atpvdoJeuKonP/DJinCPeTwVc XtayX/ERlvode/gu3Zk4TRQ95ONNUunSCdiKb1hk7fj5oUoe7HHVK7r5al8JKfwYLEkw ZImw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qxND/0mZm42XCHvHVamaG/IBrDPXcu6uEcDyFY4xk/M=; fh=AUTCXtYIPsAfsiVjDV7FZSxsop6RAa/mO0GhiZgQ5Mk=; b=O9g2lnRsBjohwNFFF4LXVllxo2kRtB28wmt1QyyKiTQN/wK/zMtTJmH4hDkpA36/BF H13B42bTsdi1RF5GJoDcP+DCT89F8EAyRb6kUebWDf+/44c4cQpaA0GXC06WX/skfQnq BDr+ihafJwk7yLn2A/CNzLjlNVY/O9FCxV/Ww8mH5besOV6C0khbHC7Z39qBnaFoyx67 /mXsIcZdKjXSWGSVjDdvVmpvdCwYiPD/oeGIzL0W0jb0kWF7jsi5tZ/oEwBotkLDD7C2 gQO2lNvXjM4zWJOJpEe1QN4selF2OjiTShc0MGrWviCPvySIJ7uQW4wLu9MAzaJGA/AS +raw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iq0S1O89; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55410-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55410-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWx17t0Xqi2e4/KgZJLeGjzbH3tdVqq9XiAggedtSDoXG5xfAHL9vCc5FbwueGbbtJHOto3YmUJWKFADqkgsWGK6JS+Ng== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k8-20020a05621414e800b00680b0f40fb4si2814706qvw.206.2024.02.06.09.41.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:41:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55410-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iq0S1O89; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55410-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55410-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 812701C22F4D for ; Tue, 6 Feb 2024 17:41:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68B7418EB8; Tue, 6 Feb 2024 17:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Iq0S1O89" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F44217984 for ; Tue, 6 Feb 2024 17:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241193; cv=none; b=PqHNqfCFFormE4OJLfxKaKaknh75U95QLZlzqt4YrTV+VRQ58JvTwe3JGJ8xRjI7FX9syi4EAbSjmEKi/SxWJ82Akub+42EOGjpp3RmDIuaP1s3tjqk+Nh9vHgURe+eG9GmJ35niR9vIC3YJ87INHlspyORxrmR+RECe8ATo8Ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707241193; c=relaxed/simple; bh=kGZuyujQSSpKDsAqhvgihpAhgWWTrSHGvIIAvUQoGOQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZQ9Nfs2t64GlXlBsCV5qA/1vCZVkluLE45henNG/L5XrGXapPM4kbdmIKDOwrHbRB81Efhkztq/LeMgfk4pFnVM3UTd6EGXSb7FSsS3bopMomeyM3gvJoYWwpT82SND09xfZdcyOthjy8sFQiQlZnWp5RDYQ+vjv9NpixiDj4jw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Iq0S1O89; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707241191; 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; bh=qxND/0mZm42XCHvHVamaG/IBrDPXcu6uEcDyFY4xk/M=; b=Iq0S1O89xfdklz2o/b8n9xr32cokT/O53lIuoklhGr58FxS/cqY4fXXOE3+fidX+BBT2Wb e79yn7N3ZQ/YmvuLkbYOxeD3VtB+X2LQb1bzG+eQp57U94FfssCxO3y0reYrDRLpz9dhsu ZRmEAGpl0Fj42Q0wG6uGMVR+U60E4K8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-y-6ALdsPOPquZcBcqHR_VQ-1; Tue, 06 Feb 2024 12:39:47 -0500 X-MC-Unique: y-6ALdsPOPquZcBcqHR_VQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AD7829AC002; Tue, 6 Feb 2024 17:39:46 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.39.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A752026D06; Tue, 6 Feb 2024 17:39:39 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Arnd Bergmann , Jason Baron , Steven Rostedt , Ard Biesheuvel , Frederic Weisbecker , "Paul E. McKenney" , Feng Tang , Andrew Morton , "Mike Rapoport (IBM)" , Vlastimil Babka , David Hildenbrand , "ndesaulniers@google.com" , Michael Kelley , "Masami Hiramatsu (Google)" Subject: [PATCH v2 0/5] jump_label: Fix __ro_after_init keys for modules & annotate some keys Date: Tue, 6 Feb 2024 18:39:06 +0100 Message-ID: <20240206173911.4131670-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790172259792073525 X-GMAIL-MSGID: 1790172259792073525 Hi folks, This series fixes __ro_after_init keys used in modules (courtesy of PeterZ) and flags more keys as __ro_after_init. Further context for why I'm looking into this here: http://lore.kernel.org/r/20230720163056.2564824-1-vschneid@redhat.com Compile & boot tested for x86_64_defconfig and i386_defconfig. @Peter, regarding making __use_tsc x86_32, I hit a few snags. Currently, for the static key to be enabled, we (mostly) need: o X86_FEATURE_TSC is in CPUID o determine_cpu_tsc_frequencies passes All X86_64 systems have a TSC, so the CPUID feature is a given there. Calibrating the TSC can end up depending on different things: o CPUID accepting 0x16 as eax input (cf. cpu_khz_from_cpuid()) o MSR_FSB_FREQ being available (cf. cpu_khz_from_msr()) o pit_hpet_ptimer_calibrate_cpu() doesn't mess up I couldn't find any guarantees for X86_64 on having the processor frequency information CPUID leaf, nor for the FSB_FREQ MSR (both tsc_msr_cpu_ids and the SDM seem to point at only a handful of models). pit_hpet_ptimer_calibrate_cpu() relies on having either HPET or the ACPI PM timer, the latter being widely available, though X86_PM_TIMER can be disabled via EXPERT. The question here is: are there any guarantees that at least one of these can be relied upon for x86_64? And with all of that, there is still the "apicpmtimer" cmdline option which currently invokes notsc_setup() on x86_64. The justification I found for it was in 0c3749c41f5e ("[PATCH] x86_64: Calibrate APIC timer using PM timer"): """ On some broken motherboards (at least one NForce3 based AMD64 laptop) the PIT timer runs at a incorrect frequency. This patch adds a new option "apicpmtimer" that allows to use the APIC timer and calibrate it using the PMTimer. """ Revisions ========= v1 -> v2 ++++++++ - Collected tags (Josh, Sean) - Fixed CONFIG_JUMP_LABEL=n compile fail (lkp) Cheers, Valentin Peter Zijlstra (1): jump_label,module: Don't alloc static_key_mod for __ro_after_init keys Valentin Schneider (4): context_tracking: Make context_tracking_key __ro_after_init x86/kvm: Make kvm_async_pf_enabled __ro_after_init x86/speculation: Make mds_user_clear __ro_after_init x86/tsc: Make __use_tsc __ro_after_init arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kernel/kvm.c | 2 +- arch/x86/kernel/tsc.c | 2 +- include/asm-generic/sections.h | 5 ++++ include/linux/jump_label.h | 3 +++ init/main.c | 1 + kernel/context_tracking.c | 2 +- kernel/jump_label.c | 49 ++++++++++++++++++++++++++++++++++ 8 files changed, 62 insertions(+), 4 deletions(-) --- 2.43.0