diff mbox

[2/8] KVM: s390: Split up __vcpu_run into three parts

Message ID 1378974829-46578-3-git-send-email-borntraeger@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Borntraeger Sept. 12, 2013, 8:33 a.m. UTC
From: Thomas Huth <thuth@linux.vnet.ibm.com>

In preparation for the following patch (which will change the indentation
of __vcpu_run quite a bit), this patch puts most of the code from __vcpu_run
into separate functions. The first function handles the code that runs
before the SIE instruction and the other one handles the code that runs
afterwards.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 54 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 37 insertions(+), 17 deletions(-)

Comments

Paolo Bonzini Sept. 12, 2013, 8:59 a.m. UTC | #1
Il 12/09/2013 10:33, Christian Borntraeger ha scritto:
>  
>  	vcpu->arch.sie_block->icptcode = 0;
> -	VCPU_EVENT(vcpu, 6, "entering sie flags %x",
> -		   atomic_read(&vcpu->arch.sie_block->cpuflags));
> -	trace_kvm_s390_sie_enter(vcpu,
> -				 atomic_read(&vcpu->arch.sie_block->cpuflags));
> +	cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
> +	VCPU_EVENT(vcpu, 6, "entering sie flags %x", cpuflags);
> +	trace_kvm_s390_sie_enter(vcpu, cpuflags);

I don't have this VCPU_EVENT in kvm/queue, it is after preempt_enable:

        vcpu->arch.sie_block->icptcode = 0;
        preempt_disable();
        kvm_guest_enter();
        preempt_enable();
        VCPU_EVENT(vcpu, 6, "entering sie flags %x",
                   atomic_read(&vcpu->arch.sie_block->cpuflags));
        trace_kvm_s390_sie_enter(vcpu,
                                 atomic_read(&vcpu->arch.sie_block->cpuflags));
        rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);

Patch missing?  Perhaps you should send a pull request instead as soon as
3.12-rc1 comes out.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christian Borntraeger Sept. 12, 2013, 9:09 a.m. UTC | #2
On 12/09/13 10:59, Paolo Bonzini wrote:
> Il 12/09/2013 10:33, Christian Borntraeger ha scritto:
>>  
>>  	vcpu->arch.sie_block->icptcode = 0;
>> -	VCPU_EVENT(vcpu, 6, "entering sie flags %x",
>> -		   atomic_read(&vcpu->arch.sie_block->cpuflags));
>> -	trace_kvm_s390_sie_enter(vcpu,
>> -				 atomic_read(&vcpu->arch.sie_block->cpuflags));
>> +	cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
>> +	VCPU_EVENT(vcpu, 6, "entering sie flags %x", cpuflags);
>> +	trace_kvm_s390_sie_enter(vcpu, cpuflags);
> 
> I don't have this VCPU_EVENT in kvm/queue, it is after preempt_enable:

Huh? This was moved with

commit 2b29a9fdcb92bfc6b6f4c412d71505869de61a56
Author: Dominik Dingel <dingel@linux.vnet.ibm.com>
Date:   Fri Jul 26 15:04:00 2013 +0200

    KVM: s390: move kvm_guest_enter,exit closer to sie


which is clearly in kvm/qeue:

https://git.kernel.org/cgit/virt/kvm/kvm.git/tree/arch/s390/kvm/kvm-s390.c?h=queue


--- snip---
	vcpu->arch.sie_block->icptcode = 0;
	VCPU_EVENT(vcpu, 6, "entering sie flags %x",
		   atomic_read(&vcpu->arch.sie_block->cpuflags));
	trace_kvm_s390_sie_enter(vcpu,
				 atomic_read(&vcpu->arch.sie_block->cpuflags));

	/*
	 * As PF_VCPU will be used in fault handler, between guest_enter
	 * and guest_exit should be no uaccess.
	 */
	preempt_disable();
	kvm_guest_enter();
	preempt_enable();
	rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
	kvm_guest_exit();

	VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
		   vcpu->arch.sie_block->icptcode);
	trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
