From patchwork Sat May 6 16:48:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 9715041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94FC860234 for ; Sat, 6 May 2017 16:48:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938EB2861C for ; Sat, 6 May 2017 16:48:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 883EB28621; Sat, 6 May 2017 16:48:48 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FAKE_REPLY_C, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDB892861C for ; Sat, 6 May 2017 16:48:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752146AbdEFQsd (ORCPT ); Sat, 6 May 2017 12:48:33 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:36061 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbdEFQsb (ORCPT ); Sat, 6 May 2017 12:48:31 -0400 Received: by mail-qt0-f193.google.com with SMTP id j13so4641342qta.3; Sat, 06 May 2017 09:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=p9NbFV35lVXilSaJVdITZ7qjNgNAIDYp1x+RxbjkbIw=; b=h2lDLmLZky2mGPm6Lymw2aMdj1Z89aEP2Zxk9ACnBO1/CHXIdzEzTVvQ+UOkz7CEY5 MaI8Xh+O74mM6bECOrv5T2S+aESqm06IRbruMTxGKO1g70jUcTncWL40/6ZinFQdPk/p Ghkix6W0Dqh3dNBV0/ifJm/azpMiV0J5/ha59hKeBHiaYEVcgpi7D+Bb8Iss18hzPb53 RFZfjWOyeYF5d/UGtSmQRqJcQ9E/N6HVPbWlhMtUSS7cSKUL8ULQCKLdeae4pf5rBppj ttyjr4H9koypTqnkonGwZRQ+5XoVF0wC+EBtVG/54EKPsWpiL92R45xq2y0ty8z9GNkE cJvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=p9NbFV35lVXilSaJVdITZ7qjNgNAIDYp1x+RxbjkbIw=; b=TsRLnpbavoAI307RH4rpqqWOWSq6GyEj42VQDHCk412JtfqjAoiOMgLN0vXvsNgADL be4yJFavcIjHzIw31UUTKYvL/qenpPCa2seDPVO/KLoYDIfCb67/8PHyxYit0VYFZ4Ku VPEjLeFcwkhputEfFgiz5v60zzPheB/u5RpSVIVoRwgH7ZsE/Oz8aLyGbIet/JW4AGKo fmvgwRgUFTSj3jfqQkObnxlI9V6gDt8vx1lhgS9fKA0DgcZU64d9fy78x1aheLBQ8e9y sAmBMaJhcOVf0NcTCq0TSROt1AB+8eAY9dtVZB37gd65HdL48/c20T5FSO4YJFCXnb/A abZQ== X-Gm-Message-State: AODbwcBvhHubGwwW0KYSvsDfAN5dn94tvy01cyAhua2vT+vMVMOo49Ye V/Z/2I5ig/jOTw== X-Received: by 10.200.54.173 with SMTP id a42mr3385443qtc.204.1494089310341; Sat, 06 May 2017 09:48:30 -0700 (PDT) Received: from HEDWIG.INI.CMU.EDU (HEDWIG.INI.CMU.EDU. [128.2.16.51]) by smtp.gmail.com with ESMTPSA id 60sm5704047qta.14.2017.05.06.09.48.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 May 2017 09:48:29 -0700 (PDT) Date: Sat, 6 May 2017 12:48:27 -0400 From: "Gabriel L. Somlo" To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Alexander Graf , "Michael S. Tsirkin" Subject: Re: [PATCH 0/4] KVM: x86: kvm_mwait_in_guest() cleanup and fixes Message-ID: <20170506164825.GG27819@HEDWIG.INI.CMU.EDU> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170504180714.GA18107@potion> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.8.0 (2017-02-23) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, May 04, 2017 at 08:07:15PM +0200, Radim Krčmář wrote: > 2017-05-04 13:56-0400, Gabriel L. Somlo: > > If I wanted to test this (e.g. with OS X 10.8 guests on several of my older > > Mac boxes running Fedora), which git repo would you have me use? (The series > > won't apply directly on top of git://git.kernel.org/pub/scm/virt/kvm/kvm.git). > > The queue branch of that repo. This series depends on a patch that is > applied there: > > 668fffa3f838 kvm: better MWAIT emulation for guests > > I forgot to mention that, sorry. OK, here's where I'm at right now: With this series applied on top of 'queue', my MacbookAir4,2 running F25 (with the kvm/queue kernel) works fine, i.e. loads the kvm-intel module successfully, and mwaits in L1 guest mode, reporting 400% cpu but staying cool (guest started with -smp 4). So far, so good. On the MacPro1,1, I first had to revert 2c82878b0cb38fd ("KVM: VMX: require virtual NMI support") to get around this error: # modprobe -v kvm-intel insmod /lib/modules/4.11.0-rc3+/kernel/virt/lib/irqbypass.ko insmod /lib/modules/4.11.0-rc3+/kernel/arch/x86/kvm/kvm.ko insmod /lib/modules/4.11.0-rc3+/kernel/arch/x86/kvm/kvm-intel.ko modprobe: ERROR: could not insert 'kvm_intel': Input/output error Next, it turns out that on the MacPro1,1 kvm_mwait_in_guest() returns TRUE, which causes OS X 10.7 (the one that mwaits without checking CPUID) to misbehave. Forcing the function to return 0 (FALSE) solves the problem: After this change, I get: [ 1201.529002] kvm_mwait_in_guest: 1 [ 1201.529024] kvm_mwait_in_guest: 1 [ 1201.529029] kvm_mwait_in_guest: 1 [ 1201.529038] kvm_mwait_in_guest: 1 [ 1201.529047] kvm_mwait_in_guest: 1 [ 1225.150235] kvm: MONITOR instruction emulated as NOP! [ 1225.150240] kvm: MWAIT instruction emulated as NOP! indicating that it *would* have returned TRUE if I let it :) This is a 2x dual-core Xeon, cca 2006 vintage, and the last (4th) CPU in /proc/cpuinfo returns: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 15 model name : Intel(R) Xeon(R) CPU 5150 @ 2.66GHz stepping : 6 microcode : 0xd2 cpu MHz : 2659.977 cache size : 4096 KB physical id : 3 siblings : 2 core id : 0 cpu cores : 2 apicid : 6 initial apicid : 6 fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm tpr_shadow dtherm bugs : bogomips : 5320.03 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: So, in conclusion; it's not important to *me* that this old machine keeps working, I'm just volunteering test data points. So please don't feel obligated in any way to go out of your way on my account. OTOH, I'm happy to provide feedback as long as you would like me to. Along the same lines: Paolo, as the author of commit 2c82878b0cb38fd, is the Xeon chip listed above one of the "obsolete for virtualization" models ? In that case, it makes no sense for me to keep using it for tests, and the fact that it misbehaves with L1 MWAIT should also not matter at all. Let me know what you all think. Thanks, --Gabriel diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index b49add7..249362c 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -216,9 +216,12 @@ static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec) static inline bool kvm_mwait_in_guest(void) { - return boot_cpu_has(X86_FEATURE_MWAIT) && + bool ret; + ret = boot_cpu_has(X86_FEATURE_MWAIT) && !boot_cpu_has_bug(X86_BUG_AMD_E400) && !boot_cpu_has_bug(X86_BUG_MONITOR); + printk(KERN_INFO "kvm_mwait_in_guest: %d\n", ret); + return 0; } #endif