From patchwork Fri Jan 25 11:41:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 10781289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 597A16C2 for ; Fri, 25 Jan 2019 11:55:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 465152E6B9 for ; Fri, 25 Jan 2019 11:55:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A5E12E6E7; Fri, 25 Jan 2019 11:55:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C612E2E6B9 for ; Fri, 25 Jan 2019 11:55:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:43150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn04j-00043I-Se for patchwork-qemu-devel@patchwork.kernel.org; Fri, 25 Jan 2019 06:55:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmzsM-00039o-32 for qemu-devel@nongnu.org; Fri, 25 Jan 2019 06:42:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmzsI-0007Qt-6S for qemu-devel@nongnu.org; Fri, 25 Jan 2019 06:42:20 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gmzsG-0007Po-H2 for qemu-devel@nongnu.org; Fri, 25 Jan 2019 06:42:18 -0500 Received: by mail-wr1-f65.google.com with SMTP id z5so9920002wrt.11 for ; Fri, 25 Jan 2019 03:42:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aFS+kz68Od30dwca2hv13J4E4UtuWamMqkN+odCkpZE=; b=g2LsupAEMrq61K5MUUQpVAirwq1HYXjnLWjvMvF8iAkAdBqcYZ+6ccQGpvMEETWctJ 9pKlAcflWOn6VBX6tJ66har1CEnOyL3XWzqoHCuBkEabTxRnJKXh0grJgVimWp/KAP3m WWnEWAo8viSo/kkvN/U1cvh+NlWzWkfqrSL8OGHJemxVRINpDiKk5pjrjLt7cZCE8Omi +hKffHFfdtNe46X31ArXu7UYlRI7sGDJLBANd+Ied4vpG3avgLg55UBS6ZAYg3MpuAvo RBE9ZUPEPSwwkBZctNLGah8/DjZDFoVtVnnzIvY7H+q5hhgbefQVMamTjvYzzyobP3HA Rokg== X-Gm-Message-State: AJcUukdWVFYB+ok04IAz9mToqLbWQe5Zl4K0BzLuHNBhLTvKXDST0KN0 WhUjK3K02LeGAyyMGCdBfu5fJmqQepwv7w== X-Google-Smtp-Source: ALg8bN4khFJ2igTJAg5RKTWBtL80xQIx4m+12D0pLCBmtQrF/yLe5qduZIwsfJmqkJQhbPvsQjC0YA== X-Received: by 2002:adf:f091:: with SMTP id n17mr11058811wro.292.1548416535303; Fri, 25 Jan 2019 03:42:15 -0800 (PST) Received: from vitty.brq.redhat.com.cz ([147.229.117.36]) by smtp.gmail.com with ESMTPSA id x81sm64944415wmg.17.2019.01.25.03.42.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jan 2019 03:42:14 -0800 (PST) From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 12:41:55 +0100 Message-Id: <20190125114155.32062-9-vkuznets@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125114155.32062-1-vkuznets@redhat.com> References: <20190125114155.32062-1-vkuznets@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.65 Subject: [Qemu-devel] [PATCH RFC 8/8] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Marcelo Tosatti , Roman Kagan , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hyper-V on KVM can only use Synthetic timers with Direct Mode (opting for an interrupt instead of VMBus message). This new capability is only announced in KVM_GET_SUPPORTED_HV_CPUID. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 15 +++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b776be5223..986cbe88dd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5771,6 +5771,7 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_BOOL("hv-tlbflush", X86CPU, hyperv_tlbflush, false), DEFINE_PROP_BOOL("hv-evmcs", X86CPU, hyperv_evmcs, false), DEFINE_PROP_BOOL("hv-ipi", X86CPU, hyperv_ipi, false), + DEFINE_PROP_BOOL("hv-stimer-direct", X86CPU, hyperv_stimer_direct, false), DEFINE_PROP_BOOL("hv-all", X86CPU, hyperv_all, false), 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 9b5c2715cc..9716cd89d7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1397,6 +1397,7 @@ struct X86CPU { bool hyperv_tlbflush; bool hyperv_evmcs; bool hyperv_ipi; + bool hyperv_stimer_direct; bool hyperv_all; bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index c0272b3a01..cffac10b45 100644 --- a/target/i386/hyperv-proto.h +++ b/target/i386/hyperv-proto.h @@ -49,6 +49,7 @@ #define HV_GUEST_IDLE_STATE_AVAILABLE (1u << 5) #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) #define HV_GUEST_CRASH_MSR_AVAILABLE (1u << 10) +#define HV_STIMER_DIRECT_MODE_AVAILABLE (1u << 19) /* * HV_CPUID_ENLIGHTMENT_INFO.EAX bits diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 14d74ca9c7..e7d0f4d3fe 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -648,6 +648,7 @@ static bool hyperv_enabled(X86CPU *cpu) cpu->hyperv_reenlightenment || cpu->hyperv_tlbflush || cpu->hyperv_ipi || + cpu->hyperv_stimer_direct || cpu->hyperv_all); } @@ -823,6 +824,15 @@ static struct { {0} } }, + { + .name = "hv-stimer-direct", + .desc = "direct mode timers", + .flags = { + {.fw = FEAT_HYPERV_EDX, + .bits = HV_STIMER_DIRECT_MODE_AVAILABLE}, + {0} + } + }, }; static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max) @@ -1169,6 +1179,8 @@ static int hyperv_handle_properties(CPUState *cs, r |= hv_cpuid_check_and_set(cs, cpuid, "hv-tlbflush", &cpu->hyperv_tlbflush); r |= hv_cpuid_check_and_set(cs, cpuid, "hv-ipi", &cpu->hyperv_ipi); + r |= hv_cpuid_check_and_set(cs, cpuid, "hv-stimer-direct", + &cpu->hyperv_stimer_direct); /* Dependencies */ if (cpu->hyperv_synic && !cpu->hyperv_synic_kvm_only && @@ -1189,6 +1201,9 @@ static int hyperv_handle_properties(CPUState *cs, if (cpu->hyperv_ipi && !cpu->hyperv_vpindex) { r |= hv_report_missing_dep(cpu, "hv-ipi", "hv-vpindex"); } + if (cpu->hyperv_stimer_direct && !cpu->hyperv_stimer) { + r |= hv_report_missing_dep(cpu, "hv-stimer-direct", "hv-stimer"); + } /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ env->features[FEAT_HYPERV_EDX] |= HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE;