From patchwork Wed Jun 21 03:14:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 9800641 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 97C11600F6 for ; Wed, 21 Jun 2017 03:15:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FB8527DCD for ; Wed, 21 Jun 2017 03:15:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7485327FA5; Wed, 21 Jun 2017 03:15:35 +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 0AAE127DCD for ; Wed, 21 Jun 2017 03:15:34 +0000 (UTC) Received: from localhost ([::1]:51619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNW7B-0005Uo-2T for patchwork-qemu-devel@patchwork.kernel.org; Tue, 20 Jun 2017 23:15:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNW6e-0005UL-Ni for qemu-devel@nongnu.org; Tue, 20 Jun 2017 23:15:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNW6a-0004pl-NS for qemu-devel@nongnu.org; Tue, 20 Jun 2017 23:15:00 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:35930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNW6a-0004pM-Hj for qemu-devel@nongnu.org; Tue, 20 Jun 2017 23:14:56 -0400 Received: by mail-pg0-x244.google.com with SMTP id e187so16301501pgc.3 for ; Tue, 20 Jun 2017 20:14:55 -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; bh=eQdXTo12+iZGtdkkT7nUATt7vdkpZLlRHP7bjPwsnd0=; b=Mqo3OtiKRGUwS7Hm6iUFoc4+YE1UL1R36c54oL0eKqQvEZ2jx0mVUHLbrgKes8W6cJ /EmfKMpOxPF4oyqtgoQelRQI0YhohkMMiprQ/JBup/Z9lOwIa5Xk0EhUQ1gS8R49xhJn FHoxeO9QpWmp0BE/6etpsKITN0u4ztoM99v9783mS25A0UBN1ioJM2KsqOwFlQZz9QXu mdQjJaUUayd8vWSPd38j4DTke1d0lWAXNFJOWWlHVEw8d/J7TjI+Gk61A6EW6EeE5/Vj f7jPwcu6u8fT2PzUOZEWnFhYFs16bWGaCMDWf5WP1zvaqVXhg5u5foz424uAu+hpmnn1 Sfgg== 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; bh=eQdXTo12+iZGtdkkT7nUATt7vdkpZLlRHP7bjPwsnd0=; b=YtVq7lKGTrj+5IP5ldNW6ETDp9BvWoOSgkwMVYtVwr29oTHdj5+GZ9krxuC+GQfqRM SSyLw8hPfldzcFEGPShAHqbWso8AJ3J4N2J7kzMc2k21hon80GifqBdMYsSBg/6Vh8GN BFpmIkzMpNcUaAQcukRrGdGGjZbM/ATwsfwRpYxjQYLceCWtllEd3WbnXJxe+q6zDUcr 3OVvAnncpKZJE0MA+tYzF0mXCJ6bK0xZSYL8d06D6uHh3vILJ1Mrhh6gEpLAzL+tvQ7I Hkt+58IwLZnUIW5uFPHsBCazaz4N1t+d3p9Q8+fTX5INi/5zdTz7VG85gxPdMTTowFrr fDiw== X-Gm-Message-State: AKS2vOxawgar5ywqYZBQaNMeHgmt7wrznDZIJwpC8mFQ0z3Itop8INzC PqF4JMfkdamkMR+K X-Received: by 10.99.99.193 with SMTP id x184mr29922555pgb.13.1498014893942; Tue, 20 Jun 2017 20:14:53 -0700 (PDT) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id i63sm32132616pge.56.2017.06.20.20.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 20:14:53 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Tue, 20 Jun 2017 20:14:49 -0700 Message-Id: <1498014889-52658-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 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] 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 pf flag to KVM_GET/SET_VCPU_EVENTS interface. Signed-off-by: Wanpeng Li --- linux-headers/asm-x86/kvm.h | 2 ++ target/i386/cpu.h | 1 + target/i386/kvm.c | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index c2824d0..435f03f 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 @@ -300,6 +301,7 @@ struct kvm_vcpu_events { __u8 has_error_code; __u8 pad; __u32 error_code; + bool async_page_fault; } exception; struct { __u8 injected; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index cfe825f..f409958 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1105,6 +1105,7 @@ typedef struct CPUX86State { /* exception/interrupt handling */ int error_code; + bool 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..793d1e1 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2493,6 +2493,7 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) events.exception.has_error_code = env->has_error_code; events.exception.error_code = env->error_code; events.exception.pad = 0; + events.exception.async_page_fault = env->async_page_fault; events.interrupt.injected = (env->interrupt_injected >= 0); events.interrupt.nr = env->interrupt_injected; @@ -2531,7 +2532,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); @@ -2556,6 +2558,8 @@ static int kvm_get_vcpu_events(X86CPU *cpu) events.exception.injected ? events.exception.nr : -1; env->has_error_code = events.exception.has_error_code; env->error_code = events.exception.error_code; + if (events.flags & KVM_VCPUEVENT_VALID_ASYNC_PF) + env->async_page_fault = events.exception.async_page_fault; env->interrupt_injected = events.interrupt.injected ? events.interrupt.nr : -1;