--- snip---


> 
>         vcpu->arch.sie_block->icptcode = 0;
>         preempt_disable();
>         kvm_guest_enter();
>         preempt_enable();
>         VCPU_EVENT(vcpu, 6, "entering sie flags %x",
>                    atomic_read(&vcpu->arch.sie_block->cpuflags));
>         trace_kvm_s390_sie_enter(vcpu,
>                                  atomic_read(&vcpu->arch.sie_block->cpuflags));
>         rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
> 
> Patch missing?  Perhaps you should send a pull request instead as soon as
> 3.12-rc1 comes out.

For future patches, yes. I will go out for a kernel.org account, but it will certainly
take some time.

Christian



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini Sept. 12, 2013, 9:13 a.m. UTC | #3
Il 12/09/2013 11:09, Christian Borntraeger ha scritto:
>> > I don't have this VCPU_EVENT in kvm/queue, it is after preempt_enable:
> Huh? This was moved with
> 
> commit 2b29a9fdcb92bfc6b6f4c412d71505869de61a56
> Author: Dominik Dingel <dingel@linux.vnet.ibm.com>
> Date:   Fri Jul 26 15:04:00 2013 +0200
> 
>     KVM: s390: move kvm_guest_enter,exit closer to sie

Nevermind...

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index e3e7ff7..69c7592 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -689,9 +689,9 @@  static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu)
 	return 0;
 }
 
-static int __vcpu_run(struct kvm_vcpu *vcpu)
+static int vcpu_pre_run(struct kvm_vcpu *vcpu)
 {
-	int rc;
+	int rc, cpuflags;
 
 	memcpy(&vcpu->arch.sie_block->gg14, &vcpu->run->s.regs.gprs[14], 16);
 
@@ -709,28 +709,24 @@  static int __vcpu_run(struct kvm_vcpu *vcpu)
 		return rc;
 
 	vcpu->arch.sie_block->icptcode = 0;
-	VCPU_EVENT(vcpu, 6, "entering sie flags %x",
-		   atomic_read(&vcpu->arch.sie_block->cpuflags));
-	trace_kvm_s390_sie_enter(vcpu,
-				 atomic_read(&vcpu->arch.sie_block->cpuflags));
+	cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
+	VCPU_EVENT(vcpu, 6, "entering sie flags %x", cpuflags);
+	trace_kvm_s390_sie_enter(vcpu, cpuflags);
 
-	/*
-	 * As PF_VCPU will be used in fault handler, between guest_enter
-	 * and guest_exit should be no uaccess.
-	 */
-	preempt_disable();
-	kvm_guest_enter();
-	preempt_enable();
-	rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
-	kvm_guest_exit();
+	return 0;
+}
+
+static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
+{
+	int rc;
 
 	VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
 		   vcpu->arch.sie_block->icptcode);
 	trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
 
-	if (rc > 0)
+	if (exit_reason >= 0) {
 		rc = 0;
-	if (rc < 0) {
+	} else {
 		if (kvm_is_ucontrol(vcpu->kvm)) {
 			rc = SIE_INTERCEPT_UCONTROL;
 		} else {
@@ -741,6 +737,30 @@  static int __vcpu_run(struct kvm_vcpu *vcpu)
 	}
 
 	memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
+
+	return rc;
+}
+
+static int __vcpu_run(struct kvm_vcpu *vcpu)
+{
+	int rc, exit_reason;
+
+	rc = vcpu_pre_run(vcpu);
+	if (rc)
+		return rc;
+
+	/*
+	 * As PF_VCPU will be used in fault handler, between guest_enter
+	 * and guest_exit should be no uaccess.
+	 */
+	preempt_disable();
+	kvm_guest_enter();
+	preempt_enable();
+	exit_reason = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
+	kvm_guest_exit();
+
+	rc = vcpu_post_run(vcpu, exit_reason);
+
 	return rc;
 }