From: Keir Fraser Date: Sat, 9 Apr 2011 11:42:24 +0000 (+0100) Subject: nestedhvm: Remove nhvm_{initialise,destroy,reset}. X-Git-Tag: 4.2.0-rc1~2385 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a2b5f214696a76d24f4f464d77f552b8c2a81879;p=xen.git nestedhvm: Remove nhvm_{initialise,destroy,reset}. They are a pointless level of abstraction beneath nestedhvm_* variants of the same operations, which all callers should be using. At the same time, nestedhvm_vcpu_initialise() does not need to call destroy if initialisation fails. That is the vendor-specific init function's job (clearing up its own state on failure). Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 1ae4df98f0..edeffe06cf 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4020,26 +4020,6 @@ int hvm_memory_event_int3(unsigned long gla) } #endif /* __x86_64__ */ -int nhvm_vcpu_initialise(struct vcpu *v) -{ - if (hvm_funcs.nhvm_vcpu_initialise) - return hvm_funcs.nhvm_vcpu_initialise(v); - return -EOPNOTSUPP; -} - -void nhvm_vcpu_destroy(struct vcpu *v) -{ - if ( hvm_funcs.nhvm_vcpu_destroy ) - hvm_funcs.nhvm_vcpu_destroy(v); -} - -int nhvm_vcpu_reset(struct vcpu *v) -{ - if (hvm_funcs.nhvm_vcpu_reset) - return hvm_funcs.nhvm_vcpu_reset(v); - return -EOPNOTSUPP; -} - int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs) { if (hvm_funcs.nhvm_vcpu_hostrestore) diff --git a/xen/arch/x86/hvm/nestedhvm.c b/xen/arch/x86/hvm/nestedhvm.c index ef9a867527..fb239b9bb4 100644 --- a/xen/arch/x86/hvm/nestedhvm.c +++ b/xen/arch/x86/hvm/nestedhvm.c @@ -25,7 +25,6 @@ #include /* for local_event_delivery_(en|dis)able */ #include /* for paging_mode_hap() */ - /* Nested HVM on/off per domain */ bool_t nestedhvm_enabled(struct domain *d) @@ -63,7 +62,8 @@ nestedhvm_vcpu_reset(struct vcpu *v) nv->nv_flushp2m = 0; nv->nv_p2m = NULL; - nhvm_vcpu_reset(v); + if ( hvm_funcs.nhvm_vcpu_reset ) + hvm_funcs.nhvm_vcpu_reset(v); /* vcpu is in host mode */ nestedhvm_vcpu_exit_guestmode(v); @@ -72,13 +72,11 @@ nestedhvm_vcpu_reset(struct vcpu *v) int nestedhvm_vcpu_initialise(struct vcpu *v) { - int rc; + int rc = -EOPNOTSUPP; - if ( (rc = nhvm_vcpu_initialise(v)) ) - { - nhvm_vcpu_destroy(v); - return rc; - } + if ( !hvm_funcs.nhvm_vcpu_initialise || + ((rc = hvm_funcs.nhvm_vcpu_initialise(v)) != 0) ) + return rc; nestedhvm_vcpu_reset(v); return 0; @@ -87,8 +85,8 @@ nestedhvm_vcpu_initialise(struct vcpu *v) void nestedhvm_vcpu_destroy(struct vcpu *v) { - if ( nestedhvm_enabled(v->domain) ) - nhvm_vcpu_destroy(v); + if ( nestedhvm_enabled(v->domain) && hvm_funcs.nhvm_vcpu_destroy ) + hvm_funcs.nhvm_vcpu_destroy(v); } static void diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 1445fd982e..12bd8a82b1 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -412,12 +412,6 @@ static inline int hvm_memory_event_int3(unsigned long gla) * Nested HVM */ -/* Initialize vcpu's struct nestedhvm */ -int nhvm_vcpu_initialise(struct vcpu *v); -/* Destroy and free vcpu's struct nestedhvm */ -void nhvm_vcpu_destroy(struct vcpu *v); -/* Reset vcpu's state when l1 guest disables nested virtualization */ -int nhvm_vcpu_reset(struct vcpu *v); /* Restores l1 guest state */ int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs); /* Fill l1 guest's VMCB/VMCS with data provided by generic exit codes