From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F9C0C43441 for ; Tue, 13 Nov 2018 15:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61A3F2087A for ; Tue, 13 Nov 2018 15:22:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61A3F2087A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388080AbeKNBVM (ORCPT ); Tue, 13 Nov 2018 20:21:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732028AbeKNBVM (ORCPT ); Tue, 13 Nov 2018 20:21:12 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD0B0307DAAC; Tue, 13 Nov 2018 15:22:36 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.34.244.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679661001938; Tue, 13 Nov 2018 15:22:32 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org, Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , x86@kernel.org, "Michael Kelley (EOSG)" Subject: [QEMU PATCH] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers Date: Tue, 13 Nov 2018 16:22:17 +0100 Message-Id: <20181113152218.22049-5-vkuznets@redhat.com> In-Reply-To: <20181113152218.22049-1-vkuznets@redhat.com> References: <20181113152218.22049-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 13 Nov 2018 15:22:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Vitaly Kuznetsov --- linux-headers/linux/kvm.h | 1 + target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 11 +++++++++++ 5 files changed, 15 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index f11a7eb49c..43fb240b60 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -965,6 +965,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_COALESCED_PIO 162 #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 #define KVM_CAP_EXCEPTION_PAYLOAD 164 +#define KVM_CAP_HYPERV_STIMER_DIRECT 166 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/target/i386/cpu.c b/target/i386/cpu.c index af7e9f09cc..cd42fb81dd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5733,6 +5733,7 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_BOOL("hv-reenlightenment", X86CPU, hyperv_reenlightenment, false), DEFINE_PROP_BOOL("hv-tlbflush", X86CPU, hyperv_tlbflush, false), DEFINE_PROP_BOOL("hv-ipi", X86CPU, hyperv_ipi, false), + DEFINE_PROP_BOOL("hv-stimer-direct", X86CPU, hyperv_stimer_direct, false), DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index ad0e0b4534..a3d7cac8be 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1392,6 +1392,7 @@ struct X86CPU { bool hyperv_reenlightenment; bool hyperv_tlbflush; bool hyperv_ipi; + bool hyperv_stimer_direct; bool check_cpuid; bool enforce_cpuid; bool expose_kvm; diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index 8c572cd7c2..4543112cf5 100644 --- a/target/i386/hyperv-proto.h +++ b/target/i386/hyperv-proto.h @@ -48,6 +48,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 796a049a0d..f12321e0f7 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -797,6 +797,17 @@ static int hyperv_handle_properties(CPUState *cs) } env->features[FEAT_HYPERV_EAX] |= HV_SYNTIMERS_AVAILABLE; } + if (cpu->hyperv_stimer_direct) { + if (kvm_check_extension(cs->kvm_state, + KVM_CAP_HYPERV_STIMER_DIRECT) <= 0) { + fprintf(stderr, "Hyper-V timers direct mode " + "(requested by 'hv-stimer-direct' cpu flag) " + " is not supported by kernel\n"); + return -ENOSYS; + } + env->features[FEAT_HYPERV_EDX] |= HV_STIMER_DIRECT_MODE_AVAILABLE; + } + return 0; } -- 2.17.2