Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1373138 > unrolled thread

[PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks

Started bySuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
First post2016-04-07 10:30 +0200
Last post2016-04-13 00:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> - 2016-04-07 10:30 +0200
    Re: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM  init/uninit hooks Radim Krčmář <rkrcmar@redhat.com> - 2016-04-11 22:50 +0200
      Re: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM  init/uninit hooks Paolo Bonzini <pbonzini@redhat.com> - 2016-04-13 00:00 +0200

#1373138 — [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks

FromSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Date2016-04-07 10:30 +0200
Subject[PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks
Message-ID<rldu9-10J-1@gated-at.bofh.it>
Adding function pointers in struct kvm_x86_ops for processor-specific
layer to provide hooks for when KVM initialize and un-initialize VM.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 arch/x86/include/asm/kvm_host.h | 3 +++
 arch/x86/kvm/x86.c              | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f62a9f37..22bd70c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -848,6 +848,9 @@ struct kvm_x86_ops {
 	bool (*cpu_has_high_real_mode_segbase)(void);
 	void (*cpuid_update)(struct kvm_vcpu *vcpu);
 
+	int (*vm_init)(struct kvm *kvm);
+	void (*vm_uninit)(struct kvm *kvm);
+
 	/* Create, but do not attach this VCPU */
 	struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
 	void (*vcpu_free)(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 742d0f7..d12583e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7754,6 +7754,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm_page_track_init(kvm);
 	kvm_mmu_init_vm(kvm);
 
+	if (kvm_x86_ops->vm_init)
+		return kvm_x86_ops->vm_init(kvm);
+
 	return 0;
 }
 
@@ -7781,6 +7784,9 @@ static void kvm_free_vcpus(struct kvm *kvm)
 	kvm_for_each_vcpu(i, vcpu, kvm)
 		kvm_arch_vcpu_free(vcpu);
 
+	if (kvm_x86_ops->vm_uninit)
+		kvm_x86_ops->vm_uninit(kvm);
+
 	mutex_lock(&kvm->lock);
 	for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
 		kvm->vcpus[i] = NULL;
-- 
1.9.1

[toc] | [next] | [standalone]


#1376282 — Re: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-04-11 22:50 +0200
SubjectRe: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks
Message-ID<rmQWu-3to-9@gated-at.bofh.it>
In reply to#1373138
2016-04-07 03:20-0500, Suravee Suthikulpanit:
> Adding function pointers in struct kvm_x86_ops for processor-specific
> layer to provide hooks for when KVM initialize and un-initialize VM.
> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> @@ -7781,6 +7784,9 @@ static void kvm_free_vcpus(struct kvm *kvm)
>  	kvm_for_each_vcpu(i, vcpu, kvm)
>  		kvm_arch_vcpu_free(vcpu);
>  
> +	if (kvm_x86_ops->vm_uninit)
> +		kvm_x86_ops->vm_uninit(kvm);

vm_uninit() doesn't seem to have much to do with kvm_free_vcpus(),
please call it from kvm_arch_destroy_vm().

(kvm_x86_ops.vm_destroy would be a better name then.)

[toc] | [prev] | [next] | [standalone]


#1377343 — Re: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-04-13 00:00 +0200
SubjectRe: [PART1 RFC v4 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks
Message-ID<rnevN-67f-19@gated-at.bofh.it>
In reply to#1376282

On 11/04/2016 22:49, Radim Krčmář wrote:
>> > @@ -7781,6 +7784,9 @@ static void kvm_free_vcpus(struct kvm *kvm)
>> >  	kvm_for_each_vcpu(i, vcpu, kvm)
>> >  		kvm_arch_vcpu_free(vcpu);
>> >  
>> > +	if (kvm_x86_ops->vm_uninit)
>> > +		kvm_x86_ops->vm_uninit(kvm);
> vm_uninit() doesn't seem to have much to do with kvm_free_vcpus(),
> please call it from kvm_arch_destroy_vm().
> 
> (kvm_x86_ops.vm_destroy would be a better name then.)

Especially, you're calling it with struct kvm full of dangling pointer,
so please call it early, right after the "if (current->mm == kvm->mm)"
block.

Paolo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web