From patchwork Mon Jul 19 15:31:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 112705 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6JFZZV6000799 for ; Mon, 19 Jul 2010 15:35:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936227Ab0GSPeo (ORCPT ); Mon, 19 Jul 2010 11:34:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936072Ab0GSPb1 (ORCPT ); Mon, 19 Jul 2010 11:31:27 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6JFV5lL009108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Jul 2010 11:31:05 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6JFV4UU009933; Mon, 19 Jul 2010 11:31:05 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id A63CA18D3F8; Mon, 19 Jul 2010 18:31:02 +0300 (IDT) From: Gleb Natapov To: kvm@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, avi@redhat.com, mingo@elte.hu, a.p.zijlstra@chello.nl, tglx@linutronix.de, hpa@zytor.com, riel@redhat.com, cl@linux-foundation.org, mtosatti@redhat.com Subject: [PATCH v5 11/12] Let host know whether the guest can handle async PF in non-userspace context. Date: Mon, 19 Jul 2010 18:31:01 +0300 Message-Id: <1279553462-7036-12-git-send-email-gleb@redhat.com> In-Reply-To: <1279553462-7036-1-git-send-email-gleb@redhat.com> References: <1279553462-7036-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 19 Jul 2010 15:35:37 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 45e6c12..c675d5d 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -367,6 +367,7 @@ struct kvm_vcpu_arch { cpumask_var_t wbinvd_dirty_mask; u32 __user *apf_data; + bool apf_send_user_only; u32 apf_memslot_ver; u64 apf_msr_val; u32 async_pf_id; diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h index edf07cf..a33372c 100644 --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h @@ -38,6 +38,7 @@ #define KVM_MAX_MMU_OP_BATCH 32 #define KVM_ASYNC_PF_ENABLED (1 << 0) +#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) /* Operations for KVM_HC_MMU_OP */ #define KVM_MMU_OP_WRITE_PTE 1 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 914b0fc..462b47d 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -429,6 +429,9 @@ void __cpuinit kvm_guest_cpu_init(void) if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF)) { u64 pa = __pa(&__get_cpu_var(apf_reason)); +#ifdef CONFIG_PREEMPT + pa |= KVM_ASYNC_PF_SEND_ALWAYS; +#endif if (native_write_msr_safe(MSR_KVM_ASYNC_PF_EN, pa | KVM_ASYNC_PF_ENABLED, pa >> 32)) return; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5482db0..ba351f5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1222,8 +1222,8 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) int offset = offset_in_page(gpa); unsigned long addr; - /* Bits 1:5 are resrved, Should be zero */ - if (data & 0x3e) + /* Bits 2:5 are resrved, Should be zero */ + if (data & 0x3c) return 1; vcpu->arch.apf_msr_val = data; @@ -1246,6 +1246,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) return 1; } vcpu->arch.apf_memslot_ver = vcpu->kvm->memslot_version; + vcpu->arch.apf_send_user_only = !(data & KVM_ASYNC_PF_SEND_ALWAYS); kvm_async_pf_wakeup_all(vcpu); return 0; }