From patchwork Mon Nov 23 14:31:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11925443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93547C56202 for ; Mon, 23 Nov 2020 14:31:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 332332083E for ; Mon, 23 Nov 2020 14:31:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rwSZO9BP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 332332083E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.34483.65580 (Exim 4.92) (envelope-from ) id 1khCsF-0000Ct-7a; Mon, 23 Nov 2020 14:31:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 34483.65580; Mon, 23 Nov 2020 14:31:23 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khCsF-0000Cl-4V; Mon, 23 Nov 2020 14:31:23 +0000 Received: by outflank-mailman (input) for mailman id 34483; Mon, 23 Nov 2020 14:31:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khCsD-0000Ce-T1 for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 14:31:21 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 24754e3a-a5a6-41cf-8762-b3a6221cee56; Mon, 23 Nov 2020 14:31:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2EACAACD5; Mon, 23 Nov 2020 14:31:20 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khCsD-0000Ce-T1 for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 14:31:21 +0000 X-Inumbo-ID: 24754e3a-a5a6-41cf-8762-b3a6221cee56 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 24754e3a-a5a6-41cf-8762-b3a6221cee56; Mon, 23 Nov 2020 14:31:21 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606141880; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IsGbx7nHAowOELB1I3S+0clwo01gLUbz8o/IEuZBhpE=; b=rwSZO9BPFZHHcFHWKBUzLbQPaBugEUg808iZMW88IY0qavsHxBEnfIvAMiZ2+btxdPkBCF RUBcemqpJHiZ3FwEEqKIC65HjJiEdnveeq+X4TLWmkZwURhovAPfdemP7HL0HKN1nfID/0 W6v/VmD7k9T7/MtMlXdRkCALwfeLldA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2EACAACD5; Mon, 23 Nov 2020 14:31:20 +0000 (UTC) Subject: [PATCH v2 09/17] x86: use xvmalloc() for extended context buffer allocations From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Wei Liu , =?utf-8?q?R?= =?utf-8?q?oger_Pau_Monn=C3=A9?= References: <255f466c-3c95-88c5-3e55-0f04c9ae1b12@suse.com> Message-ID: <1e352dd9-016c-d15e-c1bb-64fb28df8b73@suse.com> Date: Mon, 23 Nov 2020 15:31:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <255f466c-3c95-88c5-3e55-0f04c9ae1b12@suse.com> Content-Language: en-US This is in preparation for the buffer sizes exceeding a page's worth of space, as will happen with AMX as well as Architectural LBR. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -331,7 +332,7 @@ long arch_do_domctl( goto sethvmcontext_out; ret = -ENOMEM; - if ( (c.data = xmalloc_bytes(c.size)) == NULL ) + if ( (c.data = xvmalloc_bytes(c.size)) == NULL ) goto sethvmcontext_out; ret = -EFAULT; @@ -343,7 +344,7 @@ long arch_do_domctl( domain_unpause(d); sethvmcontext_out: - xfree(c.data); + xvfree(c.data); break; } @@ -373,7 +374,7 @@ long arch_do_domctl( /* Allocate our own marshalling buffer */ ret = -ENOMEM; - if ( (c.data = xmalloc_bytes(c.size)) == NULL ) + if ( (c.data = xvmalloc_bytes(c.size)) == NULL ) goto gethvmcontext_out; domain_pause(d); @@ -386,7 +387,7 @@ long arch_do_domctl( gethvmcontext_out: copyback = true; - xfree(c.data); + xvfree(c.data); break; } @@ -904,7 +905,7 @@ long arch_do_domctl( if ( !ret && size > PV_XSAVE_HDR_SIZE ) { unsigned int xsave_size = size - PV_XSAVE_HDR_SIZE; - void *xsave_area = xmalloc_bytes(xsave_size); + void *xsave_area = xvmalloc_bytes(xsave_size); if ( !xsave_area ) { @@ -918,7 +919,7 @@ long arch_do_domctl( if ( copy_to_guest_offset(evc->buffer, offset, xsave_area, xsave_size) ) ret = -EFAULT; - xfree(xsave_area); + xvfree(xsave_area); } vcpu_unpause(v); @@ -938,7 +939,7 @@ long arch_do_domctl( evc->size > PV_XSAVE_SIZE(xfeature_mask) ) goto vcpuextstate_out; - receive_buf = xmalloc_bytes(evc->size); + receive_buf = xvmalloc_bytes(evc->size); if ( !receive_buf ) { ret = -ENOMEM; @@ -948,7 +949,7 @@ long arch_do_domctl( offset, evc->size) ) { ret = -EFAULT; - xfree(receive_buf); + xvfree(receive_buf); goto vcpuextstate_out; } @@ -966,7 +967,7 @@ long arch_do_domctl( ret = 0; if ( ret ) { - xfree(receive_buf); + xvfree(receive_buf); goto vcpuextstate_out; } @@ -994,7 +995,7 @@ long arch_do_domctl( vcpu_unpause(v); } - xfree(receive_buf); + xvfree(receive_buf); } #undef PV_XSAVE_HDR_SIZE --- a/xen/arch/x86/hvm/save.c +++ b/xen/arch/x86/hvm/save.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -154,7 +155,7 @@ int hvm_save_one(struct domain *d, unsig else v = d->vcpu[instance]; ctxt.size = hvm_sr_handlers[typecode].size; - ctxt.data = xmalloc_bytes(ctxt.size); + ctxt.data = xvmalloc_bytes(ctxt.size); if ( !ctxt.data ) return -ENOMEM; @@ -200,7 +201,7 @@ int hvm_save_one(struct domain *d, unsig else domain_unpause(d); - xfree(ctxt.data); + xvfree(ctxt.data); return rv; }