From patchwork Sat Dec 14 13:45:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908507 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53651990D3 for ; Sat, 14 Dec 2024 13:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184005; cv=fail; b=RiJ79ECu2P7uRMhGrXh9arI/pF2k85hJFZTNC5yS3egALy6763JcLaEd+i5GyEJdMFfTcXvQaSQI1PHdKC18EDH49dZWp/vBbfGcpEkZ+ETL59GWrv+C9E5+/wS52fLoj7VmopVCbr7KoGjimbWfaHgdQVZR9SkPTFru4Yjs8iI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184005; c=relaxed/simple; bh=xm7pJRNdtClbqmK64xXUGbItCXn1o4SYhEEftIzeee4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Yhul6xyJL7g47BJKho2+sxKW2dR4kMGGuaAvxQ+BiGTPxVsOHDI9acYQFIJ5QocSTGjkVaxSmdadtHz/f23IIFYBpLsyuSKlVHzQ4J/pvB4mjJtjXIQc960K8FO5bQrH5JIuiYFGrMgyjbrSFivP/bB4GmhuuOF3uVrz/06M5yU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=SfagUYh/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=YgpxIid/; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SfagUYh/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="YgpxIid/" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEDfrI6028739; Sat, 14 Dec 2024 13:46:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b= SfagUYh/eSK5LNJIlB7YwQX9wlelsvkNh7CULSsM4VJe95Rm96PL9UAfzjxEfaV4 QQgSQCHLcGHdpfhU62NUOp2bCHMmZCyoAEEH9a1S4K+LfCzh4YWcQQH+1QzuM+J9 brsFbs/GlH8cGPf3u0RTt3Zyz+hlFS9cpoF2HoAPEfjmGcTX+IDNXhytjm9B55pI 1etXLBXxivUgGmwLtZ+Bch92m/N3M9qgDjdeqmqoVM/wLqORNbyw2KoFhdjOd+bv LhNo7noyC8Hs8YjiR2OVO5Uzi+zTfisakEAB1wywMqWquKj/TLUbOGk/1tXQ0UDI Yrf3oMgqpVKf+KaNQF5w1Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0ec0guc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:27 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEAHq7I032785; Sat, 14 Dec 2024 13:46:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fbu0px-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BP6rj7xqKG8QIHsYCn6VvMDoyo5PIuqnlKZlCQyQgpRSJKayZc66J5EcH0Ffg2ziTWmyK5RT8vgWszTTIYcOOTGgIPVJDlfOw3gMeRhd9Ve7aENspB1THrFfh9B6mPU8Dtw9y85YwghqyBkGgDR3TBVvfa1IR9peTkVMZU3NgjCgMyjWrWNTTQw9Y0QPMkvcyWIbcFCp0MxCr2xaEbEK4msL5lihf87loOwwj3vB3T3VDEcSD1/Ab/PSJsdhRH0g60Prcyqto6JHIfa6epnVvVZhHitkucB8xr28iNsc69Gy7nPbmK6d4rWXWKdeRFdkPOnkF0Vy1CcyFKgTRx2yWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b=Th2xft1ZwPf0sDyRcM/4M6n5+HCrxmnVp+/5KiZYcsK+LsEZ1LTZS1FTvAhDZTvCx4UNglbTmpaX3kN856QTtVXZO2VtfrsGN08i9p82d2Mrc37WyZPAKM6P6ELv7EcY/Q7WBScz5lTYPbuWyKh6pwLKqbiVsHEo8+IH7StH140PCa8k8GgubqqQdIu/iNJkZSG6WH0Et2DdAx/KFT8iGzOt64vdzaYaUEfDf2YdHEhf/su/mWz2Rfm3CBcVdP71do/8+kLh62eThRlKlFEk2LnPzVkf9pKQVGR3r4RbnuCDsKFs14D6ZVGWxBS4vLQO1FIDLmlGH7MrSau0B4++pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b=YgpxIid/B+qeUrKRjjzjnNQLca+cjecY6pZTqzdHTeO/vz2eXy1IUOHjhx78jgc4cqJ2iJER845XkWgCtaDVHHX6J/Acgn7gPwhDE6eP6CiJevXzFgdR4wTLT5ZisHc9CqQLee1xTlRmEubTDF6nvOgEtd/hMd8o8v7/5OdIEJk= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:10 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:10 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 6/7] hostmem: Handle remapping of RAM Date: Sat, 14 Dec 2024 13:45:54 +0000 Message-ID: <20241214134555.440097-7-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: SJ0PR13CA0096.namprd13.prod.outlook.com (2603:10b6:a03:2c5::11) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: e0f87c67-f638-466e-7837-08dd1c45ab1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: HI4H8nxD+pEyd9PVQ+e9mwv/dHN99D2ju7TcemZwuJBHRXaZKcP+vf6dLkDyHwCSfx1R+N8Ocf6haYLFrj/488B5hVGfRmT9m58Lq3ca8ZN6JkDa8rvuz5RW4QmJ0sQOl6Cx2V+R+5PfJl1F4F1S4vB7Vg/b8mmqN93hVvZWv9/eEvj2Y2LhdtJhn6maxwPWBp7ixJLFVgjqY1NooJgqGd/lm+QyXrM5zReRkDlHJoGQy7np8eFH1JlMUMDFCO28tWHEpOUPedfXH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x3kTcp3OSq7R5SQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kRFP41Du6QAr7Iezlzovj5UNHX3xz2nP1TTzbSqcVAONQbmKhxeCFQHcR8jDtHgMk/gY/5ZM8l2+dDysTyrHwLF+Mk5TC+kub+LwWYWURf3o8EI7WnYQPcHUW6guUnHczJIXdG0aP10MlPn+rwNd3psvFf0N34jPDrmVRqSm7STrChPjQ1grXqIKsjoqz1XWqEzYZr72Ma++JsO0RV0qHjF9CLXUl3vnbrmksnBltEHUDPhh+1gBklubMF7Shd24PLzT5mqiO3e3qkOZ8HygVYPrkm0yvHA9an4RnoWwpcC2puCldIAR6YbBBDQGCzBl6+9vpBonpPQ9Zx0bceBZqVjTmIyqCr67/wjBR9lEv0Ahh1oSZ5a/ELhgDmQRw8N4aEzB9fPBkGXyzQpwQf5xlkF75WBvTCBtXLT4OaayyJgS8Z6e+qVPnvKC3A3bhNg0d6NKRxCu33SXT54lDejHOFLxpWxMbXocLQCc5PnXBhkR3iB8nQvwJSkAwVVdRWBWT0thPJ7DkE6gLP29QPs51G/kea7+XhJgj57JdVGVLb44/ycFucmXbn57JzF59CioMbw7+o2Fn8otnHY3Hla0OU/e8xMySstVfOhAU71JUGVKFZyO32/OOoagyWJiqetqNlWUHzGrTP2QIBu//aIEqvRJF/JyeksPNYpJbsv2MvEAe5nqg2E7cr2EEc/fiji4AThyJQCXy8VQxYcvmlpXjQnGtnwXY/PY+hRmUILGUfUkBsEtRM4fMarn1uAmCRhs1tCNoarxIigQUm8HvoWSatGgEqpcgXB/KoVF7rPVlbnLk7W5X88Z3Y0X5RNrjGcldEwjUAsp5we3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EBiEk7UudSBsH+TZ37rdOSzzFwEUNXUfRXNqqfmX8QNrZxr8c9LLPOksTxIsKKc8FxAfwgD8AapzOKBXb0vdzkCjqjGXNX3+DUnbizmO1ipKoFj+Pj2Ilu8hqwlelUnvAP9+qP0a0dXqliZYM8Hryjx/z3ViA/hOWA3LA9rIM7iW23xRAA4kHLaSA1Bqnd9y61RQhcweOAeNFKxUHryFj3HmLmbUM5ofZtLLFZ0sIQLTVsFiLj68k5ixCvT+WzPQKT655Ohr+mQgJK0AwIBT2UBq6DRDsHnTHYWQexj1pkmFIJOIu2aZjIPiJS3kMuI0XwLhpbTSAPTq/11hw6qMZPyvGJmfIbMIbYYFVBXbXMKDFtsIttc3ZqxLraQOIr4VwWSQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0f87c67-f638-466e-7837-08dd1c45ab1e X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:10.7303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oxW8/U6B14Jjsn5y2lZwhY6ofRS/38NI0Z5jEnyyKZWoEHrwECwQz8AgZdfhoAVqiOLGGWOlvMcepVLRu1ESPkF6nb6fH3U69WisY6IgQdU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: 1Oqh_ytNV5pxRKI1eBZ1fujzkbwU7Xyw X-Proofpoint-ORIG-GUID: 1Oqh_ytNV5pxRKI1eBZ1fujzkbwU7Xyw From: David Hildenbrand Let's register a RAM block notifier and react on remap notifications. Simply re-apply the settings. Exit if something goes wrong. Note: qemu_ram_remap() will not remap when RAM_PREALLOC is set. Could be that hostmem is still missing to update that flag ... Signed-off-by: David Hildenbrand Signed-off-by: William Roche --- backends/hostmem.c | 34 ++++++++++++++++++++++++++++++++++ include/sysemu/hostmem.h | 1 + 2 files changed, 35 insertions(+) diff --git a/backends/hostmem.c b/backends/hostmem.c index bf85d716e5..863f6da11d 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -361,11 +361,37 @@ static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v, backend->prealloc_threads = value; } +static void host_memory_backend_ram_remapped(RAMBlockNotifier *n, void *host, + size_t offset, size_t size) +{ + HostMemoryBackend *backend = container_of(n, HostMemoryBackend, + ram_notifier); + Error *err = NULL; + + if (!host_memory_backend_mr_inited(backend) || + memory_region_get_ram_ptr(&backend->mr) != host) { + return; + } + + host_memory_backend_apply_settings(backend, host + offset, size, &err); + if (err) { + /* + * If memory settings can't be successfully applied on remap, + * don't take the risk to continue without them. + */ + error_report_err(err); + exit(1); + } +} + static void host_memory_backend_init(Object *obj) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); MachineState *machine = MACHINE(qdev_get_machine()); + backend->ram_notifier.ram_block_remapped = host_memory_backend_ram_remapped; + ram_block_notifier_add(&backend->ram_notifier); + /* TODO: convert access to globals to compat properties */ backend->merge = machine_mem_merge(machine); backend->dump = machine_dump_guest_core(machine); @@ -379,6 +405,13 @@ static void host_memory_backend_post_init(Object *obj) object_apply_compat_props(obj); } +static void host_memory_backend_finalize(Object *obj) +{ + HostMemoryBackend *backend = MEMORY_BACKEND(obj); + + ram_block_notifier_remove(&backend->ram_notifier); +} + bool host_memory_backend_mr_inited(HostMemoryBackend *backend) { /* @@ -595,6 +628,7 @@ static const TypeInfo host_memory_backend_info = { .instance_size = sizeof(HostMemoryBackend), .instance_init = host_memory_backend_init, .instance_post_init = host_memory_backend_post_init, + .instance_finalize = host_memory_backend_finalize, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 67f45abe39..98309a9457 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -83,6 +83,7 @@ struct HostMemoryBackend { HostMemPolicy policy; MemoryRegion mr; + RAMBlockNotifier ram_notifier; }; bool host_memory_backend_mr_inited(HostMemoryBackend *backend);