From patchwork Thu Jan 10 12:01:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Kotov X-Patchwork-Id: 10755627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CC1E13BF for ; Thu, 10 Jan 2019 12:08:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 290DF20408 for ; Thu, 10 Jan 2019 12:08:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CD26292CC; Thu, 10 Jan 2019 12:08: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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7A8520408 for ; Thu, 10 Jan 2019 12:08:18 +0000 (UTC) Received: from localhost ([127.0.0.1]:53606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ8D-0006XA-SO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 10 Jan 2019 07:08:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ1m-0001CP-38 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZ1l-00005l-23 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:38 -0500 Received: from forwardcorp1j.cmail.yandex.net ([2a02:6b8:0:1630::190]:46728) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghZ1k-0008SW-AC for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:36 -0500 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1j.cmail.yandex.net (Yandex) with ESMTP id DD704214C0; Thu, 10 Jan 2019 15:01:28 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id d2V7HgmQQs-1ShCtckd; Thu, 10 Jan 2019 15:01:28 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1547121688; bh=yvT5e3Voe+f4VgnYTnsxIaLwwaR8Q/7pKbPJONY6WzM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=nuQh95ymu6QPoIGvJeRL7xf11k5GvYZ1RSNlJ9wuxCf+j6SWJ5/wpocIz3bDmSvMw yqzLVk2q7GcTTwkH62bLpspD4nlXYcvhV7Q2g5HvniQcgQS+r2UvKj3VZm0EASIikV DDbNOYoSfa+h9HAOpupp55O+3OKlLfrA3nfJ7/ks= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:e1bb:a1a7:a235:d6b4]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id v4PGSBu40N-1ShWTwNP; Thu, 10 Jan 2019 15:01:28 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Yury Kotov To: qemu-devel@nongnu.org, Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier Date: Thu, 10 Jan 2019 15:01:18 +0300 Message-Id: <20190110120120.9943-3-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110120120.9943-1-yury-kotov@yandex-team.ru> References: <20190110120120.9943-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:6b8:0:1630::190 Subject: [Qemu-devel] [PATCH 2/4] exec: add RAM_EXTERNAL flag to mark non-QEMU allocated blocks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wrfsh@yandex-team.ru Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This flag allows to determine whether RAM block is available from the outside. E.g. when we use -object memory-backend-file or -mem-path options we have a RAM block which is mapped to shared file. We need this flag in the following commits. Signed-off-by: Yury Kotov --- backends/hostmem-file.c | 3 ++- exec.c | 2 +- include/exec/memory.h | 3 +++ numa.c | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 7a34e25c43..37fe28f2ac 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -63,7 +63,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) name, backend->size, fb->align, (backend->share ? RAM_SHARED : 0) | - (fb->is_pmem ? RAM_PMEM : 0), + (fb->is_pmem ? RAM_PMEM : 0) | + RAM_EXTERNAL, fb->mem_path, errp); g_free(name); #endif diff --git a/exec.c b/exec.c index 6e875f0640..ef2f29d7cb 100644 --- a/exec.c +++ b/exec.c @@ -2241,7 +2241,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, int64_t file_size; /* Just support these ram flags by now. */ - assert((ram_flags & ~(RAM_SHARED | RAM_PMEM)) == 0); + assert((ram_flags & ~(RAM_SHARED | RAM_PMEM | RAM_EXTERNAL)) == 0); if (xen_enabled()) { error_setg(errp, "-mem-path not supported with Xen"); diff --git a/include/exec/memory.h b/include/exec/memory.h index ffd23ed8d8..3a9cb34f1e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -126,6 +126,9 @@ typedef struct IOMMUNotifier IOMMUNotifier; /* RAM is a persistent kind memory */ #define RAM_PMEM (1 << 5) +/* RAM is from external source (e.g. from file) */ +#define RAM_EXTERNAL (1 << 6) + static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, IOMMUNotifierFlag flags, hwaddr start, hwaddr end, diff --git a/numa.c b/numa.c index 50ec016013..653c5a08de 100644 --- a/numa.c +++ b/numa.c @@ -482,8 +482,8 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, if (mem_path) { #ifdef __linux__ Error *err = NULL; - memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &err); + memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, + RAM_EXTERNAL, mem_path, &err); if (err) { error_report_err(err); if (mem_prealloc) {