On 2/14/2025 9:33 AM, Bruce Ashfield wrote:
This is a cherry-pick from 6.12, as such, it should
be clearly indicated that it is a backport request.

That being said, I think we could simply this fragment
a bit.

How are you enabling it via kernel-features ? Rather
than having a common fragment "qemu-kvm-enable.scc",
we could just have the two architecture specific ones
and do the conditional inclusion at the recipe / meta-data
level.

I assume you are enabling it via KERNEL_FEATURES ? If
so, the addition to the KERNEL_FEATURES could test on the
architecture and directly include the required fragment.

After some time, I could then remove the generic one
and not rely on the scc internal conditional (which makes
processing complicated in some scenarios)

Bruce
Hi Bruce,

I cherry-pick https://git.yoctoproject.org/yocto-kernel-cache/commit/?id=57840835a5983dedbec5436968634a13338c7d73 from yocto-5.15. I just test it on amd-zynqmp (arm 64-bit) board and intel-x86-64 (ia 64-bit) board on yocto-6.6.

How to test:
1. add below line to conf/local.conf
  KERNEL_FEATURES += "features/kvm/qemu-kvm-enable.scc"

2. apply patch to kernel-meta(tmp-glibc/work/xxx/linux-yocto/6.6.74+git/kernel-meta)

3. compile kernel with the changes
  bitbake -C kernel_configme -f linux-yocto

4. check kernel .config and kvm output files
  1) check whether relational options in patch is enabled.
  2) check whether kvm files in arch/xxx/kvm is compiled
     (cd tmp-glibc/work/xxx/linux-yocto/xxx/linux_xxx_build)
5. Build linux-yocto and rootfs. Boot up the kernel image on amd-zynqmp board or intel-x86-64 board   1)  run "virt-host-validate" command to verify the file "/dev/kvm" should exist.

In message: [linux-yocto][yocto-kernel-cache yocto-6.6][PATCH] features/kvm: 
enable kvm configs for arm64
on 13/02/2025 [email protected] wrote:

From: Wenlin Kang <[email protected]>

The CONFIG_VIRTUALIZATION is not enabled for ARM64, but it is
default for X86. And CONFIG_KVM depends on CONFIG_VIRTUALIZATION.

In addition, the CONFIG_KVM is a bool type in ARM64, it could not
be built as a kernel module, so split KVM configs out based the
architecture to standalone files.

Signed-off-by: Liu Haitao <[email protected]>
Signed-off-by: Wenlin Kang <[email protected]>
Signed-off-by: Bin Lan <[email protected]>
---
  features/kvm/qemu-kvm-arm64.cfg  | 3 +++
  features/kvm/qemu-kvm-enable.scc | 5 +++++
  features/kvm/qemu-kvm-x86.cfg    | 4 ++++
  features/kvm/qemu-kvm.cfg        | 3 ---
  4 files changed, 12 insertions(+), 3 deletions(-)
  create mode 100644 features/kvm/qemu-kvm-arm64.cfg
  create mode 100644 features/kvm/qemu-kvm-x86.cfg

diff --git a/features/kvm/qemu-kvm-arm64.cfg b/features/kvm/qemu-kvm-arm64.cfg
new file mode 100644
index 00000000..143a7bc4
--- /dev/null
+++ b/features/kvm/qemu-kvm-arm64.cfg
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: MIT
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM=y
diff --git a/features/kvm/qemu-kvm-enable.scc b/features/kvm/qemu-kvm-enable.scc
index 880bdaa0..23b4af5f 100644
--- a/features/kvm/qemu-kvm-enable.scc
+++ b/features/kvm/qemu-kvm-enable.scc
@@ -3,3 +3,8 @@ define KFEATURE_DESCRIPTION "Enable KVM host support"
  define KFEATURE_COMPATIBILITY board

  kconf non-hardware qemu-kvm.cfg
+if [ "$KARCH" = "x86_64" ] || [ "$KARCH" = "x86" ] || [ "$KARCH" = "i386" ]; 
then
+     kconf non-hardware qemu-kvm-x86.cfg
+elif [ "$KARCH" = "arm64" ]; then
+     kconf non-hardware qemu-kvm-arm64.cfg
+fi
diff --git a/features/kvm/qemu-kvm-x86.cfg b/features/kvm/qemu-kvm-x86.cfg
new file mode 100644
index 00000000..5c885b9e
--- /dev/null
+++ b/features/kvm/qemu-kvm-x86.cfg
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: MIT
+CONFIG_KVM=m
+CONFIG_KVM_INTEL=m
+CONFIG_KVM_AMD=m
diff --git a/features/kvm/qemu-kvm.cfg b/features/kvm/qemu-kvm.cfg
index aa0c29ff..3eef744e 100644
--- a/features/kvm/qemu-kvm.cfg
+++ b/features/kvm/qemu-kvm.cfg
@@ -1,7 +1,4 @@
  # SPDX-License-Identifier: MIT
-CONFIG_KVM=m
-CONFIG_KVM_INTEL=m
-CONFIG_KVM_AMD=m
  CONFIG_TUN=y

  # Macvtap
--
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14775): 
https://lists.yoctoproject.org/g/linux-yocto/message/14775
Mute This Topic: https://lists.yoctoproject.org/mt/111159504/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to