From patchwork Fri Aug 3 10:55:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Bader X-Patchwork-Id: 1270371 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B46AD3FD2B for ; Fri, 3 Aug 2012 10:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450Ab2HCKzk (ORCPT ); Fri, 3 Aug 2012 06:55:40 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:41862 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753390Ab2HCKzj (ORCPT ); Fri, 3 Aug 2012 06:55:39 -0400 Received: from p5b2e35a5.dip.t-dialin.net ([91.46.53.165] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SxFXb-0002in-9N; Fri, 03 Aug 2012 10:55:35 +0000 From: Stefan Bader To: Avi Kivity Cc: , Stefan Bader , Gleb Natapov , Andy Whitcroft , kvm@vger.kernel.org Subject: Date: Fri, 3 Aug 2012 12:55:32 +0200 Message-Id: <1343991332-8086-1-git-send-email-stefan.bader@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <501A9C3D.9080602@redhat.com> References: <501A9C3D.9080602@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Subject: Re: Nested kvm_intel broken on pre 3.3 hosts > No, you're backporting the entire feature. All we need is to expose > RDPMC intercept to the guest. Oh well, I thought that was the thing you asked for... > It should be sufficient to backport the bits in > nested_vmx_setup_ctls_msrs() and nested_vmx_exit_handled(). Ok, how about that? It is probably wrong again, but at least it allows to load the kvm-intel module from within a nested guest and not having the feature pretend to fail seems the closest thing to do... --- From 0aeb99348363b7aeb2b0bd92428cb212159fa468 Mon Sep 17 00:00:00 2001 From: Stefan Bader Date: Thu, 10 Nov 2011 14:57:25 +0200 Subject: [PATCH] KVM: VMX: Fake intercept RDPMC Based on commit fee84b079d5ddee2247b5c1f53162c330c622902 upstream. Intercept RDPMC and forward it to the PMU emulation code. But drop the requirement for the feature being present and instead of forwarding, cause a GP as if the call had failed. BugLink: http://bugs.launchpad.net/bugs/1031090 Signed-off-by: Stefan Bader --- arch/x86/kvm/vmx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7315488..fc937f2 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1956,6 +1956,7 @@ static __init void nested_vmx_setup_ctls_msrs(void) #endif CPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING | CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_EXITING | + CPU_BASED_RDPMC_EXITING | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; /* * We can allow some features even when not supported by the @@ -4613,6 +4614,14 @@ static int handle_invlpg(struct kvm_vcpu *vcpu) return 1; } +static int handle_rdpmc(struct kvm_vcpu *vcpu) +{ + /* Instead of implementing the feature, cause a GP */ + kvm_complete_insn_gp(vcpu, 1); + + return 1; +} + static int handle_wbinvd(struct kvm_vcpu *vcpu) { skip_emulated_instruction(vcpu); @@ -5563,6 +5572,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { [EXIT_REASON_HLT] = handle_halt, [EXIT_REASON_INVD] = handle_invd, [EXIT_REASON_INVLPG] = handle_invlpg, + [EXIT_REASON_RDPMC] = handle_rdpmc, [EXIT_REASON_VMCALL] = handle_vmcall, [EXIT_REASON_VMCLEAR] = handle_vmclear, [EXIT_REASON_VMLAUNCH] = handle_vmlaunch,