From nobody Sun Nov 16 10:57:08 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=1741360780; cv=none; d=zohomail.com; s=zohoarc; b=HCBMOcpMVZVfFC00REc9ItWtRYc+NagAA3fFmH2//gXwyWjniK3akNfDZC+7Kbgp084oMJvMINcL/lEh+64cwV5uAwGPpa2fVJFvvXLypnQNATWrcxZpN+L4uyreZRy/5J1qBy6d8+Fx+foFUPT/PdyoUp3HyQAcxzi8RQnj4+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741360780; 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=F7c3iP1EwbjahBsBwJBDuZ0vBFhZFt0AdLkeHdIl4iU=; b=YNLFJQIa0SQ9D2Zizxny08sHPhmY75N7l0J8YB03XN3NhWYpHyOvDcwNbAJBaytz+ZDEP0k7UcXB6+yODf4WfjH0BprZrUbLEsGovutcs0IGFbmZx8reD4U6dn8aMJLKuDHyWYw14zWmF7lF7pGtlWQwq5XqYCzwf5Gb1rtFcvo= 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 1741360780977187.27800572327317; Fri, 7 Mar 2025 07:19:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqZU5-0007hq-GA; Fri, 07 Mar 2025 10:19:33 -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 1tqZQy-0005s1-R5 for qemu-devel@nongnu.org; Fri, 07 Mar 2025 10:16:27 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqZQw-00047t-1d for qemu-devel@nongnu.org; Fri, 07 Mar 2025 10:16:20 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-391342fc0b5so1120644f8f.3 for ; Fri, 07 Mar 2025 07:16:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912bfdff72sm5699359f8f.36.2025.03.07.07.16.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Mar 2025 07:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741360570; x=1741965370; 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=F7c3iP1EwbjahBsBwJBDuZ0vBFhZFt0AdLkeHdIl4iU=; b=I+AqqkYRu7/BYHT85Yd6zARaMRV6QX/mfoN2+rzXjt4TbPKmXN5wYnnlr8HO3tef63 xnS8AgudIH3YnVSU4GDI4luyxNFQzT4VOxWzqbkwGW3PZzv1IwlQtBbiGfjQxb98udFy uwwAZB9xvu29+oFn1wbWDvWja9p2elbOFbOKR73P4Ab6+7wO+oDLkaedW1pU0q0I+DLH s/79x3DLtXXpXG2ApNYVitnSS3XEE8mVn+DSbZdV6KjZOPHXN0QAK8+c8lDlqdKWGmjE k5T2H8KVuItbKLfHijW1jI0SQ0QHSc4D01D6yb6fn6Ku7BYNq9n2D/qf8kBA4tv6vBDm RJ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741360570; x=1741965370; 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=F7c3iP1EwbjahBsBwJBDuZ0vBFhZFt0AdLkeHdIl4iU=; b=VOYzrOYuNqVseZgJhH66apPbJWa9yjfBJYZpl8nUYzesr+IJwK2/yn42EV5f8JZdku jK3OqkTW6bPhzdX/0W7BpYW2rdVQmaWN5MmgjDstvpa+Qr8PMjKci3dAwN46ja1gOLwo 1pjj/cWYzkSXUW19UmQ0rtjUdmAbnHrVL7hxljVCpLiN23l51RhEVoIEwprqNkSaba+e AO9hW4UR67R87azpMfvXhCy3Ty2QdfIqLKMwzWKeFo1wWNVds2LecJTN9F38xlIr5bzv 1mbET9aM5zdynmMFywC0YYVtWp7xUV0osI39rGVuwoixRfvYy2jQmo5MvyZ1VF0mWl9/ KNOA== X-Gm-Message-State: AOJu0YzQkl96L4MK7LSGFGpwOCJbVHKDYD3BXJshyukmai4V7tRSoYUy tk67b4N2Dx6d9AKYl1FlEkDJPOgnbHtc/niGxOyPWTOx59xZFqOdiN/Pjacv4eF5x4N0LBaF39A 3X+M= X-Gm-Gg: ASbGncv9eUATy4BYr9VjVd5xKSCQXr7wh49KZfnN4MYcWzWsP1/PP/K2M6QWo3ZHAej fvk+RkOHSP3DbbARNDvyEwIgkuu0i7HUUVZvfQmr+n5R00jW3qW08rguXvQVIpnbf96EqNgBEiP A6o4UPQdGLP50I2WthCJnWjt5Gd5TavemiiyczVlv/PLqa8dlInMpB+j9Tx7f+b4VPiDkqP/ZVp kLInsh4TCkEMtl7XYd2SUQCCcNhaqmxnEDSNvSLGpAnF2SoWaMUtE2SIUuZCcm8Ig6eepBkamaf x0zWfiLES8oHUVt4ANYkXvsdK/ks8Q4j4vUa7W1XrG810brNPAQYdm1ogT4aJIYX3VeDM8fMqvz 37TofKp0j51CKzvYLPSg= X-Google-Smtp-Source: AGHT+IEQ9AsODO0s8uUfgeCwXHYIRH2k5VUAdyvIY55SzExhVfTQUW9bIRUNoXYaHt5n+3D/D+y7YA== X-Received: by 2002:a05:6000:1564:b0:38d:d666:5457 with SMTP id ffacd0b85a97d-39132da24cfmr3211167f8f.42.1741360570445; Fri, 07 Mar 2025 07:16:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Ani Sinha , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Marcel Apfelbaum , Pierrick Bouvier , Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , David Hildenbrand , Igor Mammedov , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/7] hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime Date: Fri, 7 Mar 2025 16:15:41 +0100 Message-ID: <20250307151543.8156-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250307151543.8156-1-philmd@linaro.org> References: <20250307151543.8156-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::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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: 1741360782662019000 Use qemu_arch_available() to check at runtime if a target architecture is built in. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- hw/virtio/virtio-mem.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 5f57eccbb66..8c40042108c 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 "system/arch_init.h" #include "system/numa.h" #include "system/system.h" #include "system/reset.h" @@ -170,13 +171,16 @@ 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) +{ + if (qemu_arch_available(QEMU_ARCH_I386 | QEMU_ARCH_S390X)) { + return 2 * 128 * MiB; + } else if (qemu_arch_available(QEMU_ARCH_ARM)) { + return 2 * 512 * MiB; + } else { + g_assert_not_reached(); + } +} =20 static bool virtio_mem_is_busy(void) { @@ -721,7 +725,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