From patchwork Tue Oct 6 19:25:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Langsdorf X-Patchwork-Id: 52001 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 n96JR7o4017143 for ; Tue, 6 Oct 2009 19:27:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933076AbZJFTZb (ORCPT ); Tue, 6 Oct 2009 15:25:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933068AbZJFTZb (ORCPT ); Tue, 6 Oct 2009 15:25:31 -0400 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:47858 "EHLO TX2EHSOBE008.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933067AbZJFTZa convert rfc822-to-8bit (ORCPT ); Tue, 6 Oct 2009 15:25:30 -0400 Received: from mail143-tx2-R.bigfish.com (10.9.14.245) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 8.1.340.0; Tue, 6 Oct 2009 19:24:50 +0000 Received: from mail143-tx2 (localhost.localdomain [127.0.0.1]) by mail143-tx2-R.bigfish.com (Postfix) with ESMTP id E6F221220503; Tue, 6 Oct 2009 19:24:49 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i6bh65h) X-Spam-TCS-SCL: 4:0 X-FB-SS: 5, Received: by mail143-tx2 (MessageSwitch) id 1254857078795424_12917; Tue, 6 Oct 2009 19:24:38 +0000 (UCT) Received: from TX2EHSMHS020.bigfish.com (unknown [10.9.14.238]) by mail143-tx2.bigfish.com (Postfix) with ESMTP id 8AAD81B38051; Tue, 6 Oct 2009 19:24:38 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by TX2EHSMHS020.bigfish.com (10.9.99.120) with Microsoft SMTP Server (TLS) id 14.0.482.32; Tue, 6 Oct 2009 19:24:38 +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 n96JOXvB023547; Tue, 6 Oct 2009 14:24:36 -0500 X-WSS-ID: 0KR3XWS-02-GHV-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 2AE83C84F1; Tue, 6 Oct 2009 14:24:28 -0500 (CDT) Received: from sausexmb4.amd.com ([163.181.3.15]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 6 Oct 2009 14:24:33 -0500 Received: from wshpnow.amd.com ([10.236.48.99]) by sausexmb4.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 6 Oct 2009 14:24:32 -0500 From: Mark Langsdorf To: linux-kernel@vger.kernel.org Subject: [PATCH][retry 3] Support Pause Filter in AMD processors Date: Tue, 6 Oct 2009 14:25:02 -0500 User-Agent: KMail/1.9.10 CC: avi@qumranet.com, avi@redhat.com, kvm@vger.kernel.org References: <200910021449.59284.mark.langsdorf@amd.com> In-Reply-To: <200910021449.59284.mark.langsdorf@amd.com> MIME-Version: 1.0 Content-Disposition: inline Message-ID: <200910061425.03191.mark.langsdorf@amd.com> X-OriginalArrivalTime: 06 Oct 2009 19:24:32.0590 (UTC) FILETIME=[A1CCDEE0:01CA46BA] 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 279a2ae..a07f969 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 */ @@ -660,6 +661,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); } @@ -2261,6 +2267,12 @@ static int interrupt_window_interception(struct vcpu_svm *svm) return 1; } +static int pause_interception(struct vcpu_svm *svm) +{ + kvm_vcpu_on_spin(&(svm->vcpu)); + 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, @@ -2296,6 +2308,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,