From: "Jan Beulich" Subject: [PATCH 3/6] x86/HVM: prefer is_..._domain() over is_..._vcpu() Date: Thu, 11 Jun 2015 11:21:19 +0100 Message-ID: <55797D3F02000078000838C1@mail.emea.novell.com> References: <55797BF702000078000838AF@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2A1E0B0F.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z2zbx-0002z1-0L for xen-devel@lists.xenproject.org; Thu, 11 Jun 2015 10:21:25 +0000 In-Reply-To: <55797BF702000078000838AF@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part2A1E0B0F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... when the domain pointer is already available or such operations occur frequently in a function. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -445,7 +445,7 @@ void hvm_do_resume(struct vcpu *v) =20 check_wakeup_from_wait(); =20 - if ( is_hvm_vcpu(v) ) + if ( is_hvm_domain(d) ) pt_restore_timer(v); =20 list_for_each_entry ( s, @@ -2312,7 +2312,7 @@ int hvm_vcpu_initialise(struct vcpu *v) =20 v->arch.hvm_vcpu.inject_trap.vector =3D -1; =20 - if ( is_pvh_vcpu(v) ) + if ( is_pvh_domain(d) ) { v->arch.hvm_vcpu.hcall_64bit =3D 1; /* PVH 32bitfixme. */ /* This is for hvm_long_mode_enabled(v). */ @@ -2364,9 +2364,7 @@ int hvm_vcpu_initialise(struct vcpu *v) =20 void hvm_vcpu_destroy(struct vcpu *v) { - struct domain *d =3D v->domain; - - hvm_all_ioreq_servers_remove_vcpu(d, v); + hvm_all_ioreq_servers_remove_vcpu(v->domain, v); =20 nestedhvm_vcpu_destroy(v); =20 @@ -4921,6 +4920,7 @@ extern const uint8_t hypercall_args_tabl int hvm_do_hypercall(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; + struct domain *currd =3D curr->domain; struct segment_register sreg; int mode =3D hvm_guest_x86_mode(curr); uint32_t eax =3D regs->eax; @@ -4941,12 +4941,12 @@ int hvm_do_hypercall(struct cpu_user_reg break; } =20 - if ( (eax & 0x80000000) && is_viridian_domain(curr->domain) ) + if ( (eax & 0x80000000) && is_viridian_domain(currd) ) return viridian_hypercall(regs); =20 if ( (eax >=3D NR_hypercalls) || - (is_pvh_vcpu(curr) ? !pvh_hypercall64_table[eax] - : !hvm_hypercall32_table[eax]) ) + (is_pvh_domain(currd) ? !pvh_hypercall64_table[eax] + : !hvm_hypercall32_table[eax]) ) { regs->eax =3D -ENOSYS; return HVM_HCALL_completed; @@ -4980,7 +4980,7 @@ int hvm_do_hypercall(struct cpu_user_reg #endif =20 curr->arch.hvm_vcpu.hcall_64bit =3D 1; - regs->rax =3D (is_pvh_vcpu(curr) + regs->rax =3D (is_pvh_domain(currd) ? pvh_hypercall64_table : hvm_hypercall64_table)[eax](rdi, rsi, rdx, r10, = r8, r9); curr->arch.hvm_vcpu.hcall_64bit =3D 0; @@ -5001,7 +5001,7 @@ int hvm_do_hypercall(struct cpu_user_reg } #endif } - else if ( unlikely(is_pvh_vcpu(curr)) ) + else if ( unlikely(is_pvh_domain(currd)) ) regs->_eax =3D -ENOSYS; /* PVH 32bitfixme. */ else { @@ -5053,8 +5053,8 @@ int hvm_do_hypercall(struct cpu_user_reg if ( curr->arch.hvm_vcpu.hcall_preempted ) return HVM_HCALL_preempted; =20 - if ( unlikely(curr->domain->arch.hvm_domain.qemu_mapcache_invalidate) = && - test_and_clear_bool(curr->domain->arch.hvm_domain. + if ( unlikely(currd->arch.hvm_domain.qemu_mapcache_invalidate) && + test_and_clear_bool(currd->arch.hvm_domain. qemu_mapcache_invalidate) ) return HVM_HCALL_invalidate; =20 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1207,7 +1207,7 @@ static int construct_vmcs(struct vcpu *v vmx_vmcs_exit(v); =20 /* PVH: paging mode is updated by arch_set_info_guest(). */ - if ( is_hvm_vcpu(v) ) + if ( is_hvm_domain(d) ) { /* will update HOST & GUEST_CR3 as reqd */ paging_update_paging_modes(v); --=__Part2A1E0B0F.1__= Content-Type: text/plain; name="use-is_X_domain-x86-HVM.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="use-is_X_domain-x86-HVM.patch" x86/HVM: prefer is_..._domain() over is_..._vcpu()=0A=0A... when the = domain pointer is already available or such operations=0Aoccur frequently = in a function.=0A=0ASigned-off-by: Jan Beulich =0A=0A---= a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ -445,7 = +445,7 @@ void hvm_do_resume(struct vcpu *v)=0A =0A check_wakeup_from_w= ait();=0A =0A- if ( is_hvm_vcpu(v) )=0A+ if ( is_hvm_domain(d) )=0A = pt_restore_timer(v);=0A =0A list_for_each_entry ( s,=0A@@ = -2312,7 +2312,7 @@ int hvm_vcpu_initialise(struct vcpu *v)=0A =0A = v->arch.hvm_vcpu.inject_trap.vector =3D -1;=0A =0A- if ( is_pvh_vcpu(v) = )=0A+ if ( is_pvh_domain(d) )=0A {=0A v->arch.hvm_vcpu.hcall= _64bit =3D 1; /* PVH 32bitfixme. */=0A /* This is for hvm_long_m= ode_enabled(v). */=0A@@ -2364,9 +2364,7 @@ int hvm_vcpu_initialise(struct = vcpu *v)=0A =0A void hvm_vcpu_destroy(struct vcpu *v)=0A {=0A- struct = domain *d =3D v->domain;=0A-=0A- hvm_all_ioreq_servers_remove_vcpu(d, = v);=0A+ hvm_all_ioreq_servers_remove_vcpu(v->domain, v);=0A =0A = nestedhvm_vcpu_destroy(v);=0A =0A@@ -4921,6 +4920,7 @@ extern const = uint8_t hypercall_args_tabl=0A int hvm_do_hypercall(struct cpu_user_regs = *regs)=0A {=0A struct vcpu *curr =3D current;=0A+ struct domain = *currd =3D curr->domain;=0A struct segment_register sreg;=0A int = mode =3D hvm_guest_x86_mode(curr);=0A uint32_t eax =3D regs->eax;=0A@@ = -4941,12 +4941,12 @@ int hvm_do_hypercall(struct cpu_user_reg=0A = break;=0A }=0A =0A- if ( (eax & 0x80000000) && is_viridian_domain(cu= rr->domain) )=0A+ if ( (eax & 0x80000000) && is_viridian_domain(currd) = )=0A return viridian_hypercall(regs);=0A =0A if ( (eax >=3D = NR_hypercalls) ||=0A- (is_pvh_vcpu(curr) ? !pvh_hypercall64_table[e= ax]=0A- : !hvm_hypercall32_table[eax]) )=0A+ = (is_pvh_domain(currd) ? !pvh_hypercall64_table[eax]=0A+ = : !hvm_hypercall32_table[eax]) )=0A {=0A = regs->eax =3D -ENOSYS;=0A return HVM_HCALL_completed;=0A@@ -4980,7 = +4980,7 @@ int hvm_do_hypercall(struct cpu_user_reg=0A #endif=0A =0A = curr->arch.hvm_vcpu.hcall_64bit =3D 1;=0A- regs->rax =3D = (is_pvh_vcpu(curr)=0A+ regs->rax =3D (is_pvh_domain(currd)=0A = ? pvh_hypercall64_table=0A : hvm_hyperc= all64_table)[eax](rdi, rsi, rdx, r10, r8, r9);=0A curr->arch.hvm_vc= pu.hcall_64bit =3D 0;=0A@@ -5001,7 +5001,7 @@ int hvm_do_hypercall(struct = cpu_user_reg=0A }=0A #endif=0A }=0A- else if ( unlikely(is_p= vh_vcpu(curr)) )=0A+ else if ( unlikely(is_pvh_domain(currd)) )=0A = regs->_eax =3D -ENOSYS; /* PVH 32bitfixme. */=0A else=0A {=0A@@ = -5053,8 +5053,8 @@ int hvm_do_hypercall(struct cpu_user_reg=0A if ( = curr->arch.hvm_vcpu.hcall_preempted )=0A return HVM_HCALL_preempted= ;=0A =0A- if ( unlikely(curr->domain->arch.hvm_domain.qemu_mapcache_inva= lidate) &&=0A- test_and_clear_bool(curr->domain->arch.hvm_domain.= =0A+ if ( unlikely(currd->arch.hvm_domain.qemu_mapcache_invalidate) = &&=0A+ test_and_clear_bool(currd->arch.hvm_domain.=0A = qemu_mapcache_invalidate) )=0A return HVM_HCALL_inv= alidate;=0A =0A--- a/xen/arch/x86/hvm/vmx/vmcs.c=0A+++ b/xen/arch/x86/hvm/v= mx/vmcs.c=0A@@ -1207,7 +1207,7 @@ static int construct_vmcs(struct vcpu = *v=0A vmx_vmcs_exit(v);=0A =0A /* PVH: paging mode is updated by = arch_set_info_guest(). */=0A- if ( is_hvm_vcpu(v) )=0A+ if ( = is_hvm_domain(d) )=0A {=0A /* will update HOST & GUEST_CR3 as = reqd */=0A paging_update_paging_modes(v);=0A --=__Part2A1E0B0F.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part2A1E0B0F.1__=--