From patchwork Mon Mar 20 17:05:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 741086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vn2Vp1KMvz9ryv for ; Tue, 21 Mar 2017 04:09:38 +1100 (AEDT) Received: from localhost ([::1]:34090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cq0oJ-0002Hz-JR for incoming@patchwork.ozlabs.org; Mon, 20 Mar 2017 13:09:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cq0l7-0000MY-PD for qemu-devel@nongnu.org; Mon, 20 Mar 2017 13:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cq0l1-0006hl-RV for qemu-devel@nongnu.org; Mon, 20 Mar 2017 13:06:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cq0l1-0006hV-MD for qemu-devel@nongnu.org; Mon, 20 Mar 2017 13:06:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBFF86264B; Mon, 20 Mar 2017 17:06:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BBFF86264B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BBFF86264B Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-55.phx2.redhat.com [10.3.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3200383802; Mon, 20 Mar 2017 17:06:10 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Date: Mon, 20 Mar 2017 18:05:57 +0100 Message-Id: <20170320170557.15645-3-lersek@redhat.com> In-Reply-To: <20170320170557.15645-1-lersek@redhat.com> References: <20170320170557.15645-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 20 Mar 2017 17:06:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] hw/acpi/vmgenid: prevent more than one vmgenid device 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: Igor Mammedov , Paolo Bonzini , Ben Warren , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" A system with multiple VMGENID devices is undefined in the VMGENID spec by omission. Cc: "Michael S. Tsirkin" Cc: Ben Warren Cc: Igor Mammedov Cc: Paolo Bonzini Signed-off-by: Laszlo Ersek Acked-by: Ben Warren Reviewed-by: Igor Mammedov --- Notes: v2: - use find_vmgenid_dev() rather than open-code object_resolve_path_type() [Michael] - add comments to both the definition of find_vmgenid_dev() and its call site in vmgenid_realize() [Michael] include/hw/acpi/vmgenid.h | 1 + hw/acpi/vmgenid.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/hw/acpi/vmgenid.h b/include/hw/acpi/vmgenid.h index 8578476baebe..7beb9592fb01 100644 --- a/include/hw/acpi/vmgenid.h +++ b/include/hw/acpi/vmgenid.h @@ -24,6 +24,7 @@ typedef struct VmGenIdState { bool write_pointer_available; } VmGenIdState; +/* returns NULL unless there is exactly one device */ static inline Object *find_vmgenid_dev(void) { return object_resolve_path_type("", VMGENID_DEVICE, NULL); diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index c3ddcc8e7cb0..a32b847fe0df 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -221,6 +221,14 @@ static void vmgenid_realize(DeviceState *dev, Error **errp) return; } + /* Given that this function is executing, there is at least one VMGENID + * device. Check if there are several. + */ + if (!find_vmgenid_dev()) { + error_setg(errp, "at most one %s device is permitted", VMGENID_DEVICE); + return; + } + qemu_register_reset(vmgenid_handle_reset, vms); }