From nobody Tue Nov 4 18:42:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530339525954487.4285277335633; Fri, 29 Jun 2018 23:18:45 -0700 (PDT) Received: from localhost ([::1]:45701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ9DQ-00022q-Sl for importer@patchew.org; Sat, 30 Jun 2018 02:18:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ95t-0003yJ-KS for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:10:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZ95o-0001cU-Uy for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:10:49 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:55236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZ95o-0001bV-Mo for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:10:44 -0400 Received: by mail-wm0-x235.google.com with SMTP id i139-v6so4085130wmf.4 for ; Fri, 29 Jun 2018 23:10:44 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 24-v6sm563454wrz.94.2018.06.29.23.10.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 23:10:42 -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=tx1tiV+3OJWMuc2iLZHcW5Gg4tsz2NNHw88L4AhFUL0=; b=hTmmWwwzYdxuXPM5sChqqxuqRkwPTurx3U3jmFgfbi3e276aHXb9//3Wfk0nB/vlDX PmTVO0ZnX2/vOZLK91speZsjneqA8a+rwd0Kyzraiu4ZI2hVSrpDHQPIdVBeDBoRyVTf mTqx7BBxor/Jl5kvRm6Go/HtwcD4xxJvWB0OmF3uBXp9844n7QI6q64u9lmjGb2Keq/u DDeIGePgecIiVDoTpmxtmMlCJP9gokiZxjP67T5CELXT8Qhz9sGixNndpNoAZ/7uEMay 7RzlXsRIaKfK9We1dW3yBoALJ5g58TWIWLPV+dlyhMF9drz6BUOXlSq2uHlEGfke4YC7 UrQg== 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=tx1tiV+3OJWMuc2iLZHcW5Gg4tsz2NNHw88L4AhFUL0=; b=iuZEHuAniNaaRfh4Xdfa7hlv8/osgMVEvd4EYYYuD5eOJvuvLINSsN74rsQF+73njd R7uKUkT/+aydlC+YVZ8xdsAEY2wqc7IQcsLYjBfcc1f2NjXJ3ndjJTG3yjR3NbzM69tQ iMXtg/bbE8bSMg/jyHIxcjaXntK58s5SBPkPMU+bVCv+pvcgpZoo6Ae6gcCSLxXJb9/c YAwlM9nau3aoYJr5kAlB4yOrNBHffFTHLTwK5GNaSBAmOdG1tlXWepAcSrbUv7s+V2Zx LWVuvmwNYHx5wV6rm/7kM1HkcCm7XRk1hAq9/4w8X0ty/Y4CTAgIL9Ba8MFLscZoQGAx x56Q== X-Gm-Message-State: APt69E0kD356w1ZEyLb8edMkpkrfyNDK9aWiW3ZwBUqR/DtKCiKdIcOH mN/o1t0nTRuYZLjKfUFon3MUICpL X-Google-Smtp-Source: AAOMgpc+UcJaNg2zs67CaboOKLui/3LBrxUe8aLAK/rUuCuY4KrDVrGxGgB1HLXovCXPMOtdJS9EJg== X-Received: by 2002:a1c:c241:: with SMTP id s62-v6mr3669491wmf.146.1530339043466; Fri, 29 Jun 2018 23:10:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 30 Jun 2018 08:09:54 +0200 Message-Id: <20180630061040.6018-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180630061040.6018-1-pbonzini@redhat.com> References: <20180630061040.6018-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::235 Subject: [Qemu-devel] [PULL 01/47] i386/kvm: add support for Hyper-V TLB flush 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Add support for Hyper-V TLB flush which recently got added to KVM. Just like regular Hyper-V we announce HV_EX_PROCESSOR_MASKS_RECOMMENDED regardless of how many vCPUs we have. Windows is 'smart' and uses less expensive non-EX Hypercall whenever possible (when it wants to flush TLB for all vCPUs or the maximum vCPU index in the vCPU set requires flushing is less than 64). Signed-off-by: Vitaly Kuznetsov Message-Id: <20180610184927.19309-1-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 15 ++++++++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1e6a7d0..d57f310 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5415,6 +5415,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("hv-stimer", X86CPU, hyperv_stimer, false), DEFINE_PROP_BOOL("hv-frequencies", X86CPU, hyperv_frequencies, false), DEFINE_PROP_BOOL("hv-reenlightenment", X86CPU, hyperv_reenlightenment,= false), + DEFINE_PROP_BOOL("hv-tlbflush", X86CPU, hyperv_tlbflush, 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 8eaefee..8b1ddfe 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1367,6 +1367,7 @@ struct X86CPU { bool hyperv_stimer; bool hyperv_frequencies; bool hyperv_reenlightenment; + bool hyperv_tlbflush; bool check_cpuid; bool enforce_cpuid; bool expose_kvm; diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index 93352eb..d6d5a79 100644 --- a/target/i386/hyperv-proto.h +++ b/target/i386/hyperv-proto.h @@ -58,6 +58,7 @@ #define HV_APIC_ACCESS_RECOMMENDED (1u << 3) #define HV_SYSTEM_RESET_RECOMMENDED (1u << 4) #define HV_RELAXED_TIMING_RECOMMENDED (1u << 5) +#define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11) =20 /* * Basic virtualized MSRs diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 032f0ad..ebb2d23 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -601,7 +601,8 @@ static bool hyperv_enabled(X86CPU *cpu) cpu->hyperv_runtime || cpu->hyperv_synic || cpu->hyperv_stimer || - cpu->hyperv_reenlightenment); + cpu->hyperv_reenlightenment || + cpu->hyperv_tlbflush); } =20 static int kvm_arch_set_tsc_khz(CPUState *cs) @@ -839,6 +840,18 @@ int kvm_arch_init_vcpu(CPUState *cs) if (cpu->hyperv_vapic) { c->eax |=3D HV_APIC_ACCESS_RECOMMENDED; } + if (cpu->hyperv_tlbflush) { + if (kvm_check_extension(cs->kvm_state, + KVM_CAP_HYPERV_TLBFLUSH) <=3D 0) { + fprintf(stderr, "Hyper-V TLB flush support " + "(requested by 'hv-tlbflush' cpu flag) " + " is not supported by kernel\n"); + return -ENOSYS; + } + c->eax |=3D HV_REMOTE_TLB_FLUSH_RECOMMENDED; + c->eax |=3D HV_EX_PROCESSOR_MASKS_RECOMMENDED; + } + c->ebx =3D cpu->hyperv_spinlock_attempts; =20 c =3D &cpuid_data.entries[cpuid_i++]; --=20 1.8.3.1