From patchwork Fri Jan 12 14:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 1886124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=kY1w8LMo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TBNYv0qvTz1yP3 for ; Sat, 13 Jan 2024 01:04:03 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOI7N-00048f-NB; Fri, 12 Jan 2024 09:02:43 -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 1rOI7H-00045U-LI for qemu-devel@nongnu.org; Fri, 12 Jan 2024 09:02:38 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOI7F-00060Z-NH for qemu-devel@nongnu.org; Fri, 12 Jan 2024 09:02:35 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d426ad4433so43168475ad.0 for ; Fri, 12 Jan 2024 06:02:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705068151; x=1705672951; 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=dTdGOl9slcZkcRMyhG4duGeAzjUzLWjR8F5t/SxIbuQ=; b=kY1w8LMoutBh5GvxxBtYMVX8IGAmUDvdoqNBOxzDpP7IAY0G18HQUB+15ANxkvqrVh SeifhNa3Jz2yQNy+KCacz9fXPV5taDK7qKnvOWTj9wretRW4tHAGIbnxBhjDB/Ep+agD qY5MRm78mITOCbBE5bjCIGPNqDyiffOEtojr/fDyQhlPMWC3w+hBnYtn5kwB+cdOs+Xi p/iGI06H1iDzb7fi8F2v4P0ImtJNOVXCnTAb4B8wVfqVw/+nh6K5z7V1ZPmQ7CCu/uuy WMBURP8BI2+Sdz3Jm+zTX3wfQ7lJVoyeAl+a+xU1I8uVTQscN7k6hcJpwKitv3tvBYC4 2KiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705068151; x=1705672951; 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=dTdGOl9slcZkcRMyhG4duGeAzjUzLWjR8F5t/SxIbuQ=; b=e2sLcCVN5Cf8/2zX36584cIGnIocoWgHjAHwYuiLb2YUctDFYmvvqPdag3tyF3a6kc FhrOLfg0ceQlXwDaiLsNOwOCc37imXYqN9qtQpe9ORXz6YWWrwMiAMj1v2sPO488FWOD g8Ubs3zi0heZjhmTbpmJ6BGU89zr6gOBM05sGD/aYzDGwMMP3FjUNZj7ORoXRT3jCBu5 ItCZSAkOn5P8pl0PruvWWiFzqu9ILOdiZS/ZVVeKfyCSb/dq/s3CGHhqE8uK+vIHJwMP weTfLZXcR89IBn+5gwwS33y3wwyAGxgGM0SgW/Udz+QzX3gi6jnVoaIkmxOzf93tcg1+ yFPQ== X-Gm-Message-State: AOJu0Yx6fTOMSCz/ty/c7JH+PxJ+g3xCpo/twgWgZgM5TLN12ct50vgM 9FwtNXYd7s3mGQXmcrfI2P00WgOk7kazE01rxJ8+2/+Uuosh7g== X-Google-Smtp-Source: AGHT+IEhjHIRhjBwt2KokMMHci8G8VatSp8O2awaWSFk3DBXzLA7XD+N7eAKB0FJg07Iq7Hd45hKCw== X-Received: by 2002:a17:902:8214:b0:1d5:844:da22 with SMTP id x20-20020a170902821400b001d50844da22mr778108pln.15.1705068151608; Fri, 12 Jan 2024 06:02:31 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([152.234.123.64]) by smtp.gmail.com with ESMTPSA id t5-20020a1709028c8500b001cf6453b237sm3116927plo.236.2024.01.12.06.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 06:02:31 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza , Vladimir Isaev Subject: [PATCH v5 7/8] target/riscv/cpu.c: move 'mimpid' to riscv_cpu_properties[] Date: Fri, 12 Jan 2024 11:02:00 -0300 Message-ID: <20240112140201.127083-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240112140201.127083-1-dbarboza@ventanamicro.com> References: <20240112140201.127083-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62f.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Keep all class properties in riscv_cpu_properties[]. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Tested-by: Vladimir Isaev --- target/riscv/cpu.c | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3adc3a04f8..ab77649c4c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2015,6 +2015,41 @@ static const PropertyInfo prop_mvendorid = { .set = prop_mvendorid_set, }; +static void prop_mimpid_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool dynamic_cpu = riscv_cpu_is_dynamic(obj); + RISCVCPU *cpu = RISCV_CPU(obj); + uint64_t prev_val = cpu->cfg.mimpid; + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + if (!dynamic_cpu && prev_val != value) { + error_setg(errp, "Unable to change %s mimpid (0x%" PRIu64 ")", + object_get_typename(obj), prev_val); + return; + } + + cpu->cfg.mimpid = value; +} + +static void prop_mimpid_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint64_t value = RISCV_CPU(obj)->cfg.mimpid; + + visit_type_uint64(v, name, &value, errp); +} + +static const PropertyInfo prop_mimpid = { + .name = "mimpid", + .get = prop_mimpid_get, + .set = prop_mimpid_set, +}; + /* * RVA22U64 defines some 'named features' or 'synthetic extensions' * that are cache related: Za64rs, Zic64b, Ziccif, Ziccrse, Ziccamoa @@ -2102,6 +2137,7 @@ static Property riscv_cpu_properties[] = { {.name = "cboz_blocksize", .info = &prop_cboz_blksize}, {.name = "mvendorid", .info = &prop_mvendorid}, + {.name = "mimpid", .info = &prop_mimpid}, #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), @@ -2183,35 +2219,6 @@ static const struct SysemuCPUOps riscv_sysemu_ops = { }; #endif -static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - bool dynamic_cpu = riscv_cpu_is_dynamic(obj); - RISCVCPU *cpu = RISCV_CPU(obj); - uint64_t prev_val = cpu->cfg.mimpid; - uint64_t value; - - if (!visit_type_uint64(v, name, &value, errp)) { - return; - } - - if (!dynamic_cpu && prev_val != value) { - error_setg(errp, "Unable to change %s mimpid (0x%" PRIu64 ")", - object_get_typename(obj), prev_val); - return; - } - - cpu->cfg.mimpid = value; -} - -static void cpu_get_mimpid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - uint64_t value = RISCV_CPU(obj)->cfg.mimpid; - - visit_type_uint64(v, name, &value, errp); -} - static void cpu_set_marchid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2292,9 +2299,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->gdb_arch_name = riscv_gdb_arch_name; cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml; - object_class_property_add(c, "mimpid", "uint64", cpu_get_mimpid, - cpu_set_mimpid, NULL, NULL); - object_class_property_add(c, "marchid", "uint64", cpu_get_marchid, cpu_set_marchid, NULL, NULL);