From nobody Sat Nov 15 22:23:04 2025 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=1746222401; cv=none; d=zohomail.com; s=zohoarc; b=gokVevZrCt1ur7Pidq44FfJI77I4AooqB1n4VWzoghdHQneqYXkkoDKxFJucbPyi9zYUNWGxtCNudme4pISnr6gioa6Ty/GyFYd3mblhEbNLbA9R1T8iNlko8dMO39X7pugUWqr/XNilPGW8wHVwJbTSuEMRxwhoUFClTUr22kA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746222401; 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; b=AezGzhLh/zyOLKwfZD6vTotr8zFbQeCepCxRs3Tl2bn3JqFmRFPvdp5eHSDaxr4aTsf3XCIYM7Ejyq3qaqhHog8ky9DrIkdyj2GWdAJY0h5s01bZCs7qRjzcw8NwkcEFVJxjJPA0yE0wcTOUmxl1yuQ4XbakZ7zEn0QqiiJCfsY= 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 1746222401442566.5872224490688; Fri, 2 May 2025 14:46:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAyCr-0000gR-DZ; Fri, 02 May 2025 17:46:05 -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 1uAyCp-0000fT-BP for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:03 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAyCn-0003VN-JR for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:03 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ac2bb7ca40bso404386966b.3 for ; Fri, 02 May 2025 14:46:01 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad189146f74sm104922166b.17.2025.05.02.14.45.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222359; x=1746827159; 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; b=ws/sVr45ff9wSgY51A6PofgVsR4PMqlB/g4gVXA+GUJn/mRHMbDeBCuYBPrcnyO/kO v5IBd9ylynEqKmEhVdPOkjRyUXUL4L3dz71xAzGBgUNMFGi5XKVuB+N04bSTc1g4q0fs KaxS2RKgjcIZgixbVZD3MSYzOTV6mBEJ11z2s8q83xJoG2xwc0blrSQda8e6LoIQW8Rl 8wgWkCxs9uoPUBGjFi7jfR7r7A9BQ54N8sRsXKnQDQcvbNoFI33AJqUqYP7NlBOVAoxO afCWnuTNUU+69BLfaVcji9X3Py2FCDVURoLzu+niYlNLffKZWKS5IzeTF7TFBbwk4lKo G8+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222359; x=1746827159; 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; b=U0/m5ZLt/j481yXGVgZJBIprwTyGjfpLke/mpcWvWLBvAtHqb/WtvHfM+jfXdC8dIs +dyhwWafgOUxNu+gcBJxyZyiFyrHN7W1BMv2fgj/A6AfYD4iZ3tVdb0VMkhwSCM/laA3 FK+fFlVdtcd4HJJGO59FPQJ3LltYaFhWTQwaDdERvWS5lx+UJw1pOxVb2jAvunBtX2Lb kFPHLzzo73m8sYM1QC3P1r9eruHPbPI7zdz+HI9NR7lv/sMiMn4u6xdbwwS5u4N2aEhX u7nf5e0J73EjPIlmUrns5HMKUpGSeZL9DwO+CyI8uV7NC1+LBlU5Qw8IHBPILwtbv7C6 belw== X-Gm-Message-State: AOJu0YwITXw3jLYm7XxajXw3YTPS7L/5JTIfDZiDrI3mgLa+rUFzhsoY uZ4s5Xr995FxdnvAbcN1PCKdC3XgVnmxsKpRNiwhtDLlBOyGfb4aaHDjX+p3lkiRowxKiZQbyf+ o X-Gm-Gg: ASbGnctHoXtffbSfPP1LPXr2MZbxADhx33Wpf7bQSU6d5rr9Fdo2M3RGoFrOAfrriyD zz51iWVhh6D1gUJ741aOUHr/G3OcM79lHguA1ju06f9ssjk6SQAmloM/Fd91bDYwvspYKltDuKD 8n6g6W9T4Z2IcJq9PNmf2PkPXm6WVYdd/NAYUb1FKr9vpAMbarWxj+VXXPVmeq2BUiCoXkkorE9 DCYFYq29ZseDDvTUxRUYkssxaPBxeEv0vRgzEcdLl2bbyPsuIcuU7s7syHCe8MLYDBhzAnNW7ZS fAJ0iPSAyfDhvjTvlOl36QgdQsjJr0o6Ljw4CH7ELADbuB3hKwCpMVFaatBPYNuEWeIGx5ufN+9 SEtfH74ACuArSebY= X-Google-Smtp-Source: AGHT+IHFlQBMf3j6pM6mBfV487yGfeYwWTfE2m2nJmCy6ov1DMZS+DOoNeGmL+CsdB3U8UhG+Jru0w== X-Received: by 2002:a17:906:22db:b0:ad1:8f1b:21b5 with SMTP id a640c23a62f3a-ad18f1b2528mr101985766b.36.1746222359478; Fri, 02 May 2025 14:45:59 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 1/5] qemu/target-info: Factor target_system_arch() out Date: Fri, 2 May 2025 23:45:47 +0200 Message-ID: <20250502214551.80401-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-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::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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=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 @linaro.org) X-ZM-MESSAGEID: 1746222403608116600 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/target-info.h | 9 +++++++++ hw/core/machine-qmp-cmds.c | 6 ++---- target-info.c | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h index 850a2958b9c..87b4b0e0cbb 100644 --- a/include/qemu/target-info.h +++ b/include/qemu/target-info.h @@ -9,6 +9,8 @@ #ifndef QEMU_TARGET_INFO_H #define QEMU_TARGET_INFO_H =20 +#include "qapi/qapi-types-machine.h" + /** * target_name: * @@ -16,6 +18,13 @@ */ const char *target_name(void); =20 +/** + * target_system_arch: + * + * Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_I386). + */ +SysEmuTarget target_system_arch(void); + /** * target_long_bits: * diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index d82043e1c68..8f491dba441 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -37,8 +37,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); CpuInfoFastList *head =3D NULL, **tail =3D &head; - SysEmuTarget target =3D qapi_enum_parse(&SysEmuTarget_lookup, target_n= ame(), - -1, &error_abort); + SysEmuTarget target =3D target_system_arch(); CPUState *cpu; =20 CPU_FOREACH(cpu) { @@ -139,8 +138,7 @@ QemuTargetInfo *qmp_query_target(Error **errp) { QemuTargetInfo *info =3D g_malloc0(sizeof(*info)); =20 - info->arch =3D qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1, - &error_abort); + info->arch =3D target_system_arch(); =20 return info; } diff --git a/target-info.c b/target-info.c index 16fdca7aaaf..8232d488870 100644 --- a/target-info.c +++ b/target-info.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "qemu/target-info.h" #include "qemu/target-info-impl.h" +#include "qapi/error.h" =20 const char *target_name(void) { @@ -20,6 +21,17 @@ unsigned target_long_bits(void) return target_info()->long_bits; } =20 +SysEmuTarget target_system_arch(void) +{ + static SysEmuTarget system_arch =3D SYS_EMU_TARGET__MAX; + + if (system_arch =3D=3D SYS_EMU_TARGET__MAX) { + system_arch =3D qapi_enum_parse(&SysEmuTarget_lookup, target_name(= ), -1, + &error_abort); + } + return system_arch; +} + const char *target_cpu_type(void) { return target_info()->cpu_type; --=20 2.47.1 From nobody Sat Nov 15 22:23:04 2025 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=1746222401; cv=none; d=zohomail.com; s=zohoarc; b=IbRdHDNin8VtHcY3HuAZTJvzsJw+6zGR03OSX7OTzWmVJxmkrewIV6B+pR92+ZHF+yut8TvMWBChvILcslNADYm0sEjQhMbNlDQqI59dbS0wZUEKe+0Xn6iSW0RD3BYAPnwc7yvfmwQWhDFTVNKXXO05auc+fz++6ewDi8QNTls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746222401; 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=N7Hzb0w1jlzsKSiFmuI60CliIwDp64ZHh16gYYLKY+A=; b=LYblKVb8Z+CCw/F8P9Kcx8kMWMBAa2PX+HiQW9lFJeFwiYpq38GA/bWjirnWLeJvrXDOr1fsmsjpOPKtnB1+1y1a0CTB42XiSEGpGYWQGoAfaEV11XXw+rXX6fnEkYEDxeBZf654rJbQPDPFyEil0s6mw7K67QNHaJSDe1zBngc= 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 1746222401280462.8260206494002; Fri, 2 May 2025 14:46:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAyCw-0000hm-Kq; Fri, 02 May 2025 17:46:10 -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 1uAyCu-0000hF-VQ for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:09 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450: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 1uAyCt-0003W0-0B for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:08 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-acb39c45b4eso384454866b.1 for ; Fri, 02 May 2025 14:46:06 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad1895402c7sm100512466b.164.2025.05.02.14.46.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222365; x=1746827165; 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=N7Hzb0w1jlzsKSiFmuI60CliIwDp64ZHh16gYYLKY+A=; b=FIkrvETVpM7/xF+Bqq/Zqmhjna3nhTZpAovxV7z13FoOaLqiC04VzqXoWw4AvDMQgZ NZ9kqKX7j4XqrE3GL3LrlmMXIxK4BJ1g9BNivSxphx5l6r5JMO3COQnTrIbEf3dejUgd WnSoFHuX0sGPGak3rebxlXI6MD07oObUvKVy9TEX99mCNOx2M2EHWC2Wl+X/JcoTHLCg 8I+XjBGRIz4kUlIK7ltDXZau0et3kHMOvhQ+x8lRDH0p3+3yEDnhDUstLI/pESw1B/Av ddsHCC4c0QoxKEGapTPa3OwHjz0nftBYAVDUATrdYRm89ouew05OvdNmjnmwmB+dpedw bOgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222365; x=1746827165; 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=N7Hzb0w1jlzsKSiFmuI60CliIwDp64ZHh16gYYLKY+A=; b=NUVcudW1LQd3auFwFmbMlo/zohvSpt6kFKIe9B0VToOUIC53dZhCzseXuMcyT8jIZ7 Q3fQOH4Xak0DlC5B2ia7Wsn71EfyXdSO69hD61pPyLm0GuQMX3IZvOBq+WJuIeEPIl1U 2o+1NhiGtl5+p98LHWwpkp0iHlQyddoz8xhyOLrkVu1oA6N22giSEGx9YS8Cer7s4QpW 62EeDx/gS0VyuBES68Tgl7zTAfVn6SgvHbi5Q5Lg/smMrAdnWxFmELHt0LVrw0Fwg+Yi MKT/LA90WoxaOgKOrKRmRrHuCRjzAvuspQ5M9/p3sx9EUuM604TynkBoVcnOvCn19Vtp rVCQ== X-Gm-Message-State: AOJu0YxHWcrxn3OGIOuzOSh2xNdyqJ2g1fYKAEwfTDa5pRrilc0mPD61 OADd4CatYlj+uOLcim/LkMXyz8zUCdoGGaCxqYKIt0kUiWOIUZUue6aXduZC1UKYIkgKwBxcxc9 U X-Gm-Gg: ASbGncs3gae5NVDNs7FSmjQVZ0eZgCk/T5RD/c2PQkIxoSsVvPbgGgUV6WZALWDal2m RKo7K0sdiBbJXX1MtcIeUoeePXjx8A8Nw7qW8r5QeaXjeSBpS2fvIVFmboUYHb0OKVoivnhXQjt w2HwEC7mqNl6kgt+lsNwNg0xvKcI0KzcgRSJjbarwjsrE1Z38wxhUQzBaZgl+556ifnm4RUihq3 VmL2ThQvWMQioxqR2SLlbGryUr6W2dCBzGN68UIzvFrYY2LRVSps5kuuC1HoM8GHauGhT/Hvz7j w5XbRlMujIhcCKQB4JemPdMBi3tIEsVWh/W6GjQhlQlWHOSldOFoIcuVh47rqVCpoZ2zJ39t4KH Xh0z+dhh7O2vNh8E= X-Google-Smtp-Source: AGHT+IHSKjF+MWbA44wjBev1Hm9LEvO6FYp2edyMD03VZ8CX8LAX1Fei8dTHx3IfcxkLW1QyIvSd1A== X-Received: by 2002:a17:907:3fa4:b0:abf:73ba:fd60 with SMTP id a640c23a62f3a-ad17b5dbc19mr446152966b.29.1746222364621; Fri, 02 May 2025 14:46:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 2/5] qemu/target-info: Add %target_arch field to TargetInfo Date: Fri, 2 May 2025 23:45:48 +0200 Message-ID: <20250502214551.80401-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-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::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.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=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 @linaro.org) X-ZM-MESSAGEID: 1746222402806019000 Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/target-info-impl.h | 4 +++- target-info-stub.c | 1 + target-info.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-imp= l.h index 1b51cbcfe1b..83d584d7dba 100644 --- a/include/qemu/target-info-impl.h +++ b/include/qemu/target-info-impl.h @@ -9,11 +9,13 @@ #ifndef QEMU_TARGET_INFO_IMPL_H #define QEMU_TARGET_INFO_IMPL_H =20 -#include "qemu/target-info.h" +#include "qapi/qapi-types-common.h" =20 typedef struct TargetInfo { /* runtime equivalent of TARGET_NAME definition */ const char *target_name; + /* related to TARGET_ARCH definition */ + SysEmuTarget target_arch; /* runtime equivalent of TARGET_LONG_BITS definition */ unsigned long_bits; /* runtime equivalent of CPU_RESOLVING_TYPE definition */ diff --git a/target-info-stub.c b/target-info-stub.c index fecc0e71286..2e4407ff04b 100644 --- a/target-info-stub.c +++ b/target-info-stub.c @@ -14,6 +14,7 @@ =20 static const TargetInfo target_info_stub =3D { .target_name =3D TARGET_NAME, + .target_arch =3D SYS_EMU_TARGET__MAX, .long_bits =3D TARGET_LONG_BITS, .cpu_type =3D CPU_RESOLVING_TYPE, .machine_typename =3D TYPE_MACHINE, diff --git a/target-info.c b/target-info.c index 8232d488870..5f6096606e4 100644 --- a/target-info.c +++ b/target-info.c @@ -25,6 +25,9 @@ SysEmuTarget target_system_arch(void) { static SysEmuTarget system_arch =3D SYS_EMU_TARGET__MAX; =20 + if (system_arch =3D=3D SYS_EMU_TARGET__MAX) { + system_arch =3D target_info()->target_arch; + } if (system_arch =3D=3D SYS_EMU_TARGET__MAX) { system_arch =3D qapi_enum_parse(&SysEmuTarget_lookup, target_name(= ), -1, &error_abort); --=20 2.47.1 From nobody Sat Nov 15 22:23:04 2025 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=1746222460; cv=none; d=zohomail.com; s=zohoarc; b=baa/dYyw7PdLBEruRNczSHemccoHUrtphwT7/RKFHiclXLAmb0qGvFMo1tiP47NJPMaOsbSTIGgiX24R01AD+YcttSLUJ6igcVkGFhBtQdqEQ4zDU76DFlnychqIT0jG2f9uGYZ0FooItSf3Hsa6x9Hs6pRYq4/h1HlhJKVVlBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746222460; 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=xWWrKwoCLn5b4Gd/jxCzJvCASZPS/cC4XOoTz1WNgkY=; b=BAUYs/erxS9TW9UbHA5yGoyQ81Zvxrh1IEiEYVw6AuZl4ITAZ4FqpJapnkwEg/arfYQmNnQz6GltTH1taz+bqS0gbxe9cOFzAqe2AkHiLeh4NxZKIaGGC/Rd/PZ6JlhGJ22o4QBo0F4nIcHP0LvFdbmhnRGhNY6O6HDxl15nAwk= 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 17462224606701018.2772647540381; Fri, 2 May 2025 14:47:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAyD1-0000jW-F2; Fri, 02 May 2025 17:46:15 -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 1uAyD0-0000ix-1Q for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:14 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAyCy-0003WZ-9Z for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:13 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5ed43460d6bso3849033a12.0 for ; Fri, 02 May 2025 14:46:11 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5fa77c38618sm1730083a12.81.2025.05.02.14.46.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222370; x=1746827170; 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=xWWrKwoCLn5b4Gd/jxCzJvCASZPS/cC4XOoTz1WNgkY=; b=hHYbzy5/hnO7+9EoFbqbZr/nYxf/P4txTzpr7zwmr3T5u+xLa9Mr/VaDP4TtsTzvLD c66zrOfASOG9GrfL4EKX12iZcWn4w/qfdYqxWxB9kI5cfUyc4acgvahZK0vTzuMGK1Gh neuhbZyP3r57z92B880u+p3mHBruZongJKlrYOr2ezXvrPp6Umq/JezWl1nm1rBLARI8 fr/IBYxp8bP4jS6BayhWeWz9Zgj2q89mKqRHNauAhdsWoAiHOo/0XSEtHHnd7ra+PnWM NGrfM36VF/ffYOquuWSKJy2eJVaEQ8Y1yYjiTXjSBR8yIJpPWAspSX2ByFPD41oLHhQM 4AGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222370; x=1746827170; 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=xWWrKwoCLn5b4Gd/jxCzJvCASZPS/cC4XOoTz1WNgkY=; b=d12EDH1KyhXMpN8GGPU8KcJYkajTCHAeAD7tTSYPJnhYMwCKlqLMAhm/FQLxIgW/GH Vb2gMGJvVT7E9yxbxa9ZiEUyU1V/UnJJ9EN5Yi8+yn+nMSg2NrnD8dNat2Fx+LsLbtEN moTA7B8QE/83QObX7mT0OOJDAvhaYKUg63JBj8Q/f4RTg7fu3cK/6knvZO9eZhNhv/rZ 26vW0UslLFPaCwMNuPuMcZidh1a8PJe09r/9P2NmSn7nOsTPhDzsWZHsEShBtLNIYv4Q myTeiM4ws45DWK/Sz+9B6F/GXZGj+IV+CujWxajlx+/UsrMkyRMn1UMhLXzYfjOJxFX7 OlQQ== X-Gm-Message-State: AOJu0Yxgz3SWIajlzp9UBfeJ1WCRqgRdZ+uv422mBIS35exeMqDWuD20 tVK+/aXBJvreYabV/WzJ/2JUp22tYuVVLGUJCdAwsH1OHb58sRor7IZMjDSyV2JU4HLPpfeT48V T X-Gm-Gg: ASbGnctjs19AULSLy9SlUUF9+5aHEuQRDPdXSs/eQg34Yn9P4Um31XxUmUmi3QoiVS5 pG/QIOP3kQuXm4e830vG6xjgRdQQ0BxPBpmii2SLodYmSlwt57Ah5XgDVJlF6WJZBEnuJ3LCgXf mwxqWHESIpj2D4XlWfQqvbq3vjNzfyI42qQZBKtNtF7xVrFEunujfYNufOSboPfh8/S8H3kMYrj XFPcs/O+TKc0zyszoW/aGobZACfDCkY07osmXXO3uB85yLMCax8KXf6VRyzyAQP/+SkcV1GHhUx bQ7PuqnPwRLHNBb7wbrjCpPv85E3pxOllN+UT8cRcxJg+PH5dL27GUO76lcl0JRE2Zr5NwQ5QMF 47yh6d6jJi8m1zuA= X-Google-Smtp-Source: AGHT+IFUGvg5Z/aAly33hZUUCPjjlF9COtm91m1f5WHLWcGh8DYQaD5NMOCHAvvZRLT3gnurS1qW1A== X-Received: by 2002:a05:6402:2710:b0:5f8:36b2:dc1a with SMTP id 4fb4d7f45d1cf-5fa78062dccmr3729539a12.16.1746222370036; Fri, 02 May 2025 14:46:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 3/5] hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime Date: Fri, 2 May 2025 23:45:49 +0200 Message-ID: <20250502214551.80401-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-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::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.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=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 @linaro.org) X-ZM-MESSAGEID: 1746222463728019000 Use target_system_arch() to check at runtime which target architecture is being run. Note, since TARGET_ARM is defined for TARGET_AARCH64, we check for both ARM & AARCH64 enum values. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Hildenbrand Reviewed-by: Pierrick Bouvier --- hw/virtio/virtio-mem.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index a3d1a676e71..02c47730ae8 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -170,13 +170,20 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *= rb) * necessary (as the section size can change). But it's more likely that t= he * section size will rather get smaller and not bigger over time. */ -#if defined(TARGET_X86_64) || defined(TARGET_I386) || defined(TARGET_S390X) -#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB)) -#elif defined(TARGET_ARM) -#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB)) -#else -#error VIRTIO_MEM_USABLE_EXTENT not defined -#endif +static uint64_t virtio_mem_usable_extent_size(void) +{ + switch (target_system_arch()) { + case SYS_EMU_TARGET_I386: + case SYS_EMU_TARGET_X86_64: + case SYS_EMU_TARGET_S390X: + return 2 * 128 * MiB; + case SYS_EMU_TARGET_AARCH64: + case SYS_EMU_TARGET_ARM: + return 2 * 512 * MiB; + default: + g_assert_not_reached(); + } +} =20 static bool virtio_mem_is_busy(void) { @@ -721,7 +728,7 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *= vmem, bool can_shrink) { uint64_t newsize =3D MIN(memory_region_size(&vmem->memdev->mr), - requested_size + VIRTIO_MEM_USABLE_EXTENT); + requested_size + virtio_mem_usable_extent_size(= )); =20 /* The usable region size always has to be multiples of the block size= . */ newsize =3D QEMU_ALIGN_UP(newsize, vmem->block_size); --=20 2.47.1 From nobody Sat Nov 15 22:23:04 2025 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=1746222460; cv=none; d=zohomail.com; s=zohoarc; b=gsVlfZpJEhJ8TDjXZ3QfEQuZlxnMhKBL4uCM6ryJJ3dqD8rK25lL5rIFtTWfJk5ircm14AaU7EkMBVx/4HkQ12AqarM/s2xUrxBv4DzCCcu3N9NYk88OBs/ULRdqemxu6CHrGVsGlXSdnr8REelcaAj093As7ki7Ubopgt1JmPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746222460; 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=A9FlrQnjVSYEb0+dNGQFK1FqE6e7hFamBzmAqPtToxE=; b=MB1viR/8GQVgS/IFR+mlprpKk4gmyy1uabo1kvIwa8gLL+PzhQ/A6F295tbD7OeCSjerklo9VrL3ZHm2fzs5wLf8H6fyCrvS+R4aapf62NIZkw4WZqllwOfVSMDmBFmfWXSvrjMFvY4Juct0uNg1qOjuW7a1n0GXQ2/NngehXy4= 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 1746222460670448.61827855231; Fri, 2 May 2025 14:47:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAyD7-0000ka-8N; Fri, 02 May 2025 17:46:21 -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 1uAyD5-0000k7-M6 for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:19 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAyD3-0003Wt-Ig for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:19 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-acec5b99052so424762066b.1 for ; Fri, 02 May 2025 14:46:16 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad1894c02e5sm103375066b.95.2025.05.02.14.46.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222375; x=1746827175; 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=A9FlrQnjVSYEb0+dNGQFK1FqE6e7hFamBzmAqPtToxE=; b=bnbHW9LvXT9d8U2qt/BpzFDSoPthJNq3eK1pHnVI5mVQ8vhyjo3oaJY5xoBu7nN4a3 Em3yYlHa6tcr8wiq8N+W31vQymrpSSsX9I1gd59mnArD4Nf9amNGIpRjNpUAwKtlchdX 3z37XAq43/js1+n6Jx8PoQjnLfNRXLUSpfKKX58w7TD66pKMY/awD+lLRqv9RKWf71MR qWl4BtGrAtbbL2jGcu5niDoVw6fDKS2ebfMVLYYVrLAk++7CAm5rKNz/OMLVB8Y9uOHS UVpPyWEeI8OGlKZLhmbZzCDzpdYJ8HGgqM8jBXuJutcmdG6WsEKKNja2E0SbP2VWiaqr fcow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222375; x=1746827175; 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=A9FlrQnjVSYEb0+dNGQFK1FqE6e7hFamBzmAqPtToxE=; b=DYxl/IuoDq6kOHWD2VCOGU1Jt8Dae9iVsB2dSBXj2pFERqubbJICVHLKt+lfiwhAQ5 h9jL6nydcvbGyR4klIM1QsxnzgCogqxZ/b6qGSWZJaGtcTXEfkgFUsmBn2T0GMV6sGFI hMR9pPUR392nJWAgoCVSiQQ444gzxCIiqUJa2mDl1t6LkDWzg0+pTFaJxL7LwcZjVa7I wYZ7D/wANTrOmHJwMXueAXQ/JGSfxqdXnZVCUxlR4WHKTxNL3AyfV+y3jZsktjlBzqDA EgXzDkrpsanAKn1zdfd6fUURC0ldYBztCgzz2yzp5zkzGy7B6JOS7cl2+KRBBvjjekCr Mfng== X-Gm-Message-State: AOJu0YyJI2EZfyG/ntoI1DHljI2uWFvrrR69LBdqaJMP11iVB91b38v0 uWdsdJxtiP+6uzKbqwGbWeeDZMJypKQhlXI/EjyztDo66RAkXdTgqYeZhh5kJdVbMvMptZF0Bdh C X-Gm-Gg: ASbGncug0B6WU1zmLYGBVOrL/ok/qkVBw16H4OghE0Jw95Himo3Tr735485F21VWbAb sOqd12WO5zIL4DSGVuNmS4PGmVSRbQOcTJHhIZvrJd3j5daxp7JHD5vBtickB5XCmtZcAckxfJ7 wW95EVlRpTldAWq9muMaGWP15uFMY+VcPXyPnw657LT801gvsm74B323Bt0B3zGKV49ceX5ICti 6Mi5gdgZ/orr9l97FItEh3gka5oL/Vp6uqpu5eGHgT5SVhjL3zjVFJLdC4vE+7XB18B/7zI6mue orTn8mZPan1Ag0k0NeCR9EjiNJlinYvEXx7SeDsOBt26dUrKu28jH+Mqw5ZZVlituZufBItBoOC DsFFHARknj2rn2cw= X-Google-Smtp-Source: AGHT+IFZooM1Wz6pWGutx+mAfFy+qXL5NhJpZk0lWHJ/LqYR1suoJm2hnwWEVMZYv88VEOWzcHEUVw== X-Received: by 2002:a17:907:d8e:b0:ac6:ecd8:a235 with SMTP id a640c23a62f3a-ad17adaeceamr440062066b.28.1746222375214; Fri, 02 May 2025 14:46:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 4/5] hw/virtio/virtio-mem: Convert VIRTIO_MEM_HAS_LEGACY_GUESTS to runtime Date: Fri, 2 May 2025 23:45:50 +0200 Message-ID: <20250502214551.80401-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-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::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.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=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 @linaro.org) X-ZM-MESSAGEID: 1746222463797019000 Check legacy guests support at runtime: instead of evaluating the VIRTIO_MEM_HAS_LEGACY_GUESTS definition at compile time, call target_system_arch() to detect which target is being run at runtime. Register virtio_mem_legacy_guests_properties[] at runtime. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Hildenbrand Reviewed-by: Pierrick Bouvier --- hw/virtio/virtio-mem.c | 77 ++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 02c47730ae8..4234396f774 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -15,6 +15,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/units.h" +#include "qemu/target-info.h" #include "system/numa.h" #include "system/system.h" #include "system/reset.h" @@ -33,13 +34,21 @@ =20 static const VMStateDescription vmstate_virtio_mem_device_early; =20 -/* - * We only had legacy x86 guests that did not support - * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy gu= ests. - */ -#if defined(TARGET_X86_64) || defined(TARGET_I386) -#define VIRTIO_MEM_HAS_LEGACY_GUESTS -#endif +static bool virtio_mem_has_legacy_guests(void) +{ + /* + * We only had legacy x86 guests that did not support + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have + * legacy guests. + */ + switch (target_system_arch()) { + case SYS_EMU_TARGET_I386: + case SYS_EMU_TARGET_X86_64: + return true; + default: + return false; + } +} =20 /* * Let's not allow blocks smaller than 1 MiB, for example, to keep the tra= cking @@ -143,7 +152,6 @@ static uint64_t virtio_mem_default_block_size(RAMBlock = *rb) return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE); } =20 -#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) { /* @@ -154,7 +162,6 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 && qemu_ram_pagesize(rb) =3D=3D qemu_real_host_page_size(); } -#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ =20 /* * Size the usable region bigger than the requested size if possible. Esp. @@ -1004,28 +1011,28 @@ static void virtio_mem_device_realize(DeviceState *= dev, Error **errp) rb =3D vmem->memdev->mr.ram_block; page_size =3D qemu_ram_pagesize(rb); =20 -#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) - switch (vmem->unplugged_inaccessible) { - case ON_OFF_AUTO_AUTO: - if (virtio_mem_has_shared_zeropage(rb)) { - vmem->unplugged_inaccessible =3D ON_OFF_AUTO_OFF; - } else { - vmem->unplugged_inaccessible =3D ON_OFF_AUTO_ON; + if (virtio_mem_has_legacy_guests()) { + switch (vmem->unplugged_inaccessible) { + case ON_OFF_AUTO_AUTO: + if (virtio_mem_has_shared_zeropage(rb)) { + vmem->unplugged_inaccessible =3D ON_OFF_AUTO_OFF; + } else { + vmem->unplugged_inaccessible =3D ON_OFF_AUTO_ON; + } + break; + case ON_OFF_AUTO_OFF: + if (!virtio_mem_has_shared_zeropage(rb)) { + warn_report("'%s' property set to 'off' with a memdev that= does" + " not support the shared zeropage.", + VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP); + } + break; + default: + break; } - break; - case ON_OFF_AUTO_OFF: - if (!virtio_mem_has_shared_zeropage(rb)) { - warn_report("'%s' property set to 'off' with a memdev that doe= s" - " not support the shared zeropage.", - VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP); - } - break; - default: - break; + } else { + vmem->unplugged_inaccessible =3D ON_OFF_AUTO_ON; } -#else /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ - vmem->unplugged_inaccessible =3D ON_OFF_AUTO_ON; -#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ =20 if (vmem->dynamic_memslots && vmem->unplugged_inaccessible !=3D ON_OFF_AUTO_ON) { @@ -1718,16 +1725,17 @@ static const Property virtio_mem_properties[] =3D { DEFINE_PROP_BOOL(VIRTIO_MEM_PREALLOC_PROP, VirtIOMEM, prealloc, false), DEFINE_PROP_LINK(VIRTIO_MEM_MEMDEV_PROP, VirtIOMEM, memdev, TYPE_MEMORY_BACKEND, HostMemoryBackend *), -#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) - DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIO= MEM, - unplugged_inaccessible, ON_OFF_AUTO_ON), -#endif DEFINE_PROP_BOOL(VIRTIO_MEM_EARLY_MIGRATION_PROP, VirtIOMEM, early_migration, true), DEFINE_PROP_BOOL(VIRTIO_MEM_DYNAMIC_MEMSLOTS_PROP, VirtIOMEM, dynamic_memslots, false), }; =20 +static const Property virtio_mem_legacy_guests_properties[] =3D { + DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIO= MEM, + unplugged_inaccessible, ON_OFF_AUTO_ON), +}; + static uint64_t virtio_mem_rdm_get_min_granularity(const RamDiscardManager= *rdm, const MemoryRegion *mr) { @@ -1880,6 +1888,9 @@ static void virtio_mem_class_init(ObjectClass *klass,= const void *data) RamDiscardManagerClass *rdmc =3D RAM_DISCARD_MANAGER_CLASS(klass); =20 device_class_set_props(dc, virtio_mem_properties); + if (virtio_mem_has_legacy_guests()) { + device_class_set_props(dc, virtio_mem_legacy_guests_properties); + } dc->vmsd =3D &vmstate_virtio_mem; =20 set_bit(DEVICE_CATEGORY_MISC, dc->categories); --=20 2.47.1 From nobody Sat Nov 15 22:23:04 2025 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=1746222435; cv=none; d=zohomail.com; s=zohoarc; b=JEXkZSmiZj0G+1K2iCQx34Zq8y83vPkEhwDK/bWUkeqsMwqEHU6Z9PyfRHLGtmV8jMXR/fQO5Btl7bwsjt2EEElMy/DS4L5FV3eSfb0bHE3fnzuQRjsV6piyw4CpzN/NtuOYAgy8yp5tOyy7Q33imlHwJ+LJYTZL99psyBPuDvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746222435; 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=DsDN4bksGI+t6Ajgx6lEwHOduZigzfyenP30N9rjdOI=; b=gyjGIidWMa7HVWirEqIXmhuro28iFrlsBRFZE+1RbBxF1CyAH5Y/ehoEzpEhAgKNMg6vNa2Mf/YtENfMZMF3C9GOQ5tWrU2FWjs1ibTqCLsJL2kNzaxA3Dq5Nx8SHfXxORwZN6w9Z0IVkFG4AU+D0Zn0MoZU65YfeOT86Ra5o5M= 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 1746222435566954.9503483202583; Fri, 2 May 2025 14:47:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAyDB-0000lI-3g; Fri, 02 May 2025 17:46:25 -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 1uAyDA-0000l6-8C for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:24 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAyD8-0003Xe-Ns for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:24 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ac2c663a3daso467642766b.2 for ; Fri, 02 May 2025 14:46:22 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad1895402c7sm100535466b.164.2025.05.02.14.46.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222380; x=1746827180; 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=DsDN4bksGI+t6Ajgx6lEwHOduZigzfyenP30N9rjdOI=; b=RLC2spLKgwcop4kB/u1cqoTkwAsPI5BI4Yp8fyUTKurk5ZH5iePqpsKujvutBXQyyC mhlrc7wszYMRT/qAAcfGnZ9PRepi9cIzzTq8EGx1APeUw8cXN0xzdSpLLUaoJ3M2NvbR RiKaet4AhOezzy/P5p/3TVd/gaIY5WWhDTNtWnqMPqNP1ld9n6b+fpDcXMy9PUva89AQ Hk64nDz5LWvgfQd1Tv1jEuD+xItgksHTC7OnCPe5ojS60Uxo7RYAuOu9jFKIIWIgBLXY 2SKtx5T4NNJSAx1b+OXavEyF+wqAqyDoXAuOCjbATnGmtthhza+gesWSksmf8J0oYX4p qQpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222380; x=1746827180; 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=DsDN4bksGI+t6Ajgx6lEwHOduZigzfyenP30N9rjdOI=; b=CdCiwGI+1Sk72xS4EacbkfCus1WsPa9JQyoqAXcUcH6nBeSSFmry+u0hSYPKqm2NTA O400hYVifAVSyyT70Itk5dcpHkJ/+1LezzSTG6aNwdyf+cKYVpG/oHFPewRUb7XgcC8G n3RimzgG8EnpHxWn3yc64E07adlBXOoQYMXkxEz2bPrrjbqahBgfwtYe4VOCd4zjwCsK okut3jCyr069uAE20L1vjBhSlZMqyAyOVImhx2CZDbQLNj4BBEimf8/1nBsAH3e8YH+3 0p25t2OCgURI2mSUk63eZdhjYYJGv1VOP/sWTfepn6wtMiGhEfb70zILFGLb7+WsHdZE /hMw== X-Gm-Message-State: AOJu0Yy//pBtYQNHXqJACfInHTnK5M/cL+6GsDakwMA1SMM41p6/rtMv 7lTasTjFxMjc7ixmeotGQM8+fW0mO0S4eRQ822TEyayzoQcQ+YtSeqVgKuq9e2pnubIhRBvDn/b G X-Gm-Gg: ASbGnctPqZ9Q4VwptN560JAlhlHM3BEQIJP1QGF5w2SzkY/4IQ2SF44ExKTOtoneRXk 7cEAWhtFvYLi1ZcFVuFZVj0AtexV3I866/qjZCuZflduCckfYsRSGMhvKgacfhrOwql5YHTnmC7 KD9MibtiITxWXqMxNRBSpN24Iv2EeOEeaFGj3Hp6S4ubRnYn3oBaAAlge0KyrVgMJjtokfqodA/ F5VdKuZi1ZJARepXWJ0KQehcY1toFilXsLmAZ40kYUIY1EED5PlAasrQaLw42smm/CCfuEIYG6D +VX8ONNGx4wkpPn6TBm1x3eU6xnn64u1IaOxQgzPB/Gk0gSNTRqiV1f5KcMsZ0aUuZy0ex1phmU 63YaN6kAIAZk+T2g= X-Google-Smtp-Source: AGHT+IEYBcX/pI3wzQen51X21dbxGKuxteaaxZGI6zLLmUuNwiDzk46eWWBSMsdiidXDbkWZqLpSgw== X-Received: by 2002:a17:907:3f88:b0:ace:d811:db25 with SMTP id a640c23a62f3a-ad17b01fe1dmr425125466b.60.1746222380468; Fri, 02 May 2025 14:46:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 5/5] hw/virtio: Compile virtio-mem.c once Date: Fri, 2 May 2025 23:45:51 +0200 Message-ID: <20250502214551.80401-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-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::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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=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 @linaro.org) X-ZM-MESSAGEID: 1746222437449116600 Remove unused "system/ram_addr.h" header. This file doesn't use any target specific definitions anymore, compile it once by moving it to system_virtio_ss[]. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Acked-by: David Hildenbrand Reviewed-by: Pierrick Bouvier --- hw/virtio/virtio-mem.c | 1 - hw/virtio/meson.build | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 4234396f774..f4882c6901b 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -25,7 +25,6 @@ #include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "system/ram_addr.h" #include "migration/misc.h" #include "hw/boards.h" #include "hw/qdev-properties.h" diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 164f6fd995a..525679954ee 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -56,7 +56,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_tru= e: files('vhost-vsock.c specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vh= ost-user-vsock.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-r= ng.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('virtio-= nsm.c', 'cbor-helpers.c'), libcbor]) -specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-m= em.c')) +system_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem= .c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vho= st-user-scmi.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI= '], if_true: files('vhost-user-scmi-pci.c')) =20 --=20 2.47.1