From patchwork Fri Jan 5 15:42:23 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: 760172 Delivered-To: patch@linaro.org Received: by 2002:a5d:678d:0:b0:336:6142:bf13 with SMTP id v13csp105463wru; Fri, 5 Jan 2024 07:48:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTZ6JOn1nwXdqQAYbsze8Tem7jP5IayDXwNpLB/jXA2jIv37SxOELIyaIjgiUFOO4yBMf7 X-Received: by 2002:a05:622a:5cb:b0:425:962a:1973 with SMTP id d11-20020a05622a05cb00b00425962a1973mr2430836qtb.137.1704469722857; Fri, 05 Jan 2024 07:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704469722; cv=none; d=google.com; s=arc-20160816; b=MKORBTcy59obpXWCVccajcIERoGSZFvOqgaLxeUrPLXt2GJOy5B9hZBOB2kmXm9feF VW4diXH2UgzhecjZR8bWisG8aee18u9XwsSLOQL1NlxeCfnlggd9N1Fc8ELq2K8ShXSR hyYrULmd++/is9KdDLOi7vYLt4LxbfjPU1rdMzL9PaTctflNCu0G2b5dkuEBQ/T1ylSI pPwU3AEf6BUxXpi6rBGAS9dgOVOcG8XWNF8Vpomgx9tRsZZtLk7626pZta9t8ooqQQjI PMo37buRfsdC0iyDsvjmofBzC3zpI8SxwySO+0tliazELitE4A/ECaKgeiDZ52TtoHT5 jYDw== 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=1hi5jkBMNGBwDBii6AMSMwfhTDlF/mIwoAbJvzijOtI=; fh=01uvjdnRqxrQMIijehkKba7mQP7dFS0QWXi67SxyC+g=; b=YAYXbnd3v9XF0IEV/1KYl9I3+Begjb7akncGo7blHEEenQXRYjrI8N208HO1hgUUXZ Kg/bMr0SUh2Ev1simX56oeI8HQJeKS6wHh28t+XsitDSSzkytBkKEpRSmjpw3LV6KZBT QlmxFbSIs7Jq3B9x0IqA0n9dPHPfysYygirLn2LAQqUc8jv8CddFgEOlRiY7SxkyW3yI wkISWyjml6k2liMXdkF/h5uANAwFD8XDDbWewhk2mNy8SWn+v0o/Sv+rHGloc4nERNYI U7Ta9AqdMe2GFB/bC6Ff6VYd2mQSVoQR3QQF1EmTKw+5UFkW0V6mipLDrwUOZRLQlnKV T24A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qCQrTSHe; 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 i5-20020ac85c05000000b004297dab56b2si279598qti.563.2024.01.05.07.48.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2024 07:48:42 -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=qCQrTSHe; 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-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) 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-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) 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) 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?= , 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 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+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 it by ourselves. Signed-off-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Leif Lindholm Reviewed-by: Richard Henderson Message-ID: <20231204004726.483558-8-gshan@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- 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[] = { [SBSA_GWDT_WS0] = 16, }; -static const char * const valid_cpus[] = { - 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 = 0; i < ARRAY_SIZE(valid_cpus); i++) { - if (strcmp(cpu, valid_cpus[i]) == 0) { - return true; - } - } - return false; -} - static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) { uint8_t clustersz = 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; - if (!cpu_type_valid(machine->cpu_type)) { - error_report("sbsa-ref: CPU type %s not supported", machine->cpu_type); - 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 = MACHINE_CLASS(oc); + static const char * const valid_cpu_types[] = { + 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, + }; mc->init = sbsa_ref_init; mc->desc = "QEMU 'SBSA Reference' ARM Virtual Machine"; mc->default_cpu_type = ARM_CPU_TYPE_NAME("neoverse-n1"); + mc->valid_cpu_types = valid_cpu_types; mc->max_cpus = 512; mc->pci_allow_0_address = true; mc->minimum_page_bits = 12;