diff mbox

KVM: Add async pf flag to KVM_GET/SET_VCPU_EVENTS interface

Message ID 1498014889-52658-1-git-send-email-wanpeng.li@hotmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wanpeng Li June 21, 2017, 3:14 a.m. UTC
From: Wanpeng Li <wanpeng.li@hotmail.com>

This patch adds async pf flag to KVM_GET/SET_VCPU_EVENTS interface.

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 linux-headers/asm-x86/kvm.h | 2 ++
 target/i386/cpu.h           | 1 +
 target/i386/kvm.c           | 6 +++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

no-reply@patchew.org June 21, 2017, 4:19 a.m. UTC | #1
Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH] KVM: Add async pf flag to KVM_GET/SET_VCPU_EVENTS interface
Type: series
Message-id: 1498014889-52658-1-git-send-email-wanpeng.li@hotmail.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
4910d5f KVM: Add async pf flag to KVM_GET/SET_VCPU_EVENTS interface

=== OUTPUT BEGIN ===
Checking PATCH 1/1: KVM: Add async pf flag to KVM_GET/SET_VCPU_EVENTS interface...
ERROR: code indent should never use tabs
#61: FILE: target/i386/kvm.c:2535:
+^I^I             KVM_VCPUEVENT_VALID_ASYNC_PF;$

ERROR: braces {} are necessary for all arms of this statement
#69: FILE: target/i386/kvm.c:2560:
+    if (events.flags & KVM_VCPUEVENT_VALID_ASYNC_PF)
[...]

total: 2 errors, 0 warnings, 45 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Radim Krčmář June 21, 2017, 4:28 p.m. UTC | #2
2017-06-20 20:14-0700, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> This patch adds async pf flag to KVM_GET/SET_VCPU_EVENTS interface.
> 
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
> @@ -300,6 +301,7 @@ struct kvm_vcpu_events {
>  		__u8 has_error_code;
>  		__u8 pad;
>  		__u32 error_code;
> +		bool async_page_fault;

Touching userspace interfaces is always a major fun ...

You must not change the layout of an existing structure.  You can try to
reuse the pad and hope that some userspace didn't check it for 0.
(I think it's a decent compromise between safety and sanity.)

>  	} exception;
>  	struct {
>  		__u8 injected;
> diff --git 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);

Old QEMUs would break below this point, because interrupt.injected used
to be where exception.async_page_fault is.

>      events.interrupt.nr = env->interrupt_injected;
Wanpeng Li June 22, 2017, 2:09 a.m. UTC | #3
2017-06-22 0:28 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>:
> 2017-06-20 20:14-0700, Wanpeng Li:
>> From: Wanpeng Li <wanpeng.li@hotmail.com>
>>
>> This patch adds async pf flag to KVM_GET/SET_VCPU_EVENTS interface.
>>
>> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
>> ---
>> diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
>> @@ -300,6 +301,7 @@ struct kvm_vcpu_events {
>>               __u8 has_error_code;
>>               __u8 pad;
>>               __u32 error_code;
>> +             bool async_page_fault;
>
> Touching userspace interfaces is always a major fun ...
>
> You must not change the layout of an existing structure.  You can try to
> reuse the pad and hope that some userspace didn't check it for 0.
> (I think it's a decent compromise between safety and sanity.)

Thanks for pointing out. Just fixes it in v2.

Regards,
Wanpeng Li

>
>>       } exception;
>>       struct {
>>               __u8 injected;
>> diff --git 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);
>
> Old QEMUs would break below this point, because interrupt.injected used
> to be where exception.async_page_fault is.
>
>>      events.interrupt.nr = env->interrupt_injected;
diff mbox

Patch

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;