Qemu 5.2 adds a new CPU feature named kvm-asyncpf-int. The qemu 5.2
changelog says:

A new KVM feature which improves the handling of asynchronous page
faults is available with -cpu ...,kvm-async-pf-int. This requires
Linux 5.8.

If this feature is enabled, the (jailhouse enabled) guest kernel will
run into the following situation during "jailhouse cell create". To
avoid that we need to disable this cpu feature when qemu supports it.

jailhouse console output:

FATAL: Unhandled MSR write: 4b564d02
RIP: 0xffffffff8103e117 RSP: 0xffffc900000ffe60 FLAGS: 46
RAX: 0x0000000000000000 RBX: 0x0000000000000003 RCX: 0x000000004b564d02
RDX: 0x0000000000000000 RSI: 0x0000000000000000 RDI: 0x000000004b564d02
CS: 10 BASE: 0x0000000000000000 AR-BYTES: a09b EFER.LMA 1
CR0: 0x0000000080050033 CR3: 0x000000000200a002 CR4: 0x0000000000372ea0
EFER: 0x0000000000000d01

Stack trace:

[   41.849660] #PF: supervisor instruction fetch in kernel mode
[   41.850301] #PF: error_code(0x0010) - not-present page
[   41.850839] PGD 0 P4D 0
[   41.851121] Oops: 0010 [#1] PREEMPT SMP PTI
[   41.851570] CPU: 3 PID: 25 Comm: cpuhp/3 Tainted: G           O      5.10.31 
#1
[   41.852326] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 
1.14.0-2.fc34 04/01/2014
[   41.853207] RIP: 0010:0x0
[   41.853494] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   41.854287] RSP: 0018:ffffc900000ffe60 EFLAGS: 00010046
[   41.854962] RAX: 0000000000000000 RBX: 0000000000000003 RCX: 000000004b564d02
[   41.855605] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000004b564d02
[   41.856242] RBP: ffff88803f9971a0 R08: ffff88803f9971c8 R09: ffff888002c00058
[   41.856873] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8103e827
[   41.857511] R13: ffffffff8106efa1 R14: ffff88803f9971c8 R15: 0000000000000000
[   41.858152] FS:  0000000000000000(0000) GS:ffff88803f980000(0000) 
knlGS:0000000000000000
[   41.859131] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   41.859738] CR2: ffffffffffffffd6 CR3: 000000000200a002 CR4: 0000000000372ea0
[   41.860378] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   41.860929] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[   41.861488] Call Trace:
[   41.861698]  kvm_pv_disable_apf.part.13+0x11/0x2f
[   41.862084]  kvm_cpu_down_prepare+0x42/0x50
[   41.862415]  cpuhp_invoke_callback+0xc1/0x238
[   41.862760]  ? smpboot_unregister_percpu_thread+0x59/0x59
[   41.863187]  cpuhp_thread_fun+0xdd/0x117
[   41.863518]  smpboot_thread_fn+0x190/0x1a5
[   41.863847]  kthread+0x112/0x11a
[   41.864109]  ? kthread_unpark+0x62/0x62
[   41.864412]  ret_from_fork+0x22/0x30
[   41.864765] Modules linked in: af_packet snd_hda_codec_generic evdev pcspkr 
snd_hda_intel snd_intel_dspcfg serio_raw snd_hda_codec sg snd_hda_core snd_pcm 
snd_timer snd soundcore intel_agp intel_gtt button jailhouse(O) ip_tables 
x_tables ipv6 psmouse e1000e ptp i2c_i801 i2c_smbus lpc_ich pps_core
[   41.866836] CR2: 0000000000000000
[   41.867105] ---[ end trace a63d134522cf2445 ]---
[   41.867466] RIP: 0010:0x0
[   41.867680] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   41.868216] RSP: 0018:ffffc900000ffe60 EFLAGS: 00010046
[   41.868629] RAX: 0000000000000000 RBX: 0000000000000003 RCX: 000000004b564d02
[   41.869185] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000004b564d02
[   41.869736] RBP: ffff88803f9971a0 R08: ffff88803f9971c8 R09: ffff888002c00058
[   41.870325] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8103e827
[   41.870993] R13: ffffffff8106efa1 R14: ffff88803f9971c8 R15: 0000000000000000
[   41.871501] FS:  0000000000000000(0000) GS:ffff88803f980000(0000) 
knlGS:0000000000000000
[   41.872076] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   41.872477] CR2: ffffffffffffffd6 CR3: 000000000200a002 CR4: 0000000000372ea0
[   41.872972] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   41.873469] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Signed-off-by: Florian Bezdeka <[email protected]>
---
 start-qemu.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/start-qemu.sh b/start-qemu.sh
index 7e95ec8..4e90fe3 100755
--- a/start-qemu.sh
+++ b/start-qemu.sh
@@ -26,8 +26,15 @@ case "$1" in
        x86|x86_64|amd64)
                DISTRO_ARCH=amd64
                QEMU=qemu-system-x86_64
+               
CPU_FEATURES="-kvm-pv-eoi,-kvm-pv-ipi,-kvm-asyncpf,-kvm-steal-time,-kvmclock"
+
+               # qemu >= 5.2 has kvm-asyncpf-int which needs to be disabled
+               if ${QEMU} -cpu help | grep kvm-asyncpf-int > /dev/null; then
+                       CPU_FEATURES="${CPU_FEATURES},-kvm-asyncpf-int"
+               fi
+
                QEMU_EXTRA_ARGS=" \
-                       -cpu 
host,-kvm-pv-eoi,-kvm-pv-ipi,-kvm-asyncpf,-kvm-steal-time,-kvmclock \
+                       -cpu host,${CPU_FEATURES} \
                        -smp 4 \
                        -enable-kvm -machine q35,kernel_irqchip=split \
                        -serial vc \
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/20210521080646.488836-4-florian.bezdeka%40siemens.com.

Reply via email to