From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712290; cv=none; d=zohomail.com; s=zohoarc; b=WuY5GUFYYAU2SdqA4tgsCYrtmEigu/CDV561mC+HxGtmIyiRNo4HDeRHIMCqB2wI+78bjr1U9nmEHwlQPdwfzUz2gtGjOxsmAc4wOsvfF9rMaQCxPX0CRj1FbIvu5qQKkoRkrLYy34EtuFUxK4m7y5pbJDZUTTtGHgBvP3juFdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712290; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pgvSzvRpmWevdA6Azv2SdIXa+CwDZXf40b5iS9adnz0=; b=CFGKQyxJxOexh/M6M++QiW6APs4v5cMBWMgDpAiEoHy0IOyZFwclQK/cj/KrF7pSpDpuTmw1Xo51TSfQ9oB4PGV6NGJui/zwW9VsDRlRQvN8zx0UXaiZqB+XWv7hoyW1rRVDwG9um/qJzud3TXXKve+LRrpWO2uSKYelPdfxKnw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712290976691.0034069687396; Tue, 6 Apr 2021 05:31:30 -0700 (PDT) Received: from localhost ([::1]:38732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkrh-0000OS-Fu for importer@patchew.org; Tue, 06 Apr 2021 08:31:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AF-FZ for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:55080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn2-0005kw-7c for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wm1-x335.google.com with SMTP id k128so7280291wmk.4 for ; Tue, 06 Apr 2021 05:26:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pgvSzvRpmWevdA6Azv2SdIXa+CwDZXf40b5iS9adnz0=; b=rVXZgVQ4q2Ar/ruSUqRqEA12TzvQo6DgJ3J+JjqyIh0vPh2iJ+bKZH3vPmeNEEuJRt 5Ig/v1bAnIUrZUT0hJxWnier7qWJj75ukXeua3A4l8qtJD0BIKHzANULh+135ikHNqEF F+8x2lJ9pb8YDH1C1hRWjwfWVN16JNsVNnndVreNVG0Q/wXE24pMzHVWuFiOx0NBFXPs ZMfNXQvsscvGpFZMYXtOArVEoup2Qvv8Sp/WXYDL3/w0huDaTKAcdJB64ocuxKuA1d/M 3KbC08Fbv/BeXE6ChD0RBhJEjNvGrpnN7NF9qVXPH5ASTeksyjoE3VVUcM9fYsAmeHJ6 xP+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pgvSzvRpmWevdA6Azv2SdIXa+CwDZXf40b5iS9adnz0=; b=KURJyFxtbgCU42nebYsDiNH6Wyx6qZFSvZaq9IgmOXJLyZVxjliOxbcnLcnDE966xr zbt42jrhJYJkylV5dOol4ReHSal1Ci1Zj+ZT4U01UYvfaqMYtViViLue9qB9SHywFf/n S7N/QZ6BEmgamoNDsdmmgDoHWLK247x6vRnio+HkKtKUd1oqazlXTZpviuU0UxFt7q8G Ue/KTvn6mjyll620lP0h2qR7/+iWebQlhQHD+RFZaj/NDCxPpXc87+sPM8nTXJl+oxQU NOK3CgWHFYkPB9R5tcSG7RleWGjuDl9Ing5gV0/c+nipu+AaT/YLNZopi3QKK5tYhJOg 800A== X-Gm-Message-State: AOAM532iIywYZCdeaHaaxagVfgKyuhwh+YMVABqaa5ktosnTKlWzaOOz /yuIuO58wHNia0snH+cHwJHXxn8Ww4mTD+Rd X-Google-Smtp-Source: ABdhPJx90ukWBJM3JJTEYEcyZh2b6LDr3BXXptOF1kbyMQ3FZFSNoh3QE+43wnBP1D40RFAu37cEKA== X-Received: by 2002:a05:600c:2282:: with SMTP id 2mr3866390wmf.93.1617711998172; Tue, 06 Apr 2021 05:26:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/6] include/hw/boards.h: Document machine_class_allow_dynamic_sysbus_dev() Date: Tue, 6 Apr 2021 13:26:30 +0100 Message-Id: <20210406122635.28268-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The function machine_class_allow_dynamic_sysbus_dev() is currently undocumented; add a doc comment. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Mark Cave-Ayland Reviewed-by: Eric Auger Message-id: 20210325153310.9131-2-peter.maydell@linaro.org --- include/hw/boards.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 4a90549ad85..6fc5cefcec5 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -36,7 +36,22 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); =20 +/** + * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devic= es + * @mc: Machine class + * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) + * + * Add the QOM type @type to the list of devices of which are subtypes + * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically + * created (eg by the user on the command line with -device). + * By default if the user tries to create any devices on the command line + * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; + * for the special cases which are permitted for this machine model, the + * machine model class init code must call this function to add them + * to the list of specifically permitted devices. + */ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); + /* * Checks that backend isn't used, preps it for exclusive usage and * returns migratable MemoryRegion provided by backend. --=20 2.20.1 From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712209; cv=none; d=zohomail.com; s=zohoarc; b=BoEDTp1pZ+vMcuLoY2gE6huQ+NbvdKK06HXYsuUHWlETJY17oGErSYln+E6yIrbHdXmYZQmeY5zZ51DLudBK6eNtKb+IPlb9EvYkWCXzKM6Oamjf3MCs9x5tfzjrh/OKVIbSfjDRl3jZoEMgpG2aSDClPLqJjdv9ulwT2qvjMgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712209; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=17XfflfUlGVHU6RbDSkYhvFuXhDahwD01JFccu5xxNc=; b=UFT2D3aGeqa2j+zexeGmh+zS7F1EGIwGNbixKi4tXMzPhPN7/fCvNdygTYD8asPjkS2JNelvKIFWvE6xicsbUysG83qm5RUhm6iA8jjCe6N+EQ86i/I0lkz4QVE5YFQs3NuS/v7DeyQCc8zbbxyF4+OxKKqH/fRTvO77DqGnNao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712209591675.1802867402995; Tue, 6 Apr 2021 05:30:09 -0700 (PDT) Received: from localhost ([::1]:36542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkqN-0007vt-Vz for importer@patchew.org; Tue, 06 Apr 2021 08:30:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AJ-EV for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:40791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn2-0005ky-5C for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wr1-x42e.google.com with SMTP id v11so13998727wro.7 for ; Tue, 06 Apr 2021 05:26:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=17XfflfUlGVHU6RbDSkYhvFuXhDahwD01JFccu5xxNc=; b=jnHJ2O3/JTwxGFz3/r/sMeOWs0iNNc3hh4icSpHG9ptLu+uKxFnvblSOUA2flCniqm et2RxxZsUYOghsC2WkpWfd0Adr7nYhq8gRgJE7DlVy7VOthKT+qrXGPqasfaFaf08YHP gZm2lQlYSxWiCV+V7fs70XpfgGpEp20eMyCnDisU9upyVNVLJnpVRTtAVPzTOS17OWPc WofEywGxqd6YQ1AcENXxOm+kCqs7zNzkG6lcxMhdRH2mb9o9psCn2UtSveLIk+ZjDlrL fvE4Ssj8flrKMU/yNgL8/W/rwkUdbu4DufO1Nx1mYdfxQLKaopENaPGTxSD3TN4VVI3U OGKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=17XfflfUlGVHU6RbDSkYhvFuXhDahwD01JFccu5xxNc=; b=TGyp1W0BED8w11gTgg5KoTu6ooGzc3q4/Q5Grte1m7HkdEBixQJS9ibxQ79l158ajv yGJ2YpRQhjULim+deuqxbusv4o8giN88Po3/2YDcZz3sPQ6cUKwCP68M0uUNZw2GvFyJ F3xgJIreA2z6nN1wQiiXRYq3LcONqekoU9bmkKf5z27jKO01OH+g8b0G2Im7QIjG3bwP R2jXutdfc0Bs9mTkgrxNa4fexC6itwXsLsQ7UNl+q3rHXDXeezYgMDi2Pw2UVuQBVVHO joi9xJFktNVjtg7DiKqI+uDqe0j/IinEaU4RimuLe4AdUMlWCWq368Mm5mlRGlhkgFe7 qANg== X-Gm-Message-State: AOAM533lpSTwQ3m5E59RCnRxpfB9W2IzelFpBTE+ecq1oyacAo3IjEZY BfsTAGZNb28bKaAAzckb7c7k0z8XcG0EFaeJ X-Google-Smtp-Source: ABdhPJxav+tah0SN9ysHgiLHURtgA6INquKfMj56BwqZfKi2FwKJKhkH7fR4TlyaJWJ2+eHJZmfBpQ== X-Received: by 2002:adf:e482:: with SMTP id i2mr34531523wrm.392.1617711998761; Tue, 06 Apr 2021 05:26:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/6] machine: Provide a function to check the dynamic sysbus allowlist Date: Tue, 6 Apr 2021 13:26:31 +0100 Message-Id: <20210406122635.28268-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Provide a new function dynamic_sysbus_dev_allowed() which checks the per-machine list of permitted dynamic sysbus devices and returns a boolean result indicating whether the device is allowed. We can use this in the implementation of validate_sysbus_device(), but we will also need it so that machine hotplug callbacks can validate devices rather than assuming that any sysbus device might be hotpluggable into the platform bus. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Mark Cave-Ayland Reviewed-by: Eric Auger Message-id: 20210325153310.9131-3-peter.maydell@linaro.org --- include/hw/boards.h | 24 ++++++++++++++++++++++++ hw/core/machine.c | 21 ++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6fc5cefcec5..ad6c8fd5376 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -52,6 +52,30 @@ void machine_set_cpu_numa_node(MachineState *machine, */ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); =20 +/** + * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device + * @mc: Machine class + * @dev: device to check + * + * Returns: true if @dev is a sysbus device on the machine's list + * of dynamically pluggable sysbus devices; otherwise false. + * + * This function checks whether @dev is a valid dynamic sysbus device, + * by first confirming that it is a sysbus device and then checking it + * against the list of permitted dynamic sysbus devices which has been + * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). + * + * It is valid to call this with something that is not a subclass of + * TYPE_SYS_BUS_DEVICE; the function will return false in this case. + * This allows hotplug callback functions to be written as: + * if (device_is_dynamic_sysbus(mc, dev)) { + * handle dynamic sysbus case; + * } else if (some other kind of hotplug) { + * handle that; + * } + */ +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); + /* * Checks that backend isn't used, preps it for exclusive usage and * returns migratable MemoryRegion provided by backend. diff --git a/hw/core/machine.c b/hw/core/machine.c index 9935c6ddd56..8d97094736a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -529,20 +529,31 @@ void machine_class_allow_dynamic_sysbus_dev(MachineCl= ass *mc, const char *type) QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type)); } =20 -static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) { - MachineState *machine =3D opaque; - MachineClass *mc =3D MACHINE_GET_CLASS(machine); bool allowed =3D false; strList *wl; + Object *obj =3D OBJECT(dev); + + if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { + return false; + } =20 for (wl =3D mc->allowed_dynamic_sysbus_devices; !allowed && wl; wl =3D wl->next) { - allowed |=3D !!object_dynamic_cast(OBJECT(sbdev), wl->value); + allowed |=3D !!object_dynamic_cast(obj, wl->value); } =20 - if (!allowed) { + return allowed; +} + +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) +{ + MachineState *machine =3D opaque; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { error_report("Option '-device %s' cannot be handled by this machin= e", object_class_get_name(object_get_class(OBJECT(sbdev))= )); exit(1); --=20 2.20.1 From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712174; cv=none; d=zohomail.com; s=zohoarc; b=fj1llPoK+nVsJ41gqdqgyisMUu33P4G0iFqna2qrTktYIBcqnMTrtuhk17Q2IyqbOf+IBX+o0ep/HMwx3mxLLazvYtiidiPckTh8cWlY3YJJmutH1Pgx14G6q47F+vSuBaLEVkpmnxl+h/uRShBTh9HALtNUjScNh05pFPDOaJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712174; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S/1BOY0+FoVcdWIzGFamWQ9aB5zoz/Z11SGt7VxuGjw=; b=j5itfg29QcjymDd048LZvGQiuuY4Dlm4Pw6f/YsWM/Srrjyuy992qrpRPmHha24+TLArbZD479+2QDWZvKNSlzfhB3j6gt27TBfJMQ+F2P4cw9k4POQllqVoTZiglOvJA7QV7yREpfRZqQqrXEljuYNDXRQR9Il/zwUvR5qmF4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712174298589.1245833719486; Tue, 6 Apr 2021 05:29:34 -0700 (PDT) Received: from localhost ([::1]:34244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkpo-00070e-9k for importer@patchew.org; Tue, 06 Apr 2021 08:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AG-Fl for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:43597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn2-0005lG-LZ for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wr1-x430.google.com with SMTP id x7so14012675wrw.10 for ; Tue, 06 Apr 2021 05:26:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=S/1BOY0+FoVcdWIzGFamWQ9aB5zoz/Z11SGt7VxuGjw=; b=LoEqewYCNzuy1q5jfNu7sMwQ8HQRs9jtr4ekA3XwqUIQ1uFVghyC4ZuVPEg7sddyEe Na33gecJLkDYLdsmL2zig5Tz3je85UnBRomopaciYbmX99SwP9BY4HFKYJA/tnESnJ9M Z0MquCEl+rTON8wF7ejyswRWwO5BxXAkcv+5v/MCPkyIRS3YGVJTOiQPuTTXATBc32zp 3NYeQPn/IMdYF0k8ByzKNphgG1SkbblZSjWsz3Y6PZr/WXclEaCDJDXO3alDv1b72JXR /nnhkB0UBRx8+e3VRanSsV6oeUsnwVSA9C4CdHdDVMdRNdn0zD4A2RFOg6LYZfrJAPNu DTqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S/1BOY0+FoVcdWIzGFamWQ9aB5zoz/Z11SGt7VxuGjw=; b=AP2c3CLBfzJ3r/gwfbFreuBf80JVZ0snzJOKG8zUbVpKyQmD1srk5zIeKvX+nkxw5o 8Ob4cfV5BlAm+xQr/kRjuMsG5OM9QqZrIltNh0Z9zuzCy8e088LbWeojjeOWmiMgzUXf Ly3eM/iNH8SLQOYt2XnDfIYlnIYKNex8sg/PzDsTrJ/5X+JpOf9Tu2s7QEAkAD/nN0VG WGz1YOB7myCBnTfnas7pg0pop2ahM4GEDNXvI6pBs4dk8rH/olTLIqGrWGUKwCcvh5Qq LF7ruSNIYNWP/tRA4sJj7N5+CMY8rI67ky529Xlx/mWcIBc12TOzvk/Z9Ul+a9/zxdLt 4Bxg== X-Gm-Message-State: AOAM5329uVm2QCnqXOBlFRLs8eJVW9oIclfzpsz65t/tR5zOi96jLr0S 7HdxUz6/WVxQi2zJirskMLDhwn+SDfgrOlH9 X-Google-Smtp-Source: ABdhPJyuGo7VWL9Z+9CtQhyZ+3qsVYv4OA3vvveZst7isXF3DpXkt6HIo+zlvLkd1dP8rgPhp0lrFw== X-Received: by 2002:a5d:5082:: with SMTP id a2mr6375642wrt.267.1617711999362; Tue, 06 Apr 2021 05:26:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/6] hw/arm/virt: Only try to add valid dynamic sysbus devices to platform bus Date: Tue, 6 Apr 2021 13:26:32 +0100 Message-Id: <20210406122635.28268-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The virt machine device plug callback currently calls platform_bus_link_device() for any sysbus device. This is overly broad, because platform_bus_link_device() will unconditionally grab the IRQs and MMIOs of the device it is passed, whether it was intended for the platform bus or not. Restrict hotpluggability of sysbus devices to only those devices on the dynamic sysbus allowlist. We were mostly getting away with this because the board creates the platform bus as the last device it creates, and so the hotplug callback did not do anything for all the sysbus devices created by the board itself. However if the user plugged in a device which itself uses a sysbus device internally we would have mishandled this and probably asserted. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Mark Cave-Ayland Reviewed-by: Eric Auger Message-id: 20210325153310.9131-4-peter.maydell@linaro.org --- hw/arm/virt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aa2bbd14e09..8625152a735 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2443,7 +2443,9 @@ static void virt_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 if (vms->platform_bus_dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc =3D MACHINE_GET_CLASS(vms); + + if (device_is_dynamic_sysbus(mc, dev)) { platform_bus_link_device(PLATFORM_BUS_DEVICE(vms->platform_bus= _dev), SYS_BUS_DEVICE(dev)); } @@ -2527,7 +2529,9 @@ static void virt_machine_device_unplug_cb(HotplugHand= ler *hotplug_dev, static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev) || (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } --=20 2.20.1 From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712474; cv=none; d=zohomail.com; s=zohoarc; b=HI2wDS2U9gbgClqY24L+/gK4Nrf5d+pfZNo3Wb6iz/EVtF7dJHrz/0sOptYAx8Lh3FFfiy256Ib4dVDFAx7UZ5L5VpIssKXIsPUA87K5O/3Y1WBLYhPiXkkLAA2V8B71ri7r+24IUoyoOiTTzx6M+gefIz9Erb2TcR/MnbfprlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712474; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iLpMQ2sx6x1196p+Yg3ivT09Sa5g4ilXuJd8jzez+Ck=; b=Lrbw5hLqsuZ/aU/azX9jeEu8wxEsbeDH6x2hZ5NMUVPllwT4RXQQdUAleXJ054AIKuRvB1/TluY//+rKkpelbRfd6H9AA832wtZiKzlNhTHk47ol5NjtZZ06rXMAO6iotSpiVye+VOvTw8Wi9yFJfw0b8Qvy1kykeIl+0VynKwE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712474598817.566060997123; Tue, 6 Apr 2021 05:34:34 -0700 (PDT) Received: from localhost ([::1]:45136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkuf-000392-9P for importer@patchew.org; Tue, 06 Apr 2021 08:34:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AH-Ff for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:39908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn3-0005lj-Mt for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wm1-x32d.google.com with SMTP id g18-20020a7bc4d20000b0290116042cfdd8so4091577wmk.4 for ; Tue, 06 Apr 2021 05:26:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=iLpMQ2sx6x1196p+Yg3ivT09Sa5g4ilXuJd8jzez+Ck=; b=fQDmVnDJjT+2awk47QDNUIVN5cigihQVaRRHGzhwNnv9K9LidqhUqxZGwBbv48NOUr 0xliaiJUqCSKo2EzuqnKy52Y123UwQYyf+87WS5IY++5kDkmAm3s/VLD9sW9XCSj/R6N enmSP6snfUE0xmy1ajHKijjaiE0vqRVE9iYkMsYEsftHUm+oThhJ1QAKx4vO1CBQ2HQN PtqYzIgJVMvVYQ4Bz7CM/JidzsbsixrBAvEEyp+VBH1k/LDD3vvuPyMMBaXqb+tNOwxA VFKdhMRnvEeVg1S4jG6ZKLuWN6yBA1t9g1/BSvbeJ2oYoGeiCbnjkVY7KRzhgW2zp4Wj l2BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iLpMQ2sx6x1196p+Yg3ivT09Sa5g4ilXuJd8jzez+Ck=; b=R9TPU3TZVM65Ix8RGD4ECIrLq98CsS4rYbtHe9COtuhWQsGm6T/kBDWGmP1RNimHgy R0Ul+Yt4gyKqca60t6NPjSQrvN8hsusW7oWist0gdK+X/i9Cgq5/pKZJIjFkB2D+tmeF yAmu6njSCVUENsmo6UI+yaGdinHZhSN0z1VCctwKWPOHxX4Ro/5EU9wBRFy5JnDcwTPw Is/HCPkBl8jPeqbXdd+/O3sxaVM0Vle+JifB0VBmkHG0lNUA1eH0+19t1WCq2UqRKP4C SNWa3rE0iZ10Z86q+jJyPbb2UAcUm0LDPPYc9D+Y2peW4TA1rNOUMxH7XYdx8Nmd0sYn 31Mw== X-Gm-Message-State: AOAM533RFriQgYyIe0Scg+tDBx57+zAGorxLhPQIZ0wWxPk789lQf9u2 NbpBCu9VOUQ7XqUOuPlir9hlm669Hj9nkIqZ X-Google-Smtp-Source: ABdhPJy5ucTalumWt1bth5+g6Z+VGnalodXdtAxfzv2Zm/NxQiIhZMRLepRqzdkT/oJrw7uPTwGarw== X-Received: by 2002:a1c:ed0d:: with SMTP id l13mr3930581wmh.78.1617712000060; Tue, 06 Apr 2021 05:26:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/6] hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus Date: Tue, 6 Apr 2021 13:26:33 +0100 Message-Id: <20210406122635.28268-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The e500plat machine device plug callback currently calls platform_bus_link_device() for any sysbus device. This is overly broad, because platform_bus_link_device() will unconditionally grab the IRQs and MMIOs of the device it is passed, whether it was intended for the platform bus or not. Restrict hotpluggability of sysbus devices to only those devices on the dynamic sysbus allowlist. We were mostly getting away with this because the board creates the platform bus as the last device it creates, and so the hotplug callback did not do anything for all the sysbus devices created by the board itself. However if the user plugged in a device which itself uses a sysbus device internally we would have mishandled this and probably asserted. An example of this is: qemu-system-ppc64 -M ppce500 -device macio-oldworld This isn't a sensible command because the macio-oldworld device is really specific to the 'g3beige' machine, but we now fail with a reasonable error message rather than asserting: qemu-system-ppc64: Device heathrow is not supported by this machine yet. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Mark Cave-Ayland Reviewed-by: Eric Auger Acked-by: David Gibson Message-id: 20210325153310.9131-5-peter.maydell@linaro.org --- hw/ppc/e500plat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index bddd5e7c48f..fc911bbb7bd 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -48,7 +48,9 @@ static void e500plat_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, PPCE500MachineState *pms =3D PPCE500_MACHINE(hotplug_dev); =20 if (pms->pbus_dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc =3D MACHINE_GET_CLASS(pms); + + if (device_is_dynamic_sysbus(mc, dev)) { platform_bus_link_device(pms->pbus_dev, SYS_BUS_DEVICE(dev)); } } @@ -58,7 +60,9 @@ static HotplugHandler *e500plat_machine_get_hotpug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev)) { return HOTPLUG_HANDLER(machine); } =20 --=20 2.20.1 From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712201; cv=none; d=zohomail.com; s=zohoarc; b=eEr/ZOQMmQ2u5WkL0ReFLakMWd2kh4p9z3gR4MCGptqx2vH6HgjZs/SviaMF5sGjOBPp3tei5O+PfcBb4T8D/I/pYf0wMxBcLwyYEoOVuiUoHMh8PpfZhDyQvoX14ehkD2gR4gdW9GwFPgGCpWWOGtaeC6ZBLGbZs1IQJ+SIt3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712201; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i5k40QCHXlxXK63w0Kn7F7qeT5joQ7Ot8DB9AWKVM0o=; b=ad02vXq5QIKIxndEvijrldFquJAavNFT7qN9LdlQsDTgp8lQ214Zrit+xTIkcSlNGV82Aclzu3GqvjfTsbGTX6ikulj23Gow7OfRKIuUuJEYcNMSOQTzbh6J3qpENDLPi/6bxHGvbHgj6NkOxNn97MwruPiHM4aR472L07plAaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712201802297.302101963973; Tue, 6 Apr 2021 05:30:01 -0700 (PDT) Received: from localhost ([::1]:35756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkqG-0007cT-H3 for importer@patchew.org; Tue, 06 Apr 2021 08:30:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AI-G0 for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:41945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn4-0005m2-Ed for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id a6so8013880wrw.8 for ; Tue, 06 Apr 2021 05:26:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=i5k40QCHXlxXK63w0Kn7F7qeT5joQ7Ot8DB9AWKVM0o=; b=sW57oe37fUHhEjXp0sOyCeCXOK1CshonfPGbK0x3a9KFIdREmr7mP+uovGK1VTX45p EpuKBJxWEbxwabKqkhjofjKLrGtHAFe6zgkIC1A+cdiAooNKNQbQZEYzpXBE4jiTc7ul DNHfP4lkYuJf2yB9DlV4dFP4OkTJYUWPujUCft6eU0WKeMVHWSccEgjyLNZbdyd6OsyI eVGv7qbwpRZOzmBDwtqWwNue9Zbgj1/wwKVLjDvAkA6sPSMbPR9eVx0usOeSNMgkIjdb pd127X+EUwC0T9OJP2Chb3SSszeQrZlsiwKWUWXf1kY1ytu5ZRdCTOgPy3ZwUfvesLzf NpPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i5k40QCHXlxXK63w0Kn7F7qeT5joQ7Ot8DB9AWKVM0o=; b=pJKXhudyLN78LVgmAyxOLsmWnfRuppNJRLJ+5OSb91yzzoSyd3tEWSauIv43vQYad6 MYObhjwp/CqF7UGoLwHOrBCgWJM9MkRezLQASwsZcHLhSr439RM4DI4R5vithCko7fPT 5JnyZ7N1B5JTqDMdVIeX8J8zxozn3yvmdtsUvic7IAC5NKsbEJBYWN3dA5A8pfrNLVAW YT8/tSDG1BOYkovOvi6iAE/jmOPOWBFt1YNQN1gY99qrcQggeEwYx3/tYlfHny6GYWFb 7p5AfIhV/8m69fHwSwJLv8lIyMoW/0JQRcwc/BAwz7h44Hi4QRaIG3BzJfwvp+WET8Hd CmSQ== X-Gm-Message-State: AOAM532fZl466Y1RvDezGBbhrMu8KE2y1cIB+cpixE6HITqLkYVxsoFl XNQo/qkH5N/AL3xDjRPz5yW9R9xB3G+KIssd X-Google-Smtp-Source: ABdhPJyieUiEC+aL4Vqq+Rs37VVrYmB7Enab6DH9fLAeNGrdEmHmvFJxBR/F2c7qgsj7IvAH9XNVGQ== X-Received: by 2002:adf:c587:: with SMTP id m7mr34293002wrg.369.1617712000901; Tue, 06 Apr 2021 05:26:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/6] Revert "target/arm: Make number of counters in PMCR follow the CPU" Date: Tue, 6 Apr 2021 13:26:34 +0100 Message-Id: <20210406122635.28268-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This reverts commit f7fb73b8cdd3f77e26f9fcff8cf24ff1b58d200f. This change turned out to be a bit half-baked, and doesn't work with KVM, which fails with the error: "qemu-system-aarch64: Failed to retrieve host CPU features" because KVM does not allow accessing of the PMCR_EL0 value in the scratch "query CPU ID registers" VM unless we have first set the KVM_ARM_VCPU_PMU_V3 feature on the VM. Revert the change for 6.0. Reported-by: Zenghui Yu Signed-off-by: Peter Maydell Tested-by: Zenghui Yu Message-id: 20210331154822.23332-1-peter.maydell@linaro.org --- target/arm/cpu.h | 1 - target/arm/cpu64.c | 3 --- target/arm/cpu_tcg.c | 5 ----- target/arm/helper.c | 29 ++++++++++++----------------- target/arm/kvm64.c | 2 -- 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index fe68f464b3a..193a49ec7fa 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -942,7 +942,6 @@ struct ARMCPU { uint64_t id_aa64mmfr2; uint64_t id_aa64dfr0; uint64_t id_aa64dfr1; - uint64_t reset_pmcr_el0; } isar; uint64_t midr; uint32_t revidr; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 5d9d56a33c3..f0a9e968c9c 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -141,7 +141,6 @@ static void aarch64_a57_initfn(Object *obj) cpu->gic_num_lrs =3D 4; cpu->gic_vpribits =3D 5; cpu->gic_vprebits =3D 5; - cpu->isar.reset_pmcr_el0 =3D 0x41013000; define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); } =20 @@ -195,7 +194,6 @@ static void aarch64_a53_initfn(Object *obj) cpu->gic_num_lrs =3D 4; cpu->gic_vpribits =3D 5; cpu->gic_vprebits =3D 5; - cpu->isar.reset_pmcr_el0 =3D 0x41033000; define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); } =20 @@ -247,7 +245,6 @@ static void aarch64_a72_initfn(Object *obj) cpu->gic_num_lrs =3D 4; cpu->gic_vpribits =3D 5; cpu->gic_vprebits =3D 5; - cpu->isar.reset_pmcr_el0 =3D 0x41023000; define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); } =20 diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 8252fd29f90..046e476f65f 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -301,7 +301,6 @@ static void cortex_a8_initfn(Object *obj) cpu->ccsidr[1] =3D 0x2007e01a; /* 16k L1 icache. */ cpu->ccsidr[2] =3D 0xf0000000; /* No L2 icache. */ cpu->reset_auxcr =3D 2; - cpu->isar.reset_pmcr_el0 =3D 0x41002000; define_arm_cp_regs(cpu, cortexa8_cp_reginfo); } =20 @@ -374,7 +373,6 @@ static void cortex_a9_initfn(Object *obj) cpu->clidr =3D (1 << 27) | (1 << 24) | 3; cpu->ccsidr[0] =3D 0xe00fe019; /* 16k L1 dcache. */ cpu->ccsidr[1] =3D 0x200fe019; /* 16k L1 icache. */ - cpu->isar.reset_pmcr_el0 =3D 0x41093000; define_arm_cp_regs(cpu, cortexa9_cp_reginfo); } =20 @@ -445,7 +443,6 @@ static void cortex_a7_initfn(Object *obj) cpu->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 =3D 0x41072000; define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */ } =20 @@ -488,7 +485,6 @@ static void cortex_a15_initfn(Object *obj) cpu->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 =3D 0x410F3000; define_arm_cp_regs(cpu, cortexa15_cp_reginfo); } =20 @@ -721,7 +717,6 @@ static void cortex_r5_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x0; cpu->mp_is_up =3D true; cpu->pmsav7_dregion =3D 16; - cpu->isar.reset_pmcr_el0 =3D 0x41151800; define_arm_cp_regs(cpu, cortexr5_cp_reginfo); } =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8fb6cc96e4d..d9220be7c5a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -38,6 +38,7 @@ #endif =20 #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ +#define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ =20 #ifndef CONFIG_USER_ONLY =20 @@ -1148,9 +1149,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] =3D { =20 static inline uint32_t pmu_num_counters(CPUARMState *env) { - ARMCPU *cpu =3D env_archcpu(env); - - return (cpu->isar.reset_pmcr_el0 & PMCRN_MASK) >> PMCRN_SHIFT; + return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT; } =20 /* Bits allowed to be set/cleared for PMCNTEN* and PMINTEN* */ @@ -5754,6 +5753,13 @@ static const ARMCPRegInfo el2_cp_reginfo[] =3D { .resetvalue =3D 0, .writefn =3D gt_hyp_ctl_write, .raw_writefn =3D raw_write }, #endif + /* The only field of MDCR_EL2 that has a defined architectural reset v= alue + * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N. + */ + { .name =3D "MDCR_EL2", .state =3D ARM_CP_STATE_BOTH, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 1, .crm =3D 1, .opc2 =3D 1, + .access =3D PL2_RW, .resetvalue =3D PMCR_NUM_COUNTERS, + .fieldoffset =3D offsetof(CPUARMState, cp15.mdcr_el2), }, { .name =3D "HPFAR", .state =3D ARM_CP_STATE_AA32, .cp =3D 15, .opc1 =3D 4, .crn =3D 6, .crm =3D 0, .opc2 =3D 4, .access =3D PL2_RW, .accessfn =3D access_el3_aa32ns, @@ -6683,7 +6689,7 @@ static void define_pmu_regs(ARMCPU *cpu) * field as main ID register, and we implement four counters in * addition to the cycle count register. */ - unsigned int i, pmcrn =3D pmu_num_counters(&cpu->env); + unsigned int i, pmcrn =3D PMCR_NUM_COUNTERS; ARMCPRegInfo pmcr =3D { .name =3D "PMCR", .cp =3D 15, .crn =3D 9, .crm =3D 12, .opc1 =3D 0= , .opc2 =3D 0, .access =3D PL0_RW, @@ -6698,10 +6704,10 @@ static void define_pmu_regs(ARMCPU *cpu) .access =3D PL0_RW, .accessfn =3D pmreg_access, .type =3D ARM_CP_IO, .fieldoffset =3D offsetof(CPUARMState, cp15.c9_pmcr), - .resetvalue =3D cpu->isar.reset_pmcr_el0, + .resetvalue =3D (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT) | + PMCRLC, .writefn =3D pmcr_write, .raw_writefn =3D raw_write, }; - define_one_arm_cp_reg(cpu, &pmcr); define_one_arm_cp_reg(cpu, &pmcr64); for (i =3D 0; i < pmcrn; i++) { @@ -7819,17 +7825,6 @@ void register_cp_regs_for_features(ARMCPU *cpu) .fieldoffset =3D offsetof(CPUARMState, cp15.vmpidr_el2) }, REGINFO_SENTINEL }; - /* - * The only field of MDCR_EL2 that has a defined architectural res= et - * value is MDCR_EL2.HPMN which should reset to the value of PMCR_= EL0.N. - */ - ARMCPRegInfo mdcr_el2 =3D { - .name =3D "MDCR_EL2", .state =3D ARM_CP_STATE_BOTH, - .opc0 =3D 3, .opc1 =3D 4, .crn =3D 1, .crm =3D 1, .opc2 =3D 1, - .access =3D PL2_RW, .resetvalue =3D pmu_num_counters(env), - .fieldoffset =3D offsetof(CPUARMState, cp15.mdcr_el2), - }; - define_one_arm_cp_reg(cpu, &mdcr_el2); define_arm_cp_regs(cpu, vpidr_regs); define_arm_cp_regs(cpu, el2_cp_reginfo); if (arm_feature(env, ARM_FEATURE_V8)) { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 581335e49d3..dff85f6db94 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -566,8 +566,6 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *= ahcf) ARM64_SYS_REG(3, 0, 0, 7, 1)); err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, ARM64_SYS_REG(3, 0, 0, 7, 2)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, - ARM64_SYS_REG(3, 3, 9, 12, 0)); =20 /* * Note that if AArch32 support is not present in the host, --=20 2.20.1 From nobody Sat Apr 20 08:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617712544; cv=none; d=zohomail.com; s=zohoarc; b=CVgYUDGyMONWqAfYChidG0V96fHyg1AcES3WsAcVnRpZyzztbcfpZ7tOyLdfor4A5p3m5GX6oCjhW3Jbh7t06IS4axYCr9qWnJT0yf9nTTeuIjBvDIXCBN03mzRUEA1TYggM9SN3TDya7xY3fh1manVspiVCz6feeyuBkTyAkk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617712544; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BYKj7J054b8SN4HG90SqNpzGjVv+DUotzg8W421Gheo=; b=UDT2Dqn3weG/HJSf5gMV4e9/LJTdCKjaXwh0VxWuMagF0uBneZeNWMouE6Z6f3DG1YrSSzEOAftzkd1GHipSO4DBL2mJq98wp+Di6eu7Zcj+yKMcz1rx+xN/z+iNON4EcxDTw48VJb6rZWjS6vnPZ1RrJR2h0MaCJ01gkzg9xJ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617712543989139.33304660287024; Tue, 6 Apr 2021 05:35:43 -0700 (PDT) Received: from localhost ([::1]:47356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTkvm-00041k-TE for importer@patchew.org; Tue, 06 Apr 2021 08:35:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTknn-0005AE-Fy for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:28 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:36522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTkn5-0005oV-Hg for qemu-devel@nongnu.org; Tue, 06 Apr 2021 08:27:25 -0400 Received: by mail-wm1-x333.google.com with SMTP id j20-20020a05600c1914b029010f31e15a7fso9214477wmq.1 for ; Tue, 06 Apr 2021 05:26:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id l6sm31160252wrt.56.2021.04.06.05.26.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 05:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BYKj7J054b8SN4HG90SqNpzGjVv+DUotzg8W421Gheo=; b=gVosqMZbAG3/8T+5wVJHmwo2cAKUXR/bI97Hn9xYK/xKgFN8bpY80qRtuo+vuiut9u bgqdF0FYb3STvEVErnozlNX+00mwNz/QfLWwnumzsIXv9KHISAb9gVUlHDZz5SmwNof4 qjrnGhgj/XeYOEBZPArjoF7bIvs0Sk+Rla4pKffPuJA+82PbTE21QwEjYLQ/YynPt15m UAWAEA/2BxbzSevNkUl4KMSXHE6sOshjgOLd/Xxn8rerGwQj2hRgjs43rccsxzlHuiIV 0PyIKZQt0lzINjDZaEhRkgBDcfTTGap+j+K3ke22BJsehFnuKvrya29JyCmKX7RBpCBz pTeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BYKj7J054b8SN4HG90SqNpzGjVv+DUotzg8W421Gheo=; b=VpazVmh3zSx12nrLITIofqh5eSBxsyN15LnFGTGnWJy2stRpMQ0LD12NxAvaap9b/e bKYy8fq5qDmQB25KtFfMMY+ZTNiOwBj1vy6LPATcwDQDq6VfqIiOybBGHEaeVVg6FJnt LL3PEflWIzBARzU4+WTWaVcHbbP83LDei9ZOPjSEu3uNGliVeoZqlWeWf4/TLPOk4IVa I5+as2rWO8X3uPH2kkFsyUZIZynKDFlIpUZ5PY6YMc60ryCRCqTLiBwxGSoBAQybBWxQ GR6wZWG9d/QN3/dgpfl60z8klCRWoKYMjb5HRRiWvEOkXzAx9TidmODX8S3mLSbdnE+s i30w== X-Gm-Message-State: AOAM533aRSzyCDFHirnH+yroorMhRonsbf02XFqOeHcLJFEBsu2TZd19 1ezDfj5IPvX96A5GU4PVg8GniLveLy9ykmfC X-Google-Smtp-Source: ABdhPJzzzNZAx2nmgUy5zFeXBaA6hl4E8P4Q8ClREPbIcJJnoIxQC3Jg1Q5fJKYrSoFioNwewoIskg== X-Received: by 2002:a1c:7519:: with SMTP id o25mr3817915wmc.35.1617712002028; Tue, 06 Apr 2021 05:26:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/6] Remove myself as i.mx31 maintainer Date: Tue, 6 Apr 2021 13:26:35 +0100 Message-Id: <20210406122635.28268-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406122635.28268-1-peter.maydell@linaro.org> References: <20210406122635.28268-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: "Chubb, Peter (Data61, Eveleigh)" Remove Peter Chubb as i/MX31 maintainer. I'm leaving my current job and will no longer have access to the hardware to test or maintain this port. Signed-off-by: Peter Chubb Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 69003cdc3c9..58f342108e9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -688,7 +688,6 @@ F: include/hw/misc/imx25_ccm.h F: include/hw/watchdog/wdt_imx2.h =20 i.MX31 (kzm) -M: Peter Chubb M: Peter Maydell L: qemu-arm@nongnu.org S: Odd Fixes --=20 2.20.1