From nobody Mon Nov 3 18:36:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1726145539; cv=none; d=zohomail.com; s=zohoarc; b=XzbQQTlZcdMYO/Q6GBiDP8z5nQKymShqKQmPInFCtHtPuO0ixfIlbpbi2y02OMDEVRQXVKCHE7sLLkftXgcK8bO1GC4ERJCGdRoMKrIQx6tCOyOUxsk/pJ1TAM5DHxW34N1cFuoAJ2jGS2kUcxtyTGbmUH6ZRevz2+AOL/nuaes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726145539; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8YEkouAvvU/30llpDDU3qJxEwFSco4VI7IUeqcZ2LMs=; b=MQK9yVFKrWPfP2FRD9Pz723UuqFGXeDovdqAEzCDHp2ZduvAvOts/y1hC4ZKLnoynQ9Rfw68FnB9GjnVyWUWh4CbNwIXFWcenL89SsqF0h4B6X+4hBLL3hmqQPHLu+7yjIHTvs4gB2KJ/HkqcbkYPVpMfN4Lnc8AxG0m6QeNOXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1726145538766447.81297417230905; Thu, 12 Sep 2024 05:52:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.797447.1207400 (Exim 4.92) (envelope-from ) id 1sojIn-0003x2-S6; Thu, 12 Sep 2024 12:52:01 +0000 Received: by outflank-mailman (output) from mailman id 797447.1207400; Thu, 12 Sep 2024 12:52:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sojIn-0003wv-PS; Thu, 12 Sep 2024 12:52:01 +0000 Received: by outflank-mailman (input) for mailman id 797447; Thu, 12 Sep 2024 12:52:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sojIm-0003wp-Pk for xen-devel@lists.xenproject.org; Thu, 12 Sep 2024 12:52:00 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cc39bbdd-7105-11ef-99a1-01e77a169b0f; Thu, 12 Sep 2024 14:51:58 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a7a81bd549eso112327366b.3 for ; Thu, 12 Sep 2024 05:51:58 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c72e49sm743329566b.127.2024.09.12.05.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 05:51:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cc39bbdd-7105-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1726145518; x=1726750318; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8YEkouAvvU/30llpDDU3qJxEwFSco4VI7IUeqcZ2LMs=; b=FFsm3JOVDeFs7Bc8Kh73sUo5nwG6tKDONnURJbLsgEHZr2aG+ZTCiGA4gMHHfXxPMJ fdvrgn4WNUdd3ET2URKZXBSEVoCNw+7RBCBToNHOhasB2qWijPG8VWzwEpOi4XNBfoWN nVw4xEzVWCGneOQ/rKw3H+ekZO2LN2Pao3zLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726145518; x=1726750318; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8YEkouAvvU/30llpDDU3qJxEwFSco4VI7IUeqcZ2LMs=; b=IYzxTSDD5xNwWRDT20r0f0r204Y+EXIZy+2FEU9gMrDFej1wP+910mFOR60s0M3HCU L8gkO2MGw8Tlk3np9ZMckYCVsFGWl4oZUJqrCuE+t6LsWGEvmr/gx2BayFteBxtF16j3 pAROSYmqNAoQp6zxq/GoxymbnP0DfQS4CycqhqeyVQXLsFfC7H37FdasfAnSmuFl+cKX Q6SLKP6uJ0TTM5qpN5f9YK9EMMqTQ0u/I1Lto9yekLcdQmhYQE3QDGUGEte6WEIa7Its PBjiW5iPCJChH+cPLQAdtA5AqVK64bRJTcnzfLwAWHSnxCx6u7emavw72rKkg0A9tHMx 9LmA== X-Gm-Message-State: AOJu0YwLiTJk5TTys78FSXzdtBDCbA+ce1TGPpx4GJjKT0tEJne0mFqC vBrTPMxX1D77EGtDXaqYD0Ai/uePTmizhGVoJphScV1yLK6yoX893hpx+OJjfebYcVD97cSp2q4 N X-Google-Smtp-Source: AGHT+IGyh4rM/X86rR3hP6k0lhV214aDI8xNxcS5KWLOY0aW8kfkgp5eSpfw//8t6AvIs5K7T6mI2g== X-Received: by 2002:a17:907:9404:b0:a8d:592d:f76 with SMTP id a640c23a62f3a-a90296eab6amr267238166b.48.1726145517539; Thu, 12 Sep 2024 05:51:57 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Daniel Smith , Jason Andryuk Subject: [PATCH] xen/keyhandler: Move key_table[] into __ro_after_init Date: Thu, 12 Sep 2024 13:51:54 +0100 Message-Id: <20240912125154.1708025-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1726145540136116600 All registration is done at boot. Almost... iommu_dump_page_tables() is registered in iommu_hwdom_init(), which is call= ed twice when LATE_HWDOM is in use. register_irq_keyhandler() has an ASSERT() guarding againt multiple registration attempts, and the absence of bug reports hints at how many configurations use LATE_HWDOM in practice. Move the registration into iommu_setup() just after printing the overall status of the IOMMU. For starters, the hardware domain is specifically excluded by iommu_dump_page_tables(). ept_dump_p2m_table is registered in setup_ept_dump() which is non-__init, b= ut whose sole caller, start_vmx(), is __init. Move setup_ept_dump() to match. With these two tweeks, all keyhandler reigstration is from __init functions, so register_{,irq_}keyhandler() can move, and key_table[] can become __ro_after_init. No practical change. Signed-off-by: Andrew Cooper Acked-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Daniel Smith CC: Jason Andryuk CC'ing some OpenXT folks just FYI. --- xen/arch/x86/mm/p2m-ept.c | 2 +- xen/common/keyhandler.c | 10 +++++----- xen/drivers/passthrough/iommu.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 2ea574ca6aef..21728397f9ac 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1497,7 +1497,7 @@ static void cf_check ept_dump_p2m_table(unsigned char= key) rcu_read_unlock(&domlist_read_lock); } =20 -void setup_ept_dump(void) +void __init setup_ept_dump(void) { register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0= ); } diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 674e7be39e9d..6da291b34ebc 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -40,7 +40,7 @@ static struct keyhandler { const char *desc; /* Description for help message. = */ bool irq_callback, /* Call in irq context? if not, tasklet context. = */ diagnostic; /* Include in 'dump all' handler. = */ -} key_table[128] __read_mostly =3D +} key_table[128] __ro_after_init =3D { #define KEYHANDLER(k, f, desc, diag) \ [k] =3D { { .fn =3D (f) }, desc, 0, diag } @@ -99,8 +99,8 @@ void handle_keypress(unsigned char key, bool need_context) } } =20 -void register_keyhandler(unsigned char key, keyhandler_fn_t *fn, - const char *desc, bool diagnostic) +void __init register_keyhandler(unsigned char key, keyhandler_fn_t *fn, + const char *desc, bool diagnostic) { BUG_ON(key >=3D ARRAY_SIZE(key_table)); /* Key in range? */ ASSERT(!key_table[key].fn); /* Clobbering something else? */ @@ -111,8 +111,8 @@ void register_keyhandler(unsigned char key, keyhandler_= fn_t *fn, key_table[key].diagnostic =3D diagnostic; } =20 -void register_irq_keyhandler(unsigned char key, irq_keyhandler_fn_t *fn, - const char *desc, bool diagnostic) +void __init register_irq_keyhandler(unsigned char key, irq_keyhandler_fn_t= *fn, + const char *desc, bool diagnostic) { BUG_ON(key >=3D ARRAY_SIZE(key_table)); /* Key in range? */ ASSERT(!key_table[key].irq_fn); /* Clobbering something else? */ diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 50bfd62553ae..1c567d441cd5 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -271,8 +271,6 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) if ( !is_iommu_enabled(d) ) return; =20 - register_keyhandler('o', &iommu_dump_page_tables, "dump iommu page tab= les", 0); - iommu_vcall(hd->platform_ops, hwdom_init, d); } =20 @@ -596,6 +594,8 @@ int __init iommu_setup(void) } else { + register_keyhandler('o', &iommu_dump_page_tables, "dump iommu page= tables", 0); + if ( iommu_quarantine_init() ) panic("Could not set up quarantine\n"); =20 base-commit: 221f2748e8dabe8361b8cdfcffbeab9102c4c899 --=20 2.39.2