Received: by 10.192.165.156 with SMTP id m28csp570908imm; Mon, 16 Apr 2018 05:23:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BXgDL5GxxC4V/6Ld+kJUf+m99A3B5Bkq3Nb+SbvVxUJw+q3O7x4UXFrFIDWnWG4qyztGl X-Received: by 10.101.65.67 with SMTP id x3mr123537pgp.425.1523881420984; Mon, 16 Apr 2018 05:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523881420; cv=none; d=google.com; s=arc-20160816; b=zBQ7aqGmeLr+JfBBrxPRkceufwDNtoPyhIMBU8LQXnmCKPO2jPdRUxzNvAeWtXhAp9 7Ka2SU6r8GferXVJ0IqzSZT2vnZDIMZji4pIIkO5d190/+lFBIuXYb3jsc+F2YTe0/Xw 2IdhxC4BVhrV3RS5BLdmLMgMNVvdWEghhcefDGRpxN4VIRVyK0ucprdwdJXSf8+Pl3/Y JMDHFtCQ6hrItXtZO1THfo5qlrlQuhitaMJ+FjWjOGUoxQsiPxqbTmX+AiMRkCR2Hzlv RGNxsPl5fMKUhhWpG+vrcjmmeZoTQqxuqeFRVZiba7q5ubpUB7pd/OfnE3c6Mx32pagQ U92g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VHEjVIrfDHlisZoNJE4XdP8dZvWMem7Vja4vyaEh1RU=; b=NSIixMPf52ZnSCV4CKlN5ms6EYaI0DHTM93ncxhhkcTo1cJ50+kL+F0wn+y5HLW+Wv xAS4LQHocxRN9ypjg34a+vIC3JZ1TOAc/idPiwvj/E3MoLZXW0V8Q3OvMupGs4nHUzVE BZpTfYcKbr9L/mkjorlsdQbj4reyEgl2xjmFnwrxAQqm7X17r/WV/BrrT1vAnBkHaW5V fyQ6XIDTX4pQLFf+JvR5FSQC/CiH2K1wak0OxxcEvS/v9DdsOj/PYU138cllQXxSwjhY vp7lAlm2cxFqJyTvTdXN0Rz25ds9CG5WK0f4htogVzvayJSQCZD5ohKT3M9QKPM69AtZ NUMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t15si10750503pfa.170.2018.04.16.05.23.27; Mon, 16 Apr 2018 05:23:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045AbeDPLIL (ORCPT + 99 others); Mon, 16 Apr 2018 07:08:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48368 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752725AbeDPLIJ (ORCPT ); Mon, 16 Apr 2018 07:08:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55DCE8DC48; Mon, 16 Apr 2018 11:08:09 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73383111DCF1; Mon, 16 Apr 2018 11:08:07 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , linux-kernel@vger.kernel.org Subject: [PATCH v3 0/6] KVM: x86: hyperv: PV TLB flush for Windows guests Date: Mon, 16 Apr 2018 13:08:00 +0200 Message-Id: <20180416110806.4896-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 11:08:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 11:08:09 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v2: - Fixed a sparse warning in PATCH1 [kbuild test robot] Description: This is both a new feature and a bugfix. Bugfix description: It was found that Windows 2016 guests on KVM crash when they have > 64 vCPUs, non-flat topology (>1 core/thread per socket; in case it has >64 sockets Windows just ignores vCPUs above 64) and Hyper-V enlightenments (any) are enabled. The most common error reported is "PAGE FAULT IN NONPAGED AREA" but I saw different messages. Apparently, Windows doesn't expect to run on a Hyper-V server without PV TLB flush support as there's no such Hyper-V servers out there (it's only WS2016 supporting > 64 vCPUs AFAIR). Adding PV TLB flush support to KVM helps, Windows 2016 guests now boot normally (I tried '-smp 128,sockets=64,cores=1,threads=2' and '-smp 128,sockets=8,cores=16,threads=1' but other topologies should work too). Feature description: PV TLB flush helps a lot when running overcommited. KVM gained support for it recently but it is only available for Linux guests. Windows guests use emulated Hyper-V interface and PV TLB flush needs to be added there. I tested WS2016 guest with 128 vCPUs running on a 12 pCPU server. The test was running 65 threads doing 50 mmap()/munmap() for 16384 pages with a tiny random nanosleep in between (I used Cygwin. It would be great if someone could point me to a good Windows-native TLB trashing test). The average results are: Before: real 0m22.464s user 0m0.990s sys 1m26.3276s After: real 0m19.304s user 0m0.908s sys 0m36.249s When running without overcommit the results of the same test are very close so the feature can be enabled by default. Implementation details. The implementation is very simplistic and straightforward. We ignore 'address space' argument of the hypercalls (as there is no good way to figure out what's currently in CR3 of a running vCPU as generally we don't VMEXIT on guest CR3 write) and do full TLB flush on specified vCPUs. In case said vCPUs are not running TLB flush will be performed upon guest enter. Qemu (and other userspaces) need to enable CPUID feature bits to make Windows aware the feature is supported. I'll post Qemu enablement patch separately. Patches are based on the current kvm/queue branch. Vitaly Kuznetsov (6): x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header KVM: x86: hyperv: use defines when parsing hypercall parameters KVM: x86: hyperv: do rep check for each hypercall separately KVM: x86: hyperv: simplistic HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE} implementation KVM: x86: hyperv: simplistic HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}_EX implementation KVM: x86: hyperv: declare KVM_CAP_HYPERV_TLBFLUSH capability Documentation/virtual/kvm/api.txt | 9 ++ arch/x86/hyperv/mmu.c | 40 ++----- arch/x86/include/asm/hyperv-tlfs.h | 20 ++++ arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/hyperv.c | 217 ++++++++++++++++++++++++++++++++++--- arch/x86/kvm/trace.h | 51 +++++++++ arch/x86/kvm/x86.c | 1 + include/uapi/linux/kvm.h | 1 + 8 files changed, 297 insertions(+), 43 deletions(-) -- 2.14.3