From nobody Mon May 12 15:39:10 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1695245969; cv=none; d=zohomail.com; s=zohoarc; b=cFZYd7jteFXa7Efe3prydl0Yhuc4Owl+RKbka9hWlg1ULSXaSUi0Kzb1HwY1SLWk5bDJS+9f3YyaL33+DPyhGfi8YMGHL+u+rGAQm8TYZyRUn3KPkvS2aeGW6tWHyd6N3YlPRxAqTXsYtFSRVSVZazTzTLXpOuhUKkT12JBc2bU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695245969; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m97eKcYhxutpzHRkswwj8gKLRsf806rl8f4MNHOdJoo=; b=kq38I2Cx3Su3060e3ERlYAEs8AIarG9W4oWJnSX6mrEW7CD3Xs+q/I+KLjAj3rD98JzZ8U2rSRyCmYfcadMJinEvuZAnCE0E8Lvjjau85SfDrxDWAD5h2qwJRdeVEtVr/Tw6fFXRamTscoNWHxOI9btIA4hh03Qrv0iH+7xupgs= 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+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695245969946102.56319001102429; Wed, 20 Sep 2023 14:39:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qj4tX-00053D-M8; Wed, 20 Sep 2023 17:38:03 -0400 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 1qj4tV-00052G-Td for qemu-devel@nongnu.org; Wed, 20 Sep 2023 17:38:01 -0400 Received: from mail-ot1-x333.google.com ([2607:f8b0: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 1qj4tU-0006Vo-BL for qemu-devel@nongnu.org; Wed, 20 Sep 2023 17:38:01 -0400 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6c0b3cea424so202681a34.2 for ; Wed, 20 Sep 2023 14:38:00 -0700 (PDT) Received: from grind.. ([177.94.42.59]) by smtp.gmail.com with ESMTPSA id e1-20020a9d7301000000b006b83a36c08bsm64415otk.53.2023.09.20.14.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 14:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1695245879; x=1695850679; 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=m97eKcYhxutpzHRkswwj8gKLRsf806rl8f4MNHOdJoo=; b=Z/orPlfORXiVQQFuoTtCJ9Pm8wGDUf3qD4+kJUaAaqs4sktI1i/rmteXqx9AQbH9O6 jMXsNF9acBnZPr5pzi1/KanwOqnlbaKjedGRP3nJfTK6v8PCTles2GI9TscN4dWbFaXp 3+afvVntP0rclbSG53OjzXfw30gR/TXHds88Anc6rz3xcX40hW4pzXBUffw/tQEUpphr UHT9hYIf6ZitX/Ujbf68kx/WiU9WLz5XScrV+O3HMqtX5A2OKpb/qJrkdCB8CJKmQKvl wyiO4cm2n8h4FbeDI2ajGRq6Vm9iAo7+MA7UmclrvNj2mvW8M9dbCeqg5MVHTzBUx0vd dMfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695245879; x=1695850679; 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=m97eKcYhxutpzHRkswwj8gKLRsf806rl8f4MNHOdJoo=; b=Jdp8uv5PIoR0KvYIaIsLBgX8OVlmoc+h2gUhafMzF1yrGLlQQlFbH+zs9bJsCut7+Y R52BPwrZQDPgtisP7uBCVi4ppPqoraZXA5t+sc2SzrQ4J3qRusHJA82BpEysUdv5lAlE vu/R3WWddh1Ds89PUkg1WupLK/CYTZXNsDHN0EPc5spNQVavWHP/jmlBg1q0G7mmW1R5 SvZWCO2fQ7Ofp0nWbKQ8YGWo/qThwqkRGxUL6T7zpW5pztjEtEL3cWcTS9g9YJ7oWW49 BN0SKzZfLz6O6JDvPtRT3rMDli6OSlWggMwhqh9DCSrV1oRDb75Ig6vaTSESPI4c0aDi jasQ== X-Gm-Message-State: AOJu0YxMiGB6Fr+WDuSCiguaLX1KXOFIX+f5qZ0DLX7pyk/GLyH89P7d p2h7XYLAEluE4TqGReIQgjewAXOIrCJpOaF4vZE= X-Google-Smtp-Source: AGHT+IGLTEZg/5Sfg+80fwR0tsb7jfVM/dQjz37uyZEVZWfO14MX3sUnh5byC/XkQMIcMYjt61q9CQ== X-Received: by 2002:a05:6830:1d85:b0:6b8:6a83:2b17 with SMTP id y5-20020a0568301d8500b006b86a832b17mr4039342oti.33.1695245879133; Wed, 20 Sep 2023 14:37:59 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH 3/8] target/riscv/kvm/kvm-cpu.c: add missing property getters() Date: Wed, 20 Sep 2023 18:37:38 -0300 Message-ID: <20230920213743.716265-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920213743.716265-1-dbarboza@ventanamicro.com> References: <20230920213743.716265-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::333; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1695245971838100003 Content-Type: text/plain; charset="utf-8" We got along without property getters in the KVM driver because we never needed them. But the incoming query-cpu-model-expansion API will use property getters and setters to retrieve the CPU characteristics. Add the missing getters for the KVM driver for both MISA and multi-letter extension properties. We're also adding an special getter for absent multi-letter properties that KVM doesn't implement that always return false. Signed-off-by: Daniel Henrique Barboza --- target/riscv/kvm/kvm-cpu.c | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index c6615cb807..b4c231f231 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -140,6 +140,19 @@ static KVMCPUConfig kvm_misa_ext_cfgs[] =3D { KVM_MISA_CFG(RVM, KVM_RISCV_ISA_EXT_M), }; =20 +static void kvm_cpu_get_misa_ext_cfg(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **errp) +{ + KVMCPUConfig *misa_ext_cfg =3D opaque; + target_ulong misa_bit =3D misa_ext_cfg->offset; + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + bool value =3D env->misa_ext_mask & misa_bit; + + visit_type_bool(v, name, &value, errp); +} + static void kvm_cpu_set_misa_ext_cfg(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -244,6 +257,17 @@ static uint32_t kvm_cpu_cfg_get(RISCVCPU *cpu, return *ext_enabled; } =20 +static void kvm_cpu_get_multi_ext_cfg(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **errp) +{ + KVMCPUConfig *multi_ext_cfg =3D opaque; + RISCVCPU *cpu =3D RISCV_CPU(obj); + bool value =3D kvm_cpu_cfg_get(cpu, multi_ext_cfg); + + visit_type_bool(v, name, &value, errp); +} + static void kvm_cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -346,6 +370,15 @@ static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU = *cpu, CPUState *cs) } } =20 +static void cpu_get_cfg_unavailable(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **errp) +{ + bool value =3D false; + + visit_type_bool(v, name, &value, errp); +} + static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -376,7 +409,8 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *obj,= const char *prop_name) * to enable any of them. */ object_property_add(obj, prop_name, "bool", - NULL, cpu_set_cfg_unavailable, + cpu_get_cfg_unavailable, + cpu_set_cfg_unavailable, NULL, (void *)prop_name); } =20 @@ -406,7 +440,7 @@ static void kvm_riscv_add_cpu_user_properties(Object *c= pu_obj) misa_cfg->description =3D riscv_get_misa_ext_description(bit); =20 object_property_add(cpu_obj, misa_cfg->name, "bool", - NULL, + kvm_cpu_get_misa_ext_cfg, kvm_cpu_set_misa_ext_cfg, NULL, misa_cfg); object_property_set_description(cpu_obj, misa_cfg->name, @@ -422,7 +456,7 @@ static void kvm_riscv_add_cpu_user_properties(Object *c= pu_obj) KVMCPUConfig *multi_cfg =3D &kvm_multi_ext_cfgs[i]; =20 object_property_add(cpu_obj, multi_cfg->name, "bool", - NULL, + kvm_cpu_get_multi_ext_cfg, kvm_cpu_set_multi_ext_cfg, NULL, multi_cfg); } --=20 2.41.0