From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 autolearn=unavailable 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 91F33C432C3 for ; Thu, 4 Mar 2021 00:29:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C36164EEE for ; Thu, 4 Mar 2021 00:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346218AbhCDA3H (ORCPT ); Wed, 3 Mar 2021 19:29:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49543 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240184AbhCCQZ0 (ORCPT ); Wed, 3 Mar 2021 11:25:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614788615; h=from:from:reply-to:subject:subject: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=ZZNr5bceBUM/gk+WOJoUFQhb4V6dpeoGZW+3Tl4Vl7k=; b=Eok5pkFkKfDHSqSx3w/fy10d8rAED46TxgpcFa1IJRSKda/NAqvfEKypbGkFuEwqnBWpsK lxo6tsdg4hnO+tsmUZFw4PGhntmDiBbb7wk1z0NaIs5807GUBsM/v+sttsHDtPk/LzrJCB d2zGWiXl11rckb+MJFIgnobZK+jey04= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-RAejwn62MKiYt1g9lDimRQ-1; Wed, 03 Mar 2021 11:18:21 -0500 X-MC-Unique: RAejwn62MKiYt1g9lDimRQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E09E7106BB23; Wed, 3 Mar 2021 16:18:19 +0000 (UTC) Received: from MiWiFi-RA69-srv (unknown [10.40.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ABD663B8C; Wed, 3 Mar 2021 16:18:09 +0000 (UTC) Date: Wed, 3 Mar 2021 17:18:08 +0100 From: Igor Mammedov To: David Hildenbrand Cc: qemu-devel@nongnu.org, Thomas Huth , kvm@vger.kernel.org, Cornelia Huck , Peter Xu , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paolo Bonzini , Richard Henderson Subject: Re: [PATCH v1 2/2] exec: Get rid of phys_mem_set_alloc() Message-ID: <20210303171808.4822e880@MiWiFi-RA69-srv> In-Reply-To: <20210303130916.22553-3-david@redhat.com> References: <20210303130916.22553-1-david@redhat.com> <20210303130916.22553-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, 3 Mar 2021 14:09:16 +0100 David Hildenbrand wrote: > As the last user is gone, we can get rid of phys_mem_set_alloc() and > simplify. > > Cc: Paolo Bonzini > Cc: Richard Henderson > Cc: Halil Pasic > Cc: Cornelia Huck > Cc: Christian Borntraeger > Cc: Thomas Huth > Cc: Igor Mammedov > Cc: Peter Xu > Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov > --- > include/sysemu/kvm.h | 4 ---- > softmmu/physmem.c | 36 +++--------------------------------- > 2 files changed, 3 insertions(+), 37 deletions(-) > > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h > index 687c598be9..a1ab1ee12d 100644 > --- a/include/sysemu/kvm.h > +++ b/include/sysemu/kvm.h > @@ -249,10 +249,6 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap); > int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); > int kvm_on_sigbus(int code, void *addr); > > -/* interface with exec.c */ > - > -void phys_mem_set_alloc(void *(*alloc)(size_t, uint64_t *align, bool shared)); > - > /* internal API */ > > int kvm_ioctl(KVMState *s, int type, ...); > diff --git a/softmmu/physmem.c b/softmmu/physmem.c > index 19e0aa9836..141fce79e8 100644 > --- a/softmmu/physmem.c > +++ b/softmmu/physmem.c > @@ -1144,19 +1144,6 @@ static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, > uint16_t section); > static subpage_t *subpage_init(FlatView *fv, hwaddr base); > > -static void *(*phys_mem_alloc)(size_t size, uint64_t *align, bool shared) = > - qemu_anon_ram_alloc; > - > -/* > - * Set a custom physical guest memory alloator. > - * Accelerators with unusual needs may need this. Hopefully, we can > - * get rid of it eventually. > - */ > -void phys_mem_set_alloc(void *(*alloc)(size_t, uint64_t *align, bool shared)) > -{ > - phys_mem_alloc = alloc; > -} > - > static uint16_t phys_section_add(PhysPageMap *map, > MemoryRegionSection *section) > { > @@ -1962,8 +1949,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) > return; > } > } else { > - new_block->host = phys_mem_alloc(new_block->max_length, > - &new_block->mr->align, shared); > + new_block->host = qemu_anon_ram_alloc(new_block->max_length, > + &new_block->mr->align, > + shared); > if (!new_block->host) { > error_setg_errno(errp, errno, > "cannot set up guest memory '%s'", > @@ -2047,17 +2035,6 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, > return NULL; > } > > - if (phys_mem_alloc != qemu_anon_ram_alloc) { > - /* > - * file_ram_alloc() needs to allocate just like > - * phys_mem_alloc, but we haven't bothered to provide > - * a hook there. > - */ > - error_setg(errp, > - "-mem-path not supported with this accelerator"); > - return NULL; > - } > - > size = HOST_PAGE_ALIGN(size); > file_size = get_file_size(fd); > if (file_size > 0 && file_size < size) { > @@ -2247,13 +2224,6 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) > area = mmap(vaddr, length, PROT_READ | PROT_WRITE, > flags, block->fd, offset); > } else { > - /* > - * Remap needs to match alloc. Accelerators that > - * set phys_mem_alloc never remap. If they did, > - * we'd need a remap hook here. > - */ > - assert(phys_mem_alloc == qemu_anon_ram_alloc); > - > flags |= MAP_PRIVATE | MAP_ANONYMOUS; > area = mmap(vaddr, length, PROT_READ | PROT_WRITE, > flags, -1, 0); From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 102D7C433DB for ; Wed, 3 Mar 2021 16:20:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A228C64F10 for ; Wed, 3 Mar 2021 16:20:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A228C64F10 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHUED-0006qg-If for qemu-devel@archiver.kernel.org; Wed, 03 Mar 2021 11:20:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHUDO-0005iM-8H for qemu-devel@nongnu.org; Wed, 03 Mar 2021 11:19:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lHUDM-00070t-5V for qemu-devel@nongnu.org; Wed, 03 Mar 2021 11:19:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614788346; h=from:from:reply-to:subject:subject: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=ZZNr5bceBUM/gk+WOJoUFQhb4V6dpeoGZW+3Tl4Vl7k=; b=Q/Iwr/GKRZ2pTpfnHJRxsKteyB2lMYwnmLnQcA4eC4DJMgILoM4V9gPP4SehEnkFBqgivH LmfaQeC4FYbaXlWcQ8hjLPgVu3xA9JAfkUFurlpQ8ip9dQqoKVYYxon5XSXyXq0sdBlRju te0faKAyb3FkiroBqqdCX1MDyGn6QQY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-RAejwn62MKiYt1g9lDimRQ-1; Wed, 03 Mar 2021 11:18:21 -0500 X-MC-Unique: RAejwn62MKiYt1g9lDimRQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E09E7106BB23; Wed, 3 Mar 2021 16:18:19 +0000 (UTC) Received: from MiWiFi-RA69-srv (unknown [10.40.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ABD663B8C; Wed, 3 Mar 2021 16:18:09 +0000 (UTC) Date: Wed, 3 Mar 2021 17:18:08 +0100 From: Igor Mammedov To: David Hildenbrand Subject: Re: [PATCH v1 2/2] exec: Get rid of phys_mem_set_alloc() Message-ID: <20210303171808.4822e880@MiWiFi-RA69-srv> In-Reply-To: <20210303130916.22553-3-david@redhat.com> References: <20210303130916.22553-1-david@redhat.com> <20210303130916.22553-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Received-SPF: pass client-ip=216.205.24.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , kvm@vger.kernel.org, Cornelia Huck , qemu-devel@nongnu.org, Peter Xu , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, 3 Mar 2021 14:09:16 +0100 David Hildenbrand wrote: > As the last user is gone, we can get rid of phys_mem_set_alloc() and > simplify. > > Cc: Paolo Bonzini > Cc: Richard Henderson > Cc: Halil Pasic > Cc: Cornelia Huck > Cc: Christian Borntraeger > Cc: Thomas Huth > Cc: Igor Mammedov > Cc: Peter Xu > Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov > --- > include/sysemu/kvm.h | 4 ---- > softmmu/physmem.c | 36 +++--------------------------------- > 2 files changed, 3 insertions(+), 37 deletions(-) > > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h > index 687c598be9..a1ab1ee12d 100644 > --- a/include/sysemu/kvm.h > +++ b/include/sysemu/kvm.h > @@ -249,10 +249,6 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap); > int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); > int kvm_on_sigbus(int code, void *addr); > > -/* interface with exec.c */ > - > -void phys_mem_set_alloc(void *(*alloc)(size_t, uint64_t *align, bool shared)); > - > /* internal API */ > > int kvm_ioctl(KVMState *s, int type, ...); > diff --git a/softmmu/physmem.c b/softmmu/physmem.c > index 19e0aa9836..141fce79e8 100644 > --- a/softmmu/physmem.c > +++ b/softmmu/physmem.c > @@ -1144,19 +1144,6 @@ static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end, > uint16_t section); > static subpage_t *subpage_init(FlatView *fv, hwaddr base); > > -static void *(*phys_mem_alloc)(size_t size, uint64_t *align, bool shared) = > - qemu_anon_ram_alloc; > - > -/* > - * Set a custom physical guest memory alloator. > - * Accelerators with unusual needs may need this. Hopefully, we can > - * get rid of it eventually. > - */ > -void phys_mem_set_alloc(void *(*alloc)(size_t, uint64_t *align, bool shared)) > -{ > - phys_mem_alloc = alloc; > -} > - > static uint16_t phys_section_add(PhysPageMap *map, > MemoryRegionSection *section) > { > @@ -1962,8 +1949,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) > return; > } > } else { > - new_block->host = phys_mem_alloc(new_block->max_length, > - &new_block->mr->align, shared); > + new_block->host = qemu_anon_ram_alloc(new_block->max_length, > + &new_block->mr->align, > + shared); > if (!new_block->host) { > error_setg_errno(errp, errno, > "cannot set up guest memory '%s'", > @@ -2047,17 +2035,6 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, > return NULL; > } > > - if (phys_mem_alloc != qemu_anon_ram_alloc) { > - /* > - * file_ram_alloc() needs to allocate just like > - * phys_mem_alloc, but we haven't bothered to provide > - * a hook there. > - */ > - error_setg(errp, > - "-mem-path not supported with this accelerator"); > - return NULL; > - } > - > size = HOST_PAGE_ALIGN(size); > file_size = get_file_size(fd); > if (file_size > 0 && file_size < size) { > @@ -2247,13 +2224,6 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) > area = mmap(vaddr, length, PROT_READ | PROT_WRITE, > flags, block->fd, offset); > } else { > - /* > - * Remap needs to match alloc. Accelerators that > - * set phys_mem_alloc never remap. If they did, > - * we'd need a remap hook here. > - */ > - assert(phys_mem_alloc == qemu_anon_ram_alloc); > - > flags |= MAP_PRIVATE | MAP_ANONYMOUS; > area = mmap(vaddr, length, PROT_READ | PROT_WRITE, > flags, -1, 0);