From patchwork Mon Sep 12 09:51:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9326073 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 D71676089F for ; Mon, 12 Sep 2016 09:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C811828CC7 for ; Mon, 12 Sep 2016 09:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC8D528CC6; Mon, 12 Sep 2016 09:54:19 +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 54D9E28CC6 for ; Mon, 12 Sep 2016 09:54:19 +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 1bjNu2-0007nx-6f; Mon, 12 Sep 2016 09:51:50 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjNu0-0007mn-9g for xen-devel@lists.xen.org; Mon, 12 Sep 2016 09:51:48 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id AA/5E-29579-3BA76D75; Mon, 12 Sep 2016 09:51:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeJIrShJLcpLzFFi42JxWrohUndz1bV wg6b9ghZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aj2fEFp3gr3k9dzNbAeJ6ji5GTQ0LAX+LW huWsIDabgL7E7hefmEBsEQF1idMdF4HiHBzMAn4Shx74goSFBWIk5lzcB1bCIqAq0fVxFwuIz SvgITFp+hYmiJFyEueP/2QGsTkFPCXWvV8OViMEVHPm+g5WCFtN4lr/JXaIXkGJkzOfgNUwC0 hIHHzxghlkrYQAt8TfbvsJjHyzkFTNQlK1gJFpFaN6cWpRWWqRroleUlFmekZJbmJmjq6hgbF ebmpxcWJ6ak5iUrFecn7uJkZgMDEAwQ7Gxi9OhxglOZiURHmTBK+FC/El5adUZiQWZ8QXleak Fh9ilOHgUJLgba4EygkWpaanVqRl5gDDGiYtwcGjJMKbDJLmLS5IzC3OTIdInWJUlBLn7QBJC IAkMkrz4NpgsXSJUVZKmJcR6BAhnoLUotzMElT5V4ziHIxKwrzGIFN4MvNK4Ka/AlrMBLT46d bLIItLEhFSUg2MHuofC6vNj0bu7jj5Wa/TK//A3dnlu60LLbassHItV/vzPLby/BwZbm5f70U dlXOZw7PeRE2OlZYwWaXKwh3l5x9mUKWwasbPnArP/0eVufWe6DIKfJqXdvRpUdgMyV3eO+8I NUU+15ALavjM0vF0+Wsd/0yPqSwfw3V9eH6orro2TbIwf40SS3FGoqEWc1FxIgBa637AoAIAA A== X-Env-Sender: prvs=0565cf92a=Andrew.Cooper3@citrix.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1473673904!56962932!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61053 invoked from network); 12 Sep 2016 09:51:46 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 12 Sep 2016 09:51:46 -0000 X-IronPort-AV: E=Sophos;i="5.30,322,1470700800"; d="scan'208";a="377658233" From: Andrew Cooper To: Xen-devel Date: Mon, 12 Sep 2016 10:51:37 +0100 Message-ID: <1473673900-8585-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473673900-8585-1-git-send-email-andrew.cooper3@citrix.com> References: <1473673900-8585-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 3/6] x86/domctl: Simplfy XEN_DOMCTL_getvcpuextstate when xsave is not in use 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 Older guests will not use xsave even if it is available. As such, their xcr0_accum will be 0 at the point of migrate. If it is empty, forgo the memory allocation and serialisation into a zero-length buffer. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich --- xen/arch/x86/domctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 815bd33..5aa9f3a 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1087,11 +1087,13 @@ long arch_do_domctl( ret = -EFAULT; offset += sizeof(v->arch.xcr0_accum); - if ( !ret ) + + /* Serialise xsave state, if there is any. */ + if ( !ret && size > PV_XSAVE_HDR_SIZE ) { - void *xsave_area; + unsigned int xsave_size = size - PV_XSAVE_HDR_SIZE; + void *xsave_area = xmalloc_bytes(xsave_size); - xsave_area = xmalloc_bytes(size); if ( !xsave_area ) { ret = -ENOMEM; @@ -1099,11 +1101,10 @@ long arch_do_domctl( goto vcpuextstate_out; } - expand_xsave_states(v, xsave_area, - size - PV_XSAVE_HDR_SIZE); + expand_xsave_states(v, xsave_area, xsave_size); if ( copy_to_guest_offset(evc->buffer, offset, xsave_area, - size - PV_XSAVE_HDR_SIZE) ) + xsave_size) ) ret = -EFAULT; xfree(xsave_area); }