From nobody Thu Nov 28 09:50:37 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694153482; cv=none; d=zohomail.com; s=zohoarc; b=GZq9yOHot8R+fG5K0O77DN791yF4hfTHXDWDvD6CzOtaoj8iA9wxjh6ecTZ6BNjtT84wK6Fz5T4GWJb1gtuuuVzcqemMpChc98/leeRXGNDw1LumOM4gIq7R6W4nNHrmfTH8E+9aG73DZ2TKdAWX7OTyUfWp84mhiFrnLVFJcn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153482; 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=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=fouSW4e21eHMCS3Sb1Bc861y8mB4D4IlJVaQJGdS2rGkmQVz4wD9Tk0Nnk+VeB7vn5OSkTfafCyPZYlY7Lqzv/Z2R+R0wf/QSrIuLnahKW2gHudyaS4s80JVgOwyWUw67VV9C/g0hzBSbT9loK3KupfzRFR+x5tTowHG5GdXlME= 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 169415348234596.48836262439238; Thu, 7 Sep 2023 23:11:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUf1-0001wa-IY; Fri, 08 Sep 2023 02:08:07 -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 1qeUf0-0001uu-Af for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUet-00088C-Tb for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c34c9cc9b9so13563565ad.3 for ; Thu, 07 Sep 2023 23:07:59 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153278; x=1694758078; 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=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=ZpO0it1U00dTSnVoOZR2ADSMNnQkpRjaD0HfvB/GLNSTSs1NK+Lq2GL0sDGnu3iozx QRKZG8GDy47mnYbDloHw3/2W2ODOZU+iKEbPIg8lpoh1Bj3U+ZE3x8l/WKpVof2hefW/ 0CuISuH8L8TlOG8jLT2ZhqXfQPV4Xkmn9sNtB0fQGQRUPYR6uqy87RDd81U5hzRz8/Q4 5f1zXQKfnV6ccHQFUFqddBGqPzYSLwz73KtyZMY8pcJ1DTiwJczm3XbIyPJaWopBj1nW h14WTfgw2cyBEeLWzYq/YA1p/B52Wmq0E8eIhHZRb4KZO2p8RWL+OJMwe2UCUlJ3A6ej wjqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153278; x=1694758078; 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=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=JHIqctpYR7gvvAYkZBC2fw0WCLRQJvCPoPKXzUz4cWC4z2tnM2csoPpZSHkRIqUJ4c t7I9XEAlmaDSJZLLqXGNRG22w3X2DpHTZz35aW2JkEpgmN9FtIx3qzx6Qt+tPtMFzVFB JjRCNZpWxH4Dg1L4SwXHjMntQxpu8JUnurrBi9aGJZDbUyFgssHypyS5VJMPRF8ioI4N U96caYiDnTzR9h0HqbA+L97SRDA04hjFxrbulAQk9qWJdWXIitQx0ngxQM0GaOEtCgij rFlsOPUM+BlXksa28kof6wsFbh2nTU0zdWfijDV2kUgfZkHqqS+Mw8aNbd6lYbjJSLP0 N7tw== X-Gm-Message-State: AOJu0YxL5+MkB53eDO2gts/Gv6io4G3msZ0OeOQkzKx2l2JOVra+lRZc R1ZjFiTTOnLw9QfVekAs+BuC06RqHnjcKCJ/ X-Google-Smtp-Source: AGHT+IGyOudccjU3gO1Dstwaz4eyhYHlkIVPTbk0xpNm33deDsEqjJuINLehFonlAnE5qaI0zGwf0Q== X-Received: by 2002:a17:902:c40a:b0:1c3:21ae:7a4a with SMTP id k10-20020a170902c40a00b001c321ae7a4amr2279615plk.38.1694153278221; Thu, 07 Sep 2023 23:07:58 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis , Andrew Jones Subject: [PULL 48/65] target/riscv/cpu.c: split kvm prop handling to its own helper Date: Fri, 8 Sep 2023 16:04:14 +1000 Message-ID: <20230908060431.1903919-49-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=alistair23@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @gmail.com) X-ZM-MESSAGEID: 1694153483110100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Future patches will split the existing Property arrays even further, and the existing code in riscv_cpu_add_user_properties() will start to scale bad with it because it's dealing with KVM constraints mixed in with TCG constraints. We're going to pay a high price to share a couple of common lines of code between the two. Create a new riscv_cpu_add_kvm_properties() that will be forked from riscv_cpu_add_user_properties() if we're running KVM. The helper includes all properties that a KVM CPU will add. The rest of riscv_cpu_add_user_properties() body will then be relieved from having to deal with KVM constraints. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 65 ++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index db640e7460..8e6d316500 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1943,6 +1943,46 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +#ifndef CONFIG_USER_ONLY +static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) +{ + /* Check if KVM created the property already */ + if (object_property_find(obj, prop_name)) { + return; + } + + /* + * Set the default to disabled for every extension + * unknown to KVM and error out if the user attempts + * to enable any of them. + */ + object_property_add(obj, prop_name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop_name); +} + +static void riscv_cpu_add_kvm_properties(Object *obj) +{ + Property *prop; + DeviceState *dev =3D DEVICE(obj); + + kvm_riscv_init_user_properties(obj); + riscv_cpu_add_misa_properties(obj); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } +} +#endif + /* * Add CPU properties with user-facing flags. * @@ -1958,39 +1998,18 @@ static void riscv_cpu_add_user_properties(Object *o= bj) riscv_add_satp_mode_properties(obj); =20 if (kvm_enabled()) { - kvm_riscv_init_user_properties(obj); + riscv_cpu_add_kvm_properties(obj); + return; } #endif =20 riscv_cpu_add_misa_properties(obj); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { -#ifndef CONFIG_USER_ONLY - if (kvm_enabled()) { - /* Check if KVM created the property already */ - if (object_property_find(obj, prop->name)) { - continue; - } - - /* - * Set the default to disabled for every extension - * unknown to KVM and error out if the user attempts - * to enable any of them. - */ - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } -#endif qdev_property_add_static(dev, prop); } =20 for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { - continue; - } qdev_property_add_static(dev, &riscv_cpu_options[i]); } } --=20 2.41.0