[TGL][ADL] ACRN hypervisor support

Bug #1943552 reported by Chao Qin
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
intel
New
Undecided
Unassigned
Lookout-canyon-series
Fix Released
Undecided
Philip Cox

Bug Description

Description
The driver enables the host to run ACRN hypervisor which is a flexible, lightweight reference hypervisor, built with real-time and safety-criticality in mind, optimized to streamline embedded development through an open-source platform.

https://projectacrn.org/

Hardware: TigerLake/AlderLake

Target Release: 21.04
Target Kernel: TBD

External links:
https://github.com/intel/linux-intel-quilt/tree/mainline-tracking-v5.13-yocto-210727T062416Z

X-HWE-Bug: Bug #1952006

Revision history for this message
Chao Qin (chaoqin) wrote :

Please find the following patches in the above external link

0001-virt-acrn-Introduce-interfaces-for-MMIO-device-passth.acrn
0002-virt-acrn-Introduce-interfaces-for-virtual-device-cre.acrn
0003-virt-acrn-Introduce-interface-to-fetch-platform-info-.acrn
0004-virt-acrn-Do-hcall_destroy_vm-before-resource-release.acrn
0005-virt-acrn-Introduce-acrntrace-support.acrn

Changed in intel:
assignee: nobody → Alex Hung (alexhung)
Changed in intel:
assignee: Alex Hung (alexhung) → nobody
Revision history for this message
Alex Hung (alexhung) wrote :

The 4th patch is in upstream and is in intel-5.13-next

$ git show feda18792890ab251af4e60b347d56b89cd4f74b ; git tag --contains feda18792890ab251af4e60b347d56b89cd4f74b

commit feda18792890ab251af4e60b347d56b89cd4f74b
Author: Shuo Liu <email address hidden>
Date: Thu Jul 22 14:27:36 2021 +0800

    virt: acrn: Do hcall_destroy_vm() before resource release

    BugLink: https://bugs.launchpad.net/bugs/1939708

    commit 4c4c1257b844ffe5d0933684e612f92c4b78e120 upstream.

    The ACRN hypervisor has scenarios which could run a real-time guest VM.
    The real-time guest VM occupies dedicated CPU cores, be assigned with
    dedicated PCI devices. It can run without the Service VM after boot up.
    hcall_destroy_vm() returns failure when a real-time guest VM refuses.
    The clearing of flag ACRN_VM_FLAG_DESTROYED causes some kernel resource
    double-freed in a later acrn_vm_destroy().

    Do hcall_destroy_vm() before resource release to drop this chance to
    destroy the VM if hypercall fails.

    Fixes: 9c5137aedd11 ("virt: acrn: Introduce VM management interfaces")
    Cc: stable <email address hidden>
    Signed-off-by: Shuo Liu <email address hidden>
    Signed-off-by: Fei Li <email address hidden>
    Link: https://<email address hidden>
    Signed-off-by: Greg Kroah-Hartman <email address hidden>
    Signed-off-by: Kamal Mostafa <email address hidden>

diff --git a/drivers/virt/acrn/vm.c b/drivers/virt/acrn/vm.c
index 0d002a355a93..fbc9f1042000 100644
--- a/drivers/virt/acrn/vm.c
+++ b/drivers/virt/acrn/vm.c
@@ -64,6 +64,14 @@ int acrn_vm_destroy(struct acrn_vm *vm)
            test_and_set_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags))
                return 0;

+ ret = hcall_destroy_vm(vm->vmid);
+ if (ret < 0) {
+ dev_err(acrn_dev.this_device,
+ "Failed to destroy VM %u\n", vm->vmid);
+ clear_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags);
+ return ret;
+ }
+
        /* Remove from global VM list */
        write_lock_bh(&acrn_vm_list_lock);
        list_del_init(&vm->list);
@@ -78,14 +86,6 @@ int acrn_vm_destroy(struct acrn_vm *vm)
                vm->monitor_page = NULL;
        }

- ret = hcall_destroy_vm(vm->vmid);
- if (ret < 0) {
- dev_err(acrn_dev.this_device,
- "Failed to destroy VM %u\n", vm->vmid);
- clear_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags);
- return ret;
- }
-
        acrn_vm_all_ram_unmap(vm);

        dev_dbg(acrn_dev.this_device, "VM %u destroyed.\n", vm->vmid);
Ubuntu-intel-5.13-5.13.0-1005.5
Ubuntu-intel-5.13-5.13.0-1006.6
Ubuntu-intel-5.13-5.13.0-1007.7

Revision history for this message
Alex Hung (alexhung) wrote :

Patch 5 has the below message. Is there an improved version?

========================================
Subject: [PATCH 5/5] virt: acrn: Introduce acrntrace support

