From patchwork Fri Jan 5 15:42:22 2024 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: 760176 Delivered-To: patch@linaro.org Received: by 2002:a5d:678d:0:b0:336:6142:bf13 with SMTP id v13csp105621wru; Fri, 5 Jan 2024 07:49:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmgEa9Ca1lmkjFdeseEMCXQz4UBmtSV+5zaES1MRwYkPZN2b++aHI505M/AFepJIimRrvy X-Received: by 2002:a05:6214:2b0f:b0:679:f25a:8ff0 with SMTP id jx15-20020a0562142b0f00b00679f25a8ff0mr2418660qvb.26.1704469742013; Fri, 05 Jan 2024 07:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704469742; cv=none; d=google.com; s=arc-20160816; b=TyD8qrbSAg8/n0lRcwiOL9MhYFPTwoTDZJBOOZ2aUFeMw7Mi3a1B+RCgTeg84fnlZV CtiWqu7MqtT/i5TivBXpCgofBXX9PoubHsBQKRA+m2sW3pfq/fwZ1SZVH4WSqGHoweed qjRGB8aLy7jxjqSK0XWV44Y4/aOMycaMNZwMHqUw82fsm5DhUW/XyjsdNbembrZbrwm2 uha8gsU5A85TfDalSfGwHoDRIm0jduDa23auGyYHJMzvppSZFK8uM+UBoT/qJAZRx+oH Ajg5RCenIreqPfOE46TygsYhFFxRW0+suZCjYioXywjS9EMW9PfCUrVh2BwmzLl+9tNA 6rCA== 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=+mHMa1tnUIKC/Lz8fv92EG3G72QPfm2OOOA3/xxqo/c=; fh=DAPvSgCUhAarA6fZ2xgq43lJ/6n+8M24aoksosCsGI8=; b=hwJgee7OTZyvuswtgct/iVmZWiAtVpdAD4WaF5jqQZxkImK2jtai7bBPFXzb0PX/nd QDcwfD/GZ/r/1exzzZAjiTQsaoPRUYto95Lh5Slyzt6PCS0fNNJ7xcr7Od3cuMHP08ya l+d3qt48Wpm4KpBAm6lyIbvUNNiqvw9dyguMJCDr1kAYr0mG5HsMco++IhALB/YHHLzD ApLTgXSKz96+dq/DcxBkHLfFWLsMEOEzVV7Nz9Mm2PGmcyookyYZY+PJw+EBX6w256UE bVTRhIRxbFiBJip7CeGG3YTfHmHxUIpgw33kjF9XQiPcLcyNQwLcySr9oZLuU3QIb8+R 36Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EOwq83hE; 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 bj2-20020a05620a190200b007830c5ba782si922332qkb.349.2024.01.05.07.49.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2024 07:49:01 -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=EOwq83hE; 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 1rLmQC-0007Dg-Qy; Fri, 05 Jan 2024 10:47:44 -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 1rLmPM-0004Gs-W9 for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:46:54 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rLmP7-0003ty-EX for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:46:52 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40e384404e7so8453145e9.1 for ; Fri, 05 Jan 2024 07:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704469583; x=1705074383; 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=+mHMa1tnUIKC/Lz8fv92EG3G72QPfm2OOOA3/xxqo/c=; b=EOwq83hELeFzXU3fhCBRM97RIkwnmLILDORrxh2bmW24QwPbULqfd7wsz4Es911bwh HdII4/a4ZCwGC9VW56p7W5feklrHxYBna9uTCe341/xVNowZ3avbynacCH77WfUYR60Q ZaCY7UxQ0WGLEy21tWmX2eT5T4Bt9zYXj6+laWTuPUCNhZltkj+yMEISf/d/v34VhwmL jrjUG82zcNtDpGldhTm23oAuh7i7AeYLKoliImOelsmRmqE5Z16AFCj38dkmVkW0cMrS 09eE1C8LkROMEyAI9rH2h+M0wvhTU1MsRRi/MgI1y9Vc2S8tCnYcpDib6p846AWgd+84 B3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704469583; x=1705074383; 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=+mHMa1tnUIKC/Lz8fv92EG3G72QPfm2OOOA3/xxqo/c=; b=ZCbsg+ndCigijr6MuBpEbUPXbvjrHzmJdfWmW/s4V0gVkVrahZUvtXT1IbWeShMgJU ZkIkHFXXkUH8LjtR8kQkL58K2iOxCpwPCuRPuQdmumQzThb9bgKMd2wQQuROtZPTebdj 5S6Qo1xN6DYkWLeNcv565IJP0lDBJwxyObsKlQK/wT9vkLdZm2goMZZ6P6KkcxtbNsT8 RAVYubP7LIkvTvvA8xCsXuVo2Z/qyfletLEc0G0icTWPVoFZkAAUS40nqsO77E6wVSxb jY8ZQ5j0FWnBzkPIq6QH3HsThwHXHjw1QfNzVy/DtNU0CxO7HYduc3a60nm0+An8nMcs 6dTQ== X-Gm-Message-State: AOJu0YzuggUz85FwnWy9I5yu3fOnl/FXNSdckKTIRVKkzZhEZVQuCfAZ h5xKkEWNvx916Zg3jyaLpo468tuwmiFQUUUfxPfVzEajhGo= X-Received: by 2002:a05:600c:a45:b0:40e:3511:2c39 with SMTP id c5-20020a05600c0a4500b0040e35112c39mr1355661wmq.172.1704469583308; Fri, 05 Jan 2024 07:46:23 -0800 (PST) Received: from m1x-phil.lan (juv34-h02-176-184-26-1.dsl.sta.abo.bbox.fr. [176.184.26.1]) by smtp.gmail.com with ESMTPSA id w17-20020a05600c475100b0040d802a7619sm1924026wmo.38.2024.01.05.07.46.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 05 Jan 2024 07:46:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Gavin Shan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Peter Maydell Subject: [PULL 29/71] hw/arm/virt: Check CPU type in machine_run_board_init() Date: Fri, 5 Jan 2024 16:42:22 +0100 Message-ID: <20240105154307.21385-30-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240105154307.21385-1-philmd@linaro.org> References: <20240105154307.21385-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 Set mc->valid_cpu_types so that the user specified CPU type can be validated in machine_run_board_init(). We needn't to do the check by ourselves. Signed-off-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-ID: <20231204004726.483558-7-gshan@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/virt.c | 62 +++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8b060ef1d9..2793121cb4 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -204,40 +204,6 @@ static const int a15irqmap[] = { [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */ }; -static const char *valid_cpus[] = { -#ifdef CONFIG_TCG - ARM_CPU_TYPE_NAME("cortex-a7"), - ARM_CPU_TYPE_NAME("cortex-a15"), - ARM_CPU_TYPE_NAME("cortex-a35"), - ARM_CPU_TYPE_NAME("cortex-a55"), - ARM_CPU_TYPE_NAME("cortex-a72"), - ARM_CPU_TYPE_NAME("cortex-a76"), - ARM_CPU_TYPE_NAME("cortex-a710"), - ARM_CPU_TYPE_NAME("a64fx"), - ARM_CPU_TYPE_NAME("neoverse-n1"), - ARM_CPU_TYPE_NAME("neoverse-v1"), - ARM_CPU_TYPE_NAME("neoverse-n2"), -#endif - ARM_CPU_TYPE_NAME("cortex-a53"), - ARM_CPU_TYPE_NAME("cortex-a57"), -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) - ARM_CPU_TYPE_NAME("host"), -#endif - ARM_CPU_TYPE_NAME("max"), -}; - -static bool cpu_type_valid(const char *cpu) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) { - if (strcmp(cpu, valid_cpus[i]) == 0) { - return true; - } - } - return false; -} - static void create_randomness(MachineState *ms, const char *node) { struct { @@ -2042,11 +2008,6 @@ static void machvirt_init(MachineState *machine) unsigned int smp_cpus = machine->smp.cpus; unsigned int max_cpus = machine->smp.max_cpus; - if (!cpu_type_valid(machine->cpu_type)) { - error_report("mach-virt: CPU type %s not supported", machine->cpu_type); - exit(1); - } - possible_cpus = mc->possible_cpu_arch_ids(machine); /* @@ -2940,6 +2901,28 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); + static const char * const valid_cpu_types[] = { +#ifdef CONFIG_TCG + ARM_CPU_TYPE_NAME("cortex-a7"), + ARM_CPU_TYPE_NAME("cortex-a15"), + ARM_CPU_TYPE_NAME("cortex-a35"), + ARM_CPU_TYPE_NAME("cortex-a55"), + ARM_CPU_TYPE_NAME("cortex-a72"), + ARM_CPU_TYPE_NAME("cortex-a76"), + ARM_CPU_TYPE_NAME("cortex-a710"), + ARM_CPU_TYPE_NAME("a64fx"), + ARM_CPU_TYPE_NAME("neoverse-n1"), + ARM_CPU_TYPE_NAME("neoverse-v1"), + ARM_CPU_TYPE_NAME("neoverse-n2"), +#endif + ARM_CPU_TYPE_NAME("cortex-a53"), + ARM_CPU_TYPE_NAME("cortex-a57"), +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) + ARM_CPU_TYPE_NAME("host"), +#endif + ARM_CPU_TYPE_NAME("max"), + NULL + }; mc->init = machvirt_init; /* Start with max_cpus set to 512, which is the maximum supported by KVM. @@ -2966,6 +2949,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) #else mc->default_cpu_type = ARM_CPU_TYPE_NAME("max"); #endif + mc->valid_cpu_types = valid_cpu_types; mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler);