From nobody Tue Nov 26 22:18:01 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=1704469721; cv=none; d=zohomail.com; s=zohoarc; b=NCmyQY2GNnzIUOMfZA3lbHvPtrN+PrD5d5aQ+YXFtcSbVu9/9d4uOU0bEbuCRPYB+P4J1o2HEk4FzZ0gU+a8mO/Sl1jDpjE6yIZgcE+Okad2ndS17IErlONWHxvGz2qAGz+LufyLrvE96pGs8DomJYNYti6uNyaz0nAXkqexhlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704469721; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1hi5jkBMNGBwDBii6AMSMwfhTDlF/mIwoAbJvzijOtI=; b=h8EElYYF09WmpHG9cs3z8N6O749xZbsz/sVdbzsdyqYGjztUnY0CvE5RJO4fhYA8dpR/KiCu3pdrLooyONLH4tnj9tDRbV9X6Vsucl4im4LP2ZnZowoTYdZCfxR8VAQoZTIn6LQl3qS3qFxkfWGz47v247mEDDGfhFvty4v88eo= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704469721804364.9574850464676; Fri, 5 Jan 2024 07:48:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLmQC-00075s-6t; 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 1rLmPO-0004JD-SU for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:46:56 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rLmP8-0003vS-0e for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:46:54 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33687627ad0so1402680f8f.2 for ; Fri, 05 Jan 2024 07:46:37 -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 o14-20020adfeace000000b0033690139ea5sm1617406wrn.44.2024.01.05.07.46.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 05 Jan 2024 07:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704469595; x=1705074395; 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=1hi5jkBMNGBwDBii6AMSMwfhTDlF/mIwoAbJvzijOtI=; b=qCQrTSHeb8lhQbAHPNaI2JAkUkJ1CVQkgO/ZBQF5lCeLNDuCcgM9afPxF+/FJ/TBhc zMxILoEuhw0Sw6EwTEQAVe/c0ZLzUf6jwnaD2ftjefVezmm8S3EBsHDvA18vn1bEKJ/O Kr38nY0Sb9XYsQoe7syHuCY3InuUs2WgWZkZkYtkFyUT4GmBiv6TLN4mQlKVp+/IRyp7 NWtEHAzcmjI3iX3PdR4vLqsXRA99q0FzH74EGUpqNhRHy5hYK9f/KTJzCGUMzx0syOpQ VyL1Jd/AkSnDIcdJ2joyzvcAciLEZW+/LJ9mYJPK8rUTQZ/j4WEzO32HhAuydZmb4Yf8 wOTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704469595; x=1705074395; 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=1hi5jkBMNGBwDBii6AMSMwfhTDlF/mIwoAbJvzijOtI=; b=j+KeE4kvKSsid0KL0gMG/XGYxs1as45vnufEQsut7AbUI3rjYj3/NRGWQlZURjOx6b U18gtl09FRctUDNcLCAim/MSAaFe5rcQLTHfxFCpemh9rkLyD5/OG4KDI+qv/JoHOqVY BVW91cqVfctt5hEiQN8grC68lIm8PPk19XBBZqH4HZUSooSzDnVxXp/rLQu47sjI+g7s NYE99/r55MAQ8h7RvHZdVvH4z1f50DBijwgphkF3VVEIZG4lzb1OllqvGOSHmlZ9LtpJ BQYkfGPMlGfm3mPJ8WlOlIw3mJzUQIzkUnzp1URWx5ZrNpOrCbcdgRBHMDwaLW0NUCkV +p/w== X-Gm-Message-State: AOJu0Yy8c10wtk8HuywuMKf4DedaC5fvLS1+t5+Tj0vDOM0uWPY0VVT4 vA54LGFF0x/Hnixbw+B53PB14DaApEzfLqjkZMJ31GdFEE0= X-Google-Smtp-Source: AGHT+IG9tc/jLgaKDL2Qg6eCM9FJfemxntZKCZaoRWdcSm9eNff6H0Y80zJN+t6b6DZhbrFf3lxssA== X-Received: by 2002:a5d:4808:0:b0:333:5665:fa86 with SMTP id l8-20020a5d4808000000b003335665fa86mr1445590wrq.18.1704469595241; Fri, 05 Jan 2024 07:46:35 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-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=20Mathieu-Daud=C3=A9?= , Leif Lindholm , Richard Henderson , Radoslaw Biernacki , Peter Maydell , Marcin Juszkiewicz Subject: [PULL 30/71] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init() Date: Fri, 5 Jan 2024 16:42:23 +0100 Message-ID: <20240105154307.21385-31-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 Content-Type: text/plain; charset="utf-8" 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=philmd@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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704469722230100001 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 it by ourselves. Signed-off-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Leif Lindholm Reviewed-by: Richard Henderson Message-ID: <20231204004726.483558-8-gshan@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/sbsa-ref.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index f3c9704693..477dca0637 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -145,27 +145,6 @@ static const int sbsa_ref_irqmap[] =3D { [SBSA_GWDT_WS0] =3D 16, }; =20 -static const char * const valid_cpus[] =3D { - ARM_CPU_TYPE_NAME("cortex-a57"), - ARM_CPU_TYPE_NAME("cortex-a72"), - ARM_CPU_TYPE_NAME("neoverse-n1"), - ARM_CPU_TYPE_NAME("neoverse-v1"), - ARM_CPU_TYPE_NAME("neoverse-n2"), - ARM_CPU_TYPE_NAME("max"), -}; - -static bool cpu_type_valid(const char *cpu) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(valid_cpus); i++) { - if (strcmp(cpu, valid_cpus[i]) =3D=3D 0) { - return true; - } - } - return false; -} - static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) { uint8_t clustersz =3D ARM_DEFAULT_CPUS_PER_CLUSTER; @@ -733,11 +712,6 @@ static void sbsa_ref_init(MachineState *machine) const CPUArchIdList *possible_cpus; int n, sbsa_max_cpus; =20 - if (!cpu_type_valid(machine->cpu_type)) { - error_report("sbsa-ref: CPU type %s not supported", machine->cpu_t= ype); - exit(1); - } - if (kvm_enabled()) { error_report("sbsa-ref: KVM is not supported for this machine"); exit(1); @@ -898,10 +872,20 @@ static void sbsa_ref_instance_init(Object *obj) static void sbsa_ref_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + static const char * const valid_cpu_types[] =3D { + ARM_CPU_TYPE_NAME("cortex-a57"), + ARM_CPU_TYPE_NAME("cortex-a72"), + ARM_CPU_TYPE_NAME("neoverse-n1"), + ARM_CPU_TYPE_NAME("neoverse-v1"), + ARM_CPU_TYPE_NAME("neoverse-n2"), + ARM_CPU_TYPE_NAME("max"), + NULL, + }; =20 mc->init =3D sbsa_ref_init; mc->desc =3D "QEMU 'SBSA Reference' ARM Virtual Machine"; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("neoverse-n1"); + mc->valid_cpu_types =3D valid_cpu_types; mc->max_cpus =3D 512; mc->pci_allow_0_address =3D true; mc->minimum_page_bits =3D 12; --=20 2.41.0