From patchwork Tue Apr 12 11:55:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 8809691 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D5C2C0553 for ; Tue, 12 Apr 2016 11:56:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD12620148 for ; Tue, 12 Apr 2016 11:56:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13A5D201C8 for ; Tue, 12 Apr 2016 11:56:00 +0000 (UTC) Received: from localhost ([::1]:47873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apwvH-0004NM-H1 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Apr 2016 07:55:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apwuv-0004Im-Vg for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apwuu-0008LS-Rz for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:37 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:35124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apwuu-0008LN-LW for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:36 -0400 Received: by mail-qk0-x22c.google.com with SMTP id o6so4894079qkc.2 for ; Tue, 12 Apr 2016 04:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n8rEQAIiqxRpyZ946UCusoBc5tRs4LDZh8YygWCZeGM=; b=RR52gsXbr5HEU1kL9aA8Rsjd7xW71xnt1ZaHNIs2C3Taef6kc5II0doXHTHD5Ntqtu Ja3uBGJMNUjKttp9RhAFgOhRFK2HjNSijdsh5uXiQYXO8scxCs7gbU68xKDkXza9jI4c /+jCv6MYrjj1uXTmcoEUxGoJ1mTu5ylSEkpTcREHYKZKPGTnoG5WfjiQNvkfolcIQc1k PcLO9wm1qBsOeyeaEy8MhVaqdJV6l4RJLQss0ahceKqqxP7z4hRUavOIgmUyjXfQ1owF cqoQI1QO9AMiBxY2XjrR8aFQ2VEUXXH96JVjtewD18XRlsrit7FJdw9ryd8Zdo0b0KJC 5+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=n8rEQAIiqxRpyZ946UCusoBc5tRs4LDZh8YygWCZeGM=; b=FHynJQUz9677O4kVLrU7xDIb1XqaDnuxh3CgLRaQ9C6pDq1nBgob2nBwi8Rwi66sBF iM2PMdD5zLd+qFDx9tIraZCjsbR9th8qW5GPnTku/OkyEqG9DqpM0odtoxmxUz0/hnIf zsfZd/qRwN2512MhYIV5fRLCi+bkmb6BkmfUx4BXJ9KgEcaH/zswnRz5v5r5XQKHFPJh EVBStVkKzI4bU/HAhETLXkx7BAhGrNRkQjWv0Eu1TXjmSBayRhOnm8Cn65+h8eI3jikh 07q3RLJps2vHUmLqX1SJiHqG4WaFHIc1jFRzSFJOoVNc0qOfSDNbKDqrZYw+as0Acemz gSKA== X-Gm-Message-State: AOPr4FUKrGlg98P9Pish/yE4DoujVAbblG94JWoKDg8JX4AppCMVtHGdTuOUrFfi5piBrg== X-Received: by 10.55.17.102 with SMTP id b99mr2725759qkh.86.1460462136033; Tue, 12 Apr 2016 04:55:36 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id 38sm13410154qgn.6.2016.04.12.04.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Apr 2016 04:55:35 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 12 Apr 2016 13:55:21 +0200 Message-Id: <1460462129-17363-2-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1460462129-17363-1-git-send-email-marcandre.lureau@redhat.com> References: <1460462129-17363-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::22c Subject: [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier 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: pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau Move kvm mmu notifiers check before calling file_ram_alloc(). This shouldn't change the validation logic. Signed-off-by: Marc-André Lureau --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index c4f9036..dcc6632 100644 --- a/exec.c +++ b/exec.c @@ -1242,12 +1242,6 @@ static void *file_ram_alloc(RAMBlock *block, int fd = -1; int64_t page_size; - if (kvm_enabled() && !kvm_has_sync_mmu()) { - error_setg(errp, - "host lacks kvm mmu notifiers, -mem-path unsupported"); - return NULL; - } - for (;;) { fd = open(path, O_RDWR); if (fd >= 0) { @@ -1675,6 +1669,12 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, return NULL; } + if (kvm_enabled() && !kvm_has_sync_mmu()) { + error_setg(errp, + "host lacks kvm mmu notifiers, -mem-path unsupported"); + return NULL; + } + size = HOST_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr;