From nobody Fri Nov 14 16:40:29 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1760688961; cv=none; d=zohomail.com; s=zohoarc; b=fyd4zg4hXuA66e3GGE+m9gBeA1NqQjv9tyw8ohfVWKsCRO9PrTyvHwUV1kpD+BY8dIQwXw1UmGquD6E61z5LeLWcAEwafLdyRtZGPjMZcgcnBwg7V5z+gRDTajC/ApRAVbANgdXJI4IDZbQCeNYlRHatCZlIKlN1BUJ6fqrZyis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760688961; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vdypb1Ckjsl/1gDvdLx4I984psVShWZICHRICqmmfdo=; b=kRxTY4bgbYqKHnPU5YV/opqdcYgyJHyvS/GIfoNiLKHYcgGyv8gk5FBWvFJweLk/VS1MWjT6mXXu+hW0Lx5nyQwvNbYjvE/Qr/yP0Ys7cfs933/beK3/QABoxXHAVKSaL1IsKmGI1vkt/pH+JDxyTra0VOE9v3bgSXO0rvO6OJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1760688961294383.55934181113685; Fri, 17 Oct 2025 01:16:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9fcD-0006vz-6p; Fri, 17 Oct 2025 04:15:09 -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 1v9fcB-0006v7-6y for qemu-devel@nongnu.org; Fri, 17 Oct 2025 04:15:07 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9fc7-0008Md-B8 for qemu-devel@nongnu.org; Fri, 17 Oct 2025 04:15:06 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2025 01:14:57 -0700 Received: from emr-bkc.sh.intel.com ([10.112.230.82]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2025 01:14:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760688903; x=1792224903; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3BtdrjH53h57EMuz6JijtOp83I0cYTzE17aQ/+sFB6E=; b=WR3m5Yjx9c03MGeZ8i/IqogyQDYKZvXR5ZhkAOhix0Uy8efxvAzjGSl9 BKQ9VCPOv7Tc1Vnvqxhd52WfFqBLSkK+Cfgi33Q2aVHJfXxLTjcRoUU/5 lt1qg73wzu8eoyve+RA6Zye8vvLVQqGDOmeATzjzaYcB9RHnVB2fYrlt7 nM3d36BMzM+dBbRtQUiK4optk9NTQOMxwHze0DkA6OlTzQI2ClO23Py2m nhTo2RZggmR5U/aLeuL4lVzUQroXV6yx0yURpPwzudY664ChxE/+KHhb0 VT78F9CYYoZWghpmSjnzPZiyClwBNS/uvnQi26pLQ+jLICQUXw0N1rUAw g==; X-CSE-ConnectionGUID: f4CdzqXIQoi8H18atdL43g== X-CSE-MsgGUID: 6L4L4+nySo+NHtL5WjR21w== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="62985451" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="62985451" X-CSE-ConnectionGUID: I3YEi5hQR+esvjdODUAYCQ== X-CSE-MsgGUID: kY3H/arGSAuZjyNS4MMwxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="206385268" From: Chenyi Qiang To: Peter Xu , David Hildenbrand , Alexey Kardashevskiy , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Chenyi Qiang , qemu-devel@nongnu.org, Gao Chao , Li Xiaoyao Subject: [PATCH] ram-block-attributes: Avoid the overkill of shared memory with hugetlbfs backend Date: Fri, 17 Oct 2025 16:14:23 +0800 Message-ID: <20251017081445.175342-1-chenyi.qiang@intel.com> X-Mailer: git-send-email 2.43.5 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=192.198.163.15; envelope-from=chenyi.qiang@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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 @intel.com) X-ZM-MESSAGEID: 1760688963721158500 Content-Type: text/plain; charset="utf-8" Currently, private memory and shared memory have different backend in CoCo VMs. It is possible for users to specify the shared memory with hugetlbfs backend while private memory with guest_memfd backend only supports 4K page size. In this case, ram_block->page_size is different from the host page size which will trigger the assertion when getting block size. Relax the restriction to allow shared memory to use hugetlbfs backend. Fixes: 5d6483edaa92 ("ram-block-attributes: Introduce RamBlockAttributes to= manage RAMBlock with guest_memfd") Signed-off-by: Chenyi Qiang Acked-by: David Hildenbrand --- system/ram-block-attributes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c index 68e8a027032..0f39ccf9090 100644 --- a/system/ram-block-attributes.c +++ b/system/ram-block-attributes.c @@ -28,10 +28,11 @@ ram_block_attributes_get_block_size(const RamBlockAttri= butes *attr) * Because page conversion could be manipulated in the size of at leas= t 4K * or 4K aligned, Use the host page size as the granularity to track t= he * memory attribute. + * When hugetlbfs is used as backend of shared memory, ram_block->page= _size + * is different from host page size. So it is not appropriate to use + * ram_block->page_size here. */ - g_assert(attr && attr->ram_block); - g_assert(attr->ram_block->page_size =3D=3D qemu_real_host_page_size()); - return attr->ram_block->page_size; + return qemu_real_host_page_size(); } =20 =20 --=20 2.43.5