From patchwork Fri Oct 2 19:49:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Langsdorf X-Patchwork-Id: 51421 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n92Jos7p022203 for ; Fri, 2 Oct 2009 19:50:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756781AbZJBTuS (ORCPT ); Fri, 2 Oct 2009 15:50:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756109AbZJBTuS (ORCPT ); Fri, 2 Oct 2009 15:50:18 -0400 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:9540 "EHLO VA3EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750750AbZJBTuQ convert rfc822-to-8bit (ORCPT ); Fri, 2 Oct 2009 15:50:16 -0400 Received: from mail176-va3-R.bigfish.com (10.7.14.252) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 8.1.340.0; Fri, 2 Oct 2009 19:50:18 +0000 Received: from mail176-va3 (localhost.localdomain [127.0.0.1]) by mail176-va3-R.bigfish.com (Postfix) with ESMTP id BC2064705A4; Fri, 2 Oct 2009 19:50:18 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i6bh66h) X-Spam-TCS-SCL: 5:0 X-FB-SS: 5, Received: by mail176-va3 (MessageSwitch) id 1254513012325918_12063; Fri, 2 Oct 2009 19:50:12 +0000 (UCT) Received: from VA3EHSMHS015.bigfish.com (unknown [10.7.14.254]) by mail176-va3.bigfish.com (Postfix) with ESMTP id 4BC399E8059; Fri, 2 Oct 2009 19:50:12 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS015.bigfish.com (10.7.99.25) with Microsoft SMTP Server (TLS) id 14.0.482.32; Fri, 2 Oct 2009 19:50:11 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n92Jo6R1030877; Fri, 2 Oct 2009 14:50:11 -0500 X-WSS-ID: 0KQWKF8-02-H8J-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.0) with ESMTP id 2675EC84EE; Fri, 2 Oct 2009 14:49:56 -0500 (CDT) Received: from sausexmb4.amd.com ([163.181.3.15]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 2 Oct 2009 14:50:06 -0500 Received: from wshpnow.amd.com ([10.236.48.99]) by sausexmb4.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 2 Oct 2009 14:50:06 -0500 From: Mark Langsdorf To: linux-kernel@vger.kernel.org, avi@qumranet.com, avi@redhat.com, kvm@vger.kernel.org Subject: [PATCH][retry 2] Support Pause Filter in AMD processors Date: Fri, 2 Oct 2009 14:49:59 -0500 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Disposition: inline Message-ID: <200910021449.59284.mark.langsdorf@amd.com> X-OriginalArrivalTime: 02 Oct 2009 19:50:06.0098 (UTC) FILETIME=[8A309F20:01CA4399] X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 85574b7..1fecb7e 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -57,7 +57,8 @@ struct __attribute__ ((__packed__)) vmcb_control_area { u16 intercept_dr_write; u32 intercept_exceptions; u64 intercept; - u8 reserved_1[44]; + u8 reserved_1[42]; + u16 pause_filter_count; u64 iopm_base_pa; u64 msrpm_base_pa; u64 tsc_offset; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 9a4daca..d5d2e03 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -46,6 +46,7 @@ MODULE_LICENSE("GPL"); #define SVM_FEATURE_NPT (1 << 0) #define SVM_FEATURE_LBRV (1 << 1) #define SVM_FEATURE_SVML (1 << 2) +#define SVM_FEATURE_PAUSE_FILTER (1 << 10) #define NESTED_EXIT_HOST 0 /* Exit handled on host level */ #define NESTED_EXIT_DONE 1 /* Exit caused nested vmexit */ @@ -659,6 +660,11 @@ static void init_vmcb(struct vcpu_svm *svm) svm->nested.vmcb = 0; svm->vcpu.arch.hflags = 0; + if (svm_has(SVM_FEATURE_PAUSE_FILTER)) { + control->pause_filter_count = 3000; + control->intercept |= (1ULL << INTERCEPT_PAUSE); + } + enable_gif(svm); } @@ -2270,6 +2276,15 @@ static int interrupt_window_interception(struct vcpu_svm *svm) return 1; } +static int pause_interception(struct vcpu_svm *svm) +{ + static int pause_count = 0; + + kvm_vcpu_on_spin(&(svm->vcpu)); +printk(KERN_ERR "MJLL pause intercepted %d\n", ++pause_count); + return 1; +} + static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_READ_CR0] = emulate_on_interception, [SVM_EXIT_READ_CR3] = emulate_on_interception, @@ -2305,6 +2320,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_CPUID] = cpuid_interception, [SVM_EXIT_IRET] = iret_interception, [SVM_EXIT_INVD] = emulate_on_interception, + [SVM_EXIT_PAUSE] = pause_interception, [SVM_EXIT_HLT] = halt_interception, [SVM_EXIT_INVLPG] = invlpg_interception, [SVM_EXIT_INVLPGA] = invlpga_interception,