From nobody Sun Sep 28 00:33:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1561083340; cv=none; d=zoho.com; s=zohoarc; b=QZ8wpDVb/35025K+H06W+AQz3dtVtR3/WXGcEar04tLHvIR7dOodZYKgRtwmCYG02iuZJHP7/jy0IBX/mbioMfFu9cdME/f/si85/XrvwHvuy+wQGVor+eVxKq5McXHP0ZBewVmupLoVTaYIPfG1BGYKG56XsGhTgC3qx/R9VHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561083340; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rRyKyx29XW5YjtibDxKmJQDBBERS19STiC5lOwnEoTA=; b=csRHRf7KsZOUsMq1tMwU3BSWnZjx+02XuG25tLqUhsGPIrdxtBST/P2RZ/oCnS+x9jaTw44+wRtf1QTcYjD5k5ErpBhEgDqhXYPJLuNqPzl/sdfVvVpTqIkQ0oGmgYkPFnF/QUGvp/JSjxIrIOcWH2UslrB7EKA6S9i39VaWfeA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15610833402431013.9078998885399; Thu, 20 Jun 2019 19:15:40 -0700 (PDT) Received: from localhost ([::1]:54184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he95R-0004Ko-EY for importer@patchew.org; Thu, 20 Jun 2019 22:15:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41286) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8a6-0006f0-GQ for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he8a3-0006fV-JY for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:10 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1he8a2-0006Ix-SR for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:07 -0400 Received: by mail-wr1-x442.google.com with SMTP id f9so4835964wre.12 for ; Thu, 20 Jun 2019 18:42:45 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d1sm1123125wru.41.2019.06.20.18.42.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 18:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rRyKyx29XW5YjtibDxKmJQDBBERS19STiC5lOwnEoTA=; b=W073YwQ3zWFFCFrtq23gIdHcBk0rkE6/cVfxqBC5oxlc2yLnr7T1tMU9nXw7GK7U4M /XVTCNzbrd+7Pq76eoitdr/0ERiJr09i4V1od1Lc0IVAvc35jl3fiajq9/9/FzbR+dfU mpDZhdPM8d7wC9SVLoMe5nIiVKTJLcR7JHgmAdYT6szXYvVive/Ba2zjGl7xiqCy6qYu dlur63JwRMRwD+fqQLrq2Pm/cfDaxwVjwuoT76nUB+q8gJ9mmXvK8OcMMrlUG2+g0OtW q4agdzNH8TtES+AHCcuk6W8xvAu64NNFbAmOYgvF9PkA1+raVAtkiiRwt/+yd9r9PsT3 Tarw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rRyKyx29XW5YjtibDxKmJQDBBERS19STiC5lOwnEoTA=; b=l9bDvhO5mabU8UBn0JDISgqcj45nsh5ASyaO07df8cXtqxLoZeaDkC0nEFHesP5rhF W6KDyWkA7JZYOlekPHFmGhqYGyMKzlBxFRh2NXtGeGDdJdn7Jysika/7MqKtcl+tterR gjQ2yX3M02pNUZop0T7e8bP5PmlAxwM/U+sgycXKgdzCg4nb9WBMdrEk4p5XY3mEu12/ hwAFasw74L+WlB6AvUZucINHU1R2ItHL3emwipn9gtCJ32c9iCDZu/C1y4BZ1LBBxJxr fMHP6QN/PiK/Hp0gWJXg7mTTJVd++VBQuyrGOyDE50pjLOokLU9y+WHN4ijpokHUJzWF 4U+Q== X-Gm-Message-State: APjAAAXNhtM8fmU/Chm3xo16z/1xaRreb2v/eQycXHeZQDnZcJiPPcmn 2Cq8MHj2bBjWb31dFALigwbsyy3Z X-Google-Smtp-Source: APXvYqzgtimzlaBsjiVnxXxqwtOSh1Qi3lDDH49el2FQTWy6989CDpzZsyX7CK99kWVIdL9rFCDgBg== X-Received: by 2002:adf:f544:: with SMTP id j4mr22541344wrp.150.1561081364292; Thu, 20 Jun 2019 18:42:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2019 03:42:16 +0200 Message-Id: <1561081350-3723-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> References: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 11/25] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov 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 Message-Id: <20190517141924.19024-10-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 10 ++++++++++ target/i386/cpu.c | 2 ++ target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 9 +++++++++ 5 files changed, 23 insertions(+) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index beadb2d..8fdf25c 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -174,6 +174,16 @@ without the feature to find out if enabling it is bene= ficial. =20 Requires: hv-vapic =20 +3.17. hv-stimer-direct +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Hyper-V specification allows synthetic timer operation in two modes: "clas= sic", +when expiration event is delivered as SynIC message and "direct", when the= event +is delivered via normal interrupt. It is known that nested Hyper-V can only +use synthetic timers in direct mode and thus 'hv-stimer-direct' needs to be +enabled. + +Requires: hv-vpindex, hv-synic, hv-time, hv-stimer + =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 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e07996c..7beb8ab 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5883,6 +5883,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_EVMCS, 0), DEFINE_PROP_BIT64("hv-ipi", X86CPU, hyperv_features, HYPERV_FEAT_IPI, 0), + DEFINE_PROP_BIT64("hv-stimer-direct", X86CPU, hyperv_features, + HYPERV_FEAT_STIMER_DIRECT, 0), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 86edbf5..7470acf 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -749,6 +749,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define HYPERV_FEAT_TLBFLUSH 11 #define HYPERV_FEAT_EVMCS 12 #define HYPERV_FEAT_IPI 13 +#define HYPERV_FEAT_STIMER_DIRECT 14 =20 #ifndef HYPERV_SPINLOCK_NEVER_RETRY #define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index c0272b3..cffac10 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) =20 /* * HV_CPUID_ENLIGHTMENT_INFO.EAX bits diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 86de510..a323b1f 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -802,6 +802,14 @@ static struct { }, .dependencies =3D BIT(HYPERV_FEAT_VPINDEX) }, + [HYPERV_FEAT_STIMER_DIRECT] =3D { + .desc =3D "direct mode synthetic timers (hv-stimer-direct)", + .flags =3D { + {.fw =3D FEAT_HYPERV_EDX, + .bits =3D HV_STIMER_DIRECT_MODE_AVAILABLE} + }, + .dependencies =3D BIT(HYPERV_FEAT_STIMER) + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max) @@ -1124,6 +1132,7 @@ static int hyperv_handle_properties(CPUState *cs, r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TLBFLUSH); r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_EVMCS); r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_IPI); + r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER_DIRECT); =20 /* Additional dependencies not covered by kvm_hyperv_properties[] */ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) && --=20 1.8.3.1