From patchwork Wed Sep 14 15:24:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9331879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6283607FD for ; Wed, 14 Sep 2016 15:27:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D60B72A111 for ; Wed, 14 Sep 2016 15:27:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79882A151; Wed, 14 Sep 2016 15:27:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EDB92A111 for ; Wed, 14 Sep 2016 15:27:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkC3Z-00066k-LR; Wed, 14 Sep 2016 15:25:01 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkC3Y-00066Z-FB for xen-devel@lists.xenproject.org; Wed, 14 Sep 2016 15:25:00 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id F7/75-11175-BCB69D75; Wed, 14 Sep 2016 15:24:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsXS6fjDS/dU9s1 wg1v9Khbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bs6x+ZCn7rVBy/+Jm9gXGifBcjJ4eQQJ5E 78qDrCA2r4CdxNbmZ2wgtoSAocTT99fBbBYBVYnX85rBbDYBdYm2Z9uB6jk4RAQMJM4dTQIxm QX0JbatYwExhQWMJD4tFwExeQUEJf7uEAbpYwaa3b7mGcsERq5ZCJlZSDIQtpbEw1+3oGxtiW ULXzPPAhsvLbH8HwdE2Ebi1Z3pzKhKQGx3icmfulkXMHKsYtQoTi0qSy3SNTTVSyrKTM8oyU3 MzNE1NDDTy00tLk5MT81JTCrWS87P3cQIDDwGINjB+G1ZwCFGSQ4mJVHe0uCb4UJ8SfkplRmJ xRnxRaU5qcWHGGU4OJQkeF9lAuUEi1LTUyvSMnOAMQCTluDgURLh5U0HSvMWFyTmFmemQ6ROM SpKifN+A+kTAElklObBtcHi7hKjrJQwLyPQIUI8BalFuZklqPKvGMU5GJWEeY2zgKbwZOaVwE 1/BbSYCWjxljXXQRaXJCKkpBoYy9vmZayRylIo3FNY8uvQ0hifs9411U76FdNlHcXu7n4QLX7 QS8EgWDHVtHNWyM60tyF5XfMm8JRPOJWX5X4ow/yp5m5/ZcuTl8u7vujMZ2+u1+E9n3PtjX27 kO5aoY2m8ZK/f1Z89RRfvmHjfpuKty+rPGJ/dbPkZ01K/DB9r1XTMz/b5lIlluKMREMt5qLiR AB+mhaStgIAAA== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1473866696!59357750!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37903 invoked from network); 14 Sep 2016 15:24:58 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Sep 2016 15:24:58 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 14 Sep 2016 09:24:56 -0600 Message-Id: <57D987E6020000780010EE8F@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Wed, 14 Sep 2016 09:24:54 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH] x86: fold code in load_segments() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP No need to have the same logic twice. Signed-off-by: Jan Beulich x86: fold code in load_segments() No need to have the same logic twice. Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1745,22 +1745,22 @@ static void load_segments(struct vcpu *n (unsigned long *)pv->kernel_sp; unsigned long cs_and_mask, rflags; + /* Fold upcall mask and architectural IOPL into RFLAGS.IF. */ + rflags = regs->rflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); + rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; + if ( VM_ASSIST(n->domain, architectural_iopl) ) + rflags |= n->arch.pv_vcpu.iopl; + if ( is_pv_32bit_vcpu(n) ) { unsigned int *esp = ring_1(regs) ? (unsigned int *)regs->rsp : (unsigned int *)pv->kernel_sp; - unsigned int cs_and_mask, eflags; int ret = 0; /* CS longword also contains full evtchn_upcall_mask. */ cs_and_mask = (unsigned short)regs->cs | ((unsigned int)vcpu_info(n, evtchn_upcall_mask) << 16); - /* Fold upcall mask into RFLAGS.IF. */ - eflags = regs->_eflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); - eflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - if ( VM_ASSIST(n->domain, architectural_iopl) ) - eflags |= n->arch.pv_vcpu.iopl; if ( !ring_1(regs) ) { @@ -1770,7 +1770,7 @@ static void load_segments(struct vcpu *n } if ( ret | - put_user(eflags, esp-1) | + put_user(rflags, esp-1) | put_user(cs_and_mask, esp-2) | put_user(regs->_eip, esp-3) | put_user(uregs->gs, esp-4) | @@ -1805,12 +1805,6 @@ static void load_segments(struct vcpu *n cs_and_mask = (unsigned long)regs->cs | ((unsigned long)vcpu_info(n, evtchn_upcall_mask) << 32); - /* Fold upcall mask into RFLAGS.IF. */ - rflags = regs->rflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); - rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - if ( VM_ASSIST(n->domain, architectural_iopl) ) - rflags |= n->arch.pv_vcpu.iopl; - if ( put_user(regs->ss, rsp- 1) | put_user(regs->rsp, rsp- 2) | put_user(rflags, rsp- 3) | --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1745,22 +1745,22 @@ static void load_segments(struct vcpu *n (unsigned long *)pv->kernel_sp; unsigned long cs_and_mask, rflags; + /* Fold upcall mask and architectural IOPL into RFLAGS.IF. */ + rflags = regs->rflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); + rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; + if ( VM_ASSIST(n->domain, architectural_iopl) ) + rflags |= n->arch.pv_vcpu.iopl; + if ( is_pv_32bit_vcpu(n) ) { unsigned int *esp = ring_1(regs) ? (unsigned int *)regs->rsp : (unsigned int *)pv->kernel_sp; - unsigned int cs_and_mask, eflags; int ret = 0; /* CS longword also contains full evtchn_upcall_mask. */ cs_and_mask = (unsigned short)regs->cs | ((unsigned int)vcpu_info(n, evtchn_upcall_mask) << 16); - /* Fold upcall mask into RFLAGS.IF. */ - eflags = regs->_eflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); - eflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - if ( VM_ASSIST(n->domain, architectural_iopl) ) - eflags |= n->arch.pv_vcpu.iopl; if ( !ring_1(regs) ) { @@ -1770,7 +1770,7 @@ static void load_segments(struct vcpu *n } if ( ret | - put_user(eflags, esp-1) | + put_user(rflags, esp-1) | put_user(cs_and_mask, esp-2) | put_user(regs->_eip, esp-3) | put_user(uregs->gs, esp-4) | @@ -1805,12 +1805,6 @@ static void load_segments(struct vcpu *n cs_and_mask = (unsigned long)regs->cs | ((unsigned long)vcpu_info(n, evtchn_upcall_mask) << 32); - /* Fold upcall mask into RFLAGS.IF. */ - rflags = regs->rflags & ~(X86_EFLAGS_IF|X86_EFLAGS_IOPL); - rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - if ( VM_ASSIST(n->domain, architectural_iopl) ) - rflags |= n->arch.pv_vcpu.iopl; - if ( put_user(regs->ss, rsp- 1) | put_user(regs->rsp, rsp- 2) | put_user(rflags, rsp- 3) |