From patchwork Thu Jun 22 02:07:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 9803309 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 A7E6260234 for ; Thu, 22 Jun 2017 02:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 983DD2679B for ; Thu, 22 Jun 2017 02:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C79128539; Thu, 22 Jun 2017 02:08:03 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21E552679B for ; Thu, 22 Jun 2017 02:08:02 +0000 (UTC) Received: from localhost ([::1]:56677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNrXM-0001i9-J1 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Jun 2017 22:08:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNrWp-0001hs-Hp for qemu-devel@nongnu.org; Wed, 21 Jun 2017 22:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNrWm-0001NH-EC for qemu-devel@nongnu.org; Wed, 21 Jun 2017 22:07:27 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:35584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNrWm-0001Mv-8v for qemu-devel@nongnu.org; Wed, 21 Jun 2017 22:07:24 -0400 Received: by mail-pg0-x244.google.com with SMTP id f127so509752pgc.2 for ; Wed, 21 Jun 2017 19:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8wKWRDMigvT5kFgPm+eHSQmvViABLDrsSrQ2YS/TQ3E=; b=Og1R6hPTWkBqJcavTEvbWwgmGjIs5GdRB37K48m773LsPh9inhKDtccAAqg6ZVPMG2 mpKCYhY+rpsaWVcOzjYZZKQZ1Q0nxY/BNsqaB3ltaB/lh4mYzrZPlJiU0g4Z9aoj95L1 eMECiSIr3K5mv6B49wM1iHNKCnCIuhabZNCiie4WZh6z2q+nlGYfte9VsH0fm1cl4/Ls 5KXqGwYed8J2fUlbYf8vDxM2O8b73lu/5M5A5iuhf4isG69ZZAWjAbMtgi8T9VKDXjWk egsJIrBrdWiHaSUjv0W4SPgRiBZgGFYOpzf9Sr616JR4p3udI7oZmdU5xtmT9dGwcSVv 2YCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8wKWRDMigvT5kFgPm+eHSQmvViABLDrsSrQ2YS/TQ3E=; b=gaSrY8qTxuL2hLJnFSGiYw9Wlf5NDk0kAaD0UGmn0G/ALPo+c1tE6cspdWC5m4GzBE BvwTZ4MPKie4jQX2dFjlTv1l+p+07efLAVOTs2W6fzkeuv18AY1/aHzVtTo4eTjrH/zx bdcWoaXipXr7c7wc8iVQrowyYvCfx8mY94w/Dpnlav9JKdszbOFOhReydtR2XBhmrkve LkEf9oiWXvg803k0xV8LC12WXBxQEoh6YXA6U/7WhaYTC+7E+ViQUosxXPVx2ym/TP3D pmBN8MwpiJjEyHQ1XN9/OXLxpKNB2kzJ102G8g/GdPef1B7glbGULzJ3S2RnESIeq3/N V3pQ== X-Gm-Message-State: AKS2vOwQYDjgnAf6okJ2mTpiX/bmNKgTSHsLmLqRv8oJGEHa/6UEkBqA TyJr38yiGkCK25TV X-Received: by 10.98.72.198 with SMTP id q67mr207900pfi.23.1498097242813; Wed, 21 Jun 2017 19:07:22 -0700 (PDT) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id w69sm127832pfk.107.2017.06.21.19.07.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 19:07:22 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Wed, 21 Jun 2017 19:07:18 -0700 Message-Id: <1498097238-6301-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2] KVM: Add async pf flag to KVM_GET/SET_VCPU_EVENTS interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Wanpeng Li , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wanpeng Li This patch adds async page fault flag to KVM_GET/SET_VCPU_EVENTS interface. Cc: Paolo Bonzini Cc: Radim Krčmář Signed-off-by: Wanpeng Li --- v1 -> v2: * reuse the pad for async_page_fault * cleanup coding style linux-headers/asm-x86/kvm.h | 3 ++- target/i386/cpu.h | 1 + target/i386/kvm.c | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index c2824d0..27b368b 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -287,6 +287,7 @@ struct kvm_reinject_control { #define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002 #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004 #define KVM_VCPUEVENT_VALID_SMM 0x00000008 +#define KVM_VCPUEVENT_VALID_ASYNC_PF 0x00000010 /* Interrupt shadow states */ #define KVM_X86_SHADOW_INT_MOV_SS 0x01 @@ -298,7 +299,7 @@ struct kvm_vcpu_events { __u8 injected; __u8 nr; __u8 has_error_code; - __u8 pad; + __u8 async_page_fault; __u32 error_code; } exception; struct { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index cfe825f..90cb692 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1105,6 +1105,7 @@ typedef struct CPUX86State { /* exception/interrupt handling */ int error_code; + uint8_t async_page_fault; int exception_is_int; target_ulong exception_next_eip; target_ulong dr[8]; /* debug registers; note dr4 and dr5 are unused */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 49b6115..b2405ec 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2491,8 +2491,8 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) events.exception.injected = (env->exception_injected >= 0); events.exception.nr = env->exception_injected; events.exception.has_error_code = env->has_error_code; + events.exception.async_page_fault = env->async_page_fault; events.exception.error_code = env->error_code; - events.exception.pad = 0; events.interrupt.injected = (env->interrupt_injected >= 0); events.interrupt.nr = env->interrupt_injected; @@ -2531,7 +2531,8 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) if (level >= KVM_PUT_RESET_STATE) { events.flags |= - KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR; + KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR | + KVM_VCPUEVENT_VALID_ASYNC_PF; } return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events); @@ -2555,6 +2556,9 @@ static int kvm_get_vcpu_events(X86CPU *cpu) env->exception_injected = events.exception.injected ? events.exception.nr : -1; env->has_error_code = events.exception.has_error_code; + if (events.flags & KVM_VCPUEVENT_VALID_ASYNC_PF) { + env->async_page_fault = events.exception.async_page_fault; + } env->error_code = events.exception.error_code; env->interrupt_injected =