From: "Jan Beulich" Subject: [PATCH 1/3] x86: streamline hypercall_create_continuation() Date: Thu, 08 Jan 2015 15:22:25 +0000 Message-ID: <54AEAEC10200007800052B79@mail.emea.novell.com> References: <54AEAD2C0200007800052B56@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part93A664A1.0__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y9Eur-0007bA-RZ for xen-devel@lists.xenproject.org; Thu, 08 Jan 2015 15:22:30 +0000 In-Reply-To: <54AEAD2C0200007800052B56@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: 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. --=__Part93A664A1.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - drop clearing of excessive multicall arguments in compat case (no longer needed now that hypercall_xlat_continuation() only checks the actual arguments) - latch current into a local variable - use the cached value of hvm_guest_x86_mode() instead of re-executing it - scope restrict "regs" - while at it, convert the remaining two argument checking BUG_ON()s in hypercall_xlat_continuation() to ASSERT()s Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1675,7 +1675,6 @@ unsigned long hypercall_create_continuat unsigned int op, const char *format, ...) { struct mc_state *mcs =3D ¤t->mc_state; - struct cpu_user_regs *regs; const char *p =3D format; unsigned long arg; unsigned int i; @@ -1689,26 +1688,23 @@ unsigned long hypercall_create_continuat =20 for ( i =3D 0; *p !=3D '\0'; i++ ) mcs->call.args[i] =3D next_arg(p, args); - if ( is_pv_32on64_domain(current->domain) ) - { - for ( ; i < 6; i++ ) - mcs->call.args[i] =3D 0; - } } else { - regs =3D guest_cpu_user_regs(); - regs->eax =3D op; + struct cpu_user_regs *regs =3D guest_cpu_user_regs(); + struct vcpu *curr =3D current; + + regs->eax =3D op; =20 /* Ensure the hypercall trap instruction is re-executed. */ - if ( is_pv_vcpu(current) ) + if ( is_pv_vcpu(curr) ) regs->eip -=3D 2; /* re-execute 'syscall' / 'int $xx' */ else - current->arch.hvm_vcpu.hcall_preempted =3D 1; + curr->arch.hvm_vcpu.hcall_preempted =3D 1; =20 - if ( is_pv_vcpu(current) ? - !is_pv_32on64_vcpu(current) : - (hvm_guest_x86_mode(current) =3D=3D 8) ) + if ( is_pv_vcpu(curr) ? + !is_pv_32on64_vcpu(curr) : + curr->arch.hvm_vcpu.hcall_64bit ) { for ( i =3D 0; *p !=3D '\0'; i++ ) { @@ -1759,9 +1755,8 @@ int hypercall_xlat_continuation(unsigned =20 ASSERT(nr <=3D ARRAY_SIZE(mcs->call.args)); ASSERT(!(mask >> nr)); - - BUG_ON(id && *id >=3D nr); - BUG_ON(id && (mask & (1U << *id))); + ASSERT(!id || *id < nr); + ASSERT(!id || !(mask & (1U << *id))); =20 va_start(args, mask); =20 --=__Part93A664A1.0__= Content-Type: text/plain; name="x86-hcc-streamline.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-hcc-streamline.patch" x86: streamline hypercall_create_continuation()=0A=0A- drop clearing of = excessive multicall arguments in compat case (no=0A longer needed now = that hypercall_xlat_continuation() only checks the=0A actual arguments)=0A= - latch current into a local variable=0A- use the cached value of = hvm_guest_x86_mode() instead of re-executing=0A it=0A- scope restrict = "regs"=0A- while at it, convert the remaining two argument checking = BUG_ON()s in=0A hypercall_xlat_continuation() to ASSERT()s=0A=0ASigned-off= -by: Jan Beulich =0A=0A--- a/xen/arch/x86/domain.c=0A+++= b/xen/arch/x86/domain.c=0A@@ -1675,7 +1675,6 @@ unsigned long hypercall_cr= eate_continuat=0A unsigned int op, const char *format, ...)=0A {=0A = struct mc_state *mcs =3D ¤t->mc_state;=0A- struct cpu_user_regs = *regs;=0A const char *p =3D format;=0A unsigned long arg;=0A = unsigned int i;=0A@@ -1689,26 +1688,23 @@ unsigned long hypercall_create_co= ntinuat=0A =0A for ( i =3D 0; *p !=3D '\0'; i++ )=0A = mcs->call.args[i] =3D next_arg(p, args);=0A- if ( is_pv_32on64_domai= n(current->domain) )=0A- {=0A- for ( ; i < 6; i++ )=0A- = mcs->call.args[i] =3D 0;=0A- }=0A }=0A = else=0A {=0A- regs =3D guest_cpu_user_regs();=0A- = regs->eax =3D op;=0A+ struct cpu_user_regs *regs =3D guest_cpu_user= _regs();=0A+ struct vcpu *curr =3D current;=0A+=0A+ = regs->eax =3D op;=0A =0A /* Ensure the hypercall trap instruction = is re-executed. */=0A- if ( is_pv_vcpu(current) )=0A+ if ( = is_pv_vcpu(curr) )=0A regs->eip -=3D 2; /* re-execute = 'syscall' / 'int $xx' */=0A else=0A- current->arch.hvm_v= cpu.hcall_preempted =3D 1;=0A+ curr->arch.hvm_vcpu.hcall_preempt= ed =3D 1;=0A =0A- if ( is_pv_vcpu(current) ?=0A- = !is_pv_32on64_vcpu(current) :=0A- (hvm_guest_x86_mode(current) = =3D=3D 8) )=0A+ if ( is_pv_vcpu(curr) ?=0A+ !is_pv_32on6= 4_vcpu(curr) :=0A+ curr->arch.hvm_vcpu.hcall_64bit )=0A = {=0A for ( i =3D 0; *p !=3D '\0'; i++ )=0A {=0A@@ = -1759,9 +1755,8 @@ int hypercall_xlat_continuation(unsigned=0A =0A = ASSERT(nr <=3D ARRAY_SIZE(mcs->call.args));=0A ASSERT(!(mask >> = nr));=0A-=0A- BUG_ON(id && *id >=3D nr);=0A- BUG_ON(id && (mask & = (1U << *id)));=0A+ ASSERT(!id || *id < nr);=0A+ ASSERT(!id || !(mask = & (1U << *id)));=0A =0A va_start(args, mask);=0A =0A --=__Part93A664A1.0__= 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 --=__Part93A664A1.0__=--