!! Don't upstream this patch directly !!
Need refine to upstream quality.

Revision history for this message
Alex Hung (alexhung) wrote :

A test kernel based on Ubuntu-intel-5.13-5.13.0-1008.8 with the following four patches is available @ https://people.canonical.com/~alexhung/LP1943552/

8bc1cdb UBUNTU: SAUCE: virt: acrn: Introduce acrntrace support
e07b311 UBUNTU: SAUCE: virt: acrn: Introduce interface to fetch platform info from the hypervisor
f57aa7e virt: acrn: Introduce interfaces for virtual device creating/destroying
0472b53 virt: acrn: Introduce interfaces for MMIO device passthrough

Note: 0004-virt-acrn-Do-hcall_destroy_vm-before-resource-release.acrn was included already (see #2)

Alex Hung (alexhung)
description: updated
Revision history for this message
Alex Hung (alexhung) wrote :

@chaoqin,

I pushed the patches to https://code.launchpad.net/~alexhung/+git/focal/+ref/iotg-adl/1943552 with comments above.

Please have a look and keep me posted if there are improvements or fixes to be made

Revision history for this message
Alex Hung (alexhung) wrote :

There are 2 patches that aren't in upstream yet. Does Intel have plans to submit them to upstream? If not, what is the reason?

UBUNTU: SAUCE: virt: acrn: Introduce interface to fetch
UBUNTU: SAUCE: virt: acrn: Introduce acrntrace support

Revision history for this message
Chao Qin (chaoqin) wrote :

Yes, we have upstream plan for these 2 commits in the new year 2022.

Revision history for this message
Chao Qin (chaoqin) wrote :

Please backport the following ones to v5.15

29a9f27574692a71c04fd41ca4bbf8eae842af13 virt: acrn: Introduce interfaces for MMIO device passthrough
424f1ac2d832f31a2814c799bd50decf6a9f8e74 virt: acrn: Introduce interfaces for virtual device creating/destroying

Ana Lasprilla (anamlt)
information type: Private → Public
Revision history for this message
Sachin Mokashi (sachinmokashi) wrote :

Testcases for TGL with ACRN Hypervisor Version 2.7

TC1: General_Service_OS:

Setup before execute test:

Follow steps to build ACRN hypervisor and setup the SOS
https://projectacrn.github.io/2.7/getting-started/getting-started.html

depending on hardware, there might need to modify the scenario XML and boot option to specify the rootfs and ramdisk
* for my case, Service OS install on NVME SSD, the modification as below
1. Update ramdisk_mod in scenario XML as below, update rootfs to /dev/nvme0n1p2 or add root=/dev/nvme0n1p2 in service VM boot args.
<os_config>

  <ramdisk_mod>Linux_Initrd</ramdisk_mod>

</os_config>

2. Add “module2 /path/to/initrd-image Linux_Initrd” in grub menuentry
Step:
1. 1.From acrn serial console, switch to SOS console with command "vm_console 0"
ACRN:> vm_console 0
2. 2. Login SOS
3. 3. input command "dmesg | grep ACRN"

Expected result:

[ 0.000000] Hypervisor detected: ACRN

TC2: Boot_RTVM:

Prerequisites : successfully Boot Service OS (TC1: General_Service_OS)

Setup before execute test:

Prepare any linux based RTVM image, we uses yocto build image follows these document to build
https://github.com/intel/meta-acrn/blob/master/docs/getting-started.md

generate the launch script launch_user_vm_id2.sh using misc/config_tools/launch_config/launch_cfg_gen.py.

edit launch_user_vm_id2.sh acrn-dm section, set virtio-blk to rtvm image.

Step:
1. 1. from SOS GUI or SOS serial console, run command "bash ./launch_user_vm_id2.sh"

Expected result:
launch rtvm successfully

TC3: CPU_Static_Partitioning_Scheduling:

Prerequisites : successfully Boot RTVM(TC2: Boot_RTVM)

Step:
1. from acrn serial, switch to SOS console
ACRN:> vm_console 0
2.execute 'cat /proc/cpuinfo',check CPU core.
3. launch UOS
4.Check CPU status by "cat /proc/cpuinfo" in uos.

Expected result:
Step2: Expect to see 8 cores on 8 core platform
Step5:Expect to see 1cores since launch.sh pass-through 1 cores.

TC4: Memory_Partitioning_RTVM:

Prerequisites : successfully Boot RTVM(TC2: Boot_RTVM)

Step:
1.From uos console Check ‘ cat /proc/meminfo’ and see if the available memory is close the size passed through to UOS (see mem_size in launch script)

Expected result:
Memtotal should close to amount given in ./launch_user_vm_id2.sh acrn-dm -m option.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.