From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575590908534.1623469760735; Thu, 2 Sep 2021 02:39:50 -0700 (PDT) Received: from localhost ([::1]:47944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjCH-00008n-Qs for importer@patchew.org; Thu, 02 Sep 2021 05:39:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9I-0002cN-O2 for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9H-0005FD-0p for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-t1Z6qGpYOkOAj6KZL8lYzQ-1; Thu, 02 Sep 2021 05:35:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5DF0101371C for ; Thu, 2 Sep 2021 09:35:35 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFF266A05B; Thu, 2 Sep 2021 09:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mQvQsY+7GTKZG9iGQ2AT0h6SFz4fTB8TgjuB331b6LE=; b=I1W5CyCUH/wF8mHjVIw3LTtjqMUOkM67ctirTjlssoBqyBIwULWmb0kfvPpw0eVFmDz5JP yMv6GmDkaToJqP6VfRTKPBHsFfxPcZnbXoKvOpjKDcR5w5acNlnI9MTQdwnpCgfwlhxqJw OgodgIw0JqLf/++OPbk7K1kaSJyzaP4= X-MC-Unique: t1Z6qGpYOkOAj6KZL8lYzQ-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 1/8] i386: Add 6.2 machine types Date: Thu, 2 Sep 2021 11:35:23 +0200 Message-Id: <20210902093530.345756-2-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575592565100001 Content-Type: text/plain; charset="utf-8" Introduce 6.2 machine types and the required infrastructure for adding compat properties to pre-6.2 machine types. Signed-off-by: Vitaly Kuznetsov --- hw/core/machine.c | 3 +++ hw/i386/pc.c | 3 +++ hw/i386/pc_piix.c | 14 +++++++++++++- hw/i386/pc_q35.c | 13 ++++++++++++- include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 54e040587dd3..9d0d1194e1ef 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -46,6 +46,9 @@ GlobalProperty hw_compat_6_0[] =3D { }; const size_t hw_compat_6_0_len =3D G_N_ELEMENTS(hw_compat_6_0); =20 +GlobalProperty hw_compat_6_1[] =3D {}; +const size_t hw_compat_6_1_len =3D G_N_ELEMENTS(hw_compat_6_1); + GlobalProperty hw_compat_5_2[] =3D { { "ICH9-LPC", "smm-compat", "on"}, { "PIIX4_PM", "smm-compat", "on"}, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 102b22394689..1276bfeee456 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -93,6 +93,9 @@ #include "trace.h" #include CONFIG_DEVICES =20 +GlobalProperty pc_compat_6_1[] =3D {}; +const size_t pc_compat_6_1_len =3D G_N_ELEMENTS(pc_compat_6_1); + GlobalProperty pc_compat_6_0[] =3D { { "qemu64" "-" TYPE_X86_CPU, "family", "6" }, { "qemu64" "-" TYPE_X86_CPU, "model", "6" }, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1bc30167acc0..c5da7739cef7 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -412,7 +412,7 @@ static void pc_i440fx_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); } =20 -static void pc_i440fx_6_1_machine_options(MachineClass *m) +static void pc_i440fx_6_2_machine_options(MachineClass *m) { PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_machine_options(m); @@ -421,6 +421,18 @@ static void pc_i440fx_6_1_machine_options(MachineClass= *m) pcmc->default_cpu_version =3D 1; } =20 +DEFINE_I440FX_MACHINE(v6_2, "pc-i440fx-6.2", NULL, + pc_i440fx_6_2_machine_options); + +static void pc_i440fx_6_1_machine_options(MachineClass *m) +{ + pc_i440fx_6_2_machine_options(m); + m->alias =3D NULL; + m->is_default =3D false; + compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); + compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); +} + DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, pc_i440fx_6_1_machine_options); =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index eeb0b185b118..565fadce540c 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -354,7 +354,7 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =3D 288; } =20 -static void pc_q35_6_1_machine_options(MachineClass *m) +static void pc_q35_6_2_machine_options(MachineClass *m) { PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_machine_options(m); @@ -362,6 +362,17 @@ static void pc_q35_6_1_machine_options(MachineClass *m) pcmc->default_cpu_version =3D 1; } =20 +DEFINE_Q35_MACHINE(v6_2, "pc-q35-6.2", NULL, + pc_q35_6_2_machine_options); + +static void pc_q35_6_1_machine_options(MachineClass *m) +{ + pc_q35_6_2_machine_options(m); + m->alias =3D NULL; + compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); + compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); +} + DEFINE_Q35_MACHINE(v6_1, "pc-q35-6.1", NULL, pc_q35_6_1_machine_options); =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index accd6eff35ab..463a5514f97d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -353,6 +353,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) =20 +extern GlobalProperty hw_compat_6_1[]; +extern const size_t hw_compat_6_1_len; + extern GlobalProperty hw_compat_6_0[]; extern const size_t hw_compat_6_0_len; =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 88dffe751724..97b4ab79b534 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -196,6 +196,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, siz= e_t flash_size); void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry); =20 +extern GlobalProperty pc_compat_6_1[]; +extern const size_t pc_compat_6_1_len; + extern GlobalProperty pc_compat_6_0[]; extern const size_t pc_compat_6_0_len; =20 --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163057543762673.63314249798293; Thu, 2 Sep 2021 02:37:17 -0700 (PDT) Received: from localhost ([::1]:39074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLj9o-0002Sx-9K for importer@patchew.org; Thu, 02 Sep 2021 05:37:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj8J-0001h6-Tn for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:35:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj8I-0004PJ-9J for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:35:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-BQUyOU5RMfu_vF_eSp2N5w-1; Thu, 02 Sep 2021 05:35:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1984E801AE3 for ; Thu, 2 Sep 2021 09:35:38 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2174377F33; Thu, 2 Sep 2021 09:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z1tIU2YHphnYuT9wydQ/esWuZWRJ4ptwamQw8mUHyLs=; b=MNsFbzXY3WppM62tFIwnNcBAmDxYf62tgHY/aL4Kwb95V3vwuUlHLOIFk3/YfwxQTI2SZM LGaAk8Tz4yrUDScf7vDeUd6i3MAIkjXK3lANE6Cl9+jCtwRoVinPXaIGZ7oMbPgI9ZOiF1 EGRP9SLeBRhcNEkyjBJrND1vW9JTczo= X-MC-Unique: BQUyOU5RMfu_vF_eSp2N5w-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 2/8] i386: docs: Briefly describe KVM PV features Date: Thu, 2 Sep 2021 11:35:24 +0200 Message-Id: <20210902093530.345756-3-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575438830100001 Content-Type: text/plain; charset="utf-8" KVM PV features don't seem to be documented anywhere, in particular, the fact that some of the features are enabled by default and some are not can only be figured out from the code. Signed-off-by: Vitaly Kuznetsov --- docs/kvm-pv.txt | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 docs/kvm-pv.txt diff --git a/docs/kvm-pv.txt b/docs/kvm-pv.txt new file mode 100644 index 000000000000..84ad7fa60f8d --- /dev/null +++ b/docs/kvm-pv.txt @@ -0,0 +1,92 @@ +KVM paravirtualized features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + + +1. Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +In some cases when implementing a hardware interface in software is slow, = KVM +implements its own paravirtualized interfaces. + +2. Setup +=3D=3D=3D=3D=3D=3D=3D=3D=3D +KVM PV features are represented as CPU flags. The following features are e= nabled +by default for any CPU model when KVM is enabled: + kvmclock + kvm-nopiodelay + kvm-asyncpf + kvm-steal-time + kvm-pv-eoi + kvmclock-stable-bit + +'kvm-msi-ext-dest-id' feature is enabled by default in x2apic mode with sp= lit +irqchip (e.g. "-machine ...,kernel-irqchip=3Dsplit -cpu ...,x2apic"). + +Note: when cpu model 'host' is used, QEMU passes through all KVM PV featur= es +exposed by KVM to the guest. + +3. Existing features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +3.1. kvmclock +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This feature exposes KVM specific PV clocksource to the guest. + +3.2. kvm-nopiodelay +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The guest doesn't need to perform delays on PIO operations. + +3.3. kvm-mmu +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This feature is deprecated. + +3.4. kvm-asyncpf +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables asynchronous page fault mechanism. Note: since Linux-5.10 the feat= ure is +deprecated and not enabled by KVM. Use "kvm-asyncpf-int" instead. + +3.5. kvm-steal-time +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables stolen (when guest vCPU is not running) time accounting. + +3.6. kvm-pv-eoi +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables paravirtualized end-of-interrupt signaling. + +3.7. kvm-pv-unhalt +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables paravirtualized spinlocks support. + +3.8. kvm-pv-tlb-flush +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables paravirtualized TLB flush mechanism. + +3.9. kvm-pv-ipi +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables paravirtualized IPI mechanism. + +3.10. kvm-poll-control +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables host-side polling on HLT control from the guest. + +3.11. kvm-pv-sched-yield +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables paravirtualized sched yield feature. + +3.12. kvm-asyncpf-int +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Enables interrupt based asynchronous page fault mechanism. + +3.13. kvm-msi-ext-dest-id +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +Support 'Extended Destination ID' for external interrupts. The feature all= ows +to use up to 32768 CPUs without IRQ remapping (but other limits may apply = making +the number of supported vCPUs for a given configuration lower). + +3.14. kvmclock-stable-bit +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +Tells the guest that guest visible TSC value can be fully trusted for kvmc= lock +computations and no warps are expected. + +4. Useful links +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Please refer to Documentation/virt/kvm in Linux for additional detail. --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575783243134.03278079109623; Thu, 2 Sep 2021 02:43:03 -0700 (PDT) Received: from localhost ([::1]:55154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjFO-0005EH-2C for importer@patchew.org; Thu, 02 Sep 2021 05:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9c-00036h-KK for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9a-0005WY-Fo for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-46Eufp4ANmq5raRN9ewP0w-1; Thu, 02 Sep 2021 05:35:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 205BC8B5862 for ; Thu, 2 Sep 2021 09:35:40 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64AD517A98; Thu, 2 Sep 2021 09:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v9/ZYQwj0B6fy8iyO01/7uPNuPFArn6nhEp3Z2uEx1Q=; b=Q00d+RDWA5rs+736ZddcBaty7njqMMly8JmAUmc6GTxUEgBUY9fvgogjR7ItRoOmXnGjTj AF3M3PO+/PEL6njnkRxYzVfnA8xQhpJZhoi3yHtG2jqmxw1+ZxB82Vdf9jGstGDr++VzR5 fpfdWvjq2AzCy7mMN8kMgO8c0JrvPg0= X-MC-Unique: 46Eufp4ANmq5raRN9ewP0w-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 3/8] i386: Support KVM_CAP_ENFORCE_PV_FEATURE_CPUID Date: Thu, 2 Sep 2021 11:35:25 +0200 Message-Id: <20210902093530.345756-4-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575783520100001 Content-Type: text/plain; charset="utf-8" By default, KVM allows the guest to use all currently supported PV features even when they were not announced in guest visible CPUIDs. Introduce a new "kvm-pv-enforce-cpuid" flag to limit the supported feature set to the exposed features. The feature is supported by Linux >=3D 5.10 and is not enabled by default in QEMU. Signed-off-by: Vitaly Kuznetsov --- docs/kvm-pv.txt | 13 ++++++++++++- target/i386/cpu.c | 2 ++ target/i386/cpu.h | 3 +++ target/i386/kvm/kvm.c | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/kvm-pv.txt b/docs/kvm-pv.txt index 84ad7fa60f8d..d1aac533feea 100644 --- a/docs/kvm-pv.txt +++ b/docs/kvm-pv.txt @@ -87,6 +87,17 @@ the number of supported vCPUs for a given configuration = lower). Tells the guest that guest visible TSC value can be fully trusted for kvmc= lock computations and no warps are expected. =20 -4. Useful links +4. Supplementary features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +4.1. kvm-pv-enforce-cpuid +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +By default, KVM allows the guest to use all currently supported PV feature= s even +when they were not announced in guest visible CPUIDs. 'kvm-pv-enforce-cpui= d' +feature alters this behavior and limits the supported feature set to the +exposed features only. + + +5. Useful links =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Please refer to Documentation/virt/kvm in Linux for additional detail. diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97e250e8760d..a70038f172d9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6691,6 +6691,8 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), + DEFINE_PROP_BOOL("kvm-pv-enforce-cpuid", X86CPU, kvm_pv_enforce_cpuid, + false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 6c50d3ab4f1d..20273a8069dd 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1782,6 +1782,9 @@ struct X86CPU { /* Stop SMI delivery for migration compatibility with old machines */ bool kvm_no_smi_migration; =20 + /* Forcefully disable KVM PV features not exposed in guest CPUIDs */ + bool kvm_pv_enforce_cpuid; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 500d2e0e686f..49f97f345069 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1629,6 +1629,16 @@ int kvm_arch_init_vcpu(CPUState *cs) =20 cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); =20 + if (cpu->kvm_pv_enforce_cpuid) { + r =3D kvm_vcpu_enable_cap(cs, KVM_CAP_ENFORCE_PV_FEATURE_CPUID, 0,= 1); + if (r < 0) { + fprintf(stderr, + "failed to enable KVM_CAP_ENFORCE_PV_FEATURE_CPUID: %s= ", + strerror(-r)); + abort(); + } + } + for (i =3D 0; i <=3D limit; i++) { if (cpuid_i =3D=3D KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "unsupported level value: 0x%x\n", limit); --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575519976671.424294846345; Thu, 2 Sep 2021 02:38:39 -0700 (PDT) Received: from localhost ([::1]:43854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjB8-0005me-V6 for importer@patchew.org; Thu, 02 Sep 2021 05:38:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9b-000344-M9 for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9Z-0005VZ-Ve for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-KsjKQgHxMpOhDWnymJnp2A-1; Thu, 02 Sep 2021 05:35:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7F07501E3 for ; Thu, 2 Sep 2021 09:35:42 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EF5977BE7; Thu, 2 Sep 2021 09:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NChB+iqSavAeJK3mAcR1LskxwsJVsrC28OzaIoJCGbg=; b=SJMR0gyZT1szvoTj1lomYMBKS2qLhzc6reLDNxSbX+ovC6WIYb+P4EBmFAeN234j/DjQqV BEMyj366nY1rqZ569yBJPTBhykwffg6wq+q2mM0MD72D3CTPv8wKSz/LruA2ZkCIp6DFf3 RSPdkRKPrmXKET4TkZxxe0tn3J+9mkQ= X-MC-Unique: KsjKQgHxMpOhDWnymJnp2A-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 4/8] i386: Support KVM_CAP_HYPERV_ENFORCE_CPUID Date: Thu, 2 Sep 2021 11:35:26 +0200 Message-Id: <20210902093530.345756-5-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575521156100001 Content-Type: text/plain; charset="utf-8" By default, KVM allows the guest to use all currently supported Hyper-V enlightenments when Hyper-V CPUID interface was exposed, regardless of if some features were not announced in guest visible CPUIDs. hv-enforce-cpuid feature alters this behavior and only allows the guest to use exposed Hyper-V enlightenments. The feature is supported by Linux >=3D 5.14 and is not enabled by default in QEMU. Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 17 ++++++++++++++--- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 9 +++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 000638a2fd38..072709a68f47 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -203,8 +203,11 @@ When the option is set to 'on' QEMU will always enable= the feature, regardless of host setup. To keep guests secure, this can only be used in conjunction= with exposing correct vCPU topology and vCPU pinning. =20 -4. Development features -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +4. Supplementary features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +4.1. hv-passthrough +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D In some cases (e.g. during development) it may make sense to use QEMU in 'pass-through' mode and give Windows guests all enlightenments currently supported by KVM. This pass-through mode is enabled by "hv-passthrough" CPU @@ -215,8 +218,16 @@ values from KVM to QEMU. "hv-passthrough" overrides al= l other "hv-*" settings on the command line. Also, enabling this flag effectively prevents migration = as the list of enabled enlightenments may differ between target and destination h= osts. =20 +4.2. hv-enforce-cpuid +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +By default, KVM allows the guest to use all currently supported Hyper-V +enlightenments when Hyper-V CPUID interface was exposed, regardless of if +some features were not announced in guest visible CPUIDs. 'hv-enforce-cpui= d' +feature alters this behavior and only allows the guest to use exposed Hype= r-V +enlightenments. + =20 -4. Useful links +5. Useful links =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Hyper-V Top Level Functional specification and other information: https://github.com/MicrosoftDocs/Virtualization-Documentation diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a70038f172d9..36e1b6ec9c9b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6665,6 +6665,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), + DEFINE_PROP_BOOL("hv-enforce-cpuid", X86CPU, hyperv_enforce_cpuid, fal= se), =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 20273a8069dd..8822bea5c9a4 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1699,6 +1699,7 @@ struct X86CPU { uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; uint32_t hyperv_nested[4]; + bool hyperv_enforce_cpuid; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 49f97f345069..bd0b53416315 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1531,6 +1531,15 @@ static int hyperv_init_vcpu(X86CPU *cpu) cpu->hyperv_nested[0] =3D evmcs_version; } =20 + if (cpu->hyperv_enforce_cpuid) { + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENFORCE_CPUID, 0, 1= ); + if (ret < 0) { + error_report("failed to enable KVM_CAP_HYPERV_ENFORCE_CPUID: %= s", + strerror(-ret)); + return ret; + } + } + return 0; } =20 --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575980794170.38330652741217; Thu, 2 Sep 2021 02:46:20 -0700 (PDT) Received: from localhost ([::1]:38864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjIZ-00052A-Qd for importer@patchew.org; Thu, 02 Sep 2021 05:46:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9c-00036u-Lx for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9a-0005Wb-Iy for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:37:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-KLwXrHBiPKqo0qnIbUc1JA-1; Thu, 02 Sep 2021 05:35:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01547107ACC7 for ; Thu, 2 Sep 2021 09:35:45 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FA7877BE7; Thu, 2 Sep 2021 09:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JeO/dbG8cPFnuPwB0X8XkU+O/2Py6SQwP8cNEH6/1ZI=; b=CgpnSoip6a6X2ez/sb4aZhDHYn/f+Cn4ling0RFaPSH7z87DlEKqf6/4sCkWBbEufIe+mu gOZkUQrkbcyKAkObeHA12kBjzbZKQUMG51yCJ5T+ZcWOaxwxKVH7ZphoP2L2cAdaXwvEHq 0lJ+vr7haNei5XKUSYOQG3HM05G06YE= X-MC-Unique: KLwXrHBiPKqo0qnIbUc1JA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 5/8] i386: Move HV_APIC_ACCESS_RECOMMENDED bit setting to hyperv_fill_cpuids() Date: Thu, 2 Sep 2021 11:35:27 +0200 Message-Id: <20210902093530.345756-6-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575981763100001 Content-Type: text/plain; charset="utf-8" In preparation to enabling Hyper-V + APICv/AVIC move HV_APIC_ACCESS_RECOMMENDED setting out of kvm_hyperv_properties[]: the 'real' feature bit for the vAPIC features is HV_APIC_ACCESS_AVAILABLE, HV_APIC_ACCESS_RECOMMENDED is a recommendation to use the feature which we may not always want to give. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index bd0b53416315..430007c2691a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -821,9 +821,7 @@ static struct { .desc =3D "virtual APIC (hv-vapic)", .flags =3D { {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, - .bits =3D HV_APIC_ACCESS_AVAILABLE}, - {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, - .bits =3D HV_APIC_ACCESS_RECOMMENDED} + .bits =3D HV_APIC_ACCESS_AVAILABLE} } }, [HYPERV_FEAT_TIME] =3D { @@ -1366,6 +1364,7 @@ static int hyperv_fill_cpuids(CPUState *cs, c->ebx |=3D HV_POST_MESSAGES | HV_SIGNAL_EVENTS; } =20 + /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ c->edx |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE; =20 @@ -1374,6 +1373,10 @@ static int hyperv_fill_cpuids(CPUState *cs, c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC)) { + c->eax |=3D HV_APIC_ACCESS_RECOMMENDED; + } + if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { c->eax |=3D HV_NO_NONARCH_CORESHARING; } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575494905794.441104363053; Thu, 2 Sep 2021 02:38:14 -0700 (PDT) Received: from localhost ([::1]:42128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjAj-0004c5-T4 for importer@patchew.org; Thu, 02 Sep 2021 05:38:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj8l-0002IA-Ld for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj8j-0004nA-5o for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-VW83RcGvMb2deELqFWONqA-1; Thu, 02 Sep 2021 05:36:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 220D510054F6 for ; Thu, 2 Sep 2021 09:36:05 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64F227A8CE; Thu, 2 Sep 2021 09:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PaAufKRl/10roDBZGDT3aYle6tHYXiKb9vJckfGoDRs=; b=Y+8n5n236hV4j6mrCVekdkQXPoSYR30daCvYmRWxC2JssRXovW6vQn1i+xrCUcwhAckups I6GAGTs8hsuHDb67uZc+TJY2EIzV+1V2wpePN/AXhqaregItdBwS8m4N+kCIHhreRV+KEA sUi/Xv1zj2h1oa8JjEDMqirt0bUy1fg= X-MC-Unique: VW83RcGvMb2deELqFWONqA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] i386: Implement pseudo 'hv-avic' ('hv-apicv') enlightenment Date: Thu, 2 Sep 2021 11:35:28 +0200 Message-Id: <20210902093530.345756-7-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575495421100001 Content-Type: text/plain; charset="utf-8" The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC enabled. Normally, Hyper-V SynIC disables these hardware features and suggests the guest to use paravirtualized AutoEOI feature. Linux-4.15 gains support for conditional APICv/AVIC disablement, the feature stays on until the guest tries to use AutoEOI feature with SynIC. With 'HV_DEPRECATING_AEOI_RECOMMENDED' bit exposed, modern enough Windows/ Hyper-V versions should follow the recommendation and not use the (unwanted) feature. Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 10 +++++++++- target/i386/cpu.c | 4 ++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 1 + target/i386/kvm/kvm.c | 10 +++++++++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 072709a68f47..cd1ea3bbe9d7 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -189,7 +189,15 @@ enabled. =20 Requires: hv-vpindex, hv-synic, hv-time, hv-stimer =20 -3.17. hv-no-nonarch-coresharing=3Don/off/auto +3.18. hv-avic (hv-apicv) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC ena= bled. +Normally, Hyper-V SynIC disables these hardware feature and suggests the g= uest +to use paravirtualized AutoEOI feature. +Note: enabling this feature on old hardware (without APICv/AVIC support) m= ay +have negative effect on guest's performace. + +3.19. hv-no-nonarch-coresharing=3Don/off/auto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This enlightenment tells guest OS that virtual processors will never share= a physical core unless they are reported as sibling SMT threads. This inform= ation diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 36e1b6ec9c9b..a695e200d409 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6477,6 +6477,8 @@ static void x86_cpu_initfn(Object *obj) object_property_add_alias(obj, "sse4_1", obj, "sse4.1"); object_property_add_alias(obj, "sse4_2", obj, "sse4.2"); =20 + object_property_add_alias(obj, "hv-apicv", obj, "hv-avic"); + if (xcc->model) { x86_cpu_load_model(cpu, xcc->model); } @@ -6662,6 +6664,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_IPI, 0), DEFINE_PROP_BIT64("hv-stimer-direct", X86CPU, hyperv_features, HYPERV_FEAT_STIMER_DIRECT, 0), + DEFINE_PROP_BIT64("hv-avic", X86CPU, hyperv_features, + HYPERV_FEAT_AVIC, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8822bea5c9a4..d22a8d259967 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1038,6 +1038,7 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define HYPERV_FEAT_EVMCS 12 #define HYPERV_FEAT_IPI 13 #define HYPERV_FEAT_STIMER_DIRECT 14 +#define HYPERV_FEAT_AVIC 15 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index 5fbb385cc136..89f81afda7c6 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -66,6 +66,7 @@ #define HV_APIC_ACCESS_RECOMMENDED (1u << 3) #define HV_SYSTEM_RESET_RECOMMENDED (1u << 4) #define HV_RELAXED_TIMING_RECOMMENDED (1u << 5) +#define HV_DEPRECATING_AEOI_RECOMMENDED (1u << 9) #define HV_CLUSTER_IPI_RECOMMENDED (1u << 10) #define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11) #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 430007c2691a..0f3cb61a9cfd 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -924,6 +924,13 @@ static struct { }, .dependencies =3D BIT(HYPERV_FEAT_STIMER) }, + [HYPERV_FEAT_AVIC] =3D { + .desc =3D "AVIC/APICv support (hv-avic/hv-apicv)", + .flags =3D { + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, + .bits =3D HV_DEPRECATING_AEOI_RECOMMENDED} + } + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, @@ -1373,7 +1380,8 @@ static int hyperv_fill_cpuids(CPUState *cs, c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC)) { + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC) && + !hyperv_feat_enabled(cpu, HYPERV_FEAT_AVIC)) { c->eax |=3D HV_APIC_ACCESS_RECOMMENDED; } =20 --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575506575525.1498539244533; Thu, 2 Sep 2021 02:38:26 -0700 (PDT) Received: from localhost ([::1]:43128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjAv-0005Hk-Id for importer@patchew.org; Thu, 02 Sep 2021 05:38:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9H-0002cI-6k for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9E-0005Cc-Fn for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-y7ySyiUeNVyZWhApI97z2Q-1; Thu, 02 Sep 2021 05:36:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DE5C819042 for ; Thu, 2 Sep 2021 09:36:23 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 813E783BFA; Thu, 2 Sep 2021 09:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+4med4o5e0PjbTHwYVDzYIj4ycjnS9ptWt5VFOW8Vk=; b=DWvvlW2DKujSPL/TjlO6B/WLqctfesBp5dHAHehix3WyOub6ZoAs/80dKrC5vEubX6BH+i LDD+LYVN5LnArTiC9gUakAbLv/ThrWNslvJAjLdk/FdaGCLajj1V8cxQawzIBSG7KbY9gY p7tpFOdQs8YzcIyfCfQ5brsiKl2M4VI= X-MC-Unique: y7ySyiUeNVyZWhApI97z2Q-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] i386: Make Hyper-V version id configurable Date: Thu, 2 Sep 2021 11:35:29 +0200 Message-Id: <20210902093530.345756-8-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575508309100001 Content-Type: text/plain; charset="utf-8" Currently, we hardcode Hyper-V version id (CPUID 0x40000002) to WS2008R2 and it is known that certain tools in Windows check this. It seems useful to provide some flexibility by making it possible to change this info at will. CPUID information is defined in TLFS as: EAX: Build Number EBX Bits 31-16: Major Version Bits 15-0: Minor Version ECX Service Pack EDX Bits 31-24: Service Branch Bits 23-0: Service Number Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 14 ++++++++++++++ target/i386/cpu.c | 15 +++++++++++---- target/i386/cpu.h | 7 ++++++- target/i386/kvm/kvm.c | 26 ++++++++++++++++---------- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index cd1ea3bbe9d7..7803495468b7 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -211,6 +211,20 @@ When the option is set to 'on' QEMU will always enable= the feature, regardless of host setup. To keep guests secure, this can only be used in conjunction= with exposing correct vCPU topology and vCPU pinning. =20 +3.20. hv-version-id-{build,major,minor,spack,sbranch,snumber} +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX fr= om the +default (WS2008R2). +- hv-version-id-build sets 'Build Number' (32 bits) +- hv-version-id-major sets 'Major Version' (16 bits) +- hv-version-id-minor sets 'Minor Version' (16 bits) +- hv-version-id-spack sets 'Service Pack' (32 bits) +- hv-version-id-sbranch sets 'Service Branch' (8 bits) +- hv-version-id-snumber sets 'Service Number' (24 bits) + +Note: hv-version-id-* are not enlightenments and thus don't enable Hyper-V +identification when specified without any other enlightenments. + 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a695e200d409..5766e720093d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6093,10 +6093,6 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu) cpu->hyperv_interface_id[2] =3D 0; cpu->hyperv_interface_id[3] =3D 0; =20 - /* Hypervisor system identity */ - cpu->hyperv_version_id[0] =3D 0x00001bbc; - cpu->hyperv_version_id[1] =3D 0x00060001; - /* Hypervisor implementation limits */ cpu->hyperv_limits[0] =3D 64; cpu->hyperv_limits[1] =3D 0; @@ -6671,6 +6667,17 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), DEFINE_PROP_BOOL("hv-enforce-cpuid", X86CPU, hyperv_enforce_cpuid, fal= se), =20 + /* WS2008R2 identify by default */ + DEFINE_PROP_UINT32("hv-version-id-build", X86CPU, hyperv_ver_id_build, + 0x1bbc), + DEFINE_PROP_UINT16("hv-version-id-major", X86CPU, hyperv_ver_id_major, + 0x0006), + DEFINE_PROP_UINT16("hv-version-id-minor", X86CPU, hyperv_ver_id_minor, + 0x0001), + DEFINE_PROP_UINT32("hv-version-id-spack", X86CPU, hyperv_ver_id_sp, 0), + DEFINE_PROP_UINT8("hv-version-id-sbranch", X86CPU, hyperv_ver_id_sb, 0= ), + DEFINE_PROP_UINT32("hv-version-id-snumber", X86CPU, hyperv_ver_id_sn, = 0), + DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), DEFINE_PROP_BOOL("x-force-features", X86CPU, force_features, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d22a8d259967..5c2bf1079745 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1697,10 +1697,15 @@ struct X86CPU { OnOffAuto hyperv_no_nonarch_cs; uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; - uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; uint32_t hyperv_nested[4]; bool hyperv_enforce_cpuid; + uint32_t hyperv_ver_id_build; + uint16_t hyperv_ver_id_major; + uint16_t hyperv_ver_id_minor; + uint32_t hyperv_ver_id_sp; + uint8_t hyperv_ver_id_sb; + uint32_t hyperv_ver_id_sn; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 0f3cb61a9cfd..918472905e73 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1258,14 +1258,18 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error = **errp) cpu->hyperv_interface_id[3] =3D hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_EDX); =20 - cpu->hyperv_version_id[0] =3D + cpu->hyperv_ver_id_build =3D hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EAX); - cpu->hyperv_version_id[1] =3D - hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX); - cpu->hyperv_version_id[2] =3D + cpu->hyperv_ver_id_major =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX) >> 16; + cpu->hyperv_ver_id_minor =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX) & 0xffff; + cpu->hyperv_ver_id_sp =3D hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_ECX); - cpu->hyperv_version_id[3] =3D - hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX); + cpu->hyperv_ver_id_sb =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX) >> 24; + cpu->hyperv_ver_id_sn =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX) & 0xffffff; =20 cpu->hv_max_vps =3D hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMIT= S, R_EAX); @@ -1351,10 +1355,12 @@ static int hyperv_fill_cpuids(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VERSION; - c->eax =3D cpu->hyperv_version_id[0]; - c->ebx =3D cpu->hyperv_version_id[1]; - c->ecx =3D cpu->hyperv_version_id[2]; - c->edx =3D cpu->hyperv_version_id[3]; + c->eax =3D cpu->hyperv_ver_id_build; + c->ebx =3D (uint32_t)cpu->hyperv_ver_id_major << 16 | + cpu->hyperv_ver_id_minor; + c->ecx =3D cpu->hyperv_ver_id_sp; + c->edx =3D (uint32_t)cpu->hyperv_ver_id_sb << 24 | + (cpu->hyperv_ver_id_sn & 0xffffff); =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_FEATURES; --=20 2.31.1 From nobody Mon Apr 29 01:25:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630575708978269.61331971161405; Thu, 2 Sep 2021 02:41:48 -0700 (PDT) Received: from localhost ([::1]:50696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLjEB-00021p-R4 for importer@patchew.org; Thu, 02 Sep 2021 05:41:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9L-0002e2-ID for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLj9K-0005Hr-2k for qemu-devel@nongnu.org; Thu, 02 Sep 2021 05:36:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-9OQot2h6PwWStiTYQJu-uA-1; Thu, 02 Sep 2021 05:36:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A49A2102321E for ; Thu, 2 Sep 2021 09:36:25 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0D58972FB; Thu, 2 Sep 2021 09:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630575405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MGXT4bpBRhawVmYk2DOx8tX2KL+m1MBi/gOw21IPETY=; b=a0Zuk/Jf/83rQ7Gt1CO7579AQJNzXZTrsG6snIms2xfT2VDOF2QkTPq3NzAjP7R1uBo9qj aAjpwnMAibEf944V/ivNpoAbEsjxZO11mB2dvu2aNsnVrKopezOjN8EOkAneQLJUKYuOtI nTXYxestd8FrIrfGfItfxrKoggyuy88= X-MC-Unique: 9OQot2h6PwWStiTYQJu-uA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH v2 8/8] i386: Change the default Hyper-V version to match WS2016 Date: Thu, 2 Sep 2021 11:35:30 +0200 Message-Id: <20210902093530.345756-9-vkuznets@redhat.com> In-Reply-To: <20210902093530.345756-1-vkuznets@redhat.com> References: <20210902093530.345756-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Marcelo Tosatti , Maxim Levitsky , Vadim Rozenfeld , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630575710200100001 Content-Type: text/plain; charset="utf-8" KVM implements some Hyper-V 2016 functions so providing WS2008R2 version is somewhat incorrect. While generally guests shouldn't care about it and always check feature bits, it is known that some tools in Windows actually check version info. For compatibility reasons make the change for 7.2 machine types only. Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 2 +- hw/i386/pc.c | 6 +++++- target/i386/cpu.c | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 7803495468b7..5d99fd9a72b8 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -214,7 +214,7 @@ exposing correct vCPU topology and vCPU pinning. 3.20. hv-version-id-{build,major,minor,spack,sbranch,snumber} =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX fr= om the -default (WS2008R2). +default (WS2016). - hv-version-id-build sets 'Build Number' (32 bits) - hv-version-id-major sets 'Major Version' (16 bits) - hv-version-id-minor sets 'Minor Version' (16 bits) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 1276bfeee456..b2e4eef9d211 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -93,7 +93,11 @@ #include "trace.h" #include CONFIG_DEVICES =20 -GlobalProperty pc_compat_6_1[] =3D {}; +GlobalProperty pc_compat_6_1[] =3D { + { TYPE_X86_CPU, "hv-version-id-build", "0x1bbc" }, + { TYPE_X86_CPU, "hv-version-id-major", "0x0006" }, + { TYPE_X86_CPU, "hv-version-id-minor", "0x0001" }, +}; const size_t pc_compat_6_1_len =3D G_N_ELEMENTS(pc_compat_6_1); =20 GlobalProperty pc_compat_6_0[] =3D { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5766e720093d..569840deaf93 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6669,11 +6669,11 @@ static Property x86_cpu_properties[] =3D { =20 /* WS2008R2 identify by default */ DEFINE_PROP_UINT32("hv-version-id-build", X86CPU, hyperv_ver_id_build, - 0x1bbc), + 0x3839), DEFINE_PROP_UINT16("hv-version-id-major", X86CPU, hyperv_ver_id_major, - 0x0006), + 0x000A), DEFINE_PROP_UINT16("hv-version-id-minor", X86CPU, hyperv_ver_id_minor, - 0x0001), + 0x0000), DEFINE_PROP_UINT32("hv-version-id-spack", X86CPU, hyperv_ver_id_sp, 0), DEFINE_PROP_UINT8("hv-version-id-sbranch", X86CPU, hyperv_ver_id_sb, 0= ), DEFINE_PROP_UINT32("hv-version-id-snumber", X86CPU, hyperv_ver_id_sn, = 0), --=20 2.31.1