From nobody Sun Oct 5 00:12:37 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=1758154650; cv=none; d=zohomail.com; s=zohoarc; b=FZvpZM+CdzXWWkMXVIO+A6Kka0S0bLGOdnLz7M9s/MAraNB8YkYAoWTQs4uiqaN1Jm95oCnlm8UJyMV9xxplWQI5iRfMkUU6RpttuH1SZt+3MEJnMbSM7Mribty3NwsSdIuY0nNm2ioQmqML9WjvxsokwCLRvhNu7n1uyCw8JDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758154650; 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=GNWsrGjH1M9YzA8VE9MUDms++zuoo91l4kLrqq21eXI=; b=meBb5SezWRTgJDIm+kehUf6R2Ba7HSVvulGgKLhsd8eUQefiO1uxW2R0XhNgvmIa9e4Yxy+5RgFVukMQajNrhXnNh61e6YFwqHQbj/7L/AJU76K393jwrmy5nEqR5l0tSOpJRD+AbwonKff88Y3qrYoZ/Z53pdiNlIreykJ+cLA= 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 1758154650831363.610185920081; Wed, 17 Sep 2025 17:17:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6492441954; Wed, 17 Sep 2025 20:17:29 -0400 (EDT) Received: from [172.19.199.10] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id E38F841A7D; Wed, 17 Sep 2025 20:14:34 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id F23C9419A1; Wed, 17 Sep 2025 20:14:08 -0400 (EDT) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3604F419A2 for ; Wed, 17 Sep 2025 20:14:04 -0400 (EDT) Received: from localhost.localdomain (2.general.hector.uk.vpn [10.172.192.135]) (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-1.canonical.com (Postfix) with ESMTPSA id 4076141CC2 for ; Thu, 18 Sep 2025 00:14:02 +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=-3.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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=1758154442; bh=GNWsrGjH1M9YzA8VE9MUDms++zuoo91l4kLrqq21eXI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ee0bRYOOjS6rCxVtE1oYuykvIBH7A6peZI43cwFzZHYVUNRryHXKwzi1IDq0+6WVC taQyO8rJdIGpv8uh0zMKPnBB1t/t01m3JkOT4zXF9JX5Etj5lh3rUqPx0NwUvCqlXP QpQi8Z/3mfo6bgZ8Xd/MiT8ST6EIPTnsRo50CPyv9MA8lRli0NrlorWqE5Igg+mVx6 DgxnXHiFEAYiMlxQG4qMIT6PoML/yykqpNnOlZKY9IoCpog4w3qI+K2zEslDX75bhf AccyXsLHTsA5SxasV07qKSu6opnf+eTYzG9uClz8K3rvoWaVaDQi+gGbtNJ9bElEGQ ie2JF123W5mTQ== From: Hector Cao To: devel@lists.libvirt.org Subject: [PATCH v2 1/1] x86: install modules-load.d file to load msr module Date: Thu, 18 Sep 2025 02:13:57 +0200 Message-ID: <20250918001357.11373-2-hector.cao@canonical.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250918001357.11373-1-hector.cao@canonical.com> References: <20250918001357.11373-1-hector.cao@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O3ZAIPJGGHTRJG3T6ZSSNQD3BHHIXD6H X-Message-ID-Hash: O3ZAIPJGGHTRJG3T6ZSSNQD3BHHIXD6H 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: 1758154651657116600 Content-Type: text/plain; charset="utf-8" On recent Intel CPUs, some of the CPU features (e.g. vmx-* sub-features) 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.d file for msr for x86 and when qemu driver is enabled. by default, this option is enabled but user can disable it via a build option: meson ... -Dmsr_module_load=3Dfalse ... build - 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 | 19 +++++++++++++++++++ src/util/modules-load.d/msr.conf | 1 + tools/virt-host-validate-qemu.c | 7 +++++++ 4 files changed, 28 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..024c05f0dd 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -225,3 +225,22 @@ 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 + get_option('driver_qemu').enabled() and + (host_machine.cpu_family() =3D=3D 'x86' or host_machine.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 applicable : 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