From patchwork Fri Nov 17 07:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 744628 Delivered-To: patch@linaro.org Received: by 2002:a5d:5388:0:b0:32d:baff:b0ca with SMTP id d8csp741691wrv; Thu, 16 Nov 2023 23:18:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGodCBR/PIJ6x+3RPL/HqVH8qw4TQgsT5cATxIU206WDgzP9GDehpWVaNoM9yM4FhdTWWNz X-Received: by 2002:a05:620a:1aa7:b0:774:2470:6797 with SMTP id bl39-20020a05620a1aa700b0077424706797mr6312803qkb.21.1700205500004; Thu, 16 Nov 2023 23:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700205499; cv=none; d=google.com; s=arc-20160816; b=wrmCB1ASJgmWSZs793S+wL7KgukhSIc6KWObJ5s158V2zi5/qsqkgeZ4o78oDUDOjo VDHJF2NGrIUkE3np5Q5XXm4X0xCnlztGVk4Ms3MX7Y7B/Q6egM/ta7a9ntGh/LNLF07z AT4nBEh8jqQZUPuOCi88OmndE5MODR/kk7O1/WZUQt9Bdg+MW4hhP8CffRtxXGFUuLAD bCgVcTLdb1MoFb7jkDyMc6fDzR4zMQY0bZaBqviDRUZ2pun/unXhWm23gDI8HK8P3L66 SC1Tk7AyWOplfA6gGUSlldYH3CITPzEeZd0srW0teGN0XxZU7fKZOyvosLT6vbYxf+gp 0vmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CHdKGB9IdVR9xVcd4O1PYbu10XnVv29sfGXQ2wqVVus=; fh=/iNNmKky1DrOYOLWnTIBUxaMagIUG/IvUjT5dhZ7EH4=; b=c13B2OtQyqxBIXw4UZzCGqkJzTHX2XQOuZ8c8+jmLMxJVJUCRz4Q1XL6wK/k3BQCaD 2rYeo90OGICrPNBhs42b5LPiXh+7cQbDlgKypPECPF/uaBx8pArzbK4ZoGcEtRL/aqAD 563yLzjvn5bptUgHn2/7kzdAMN6kPDv6WibxZqLz3qn2arURsUUgYSOgddCxSZ0W+Ifq PpwWHLfgUv+UeI1yTxQcHh7PHvX70+emWYGfvZsoAxPt/mqkNVlTlLbQXJNQGKouOGVp Jgz9g1eLmtpHuHksaXEZeVZ4I0Gfce+BwAc4rLINbd2VbrzWH6j5I8cgrwp2Y6dESflp CLyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e9nVJquO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18-20020a05620a165200b0076da127884csi1125698qko.223.2023.11.16.23.18.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2023 23:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e9nVJquO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3t6V-0005Ld-51; Fri, 17 Nov 2023 02:17:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3t6O-0005JT-3q for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:20 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3t6M-0004Gd-CB for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:19 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40839652b97so12751025e9.3 for ; Thu, 16 Nov 2023 23:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700205434; x=1700810234; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CHdKGB9IdVR9xVcd4O1PYbu10XnVv29sfGXQ2wqVVus=; b=e9nVJquOed/Ba0IwNQX3PJV6LcyTUTvHAcMVSpuD6aNC+TYgCF8MbxxyPG4Oa2iAUg 06kZt8uk+BNestrxVb7w14BClgTF28d5G00EIfN48BePlxBqjJvVBSj9wEUfgSeg5sgw modZvWAEJok1h1g7MBvgxT3nUpI9nXgQpZkNUBqMm+ZF266k9LfC2PB6AVsv5UltvvBF FB09qYD/t5pmOhr3eqHDfDsS0V6GwfuYxicMW3l9+ANQ4oIsfDlTtYsi5MAyWK4JVwXl pso+WqVWBEYkneCZ6HAdi33kD77YwO+6fGwflm7QDgCEQDYZdJY5a6VHQbDEN0W7l8Yn iWlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700205434; x=1700810234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CHdKGB9IdVR9xVcd4O1PYbu10XnVv29sfGXQ2wqVVus=; b=XkRtJ+3mZv3sZaWGZQdpD2/MOdYTl8CFz2uhcb1lLUf5ct6JRr4ZSG1H7xr5Ht13uj Rj1wdVwodAs9JhVT9rPSv76ZTpMeHokvOUx/ywNxe+wwQoodqnAdh29K6Nb3jtOoUExt nmyp7XWVBLHa+8pA1riLgSwyiNKbjbNmAqWhA2rO0vUmc0s8jxQRjZiGeJSKXATZ1vev eCjmOmxMeAzTrsMjR24P10L87yC2Imo+E/w7iJSPouovxABfYLA1+91XQVQQIc4+m2nD YMnuOxVPnCI95s7k7QxG7Un+6ojmW9rXKXN7Uk65QfLaesKStLEUkPElwyMybB+hMZxi HM+g== X-Gm-Message-State: AOJu0YxXNakQJXao2L6/L+CH3V9pyjJSIl9kmNnvUWzw5zydaRCqaaYw NpSIs+jLlpQk/hIo/f/DfoH18+H13uIf2BJCmrs= X-Received: by 2002:a1c:7206:0:b0:3fe:4cbc:c345 with SMTP id n6-20020a1c7206000000b003fe4cbcc345mr14096613wmc.41.1700205434169; Thu, 16 Nov 2023 23:17:14 -0800 (PST) Received: from m1x-phil.lan (bd137-h02-176-184-46-187.dsl.sta.abo.bbox.fr. [176.184.46.187]) by smtp.gmail.com with ESMTPSA id u3-20020a05600c00c300b0040648217f4fsm5905684wmm.39.2023.11.16.23.17.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 23:17:13 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Subbaraya Sundeep , Arnaud Minier , Igor Mammedov , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Tyrone Ting , Hao Wu , Marcel Apfelbaum , Felipe Balbi , qemu-arm@nongnu.org, =?utf-8?q?In=C3=A8s_V?= =?utf-8?q?arhol?= , Alistair Francis , Yanan Wang , Richard Henderson , Eduardo Habkost , Peter Maydell , Helge Deller , Subbaraya Sundeep , Alexandre Iooss , Gavin Shan Subject: [PATCH-for-8.2? v2 1/4] hw/core/machine: Constify MachineClass::valid_cpu_types[] Date: Fri, 17 Nov 2023 08:17:01 +0100 Message-ID: <20231117071704.35040-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117071704.35040-1-philmd@linaro.org> References: <20231117071704.35040-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gavin Shan Constify MachineClass::valid_cpu_types[i], as suggested by Richard Henderson. Suggested-by: Richard Henderson Signed-off-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson [PMD: Constify HPPA machines, restrict valid_cpu_types to machine_class_init() handlers] Signed-off-by: Philippe Mathieu-Daudé --- include/hw/boards.h | 2 +- hw/hppa/machine.c | 22 ++++++++++------------ hw/m68k/q800.c | 11 +++++------ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index a735999298..da85f86efb 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -273,7 +273,7 @@ struct MachineClass { bool has_hotpluggable_cpus; bool ignore_memory_transaction_failures; int numa_mem_align_shift; - const char **valid_cpu_types; + const char * const *valid_cpu_types; strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; bool auto_enable_numa_with_memdev; diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 9d08f39490..c8da7c18d5 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -672,19 +672,18 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp) } } -static const char *HP_B160L_machine_valid_cpu_types[] = { - TYPE_HPPA_CPU, - NULL -}; - static void HP_B160L_machine_init_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] = { + TYPE_HPPA_CPU, + NULL + }; MachineClass *mc = MACHINE_CLASS(oc); NMIClass *nc = NMI_CLASS(oc); mc->desc = "HP B160L workstation"; mc->default_cpu_type = TYPE_HPPA_CPU; - mc->valid_cpu_types = HP_B160L_machine_valid_cpu_types; + mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_B160L_init; mc->reset = hppa_machine_reset; mc->block_default_type = IF_SCSI; @@ -709,19 +708,18 @@ static const TypeInfo HP_B160L_machine_init_typeinfo = { }, }; -static const char *HP_C3700_machine_valid_cpu_types[] = { - TYPE_HPPA64_CPU, - NULL -}; - static void HP_C3700_machine_init_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] = { + TYPE_HPPA64_CPU, + NULL + }; MachineClass *mc = MACHINE_CLASS(oc); NMIClass *nc = NMI_CLASS(oc); mc->desc = "HP C3700 workstation"; mc->default_cpu_type = TYPE_HPPA64_CPU; - mc->valid_cpu_types = HP_C3700_machine_valid_cpu_types; + mc->valid_cpu_types = valid_cpu_types; mc->init = machine_HP_C3700_init; mc->reset = hppa_machine_reset; mc->block_default_type = IF_SCSI; diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 1d7cd5ff1c..83d1571d02 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -726,19 +726,18 @@ static GlobalProperty hw_compat_q800[] = { }; static const size_t hw_compat_q800_len = G_N_ELEMENTS(hw_compat_q800); -static const char *q800_machine_valid_cpu_types[] = { - M68K_CPU_TYPE_NAME("m68040"), - NULL -}; - static void q800_machine_class_init(ObjectClass *oc, void *data) { + static const char * const valid_cpu_types[] = { + M68K_CPU_TYPE_NAME("m68040"), + NULL + }; MachineClass *mc = MACHINE_CLASS(oc); mc->desc = "Macintosh Quadra 800"; mc->init = q800_machine_init; mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040"); - mc->valid_cpu_types = q800_machine_valid_cpu_types; + mc->valid_cpu_types = valid_cpu_types; mc->max_cpus = 1; mc->block_default_type = IF_SCSI; mc->default_ram_id = "m68k_mac.ram"; From patchwork Fri Nov 17 07:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 744627 Delivered-To: patch@linaro.org Received: by 2002:a5d:5388:0:b0:32d:baff:b0ca with SMTP id d8csp741655wrv; Thu, 16 Nov 2023 23:18:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6Y9HANirC8/21YRo1kG+pb/KO4mfopcz/yPq+pbaoA5J+QspNF6CzVoi69ZmruQGDbgTe X-Received: by 2002:ac8:5cc8:0:b0:418:15ab:85b8 with SMTP id s8-20020ac85cc8000000b0041815ab85b8mr13677791qta.13.1700205490195; Thu, 16 Nov 2023 23:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700205490; cv=none; d=google.com; s=arc-20160816; b=SrN35MKNAz3I27xxPPAuxF4jYe8awfZZqo60TBfIWn92jCqsZJKegHHBdzrx5EhxGh pW5Rw08GC3C8V8rG/cP4ayjw8xNMqMYZ2Q+RHx9rCLf0tZQN37RhiQDvC9GXUofM1D5+ q6sx7+CwvMqIhzH6kPE2aiBVxELyDw93c2UZKGls7z3HtIcICHkYAqe5DQEaJrI0mvW9 WSvLe05FtR4eks4yQn8B36/fvk4RJjZI1VqjUCowQ01kkzI7X3I88nlZTvo3Na5I+ozw zLCKNHJYwAZtw541juRl5uzWn0CqUnCUUwgddnPhF9sJmkzJLZVDNBsOHYNnxYJLUSqC zqXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vTMyslaK2WpZ4IP8gJyy1ZNuQ4oQ3pn0mQiB92seVWw=; fh=/iNNmKky1DrOYOLWnTIBUxaMagIUG/IvUjT5dhZ7EH4=; b=mXB1GpE88PpIfyTLNE9/rfWAtuQaVQ1YmXlmBKa+LbPQ+Qbzz4kLS8O0PIgpctaGd0 FZlM296FMomBvWcBramJ8xhlMe/w+B478vZTZUleUBkt16P0jvf1YKRxHnJy5FqTUJib Lwxgp6dnWrilf2l25l/myA6tXQEQv0yn6xzH5eZQDaRcvbhkH2n4QJDCXl97e2f/lzAQ s5ZxrBgK29ZULtSF/eJtDt6npORHOqiuVaj6hnwNaIOMS1Vn1Hz2h5s2fDgPqHnGTgDN rH5qMy3/nlvKRiu8nCb2z/WpgqeNCqEmOx/nryCEBDOwRN4O4DVfaqvjVQnh+L+7Kvuy lfkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N65RxRGe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z11-20020a05622a060b00b004198662d6dcsi1058318qta.592.2023.11.16.23.18.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2023 23:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N65RxRGe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3t6X-0005OP-Uu; Fri, 17 Nov 2023 02:17:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3t6S-0005Le-0V for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:25 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3t6Q-0004IL-9X for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:23 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4083cd3917eso13964725e9.3 for ; Thu, 16 Nov 2023 23:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700205440; x=1700810240; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vTMyslaK2WpZ4IP8gJyy1ZNuQ4oQ3pn0mQiB92seVWw=; b=N65RxRGe1Toc16bX0HPtzdCydLBhCQc5cCy6nuzqyDOPg/3B25nxNyYhcbP7L57wvE nQzkhSzhkns2yjd/bsDskGFo7rukF/TOMycCc2g+FY1K84ZpZn51HasM0+cB8YMSOUVL yViBRNG7AesJlz1zZcI6ZlSTpvlDhOjXqk7o9TAYu4eBtZWWREakB+A3lyMgtb0Waz1j 6v6QGAFxAwXc0cNUfYMv8PlXjDZK/JnPrY6nwrv/G4QghwH3dmxBcerfZNGrL6Cab5E4 j85vUtpn2Qk1IoL2btlz/V7yyHCdRyJDM/U3q+CxWfn6Zgogmfpxu7Dvw9Dh+AtHhw9u PH3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700205440; x=1700810240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vTMyslaK2WpZ4IP8gJyy1ZNuQ4oQ3pn0mQiB92seVWw=; b=EGH+AWpiTi6DMP+QOtViUYvINL8au5KZsCcb512HmC+OEKzKdLmd5EXkcWWA+GdONA Oux/hSFTSZqsOIJe/xLXyUqXu+naed24Jx/N2R46U0irmcy3JgnejmLvG6t7JzTTPHtK AN+P0azh52D8aL3pqOkBQLRd7zZLmzGQDPyo/nJ6Zq4OJmvxJ8PnlPH2x5QgXDmjoaX7 dLO8mIxp7a9RTKFAI21/z99biUyB3Jh0ZDqTM+btp1iJYbKcRbzAtVSOXA51vbBxAdbi kO2eJ0rTtGTx6L/Waj7l8U/6cu9Na6DF/Dg99vqQByWcP7CEDAS1PAWzWovvrtmD4CK0 L6MQ== X-Gm-Message-State: AOJu0YwD8mXlTfYNynGas6dbVP31sh0XXGa7pZflCvdiQK/xSDjgfg1f Azh2Qnj1TpZmFPiTxqBHl3e3bjKJ0ogXYPA1jPw= X-Received: by 2002:a5d:6da9:0:b0:331:41ef:61f2 with SMTP id u9-20020a5d6da9000000b0033141ef61f2mr14721992wrs.15.1700205440338; Thu, 16 Nov 2023 23:17:20 -0800 (PST) Received: from m1x-phil.lan (bd137-h02-176-184-46-187.dsl.sta.abo.bbox.fr. [176.184.46.187]) by smtp.gmail.com with ESMTPSA id p17-20020a5d48d1000000b003316ad360c1sm692737wrs.24.2023.11.16.23.17.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 23:17:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Subbaraya Sundeep , Arnaud Minier , Igor Mammedov , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Tyrone Ting , Hao Wu , Marcel Apfelbaum , Felipe Balbi , qemu-arm@nongnu.org, =?utf-8?q?In=C3=A8s_V?= =?utf-8?q?arhol?= , Alistair Francis , Yanan Wang , Richard Henderson , Eduardo Habkost , Peter Maydell , Helge Deller , Subbaraya Sundeep , Alexandre Iooss , Gavin Shan Subject: [PATCH-for-8.2? v2 2/4] hw/arm/stm32f405: Report error when incorrect CPU is used Date: Fri, 17 Nov 2023 08:17:02 +0100 Message-ID: <20231117071704.35040-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117071704.35040-1-philmd@linaro.org> References: <20231117071704.35040-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Both 'netduinoplus2' and 'olimex-stm32-h405' machines ignore the CPU type requested by the command line. This might confuse users, since the following will create a machine with a Cortex-M4 CPU: $ qemu-system-aarch64 -M netduinoplus2 -cpu cortex-r5f Set the MachineClass::valid_cpu_types field (introduced in commit c9cf636d48 "machine: Add a valid_cpu_types property"). Remove the now unused MachineClass::default_cpu_type field. We now get: $ qemu-system-aarch64 -M netduinoplus2 -cpu cortex-r5f qemu-system-aarch64: Invalid CPU type: cortex-r5f-arm-cpu The valid types are: cortex-m4-arm-cpu Since the SoC family can only use Cortex-M4 CPUs, hard-code the CPU type name at the SoC level, removing the QOM property entirely. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gavin Shan Reviewed-by: Alistair Francis --- include/hw/arm/stm32f405_soc.h | 4 ---- hw/arm/netduinoplus2.c | 7 ++++++- hw/arm/olimex-stm32-h405.c | 8 ++++++-- hw/arm/stm32f405_soc.c | 8 +------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h index c968ce3ab2..d15c03c4b5 100644 --- a/include/hw/arm/stm32f405_soc.h +++ b/include/hw/arm/stm32f405_soc.h @@ -51,11 +51,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F405State, STM32F405_SOC) #define CCM_SIZE (64 * 1024) struct STM32F405State { - /*< private >*/ SysBusDevice parent_obj; - /*< public >*/ - - char *cpu_type; ARMv7MState armv7m; diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c index 515c081605..2e58984947 100644 --- a/hw/arm/netduinoplus2.c +++ b/hw/arm/netduinoplus2.c @@ -44,7 +44,6 @@ static void netduinoplus2_init(MachineState *machine) clock_set_hz(sysclk, SYSCLK_FRQ); dev = qdev_new(TYPE_STM32F405_SOC); - qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); qdev_connect_clock_in(dev, "sysclk", sysclk); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -55,8 +54,14 @@ static void netduinoplus2_init(MachineState *machine) static void netduinoplus2_machine_init(MachineClass *mc) { + static const char * const valid_cpu_types[] = { + ARM_CPU_TYPE_NAME("cortex-m4"), + NULL + }; + mc->desc = "Netduino Plus 2 Machine (Cortex-M4)"; mc->init = netduinoplus2_init; + mc->valid_cpu_types = valid_cpu_types; } DEFINE_MACHINE("netduinoplus2", netduinoplus2_machine_init) diff --git a/hw/arm/olimex-stm32-h405.c b/hw/arm/olimex-stm32-h405.c index 3aa61c91b7..d793de7c97 100644 --- a/hw/arm/olimex-stm32-h405.c +++ b/hw/arm/olimex-stm32-h405.c @@ -47,7 +47,6 @@ static void olimex_stm32_h405_init(MachineState *machine) clock_set_hz(sysclk, SYSCLK_FRQ); dev = qdev_new(TYPE_STM32F405_SOC); - qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); qdev_connect_clock_in(dev, "sysclk", sysclk); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -58,9 +57,14 @@ static void olimex_stm32_h405_init(MachineState *machine) static void olimex_stm32_h405_machine_init(MachineClass *mc) { + static const char * const valid_cpu_types[] = { + ARM_CPU_TYPE_NAME("cortex-m4"), + NULL + }; + mc->desc = "Olimex STM32-H405 (Cortex-M4)"; mc->init = olimex_stm32_h405_init; - mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4"); + mc->valid_cpu_types = valid_cpu_types; /* SRAM pre-allocated as part of the SoC instantiation */ mc->default_ram_size = 0; diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c index cef23d7ee4..a65bbe298d 100644 --- a/hw/arm/stm32f405_soc.c +++ b/hw/arm/stm32f405_soc.c @@ -149,7 +149,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) armv7m = DEVICE(&s->armv7m); qdev_prop_set_uint32(armv7m, "num-irq", 96); - qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); + qdev_prop_set_string(armv7m, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); qdev_prop_set_bit(armv7m, "enable-bitband", true); qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); qdev_connect_clock_in(armv7m, "refclk", s->refclk); @@ -287,17 +287,11 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) create_unimplemented_device("RNG", 0x50060800, 0x400); } -static Property stm32f405_soc_properties[] = { - DEFINE_PROP_STRING("cpu-type", STM32F405State, cpu_type), - DEFINE_PROP_END_OF_LIST(), -}; - static void stm32f405_soc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = stm32f405_soc_realize; - device_class_set_props(dc, stm32f405_soc_properties); /* No vmstate or reset required: device has no internal state */ } From patchwork Fri Nov 17 07:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 744629 Delivered-To: patch@linaro.org Received: by 2002:a5d:5388:0:b0:32d:baff:b0ca with SMTP id d8csp741722wrv; Thu, 16 Nov 2023 23:18:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFn72T95RIv1NEbPTtOKaETZxGotSpQy6JIUCnzZWHVskOd7styrV37xrJArG4ahJXFDg4q X-Received: by 2002:ad4:41c7:0:b0:677:9f7b:69dc with SMTP id a7-20020ad441c7000000b006779f7b69dcmr11105678qvq.25.1700205507395; Thu, 16 Nov 2023 23:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700205507; cv=none; d=google.com; s=arc-20160816; b=bDL2yhAFMHPFqomR56iDy3xEr7zMJIK22C2/64AAkwvy8J+d7m5atZ+FYrFzwWfBxJ Xv5TOFykXuLw3WGPgei8gg1OVQN8kunEYOSBuo0Ydo6o+k7hgUADQS4aC/ekYR6ReCfA 7gXUDDK2KCl0ggnrGwremc9zfBjpIABU0aLHRKHiR3v/EfPlBkA/n2YmkK+5qQQ3sD5y 9imBBz+djV8YS5Jgp42UiUnZdEVTvzJDaBhKXz1m/DXBgPZGd4+kieE5qOnHhRj53zb9 7x4QRhCDSRe94p5PFUb1vWOhGMCkoDjpPb1JSYzg8PF5aXiXAp50LNCJQSEYPUFMmmuy uRgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NH5P5ZdsVBU0A7f/AHoAHis/E7XVaC6npXWaZcl7Gsk=; fh=/iNNmKky1DrOYOLWnTIBUxaMagIUG/IvUjT5dhZ7EH4=; b=ckk5L9rFc5qBgE/d4vDnTS+BNDfDK8oSmRrxfJ8244vuT6PFoeL8oYQ8YcKBh8y21w DVrzsO2+0abL+ueoB9aZzZN8JwgUOXGOs+ggOjBYwnHr6msF6dvcpDFRN38uNtYy+EQe EoJk2pUckVv5bPox5RO946kkzzSYlecIj+6zrBHIvDH/gormeCzA/W68wBRLKxj/hIWT gKSa//qhl7s1MUr+E5Y2wji9i0S+8p3QfN0PcuUF3p0JsQXu0b0CQwIVzCHpuyPul3pX lLJYHmu9/wEmCOFmHGH5oOCb6nHxsRv3zs4Vjly39bNO3V/cbUziCy5okeSdzTxrobJD lxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YZeqypqQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l3-20020a0ce6c3000000b00670bd5a370dsi1109767qvn.215.2023.11.16.23.18.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2023 23:18:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YZeqypqQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3t6f-0005Rq-22; Fri, 17 Nov 2023 02:17:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3t6c-0005Q7-FI for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:34 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3t6Y-0004Jm-Gd for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:33 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507be298d2aso2178725e87.1 for ; Thu, 16 Nov 2023 23:17:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700205447; x=1700810247; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NH5P5ZdsVBU0A7f/AHoAHis/E7XVaC6npXWaZcl7Gsk=; b=YZeqypqQ+np7QYxoeTfr8yg/OYs4B64DMFZmyNuuCVRFnBabFcdiJ8fh6IyYbuphxb XvcnTDkxGgqWpvzRXI1CHLB34b1K1tdDPBq7khWk6+sACMtcFez3EftMBMxp6FuJG3Ox k8G++LFf5tNKueXa50C6TF8ZQh3LmUP0NIBNs+L51k32G8nZIuaOuI18Ou002pEwFXBy WrG0XTwTo/emPKq6YVbYjBEZxLnyLyiNCd2KFPcBhkAOnMpF1sKaLm+M6Ic8HD7awxlv 2WYrlbOXgeDC+K4o05JdmOtZHxEpWWNApWku5eWB86gqJec29/nc+Pd6AkUoFqNgOHdU YHUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700205447; x=1700810247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NH5P5ZdsVBU0A7f/AHoAHis/E7XVaC6npXWaZcl7Gsk=; b=toxypK0a7PFiZxv7sCDJlF+fALrIr6y402Xa5zp2wD83cbS8opWHXV/0c/ANnSzl1Y /4B2w4xW0tuqWUh1VVFS9WLg8b7/W3oQrL/+412iIuCBE9Zzq4M4kDDq5AwlUdl3LKT7 vSOlL3B3O2oZmL2waF/VWeCSSsdqn2qmpCOsymMwV0rCJ2PkhfAZXN5iuaX9Uqi3w1Ic Mt6xs23KNpK0wVrnOmj1cZ7mjC2TXWnR51+3d1oyttl/cs0S4dRvBgFnHYxYy0HRxwnU mNlVJ4Pt0Murd4awUuqBCwaXff/DQe5YbCE9woRC5o7B5tmNodKjgkopK1RxW76ZURHX g/rQ== X-Gm-Message-State: AOJu0YzedMsqLYEf0TkLgSPy2Q6pIKJe3McNTm5zRthLzCiDXWM21gLs fVXl+MeZEiKgGNX6AgO5EphIWEjPVMZm8EGJch0= X-Received: by 2002:a05:6512:11eb:b0:507:a383:fe18 with SMTP id p11-20020a05651211eb00b00507a383fe18mr11716101lfs.40.1700205446406; Thu, 16 Nov 2023 23:17:26 -0800 (PST) Received: from m1x-phil.lan (bd137-h02-176-184-46-187.dsl.sta.abo.bbox.fr. [176.184.46.187]) by smtp.gmail.com with ESMTPSA id t4-20020a5d4604000000b0032fbd0c7d04sm1417408wrq.55.2023.11.16.23.17.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 23:17:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Subbaraya Sundeep , Arnaud Minier , Igor Mammedov , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Tyrone Ting , Hao Wu , Marcel Apfelbaum , Felipe Balbi , qemu-arm@nongnu.org, =?utf-8?q?In=C3=A8s_V?= =?utf-8?q?arhol?= , Alistair Francis , Yanan Wang , Richard Henderson , Eduardo Habkost , Peter Maydell , Helge Deller , Subbaraya Sundeep , Alexandre Iooss , Gavin Shan Subject: [PATCH-for-8.2? v2 3/4] hw/arm/stm32f205: Report error when incorrect CPU is used Date: Fri, 17 Nov 2023 08:17:03 +0100 Message-ID: <20231117071704.35040-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117071704.35040-1-philmd@linaro.org> References: <20231117071704.35040-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=philmd@linaro.org; helo=mail-lf1-x12f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The 'netduino2' machine ignores the CPU type requested by the command line. This might confuse users, since the following will create a machine with a Cortex-M3 CPU: $ qemu-system-arm -M netduino2 -cpu cortex-a9 Set the MachineClass::valid_cpu_types field (introduced in commit c9cf636d48 "machine: Add a valid_cpu_types property"). Remove the now unused MachineClass::default_cpu_type field. We now get: $ qemu-system-arm -M netduino2 -cpu cortex-a9 qemu-system-arm: Invalid CPU type: cortex-a9-arm-cpu The valid types are: cortex-m3-arm-cpu Since the SoC family can only use Cortex-M3 CPUs, hard-code the CPU type name at the SoC level, removing the QOM property entirely. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gavin Shan --- include/hw/arm/stm32f205_soc.h | 4 ---- hw/arm/netduino2.c | 7 ++++++- hw/arm/stm32f205_soc.c | 9 ++------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h index 5a4f776264..4f4c8bbebc 100644 --- a/include/hw/arm/stm32f205_soc.h +++ b/include/hw/arm/stm32f205_soc.h @@ -49,11 +49,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F205State, STM32F205_SOC) #define SRAM_SIZE (128 * 1024) struct STM32F205State { - /*< private >*/ SysBusDevice parent_obj; - /*< public >*/ - - char *cpu_type; ARMv7MState armv7m; diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c index 83753d53a3..501f63a77f 100644 --- a/hw/arm/netduino2.c +++ b/hw/arm/netduino2.c @@ -44,7 +44,6 @@ static void netduino2_init(MachineState *machine) clock_set_hz(sysclk, SYSCLK_FRQ); dev = qdev_new(TYPE_STM32F205_SOC); - qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); qdev_connect_clock_in(dev, "sysclk", sysclk); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -54,8 +53,14 @@ static void netduino2_init(MachineState *machine) static void netduino2_machine_init(MachineClass *mc) { + static const char * const valid_cpu_types[] = { + ARM_CPU_TYPE_NAME("cortex-m3"), + NULL + }; + mc->desc = "Netduino 2 Machine (Cortex-M3)"; mc->init = netduino2_init; + mc->valid_cpu_types = valid_cpu_types; mc->ignore_memory_transaction_failures = true; } diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c index c6b75a381d..1a548646f6 100644 --- a/hw/arm/stm32f205_soc.c +++ b/hw/arm/stm32f205_soc.c @@ -127,7 +127,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) armv7m = DEVICE(&s->armv7m); qdev_prop_set_uint32(armv7m, "num-irq", 96); - qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); + qdev_prop_set_string(armv7m, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); qdev_prop_set_bit(armv7m, "enable-bitband", true); qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); qdev_connect_clock_in(armv7m, "refclk", s->refclk); @@ -201,17 +201,12 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) } } -static Property stm32f205_soc_properties[] = { - DEFINE_PROP_STRING("cpu-type", STM32F205State, cpu_type), - DEFINE_PROP_END_OF_LIST(), -}; - static void stm32f205_soc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = stm32f205_soc_realize; - device_class_set_props(dc, stm32f205_soc_properties); + /* No vmstate or reset required: device has no internal state */ } static const TypeInfo stm32f205_soc_info = { From patchwork Fri Nov 17 07:17:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 744630 Delivered-To: patch@linaro.org Received: by 2002:a5d:5388:0:b0:32d:baff:b0ca with SMTP id d8csp741800wrv; Thu, 16 Nov 2023 23:18:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzp//RKPWtpUSSXzkqE0S/Oq8yGCtNQIR53/fC4G+svIB528ba2VyKiv2Zuj/+jT26jDh8 X-Received: by 2002:a05:622a:1352:b0:421:f47f:d758 with SMTP id w18-20020a05622a135200b00421f47fd758mr7970310qtk.8.1700205524199; Thu, 16 Nov 2023 23:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700205524; cv=none; d=google.com; s=arc-20160816; b=vSgwF3UFtReXe17h+RyYUiIcbCMq9VT2Gp9usbQJ0WbuVa3sWdaeWKCiTBOD6lAcLs v1+qyHm4c0K3W9nR8BgjUtPZHaA8LrhdAmp4b7JwEzSklLAKHxy9eqjAbrEtQYNtekKb 4yajuIp6fb+izEGnXBHvmE9xjaJ2A7/inx1DLi+EZNI4njljgu1bRTRbIP3ExKX1kp5l b81ShLmkZm5fhF4N93yM1jXu46VfOKSdZ+64hTJdgaujtZHcBpuQAj8ONTBykGjLdYYL hrDMAwvzVoIywupukjnw/etngc/K90OyrdlMmDcfsZmpXC0KmLPdZoEGqXSfjCX80xhI 9SZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jkPUT0M619zXl9UJEyr5oJWxqcVgknV+BijjQqGI0PI=; fh=/iNNmKky1DrOYOLWnTIBUxaMagIUG/IvUjT5dhZ7EH4=; b=ThP3C9BLzRhqOaqhCAHs/oaHyXh+PwA6RWg4MVA2i/lqbcJFxSnAfUdbrb7nxxrBBN OxNElv9R2CY2A6absPr5vlaG4TXdKGgouUfyfsN0nIxLSaJ4nAfopb4AvcrwqStKYs4K DAMoX5RwJSSiIQE/ObC29cGt5iVUTtWGLdeN5Pz7qM7+ISuww9Ds6z9pIOVRYf2xSL0r QWpWRtiuse0vb1fSAVSGBAnqAyPZJXUlPPo+J1BtWOIjCnqpm3JvHsIz6soneXTfMBJQ 1s3wL8+Om+86/fJmUqP+qvYwuWAY5tNr+VCGGLzKjIqAWnsb9pcO0ObD3ZqWCFeW+b/+ JpWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nlT6RRn1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q16-20020a05622a04d000b00421a4bd9022si1064630qtx.231.2023.11.16.23.18.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2023 23:18:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nlT6RRn1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3t6h-0005Sp-3S; Fri, 17 Nov 2023 02:17:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3t6e-0005RY-P9 for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:36 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3t6c-0004Kj-86 for qemu-devel@nongnu.org; Fri, 17 Nov 2023 02:17:35 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-32f87b1c725so1217732f8f.3 for ; Thu, 16 Nov 2023 23:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700205452; x=1700810252; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jkPUT0M619zXl9UJEyr5oJWxqcVgknV+BijjQqGI0PI=; b=nlT6RRn1osVMNVwVIYTzC8UV4L+/I+iRb52SLisKanQB6HUTLQ+Ab8oM6mJCPAipkR 6O6F91rqsiCTqSy9ob8yRmaCKxRn0HBs/qyo+PWUxaum7hoh6YLnnHdsxcnKfyc0+zhS LrNVVH7P//5Y0OXNVKCgpSno6sOAzfhVVtcGzbEC9cz4ix2yEr9Tppnb2ecYrQLgcbmt U28a6aVAJttO29uYhk2lxXPLH1DmgwjwUhpj2aZ0RJuxbDZEwdBeOkAocKF0BF+fiQ1t dXfdUsnKP2tiisq4GsoLOK36gTvXXBxet1kKavkeqRQoaE/VToW0Mssaaj/5MCsoMfv7 lE4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700205452; x=1700810252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jkPUT0M619zXl9UJEyr5oJWxqcVgknV+BijjQqGI0PI=; b=wjpIwgNYa0zAtOSCECstaJtRurz5kEhEhAYq/REucx+ynv4eV0hRwLvoeqPdZzxElg yBAkYhU5I4miTKhEFnnpBwMfO8Sp6aTLUlPbfsyjsCOQf6Wmk4LuozG9qtqDxlhLuijw SsGiYQh/W82PdaRdPsNlI9F5zHIdGXkviSjMltdEMMZF6igU3PLLSBqEoeueU/9tqtyH EhfYnUMSaMbPxcGQg/dyQZfDfoOd8OQOlGh2SzWGEqo79XVwWqBpvSKY+OudIprb1fH6 lXR4jy+ALi67K2itXevfTZO5NWqeVVzJNJ3krrxUe7pBMDsCDH2UO5iELirSX+/7mge4 JpLA== X-Gm-Message-State: AOJu0Yzaf7McA/zPZsJ6tNdhMCeADfMoNmx9toKRfJKijRb4dGLnN8tb u0W3K6O1yIHjNCJJ+9uK2lNNqMULnDDWVlF0W30= X-Received: by 2002:adf:ed41:0:b0:32d:b9c5:82fc with SMTP id u1-20020adfed41000000b0032db9c582fcmr11874479wro.36.1700205452492; Thu, 16 Nov 2023 23:17:32 -0800 (PST) Received: from m1x-phil.lan (bd137-h02-176-184-46-187.dsl.sta.abo.bbox.fr. [176.184.46.187]) by smtp.gmail.com with ESMTPSA id q16-20020adfcd90000000b0032d9caeab0fsm1409272wrj.77.2023.11.16.23.17.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Nov 2023 23:17:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Subbaraya Sundeep , Arnaud Minier , Igor Mammedov , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Tyrone Ting , Hao Wu , Marcel Apfelbaum , Felipe Balbi , qemu-arm@nongnu.org, =?utf-8?q?In=C3=A8s_V?= =?utf-8?q?arhol?= , Alistair Francis , Yanan Wang , Richard Henderson , Eduardo Habkost , Peter Maydell , Helge Deller , Subbaraya Sundeep , Alexandre Iooss , Gavin Shan Subject: [PATCH-for-8.2? v2 4/4] hw/arm/stm32f100: Report error when incorrect CPU is used Date: Fri, 17 Nov 2023 08:17:04 +0100 Message-ID: <20231117071704.35040-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117071704.35040-1-philmd@linaro.org> References: <20231117071704.35040-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The 'stm32vldiscovery' machine ignores the CPU type requested by the command line. This might confuse users, since the following will create a machine with a Cortex-M3 CPU: $ qemu-system-aarch64 -M stm32vldiscovery -cpu neoverse-n1 Set the MachineClass::valid_cpu_types field (introduced in commit c9cf636d48 "machine: Add a valid_cpu_types property"). Remove the now unused MachineClass::default_cpu_type field. We now get: $ qemu-system-aarch64 -M stm32vldiscovery -cpu neoverse-n1 qemu-system-aarch64: Invalid CPU type: neoverse-n1-arm-cpu The valid types are: cortex-m3-arm-cpu Since the SoC family can only use Cortex-M3 CPUs, hard-code the CPU type name at the SoC level, removing the QOM property entirely. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gavin Shan --- include/hw/arm/stm32f100_soc.h | 4 ---- hw/arm/stm32f100_soc.c | 9 ++------- hw/arm/stm32vldiscovery.c | 7 ++++++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/hw/arm/stm32f100_soc.h b/include/hw/arm/stm32f100_soc.h index 40cd415b28..a74d7b369c 100644 --- a/include/hw/arm/stm32f100_soc.h +++ b/include/hw/arm/stm32f100_soc.h @@ -43,12 +43,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F100State, STM32F100_SOC) #define SRAM_SIZE (8 * 1024) struct STM32F100State { - /*< private >*/ SysBusDevice parent_obj; - /*< public >*/ - char *cpu_type; - ARMv7MState armv7m; STM32F2XXUsartState usart[STM_NUM_USARTS]; diff --git a/hw/arm/stm32f100_soc.c b/hw/arm/stm32f100_soc.c index f7b344ba9f..b90d440d7a 100644 --- a/hw/arm/stm32f100_soc.c +++ b/hw/arm/stm32f100_soc.c @@ -115,7 +115,7 @@ static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) /* Init ARMv7m */ armv7m = DEVICE(&s->armv7m); qdev_prop_set_uint32(armv7m, "num-irq", 61); - qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); + qdev_prop_set_string(armv7m, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); qdev_prop_set_bit(armv7m, "enable-bitband", true); qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); qdev_connect_clock_in(armv7m, "refclk", s->refclk); @@ -180,17 +180,12 @@ static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) create_unimplemented_device("CRC", 0x40023000, 0x400); } -static Property stm32f100_soc_properties[] = { - DEFINE_PROP_STRING("cpu-type", STM32F100State, cpu_type), - DEFINE_PROP_END_OF_LIST(), -}; - static void stm32f100_soc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = stm32f100_soc_realize; - device_class_set_props(dc, stm32f100_soc_properties); + /* No vmstate or reset required: device has no internal state */ } static const TypeInfo stm32f100_soc_info = { diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c index 67675e952f..190db6118b 100644 --- a/hw/arm/stm32vldiscovery.c +++ b/hw/arm/stm32vldiscovery.c @@ -47,7 +47,6 @@ static void stm32vldiscovery_init(MachineState *machine) clock_set_hz(sysclk, SYSCLK_FRQ); dev = qdev_new(TYPE_STM32F100_SOC); - qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); qdev_connect_clock_in(dev, "sysclk", sysclk); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -58,8 +57,14 @@ static void stm32vldiscovery_init(MachineState *machine) static void stm32vldiscovery_machine_init(MachineClass *mc) { + static const char * const valid_cpu_types[] = { + ARM_CPU_TYPE_NAME("cortex-m3"), + NULL + }; + mc->desc = "ST STM32VLDISCOVERY (Cortex-M3)"; mc->init = stm32vldiscovery_init; + mc->valid_cpu_types = valid_cpu_types; } DEFINE_MACHINE("stm32vldiscovery", stm32vldiscovery_machine_init)