From nobody Sun Sep 7 23:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=canonical.com ARC-Seal: i=1; a=rsa-sha256; t=1756904013; cv=none; d=zohomail.com; s=zohoarc; b=n4zubx3leAA4JpnZbFKWd5+Mc8lX4+Yr6UzQJ8Ys+6ySSPxtkCFESNN6U9eRgLPiB1e0lIF5uoj23l9a5b4clsjDVh74r1eep8hJts1IVBf2CHwwJ/xBdF0IfNcxx1lQsjbiEepuIbrPRtxg964h3lEUcyepjrMEdEPDX8d69rU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904013; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=dboEnzfHY0UTNLQWwdPaemHUK+cJe5cifkQhyPAiNHY=; b=TLDVe8Cw1F+kp0e1eo7V8hUOxOQWxl36DZfivTQf81F8UxQGD/ThMcJd75OObq7TlvG+QtzVAR00hddHOPNJuJCQowIgElLFqrTk6xq2csEKPB6urYeMmEYDmf9xY1agkhINlTX87Hiv3sgRcpGvos87tQvbJk5IjKS6iwO2QRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 175690401293692.25392585803309; Wed, 3 Sep 2025 05:53:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E6E2744208; Wed, 3 Sep 2025 08:53:31 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8449E4432F; Wed, 3 Sep 2025 08:51:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D636E44155; Wed, 3 Sep 2025 08:51:01 -0400 (EDT) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 05DFF4412E for ; Wed, 3 Sep 2025 08:51:01 -0400 (EDT) Received: from localhost.localdomain (unknown [10.101.192.134]) (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 smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 6E5603FC00 for ; Wed, 3 Sep 2025 12:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1756903860; bh=dboEnzfHY0UTNLQWwdPaemHUK+cJe5cifkQhyPAiNHY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dk/F2u5bEjsGfpAk4r7D390sI7i9oqLBeaJOgKkv1csHnPiS/wXG3mmuoP36RjiqW Uk2PhXHzIwJHZdtuJ22Fg47tBn0AWjb5bTVSiQg5YXdFbncdgpP1r+qCUggn1P+9VA d30KdEsiTDf4br4/p2qmvj2rQOTblCgaTC2lg52lHrxe9glE3oeED5E7aeCFvdRSq+ wLnZhdkdoFFFHWmC2hMGdf62gsmmcerAuHTd1Xz+Y+UcorP+arJZvItOYxSQ39zAUC tXJtIIuvQEjEcDIlKk6qzJoF1gU03qSksGe0LWE47TznuPvZZbfsnxCYzlhmSzTJ/1 BxdgXfUGM9z6Q== From: Hector Cao To: devel@lists.libvirt.org Subject: [PATCH 1/1] x86: install modules-load.d file to load msr module Date: Wed, 3 Sep 2025 14:49:39 +0200 Message-ID: <20250903124939.116181-2-hector.cao@canonical.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250903124939.116181-1-hector.cao@canonical.com> References: <20250903124939.116181-1-hector.cao@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KOSUJ2KY2AZRC6OPQGEAMTZ25PXUOANM X-Message-ID-Hash: KOSUJ2KY2AZRC6OPQGEAMTZ25PXUOANM X-MailFrom: hector.cao@canonical.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @canonical.com) X-ZM-MESSAGEID: 1756904015828116600 Content-Type: text/plain; charset="utf-8" On recent Intel CPUs, some of the CPU features (mostly vmx-* subfeatures) are listed and controlled via the MSRs (Model Specific Registers) instead of the traditional CPUID instruction method. To be able to read the MSR's values, the kernel module msr has to be loaded and the values can be read via /dev/cpu/*/msr. This commit introduces following changes: - install modules-load file for msr this is only enabled: - On x86 arch - If user asks for it explicitly via a build option: meson -Dmsr_module_load=3Dtrue build By default, it is disabled. - modify virt-host-validate to check of /dev/cpu/*/msr is available. Signed-off-by: Hector Cao --- meson_options.txt | 1 + src/util/meson.build | 17 +++++++++++++++++ src/util/modules-load.d/msr.conf | 1 + tools/virt-host-validate-qemu.c | 7 +++++++ 4 files changed, 26 insertions(+) create mode 100644 src/util/modules-load.d/msr.conf diff --git a/meson_options.txt b/meson_options.txt index 3dc3e8667b..5a9e067407 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -135,3 +135,4 @@ option('sysctl_config', type: 'feature', value: 'auto',= description: 'Whether to # dep:sysctl_config option('userfaultfd_sysctl', type: 'feature', value: 'auto', description: = 'Whether to install sysctl config for enabling unprivileged userfaultfd') option('tls_priority', type: 'string', value: 'NORMAL', description: 'set = the default TLS session priority string') +option('msr_module_load', type: 'boolean', value: true, description: 'Inst= all modules-load.d file for msr module on x86') diff --git a/src/util/meson.build b/src/util/meson.build index 69ef49139a..5471a1e9ea 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -225,3 +225,20 @@ if conf.has('WITH_LIBVIRTD') endif =20 util_inc_dir =3D include_directories('.') + +# Install the modules-load.d file to load the MSR module +# NB: For the file to taken into account and the module load to happen, us= ers must trigger +# the modules-load.d reload (by reboot or restart the systemd-modules-load= service). +msr_module_load =3D get_option('msr_module_load') +if msr_module_load and (host_machine.cpu_family() =3D=3D 'x86' or host_mac= hine.cpu_family() =3D=3D 'x86_64') + message('msr_module_load: Enabling installation of modules-load.d/msr.co= nf for x86') + + install_data( + 'modules-load.d/msr.conf', + install_dir: join_paths(sysconfdir, 'modules-load.d') + ) +elif msr_module_load + message('msr_module_load: option enabled, but not x86/x86_64 : skipping') +else + message('msr_module_load: option disabled: skipping') +endif \ No newline at end of file diff --git a/src/util/modules-load.d/msr.conf b/src/util/modules-load.d/msr= .conf new file mode 100644 index 0000000000..3e5ee7fa15 --- /dev/null +++ b/src/util/modules-load.d/msr.conf @@ -0,0 +1 @@ +msr diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qem= u.c index 833bb1b914..f582e1146e 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -95,6 +95,13 @@ int virHostValidateQEMU(void) virValidatePass(); } =20 + if (arch =3D=3D VIR_ARCH_X86_64) { + if (virHostValidateDeviceExists("QEMU", "/dev/cpu/0/msr", + VIR_HOST_VALIDATE_WARN, + _("Load the 'msr' module for bette= r x86 CPU features detection")) < 0) + ret =3D -1; + } + if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net", VIR_VALIDATE_WARN, _("Load the 'vhost_net' module to impr= ove performance of virtio networking")) < 0) --=20 2.45.2