From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543739; cv=pass; d=zohomail.com; s=zohoarc; b=INvrcgkmN8Ljm3Ws1JJiHRv8dXAb61xvXmHk3ba8qzNmRPJk/7p7egMYl59wTlwcEe4L4VtF6tvHSYrcNpSbVFJzTK+pmsauAPxCU2t5Z9vonJmUjaWInznbKO9cc/JX+2ouzQbNp/9PR553CLz0bu3GPcBXZMraI2A+bmKHz9g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543739; 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=PvHVdcfbRsDvZ6fElXJcKdsNlxg56dZulyNAkPPQhCE=; b=cjuoRhOvILA3TMwbzi69I5n4J55ASAZOy79uxOBWHG38KMoegwVZpKUGcNBZScqqi0ZMc23MC1RBH4kt0pqI/OM+/EmSKJkM5A8QDsYyG5aKrbCS794sXX41Dxv5FADwcG1u1PegB6a2anmmZR7jAeU8zuU0J6fo/RFZDT3PHHo= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543739101485.1956018410601; Fri, 10 Jan 2025 13:15:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML3-0000WX-TH; Fri, 10 Jan 2025 16:14:41 -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 1tWMKy-0000Uk-G8; Fri, 10 Jan 2025 16:14:36 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKw-0002Vl-8U; Fri, 10 Jan 2025 16:14:36 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ALBqgJ014729; Fri, 10 Jan 2025 21:14:22 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 442b8uk9ww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:22 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKIpL7004868; Fri, 10 Jan 2025 21:14:21 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xuecwpwk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:21 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:18 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:18 +0000 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=PvHVdcfbRsDvZ6fElXJcKdsNlxg56dZulyNAkPPQhCE=; b= VsRhA6VSM8uz6Dewx2SHiSAi5454+4YXP72LlpDx+TCZV2CRKSCWWN0aeYsnwiSZ KBpygz0XTGobKwKreCva1ubjD1SGQ7UWEQ+qWhO2Pu3RXkyQqA0WYRXXp7ZZI9u9 m7f0eIwH35QvMFaavdn3CD3S0RZdwUjpESI1moIaw0V7fp+r9TIdfaNfEzGepVdn L3ubmvRlHFjR5G9eUIm3o5ZRAR7PyhhgFo4Fn3JOtNeRHK0JYMzYfciOxvDr20dd qsjcya3WobfTEMN4r3MSgRwfGUKaWhhGv2dde5efI3kN3Qa7KbPjftMjLPqvJB7n qvQ4N2e20+W3lsh5hJO5sQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OItWILeVZ12pEeqXHUQJ2npkwaY5kJawmnd9h8G2V7gz46Jf7NtwFuc/H2rP5spQuiHS7813iSSAb5aUFg81noMoSUSz6aiTHYcZWs/tqhW8hs82uOssk6YDiR4Bonk+/UfRhiEdX/RLog10dt4WJU53tTR/1aKTZ2BciJkm6OaBx7+i9jcsZ4mcoIWRLm2/Ko4coCupo1qjuqz3F7EKfbMCPU2sxG1rHBuzrKhqTKWdc+rhMEC9QzsWvNMMUGhH3th5KFujJ54HdmNE2/ZVWs0MTBW5UoCo6wrELDe304n2siltPG+jcpmT5cRTQbCA46ZdBsAGnB5vuhVELydd+g== 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=PvHVdcfbRsDvZ6fElXJcKdsNlxg56dZulyNAkPPQhCE=; b=Wh+Nz6JM7BvCnXaNy+mi4jHWOSJo2tltcrk+qqTZbE5m35w9fFDp4uYIwWWSU32tir+PojKeHBURXSVHB124DtH2E2mmtqN6Ck6F/WvfclCsQfXwgneVpBiDEf5TeOQ3ujpA1sVDb1jwhCxdmzItTc9/DqdgqhCelJyQvj6KQz3TVG1G9uobtJRYULxzdygV7PMRUcGpcF5vbKmOEM6oK/AV1428p62tK76QbQoPa0jEX3La4tlhKTSEPye41zaITjrExyqOizqNdpiAfYQmSDtM9yUNiKfbjjqgcon6wBq0MeQBOJwZ4h7pmGNtjy1Vbi/BiRopGd86K7xDepIJVw== 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=PvHVdcfbRsDvZ6fElXJcKdsNlxg56dZulyNAkPPQhCE=; b=BaSWbQ7qIuvR/vtn/3qAgfl7UtaQ7hUmKkgqg7T02MeM7IDSJTT6X9LUvD097U1Eg3G7Y5a/OdxQk9ilm9LGQPUSm28BpllgpxzSoqyaS8WA8QUGz+CH5FxzjmKTAADDcqLwZuUppXowkomgCnMPMUpOoydR3hzxvoqvtuLwoFs= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 1/6] system/physmem: handle hugetlb correctly in qemu_ram_remap() Date: Fri, 10 Jan 2025 21:14:00 +0000 Message-ID: <20250110211405.2284121-2-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BLAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:208:335::26) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: 3419cb3d-0dea-4a63-48fa-08dd31bbbec2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|7416014|366016|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KjHtK3rrW0x9Osz60XBCJ30cesQb3JSLVoky5fcIUGlBhyFJDoispO8LdQKD?= =?us-ascii?Q?bdmi/VbcBx8yaGcu7J9mw1MNDEVJI39e6w1uD6iqFvasEB4p+0b0mfPAIsC7?= =?us-ascii?Q?9gv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ylu8/mQSr+aEn8HQOCUS581IWppkwEl?= =?us-ascii?Q?z5wqtwfpf/ArxeA17/gDulH1XtQaJ3liRjKsu1dPO2yvsGeN/5wv4MsiVmY6?= =?us-ascii?Q?thCzMvkboOPiL6Rc6lWMd/3t1vrT857MgxxMA6Wn78brL0GOSMYWrZnxtT76?= =?us-ascii?Q?AwpNVHNmTruoBnwupa6KMSlcJBuYmqIXPsW9F4OCsevRPQ8Qi6SBxS0g7FH7?= =?us-ascii?Q?Je5i+CK+7z4LVg4p2YAxa4p2QSFOMbnfGtHsQ8Ar6Pji/N4y4CtQx28OMUoN?= =?us-ascii?Q?tsWScjMyN2r3Pt6zYGxuJ3LY+RWa+jdXSBU65V7qBM2hqxQCx4Y5/keYYeOr?= =?us-ascii?Q?l04RdHlxoPa+ds2qDY6Bh2bab56cyQo3J2Tth098K12ijSweoywIrMUvAK+E?= =?us-ascii?Q?ACo1XFZLMlpBnHBMWsXF6e3Vzzv1?= 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)(376014)(1800799024)(7416014)(366016)(7053199007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lrxsSaRWtUYiWvu9DyW0XLqdTX/5/DUdK6ooEcSBw1NUuOjbhqxFV4NxabzW?= =?us-ascii?Q?iM4TI2+FGB52OStK8LIuWU61CHXfeaoNzSjv6r880ydjMCT8gfldqwI/2dxK?= =?us-ascii?Q?QUTs/khNAtBIiH1+nWMtOFNUfhqq3kEj57w44DHRVJeaiNi4I42q2LE7Wk10?= =?us-ascii?Q?J4xZhdqLdoJ2wJkuNfOts60sv4u3jbMMAf9PwHdjUqRdIQDqwXfBQzrhsNV/?= =?us-ascii?Q?hW+Uc8IYxVJxRZ0JDWGqUDSY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Q?07cPfze+AMfsCjBzXIRuIpLMQNDKa4xevM1RxVgC6vUx642wkSr28kKbOCzu?= =?us-ascii?Q?c4jenBGRLJld4CY2xgwNbdgcg5mJMDrdbYIarJySBSYVpTvRuLduN4woA3kA?= =?us-ascii?Q?iSQdyGsejCzhma4C3g1I8pyH63+RU7Ann2RgXxn4GHrVnN91qNbQ4L1qRqcz?= =?us-ascii?Q?uSmALIaF4OlF+xryDf4FFbjjXQPaQjH/nWNr5z3kxkwS+jkjmXSMWwIxzJnx?= =?us-ascii?Q?XQU6bJ79m4BxfJyG0qMTDGHVTJeojBQg2UG7BVGx+D8V+liDHZaOs+tEspOM?= =?us-ascii?Q?lkm5W3ZnSMyJIQLvHb+Nawr/pcUBzHwnVIx8zGgXl0JvQTzk+KP1tOmYfsfZ?= =?us-ascii?Q?NJiC8YJVD5gmh4I2DeGLpIW93PKjAlWS5xt5wtfxAW35t7uo2l4hbMhv4OCm?= =?us-ascii?Q?qWseY8JrEOMIhcAHwz0jEihyBwmITrzFrZQcH0APOf3TURU84aqtGmLGGZMc?= =?us-ascii?Q?5g=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: w318+fbGIdi5PE9PesBTYFWrPut6NMhgbDSz84elPztv5UjejvznKpAXXQDXMW46NaUDHsuk9dWgvBxUaXoMUaVg11m1M9Ymp5RVKunI/F84fTE/2KYzVJay7LXhDHUhfdiJ6k+t6WBZBuq+n+dD5ZjZQp0lqxFUP+hSwoqMOXKT0uPLrtrJBEDJRX4ZJEK25xns3zAgN2yJRc3aPhsMKhorVaXhgszxBx1YXgWG5vQwlKJYqiCWFryf1+H1p5seh5W8qV6JoT+1lXFZf056NZr8+/B+6DB13Z3h6cNuulPV0n854wbk+RoqjIwjynzwllUF6utjRoPf3iw/rCNT2+DDYL/ceSW7Dgj3J2vPPcwloppxYYsiTgCIk04KE1KCthqWBTb1MjYZDDgIr6qClitZHzE6S7/NDbiygUj4OJwyNKm4nlm2eLXc4E/fEdgxvt0P4XDdrlIBMs23VfLWDHlT+4WrMAj6XrBq8Q+KRvJjwlKjptrsjpjMuVvOdJO3fR/5fpnx7BrEME6FwtaO2X3MugHKsZfzIFQJSNwfp/JvZv9oLmrcJmSUtQnNI1o4KhwLXS65yzebzlg3g/AiuINZVtee9uHVS5ppUH2kY2Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3419cb3d-0dea-4a63-48fa-08dd31bbbec2 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:18.7508 (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: cL+Yk0i0PNMk/Y04qN3JxfQikGoM9spRMjkhprSzXuvX2pqGKLQCD9SxSfFxmgIbkkx4JtZm+YlL3Lzlu/C1v5l2dUnO1b70JJLyndulljQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-ORIG-GUID: 7dS2BJGREEZ-yTPMMTBiMhcdIzFVXPq5 X-Proofpoint-GUID: 7dS2BJGREEZ-yTPMMTBiMhcdIzFVXPq5 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=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543741391019000 Content-Type: text/plain; charset="utf-8" From: William Roche The list of hwpoison pages used to remap the memory on reset is based on the backend real page size. When dealing with hugepages, we create a single entry for the entire page. To correctly handle hugetlb, we must mmap(MAP_FIXED) a complete hugetlb page; hugetlb pages cannot be partially mapped. Co-developed-by: David Hildenbrand Signed-off-by: William Roche --- accel/kvm/kvm-all.c | 6 +++++- include/exec/cpu-common.h | 3 ++- system/physmem.c | 32 ++++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c65b790433..4f2abd5774 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1288,7 +1288,7 @@ static void kvm_unpoison_all(void *param) =20 QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { QLIST_REMOVE(page, list); - qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); + qemu_ram_remap(page->ram_addr); g_free(page); } } @@ -1296,6 +1296,10 @@ static void kvm_unpoison_all(void *param) void kvm_hwpoison_page_add(ram_addr_t ram_addr) { HWPoisonPage *page; + size_t page_size =3D qemu_ram_pagesize_from_addr(ram_addr); + + if (page_size > TARGET_PAGE_SIZE) + ram_addr =3D QEMU_ALIGN_DOWN(ram_addr, page_size); =20 QLIST_FOREACH(page, &hwpoison_page_list, list) { if (page->ram_addr =3D=3D ram_addr) { diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index b1d76d6985..dbdf22fded 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -67,7 +67,7 @@ typedef uintptr_t ram_addr_t; =20 /* memory API */ =20 -void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); +void qemu_ram_remap(ram_addr_t addr); /* This should not be used by devices. */ ram_addr_t qemu_ram_addr_from_host(void *ptr); ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); @@ -108,6 +108,7 @@ bool qemu_ram_is_named_file(RAMBlock *rb); int qemu_ram_get_fd(RAMBlock *rb); =20 size_t qemu_ram_pagesize(RAMBlock *block); +size_t qemu_ram_pagesize_from_addr(ram_addr_t addr); size_t qemu_ram_pagesize_largest(void); =20 /** diff --git a/system/physmem.c b/system/physmem.c index c76503aea8..7a87548f99 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1665,6 +1665,19 @@ size_t qemu_ram_pagesize(RAMBlock *rb) return rb->page_size; } =20 +/* Return backend real page size used for the given ram_addr */ +size_t qemu_ram_pagesize_from_addr(ram_addr_t addr) +{ + RAMBlock *rb; + + RCU_READ_LOCK_GUARD(); + rb =3D qemu_get_ram_block(addr); + if (!rb) { + return TARGET_PAGE_SIZE; + } + return qemu_ram_pagesize(rb); +} + /* Returns the largest size of page in use */ size_t qemu_ram_pagesize_largest(void) { @@ -2167,17 +2180,22 @@ void qemu_ram_free(RAMBlock *block) } =20 #ifndef _WIN32 -void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) +void qemu_ram_remap(ram_addr_t addr) { RAMBlock *block; ram_addr_t offset; int flags; void *area, *vaddr; int prot; + size_t page_size; =20 RAMBLOCK_FOREACH(block) { offset =3D addr - block->offset; if (offset < block->max_length) { + /* Respect the pagesize of our RAMBlock */ + page_size =3D qemu_ram_pagesize(block); + offset =3D QEMU_ALIGN_DOWN(offset, page_size); + vaddr =3D ramblock_ptr(block, offset); if (block->flags & RAM_PREALLOC) { ; @@ -2191,21 +2209,23 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t len= gth) prot =3D PROT_READ; prot |=3D block->flags & RAM_READONLY ? 0 : PROT_WRITE; if (block->fd >=3D 0) { - area =3D mmap(vaddr, length, prot, flags, block->fd, + area =3D mmap(vaddr, page_size, prot, flags, block->fd, offset + block->fd_offset); } else { flags |=3D MAP_ANONYMOUS; - area =3D mmap(vaddr, length, prot, flags, -1, 0); + area =3D mmap(vaddr, page_size, prot, flags, -1, 0); } if (area !=3D vaddr) { error_report("Could not remap addr: " RAM_ADDR_FMT "@" RAM_ADDR_FMT "", - length, addr); + page_size, addr); exit(1); } - memory_try_enable_merging(vaddr, length); - qemu_ram_setup_dump(vaddr, length); + memory_try_enable_merging(vaddr, page_size); + qemu_ram_setup_dump(vaddr, page_size); } + + break; } } } --=20 2.43.5 From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543806; cv=pass; d=zohomail.com; s=zohoarc; b=gy/bio2dVdSSdtWUuY9VwvFco6V7E2nJGoz9aFiylh5OmIwJxUv0KqCDKLrfVup5zl/X8s2OgoPfvMFdL0Ssmf+E5DKkIy7HHyTmrL9R4Xp6hQZw4NcH4G8bF8xzNHc0Ea/KqlZr1UOvZdJpyeegnCbwYnQZHEiIha8TI3PbzDk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543806; 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=XA+YfyyP2ahjv1kQfv3vfVQbur2dA5b4IQFKn15BJe8=; b=hZwC16LLH+WmlE/dEm+WGOBk+1ktLQ45f8dY135wXN8U/snu55ScBzD35ta0Sou2xmvL+g2M5Z8iFiSyWB8zX9lke5DzqggbJsgJuEQl7bVwyCpmkfr9U3RMic+TGLMl/vpZGNfL6q+YyHQY9m8PKc24oRDNZzFSir84cTchgUU= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543806172192.27617776962143; Fri, 10 Jan 2025 13:16:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML7-0000Yn-Vu; Fri, 10 Jan 2025 16:14:46 -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 1tWMKz-0000V1-KR; Fri, 10 Jan 2025 16:14:38 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKw-0002Vt-7m; Fri, 10 Jan 2025 16:14:37 -0500 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 50ALBwgS022287; Fri, 10 Jan 2025 21:14:24 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43xudcc0ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKIpL8004868; Fri, 10 Jan 2025 21:14:22 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xuecwpwk-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:22 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:19 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:19 +0000 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=XA+YfyyP2ahjv1kQfv3vfVQbur2dA5b4IQFKn15BJe8=; b= hfUJbl5mluLKMSW+OQIncuD6qwtJcDWBjNMg7Pkqzl6Cs5H3nWFEQ6TbBH3tbgCV xt8RJftlHGTmc3heVscPCcx/G3VT6jFNKLuoZp3gP9SjUVzUAacEdPVXYP4oJXlM C+aZ41P1Dxca8cUjM99CzdlwdnJu5IO8G6K3nT/OBwE5mBd4685qkfUgm+a/QWEI q0XnTF9WG+2P0FQxTE3kdfGngY4SHnw5rvNjwdpPoMvlauEcxLFZqQ2oz8tLLy0y ZuogUV3RSE1lhG1go9LgB0fPDhvKXVuq/kywpeNDE+AkukdvI+Wqz6pJ63nFwC+0 sRpCHz8ARtX5Q3n8G/z/4Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lVpnebEMf/Igd405IB8eX1z6R+j1qmZ6yM9bfbyhH0BG0FnEvIJlraPcLvxuYCglm1DKr4twQUd6Ga0Y571z9heZiSvV26hYddIjGVCq0d1KdyyUwQ5JsRkAGoiemWB5Kbs1mfH5aXGmH1AUxVRiOoBtUS2XhVAF6//j8rmElUMmGTbM6O5QWHdeprg2/I73FnLw/cEub4U7PS50Fdj8Q3uWvAtQaK1tZav1x0IwHuRcwYr0oEc1noadZyzuaSaWysLCcrr6Pl820ks28U+FwEhZDHq3F3DP5w1xrfYtbdA0G7OVvKgXprC2y7DvBfBIF4pMCOourn6AuJQ1hYR4MA== 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=XA+YfyyP2ahjv1kQfv3vfVQbur2dA5b4IQFKn15BJe8=; b=EPqNEriioPt7D7xz7+7QTj2z84p87jtdrvrYFfq77blf4h+EUvjnVFrI0X6gGyXTF1uRUMj3PdMyLQ5jX8SR/+l5H06CMnEnBuy5hlR25TXL09cJnMXN2tVNCQeJR5EURdSduu1uvqi+YrkyllZqlVxH7DLQWmdFnJIDZcSyeN+VTon7gMR2YFddb00giCnKRSYyndssokzBvxw8lRxbtLVRABPEtEdEH5yKydB9VsiSHLor875RR0fXvS7b6FMx7+/muH5+Shh6u0y6YVs7SAW/qpAMNH5Ei3HCPqaDDWH8tHF/JJHRbtahVleERJSCU7Hj4IslgDo+pc/1rtnFbw== 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=XA+YfyyP2ahjv1kQfv3vfVQbur2dA5b4IQFKn15BJe8=; b=h86iv37vaLzCYp1Pc3Uyzji3B0+P1BXGgyBDCaDI1cyMD5ANiMBKF0VdiTPWz5ONLMVni5RnqF7PdhuHkk55lsYLW+huwHjYphFceRjpJM/nyaXfB3omYwqKaNdP01IRszwGGETuta4uAQVpNTKX+k0UXFR+cdIIOgD1vRgF0A8= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 2/6] system/physmem: poisoned memory discard on reboot Date: Fri, 10 Jan 2025 21:14:01 +0000 Message-ID: <20250110211405.2284121-3-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BLAPR05CA0040.namprd05.prod.outlook.com (2603:10b6:208:335::21) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: fb49d750-35f6-492a-1026-08dd31bbbf5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cep5gbPFmetO5kXbtxDHtSqhIQNXc38TSuuaxqGEdZnzXiBV5c+zbigySA1f?= =?us-ascii?Q?ZDXscker2qQrU0GKBwiTTvwa3LrxxOYn7z2GD1RpGhgRPHmIGa25hMytQMYZ?= =?us-ascii?Q?yoirGB+ckv2Gyq7Qx6SPoVYpCx2cn1O+LoYS1DG6EBFry+6bry2o/9itm0fx?= =?us-ascii?Q?3HUgeWecIaMeIXiTNlqftK1MhmAVdi0ktBuMYNc8KwOs6JRniJRAJGXKjSOV?= =?us-ascii?Q?l7EkhDCQ9GWJlbZXAm0snIka1p5/CYG0hf+NDAfgWcgzR9+8k4EEIyTnUpxq?= =?us-ascii?Q?Wiv9weheYTIIGWh/WqANn14t62GmukydSzKFv5n63viem6mLI0EKkSdH3j1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hlddrhV760Q+KLcmK7wWMmb7DcKZiSPerq0TkpQ53?= =?us-ascii?Q?tDebkucnwj1nPE3bKv0UdPSjvqFmiPmAzXKlmqCugdDzvzf8/PTzWAM7i+oz?= =?us-ascii?Q?y05it+rcaJlK/SnJGillKBGBRp2cC80kH3GAeGL+zcxra6IsgT1mPBQyvHkQ?= =?us-ascii?Q?AoPIEAs+S0Kphb6EPdUGYJOIguwq?= 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)(376014)(1800799024)(7416014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CQNdoDenEgC+z6s/95ebDc/FuKas1O+QhZytiUsQBIExGY7LXcogD6GY9Xik?= =?us-ascii?Q?DBHL3ANa8vgcK3pG0fzHI9k9oY6lJz/UYtvtFGOQJsOSi/qx99pa79wC/Pyh?= =?us-ascii?Q?ggBXqI9FNdZX46VnDzIBaV2e6/aDl2/S1hKkk5QOn0xXuH/MH6rDg00Wt0IE?= =?us-ascii?Q?ClrWFQqr5RN6shFJGR8LYA0IBAnIdRROFLbGc0St3ZWgalNF9LU1bTrhx0HO?= =?us-ascii?Q?aDn8BOGR82Hh8QiqBZfGYElb98x2U/cMrAdBbEsWf7vmA22Bng+oWGCh+yyI?= =?us-ascii?Q?oKatf2Mdhm31do0SjIydqTyehrp147p2eRw43/mB9gyzP1VfyJ5YN/Cdfd3S?= =?us-ascii?Q?ZvgzGvmizhN/pq3jiVnoTHI+uvG+PYS10icSEavkVQbstF9tqfxwqo+fjdbG?= =?us-ascii?Q?Oqf+POt7aEll4r8iB8783KOc7tji6HHo7inxEp6UQvGPutEeWjuqvpzLfptR?= =?us-ascii?Q?MoNTKZl1WktWYvGqtcAOHfyc33X7XfXOSwfghe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LfSQdUrjXgtqMM675dYL6klEG8rrBth0nt0sOoqFzfrwN1?= =?us-ascii?Q?LeG4M2Nk7HcND3DkiG1qdi+5PXeTtrxVFNam+pTPIaKJ6J9TmiXoHC5mDdNZ?= =?us-ascii?Q?7lHeuamo8ckZQilHSJTP/4n7DDzC/VDFaHrf92EvcMewBPbBEWTtHPSu0lQs?= =?us-ascii?Q?2fo6GlDy3JaRHH2V2ePg9eBYHReQJRwlRZOwJaIr5osT3NA9Gym/AatP3NWx?= =?us-ascii?Q?qw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zku2ZuCEAj1Wa1JbUzLHWzyRqAghlS7eATkDqepriCJbbeQ59EOpbQlpWkOpaZsmlco+yh8EW2jfipD1XcO6fc6sRn9ilLgBtlKpuw9VAUf6FbvD3KaXoeDnrDlxDaFVTvLNUyfzM/RhnSeXeVxJ0W2LYZ9gLmkdPVhuXvl+u4M0CkcAY6LxcCE6CmBmixrlkQWg/6XJU9LfBvLeg0H6JIezLMVIxM7chkwHhz2V27M8sQwgR0mpRPpxt4kcOxf+RoFuTykF1Jk9u1EQkwtCiKDWDaeI/TstIfdBkI5PvamgUaQ2IahsJL1WZhKKgWsSTHrslZGiyB215Xv8goIlS8hlzDxEuMCNQEmxTKmLvFE3miF/iEq9faBEKIfxRdr4rCYMCpil8yUaASLQdESWlub1X4dcV67rHLm+PpbLOfElj5W1KvpgF6iHfM+j2RDLaJTed9HkMuY3LMspPJpQ2kEiNUg/kCpHljHE3QFsWU1n7m+vBLnL5pfJNyQAxpvvGLj1CCCsFWCvy0/NhA2LUG4ORbgtobNrWw1nWherm4Srls1Uj3pBIt+8QABwE6jHlTUMT3RoLtQfCLrAR2BcOFcNo+VxevyjVQVpZUvda8I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb49d750-35f6-492a-1026-08dd31bbbf5f X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:19.7275 (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: +mxpBrEuvjpudVH+kCCAvNQTmIjD0TXuFYEH0pFSJIbmxcEVTLVT0LYEJfi/jSh5kFjMb/nhBwDa+m3ExA//znRdxpwYRQOys6w0lPeDFgY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-ORIG-GUID: QdJLtNskk4yLg79v5g9Jj7kdyjpkcTbL X-Proofpoint-GUID: QdJLtNskk4yLg79v5g9Jj7kdyjpkcTbL 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=205.220.177.32; envelope-from=william.roche@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543806719116600 Content-Type: text/plain; charset="utf-8" From: William Roche Repair poisoned memory location(s), calling ram_block_discard_range(): punching a hole in the backend file when necessary and regenerating a usable memory. If the kernel doesn't support the madvise calls used by this function and we are dealing with anonymous memory, fall back to remapping the location(s). Signed-off-by: William Roche --- system/physmem.c | 57 ++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 7a87548f99..ae1caa97d8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2180,13 +2180,32 @@ void qemu_ram_free(RAMBlock *block) } =20 #ifndef _WIN32 +/* Simply remap the given VM memory location from start to start+length */ +static void qemu_ram_remap_mmap(RAMBlock *block, uint64_t start, size_t le= ngth) +{ + int flags, prot; + void *area; + void *host_startaddr =3D block->host + start; + + assert(block->fd < 0); + flags =3D MAP_FIXED | MAP_ANONYMOUS; + flags |=3D block->flags & RAM_SHARED ? MAP_SHARED : MAP_PRIVATE; + flags |=3D block->flags & RAM_NORESERVE ? MAP_NORESERVE : 0; + prot =3D PROT_READ; + prot |=3D block->flags & RAM_READONLY ? 0 : PROT_WRITE; + area =3D mmap(host_startaddr, length, prot, flags, -1, 0); + if (area !=3D host_startaddr) { + error_report("Could not remap addr: " RAM_ADDR_FMT "@" RAM_ADDR_FM= T "", + length, start); + exit(1); + } +} + void qemu_ram_remap(ram_addr_t addr) { RAMBlock *block; ram_addr_t offset; - int flags; - void *area, *vaddr; - int prot; + void *vaddr; size_t page_size; =20 RAMBLOCK_FOREACH(block) { @@ -2202,24 +2221,20 @@ void qemu_ram_remap(ram_addr_t addr) } else if (xen_enabled()) { abort(); } else { - flags =3D MAP_FIXED; - flags |=3D block->flags & RAM_SHARED ? - MAP_SHARED : MAP_PRIVATE; - flags |=3D block->flags & RAM_NORESERVE ? MAP_NORESERVE : = 0; - prot =3D PROT_READ; - prot |=3D block->flags & RAM_READONLY ? 0 : PROT_WRITE; - if (block->fd >=3D 0) { - area =3D mmap(vaddr, page_size, prot, flags, block->fd, - offset + block->fd_offset); - } else { - flags |=3D MAP_ANONYMOUS; - area =3D mmap(vaddr, page_size, prot, flags, -1, 0); - } - if (area !=3D vaddr) { - error_report("Could not remap addr: " - RAM_ADDR_FMT "@" RAM_ADDR_FMT "", - page_size, addr); - exit(1); + if (ram_block_discard_range(block, offset, page_size) !=3D= 0) { + /* + * Fall back to using mmap() only for anonymous mappin= g, + * as if a backing file is associated we may not be ab= le + * to recover the memory in all cases. + * So don't take the risk of using only mmap and fail = now. + */ + if (block->fd >=3D 0) { + error_report("Memory poison recovery failure addr:= " + RAM_ADDR_FMT "@" RAM_ADDR_FMT "", + page_size, addr); + exit(1); + } + qemu_ram_remap_mmap(block, offset, page_size); } memory_try_enable_merging(vaddr, page_size); qemu_ram_setup_dump(vaddr, page_size); --=20 2.43.5 From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543737; cv=pass; d=zohomail.com; s=zohoarc; b=h8453QtWKq4UltKLay0gAQ/u1P5EcgBSIhJpH5X0nrJhMRJ0ZIYcUnZPEYv36KQEpEEbNJrED/D8OKXAbuA5ntMSHhZ3BBYZrmWo/M62d9+oATCP2FjRndQEOfnJGXKc9h46zPV/3sidcBa5Lxv0QFP4/77BIkkHzLmYWjhI6go= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543737; 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=wm6W777iHWE/M1YLfWans4zxCm57qLpB0XgFS0A+VqE=; b=CBt0C7P7MnHEIN2+/P621+6XL2OiNBQyIC6+VgNchdrTkvRIBRNg8I0OCp4MNapCeWmE7QaW2fJb+tau/KbJWbuNm0989po9ol8k93qDreqIodODhBCDAZAGA8okPIxHiUW39Lv/8lVpECFA57uzjRgocz7MYV0dec45ZGPAOrc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543737589949.2023819333358; Fri, 10 Jan 2025 13:15:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML6-0000Xi-OX; Fri, 10 Jan 2025 16:14:44 -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 1tWML1-0000VB-8G; Fri, 10 Jan 2025 16:14:39 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKw-0002Vm-9I; Fri, 10 Jan 2025 16:14:37 -0500 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ALBsFt015562; Fri, 10 Jan 2025 21:14:24 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 442my625wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKIpL9004868; Fri, 10 Jan 2025 21:14:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xuecwpwk-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:23 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:21 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:21 +0000 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=wm6W777iHWE/M1YLfWans4zxCm57qLpB0XgFS0A+VqE=; b= ASz7OC9jY37NSnEHjSYGv2GFZnUPajcI3QVHhp5jHfPBo3Rw3MHCccexBq+KBv/A 6GJ+2SIYXcnk42hIj0wCBAZvG10OWLW0mRj/KBvQOG1kcB6EQm7c30aT8rJYuTsj iH8X9UsbadObeObb23y1awv6FS8xmZoq6/H2is1Ajv7M7Yi5XxDLlTNjNgzb3Cn3 P/iJblOptFzUowveAJs9qGL1xrqUOX+ZkJb3VWmkDlXljyPQ3Fs/vJVPKkyVlgKu C+LY7YTN5MTxxX8056HgCRXXrtyA4EoY4OPwyr/SG3aRqffOkdd1Tv4rS4HzTnmB iw0JBMy8Z+Gs9CZZJBpXUw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hri+8dZewz5A2IV3/S2Gbh3ufDhuU+cgKnslfldPXXKZYnpAaLMXyBJNHEktKb8qfPbJsOYSlekVUOuh/jVTPftm9q7EGpGnLbww8afXAAZ/k9ADP/rW7D+RUfWpmfVTcMTR5JMrD4v3n4HqFD/RUI3KZHCwCJXyg/HQrTHMzdMosfvQN6zALHZIGVszGfzHDqz/AXOHrEv2Ps1/EmwBXwiKGqrCn0zx8UORwVOu4/CvNPpoX+cWn5/b9UMNF4GsEx06wxy8zWIpIOb/ZVVTnToy/CaTmSNjDxzXmpnrgYPgTVPTnSqlQNMvP/bb0+hoB02zESnKmdA65i7xDYGMeQ== 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=wm6W777iHWE/M1YLfWans4zxCm57qLpB0XgFS0A+VqE=; b=VZlyZk6bQ1YvLeppb5ReJad02NZZqaQ7wdth6BQ4mKGxWju6LBMH7SI6IixjIbfk0lmG7KwC34QzdId2No2/XXMDILx9UHaNKUAD0yHEU69oWhlQEn1G699B2m+z2vp+pBxUImbQm+xLAzGVd216UWbncuIsApq/5+iepXUHnP/t268SzKWzNEG8A5Yhp+lJdnQnNza7ZwxpuYpwPB4n5LAgEviakZnVW4yXhnMYjnmLx6yPcI4mxt9FyGtfDF5MiSvIf9Wg0Kf/zb5StpcUdP83YRaS5XWCvaasU9Y+FWBzNgXC/GGARhVM5Abp7D52Uqnr7dd0Fk/+TCxi7hTN/Q== 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=wm6W777iHWE/M1YLfWans4zxCm57qLpB0XgFS0A+VqE=; b=rfQaOYr/wvIBO/SJR1rCVz6cwDMcc42xLWwF+fW44EhICRuT0Dab/bga26f618XRscQC60yOB1hTYrUMBnFeM+RF8HcwqszUz3d0FG1Mb+pl1ZNanw1xj2YdOhdvl6pKFBd3lD4zmB4IkerrVNvG1IhVhRijbVrvNQ+rK0mbzeI= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 3/6] accel/kvm: Report the loss of a large memory page Date: Fri, 10 Jan 2025 21:14:02 +0000 Message-ID: <20250110211405.2284121-4-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN0PR04CA0098.namprd04.prod.outlook.com (2603:10b6:408:ec::13) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: fb600ce0-78fb-4fc5-9266-08dd31bbc011 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jqMyb2+sFLG07GwDQbutXx5JdT0cdlO24VnIRrN6W+t+tETnxgGzvmuqaIFh?= =?us-ascii?Q?9MeYH1lIY+Zjr43KMv9IvmH/tlTIF9ZhprqhzMHYqVgXfCK2vhHRaS5viRoi?= =?us-ascii?Q?dVOFx0LV4XvrJ4H1DvLnUB6DO8zQLWFQxQZ6rsv90GhrV0DsbXtJxnqLEOVN?= =?us-ascii?Q?us/ESopfVMQc0WiTS6DSkxQ4GcTKx3Zelk74qn68ClTcD2y6/yZ2SJG3L3MG?= =?us-ascii?Q?5PhT4rSsaa2HRIkG9skfrZiYqsingWdOZIjjjbWRzPfAkXgq+vqYXk+oZ8be?= =?us-ascii?Q?/b8Mn0+E3FxrmYz2mgRAO7r1Lg2XbHI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anguQp9jikpCIY9s/1kOWybrtgwNlMSQmnLbY1eTYFhq8WPN?= =?us-ascii?Q?3z1ixI7XIrGp13eWJC75kumD3W28LZC2A4+Io+pS2dLiD4nqzZ4QWJpDv8G1?= =?us-ascii?Q?8+0ZBAGoAWsFY4QR+jzWkAzTAfp4xqmSp6Z0WNOG1AJ6BGUXN2AC1w6i0cy7?= =?us-ascii?Q?uKoMw5dMKXoCKxvfpjY6KKEKr8wM?= 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)(376014)(1800799024)(7416014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?F3Lo61f83tV9n44N+l5LL4AuAYUAZBhvZJkVxcFPQgkO6VHP6akZLpgLUInM?= =?us-ascii?Q?vVmtkx23RdxhNHkfCAmmbeZ+PT2RNerZcitg/rvSeRzrOrBMK8IMwIgbfFW1?= =?us-ascii?Q?Y6vaj0V2c0hTIb+3Lmph6F6cDxzCsm24+R7iIF9vCTmSZAqiIUzqzA6GukE5?= =?us-ascii?Q?a3paJFyEcLRGrsFg9Wm0doSWVrLVpwtVgnXTdyJDp98a8ao3s5ZBq86r7RXG?= =?us-ascii?Q?AN5Abl+JywbPRS7rPhyTyRvxiUU1hyHv9qaeuWmLk8Unvdy5hF96jl/cnhUA?= =?us-ascii?Q?X/8mWOsSNtD+5j42lDShi/Ut/eNLGclg8VPIHfT+Qag5qktF8aWolvCxBpJz?= =?us-ascii?Q?MC9IrLze7LQ3WHjdxv9InyMEi2Fg6abLXVS72xjHdPMWWIV/bC0NDjqDKDmQ?= =?us-ascii?Q?4/A/t4/aDUdZwOZuyj109/LM1dyKJdyH7usXoITxdbvhw3dUdYO+7kDXbrKB?= =?us-ascii?Q?f7OC453kDI5PbQ5gBCXa+PCi53lPaCOAXLckiz/3BKrVq7dD0Srgg8EtT8s1?= =?us-ascii?Q?G/JNHVWiEpvy/YtRnFbpq5jfnzhi6S1bDzQ1k43PF171SF0WLjb/risePe/N?= =?us-ascii?Q?40L4NnGmZV16X5VnFJhXRJwZXgeJvHLzTN2Q1HXJ6cg5CsX63RwdUeThBDM3?= =?us-ascii?Q?g8VSGj0H2KduymtrswHH6pBx1GRBs3UnTm7m8egbkl7jUK/z7VgL3Crzwa/T?= =?us-ascii?Q?CDK9Q/5BA8WZyLtgILQei+U73ODAX/5meQHZCKcEWAMEZlHmyomczE2rbLBA?= =?us-ascii?Q?L/pBm/PphdUlAcEv7lLmk+Of7tWC6f5ufJILSBct+r3u/qzNTEwYyvXZFJDT?= =?us-ascii?Q?uAPi61SbNECF28kxh2dqVLMnnfAwZDTmy1h9kT+y3wojILy/utcfm79prtiq?= =?us-ascii?Q?W83gTc1Utor/CD5ghNH0POub4lCP6guq4ohysiaPAOQ0wrA+gOyGukILQkbo?= =?us-ascii?Q?XVDCiWBrA4KntTWF0Q/Yyj05afsj42pADb0CLencYqVy6cx3n3IsyHR62qtx?= =?us-ascii?Q?TqJjGwnZogWQ7ltgW5rCf9RJDpadEL1wVD9IvVcXtGSoZSm/Ao9HANPCKuGl?= =?us-ascii?Q?x4mCL2ckYrZS1O/r3yE0ymLzU7IBIPOQqbYPzrVYy9DAi9hsSVLFSMXtqWqS?= =?us-ascii?Q?0SygOrx6lfoCCiLJrp3uRLtuuD4NYAMbB1/92Og872Qu0Unl6rGAXo0vSg1s?= =?us-ascii?Q?W90SCZxRdsKBgCube+f7W5wPi1enWtoaooH3N+epW0LBG+9x7ch3TUHyIO8Q?= =?us-ascii?Q?+wcUknqUic7LV8xZ8fy8yns19pc4HkokijbESy1dVEFIOMuE4xVIaLgojPMf?= =?us-ascii?Q?1cv6cnsJCpp+2Y7QLq51h6rqMd89vD2cNX9MdeKa97eUVyZwxII5uz9vsear?= =?us-ascii?Q?uux/4tog5rYU2paPcFREQ3hY2hbinuNRo7ox7UofwOOvd4kUU/yrxDPyHCy8?= =?us-ascii?Q?NP/GWN/F94yUTA+nI9HBxKf8j0/k2P3Ed9vCwCfXywotcipnGti1YktPifZ3?= =?us-ascii?Q?Zz6s6XMUCy95lcNYP96vJ3C9aWAQ4ETl/oTkfgESJAH+cNsGe5Hp4FLrZpag?= =?us-ascii?Q?mxlS1CQghWQyaOI5x/PoqTs7Ue302zJk2Quik0vCPgJejJ15BJmRnqEmzYlP?= =?us-ascii?Q?2Q=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: F5EVVlhnqs65HIfM7SjIkCZ6dyvmUqBdsPBzDyZi8FrOKmUQohr1v/ta3HXZEYp6eyCYW3ZoT9brVJ9tgD2ny1T61ha1hWyvV0D4BY4hFbfY3wd2fxN/1LnN5e7VG+dL4PgIomWodwUnn5am8SufEzhXrFoFMncehxtYtpmZ2T4pi4v2PBbDIp/6s7OLUtfFdEdKu77mIFp8i3pFcDvNNX4jHONUS6HflChApo9rsuAexUaQHZirxTvoFUjv3qWn6/R7msY0y5QhzYfBCd+GbZG+ukJpN2H8M0IwNx19EJWz1tXVrjAsFHMuIN09hcfGRhxCp53zPq1vtlmwt70ne4rLrUTzgpNPMZe4+MYGyCdRPnw1vM7emILIbFXxHUfPrzZuwpeF+HYZBP8G4iBfU3J2AjWgoH90fDyHGu243D4AulN2wQxWB7UYnpk1LBHluCeqBzezh4VBjQ81fG8vyleZG8QHqCFUmeLksWP9J2eURcnwF3brjrbNAA3X1uI3vJhzBg1T/Yx+OFIF+C7wn9wVPgsjRAgw1zydypTL20oLtGyxsWyR98jcMv8XmihGEJCjkmmqwajROjGQTJgEwcgg+r6uk1mQqHe5UnHmGRw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb600ce0-78fb-4fc5-9266-08dd31bbc011 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:20.9447 (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: 135YkcD02YxCCqft9Zj/hCLvM/XTvYFsukKBMkjiZQZs/hE4/273CAmNTHQ4AUZH1fbLlZLcQzyVYLVbc8OB0sORU+rXCJHULgNORNEimDQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-GUID: NKvnQ9IebNRvo2OzVIvdnFi8DudGaT-K X-Proofpoint-ORIG-GUID: NKvnQ9IebNRvo2OzVIvdnFi8DudGaT-K 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=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543738109116600 Content-Type: text/plain; charset="utf-8" From: William Roche In case of a large page impacted by a memory error, enhance the existing Qemu error message which indicates that the error is injected in the VM, adding "on lost large page SIZE@ADDR". Include also a similar message to the ARM platform. In the case of a large page impacted, we now report: ...Memory Error at QEMU addr X and GUEST addr Y on lost large page SIZE@ADD= R of type... Signed-off-by: William Roche --- accel/kvm/kvm-all.c | 4 ---- target/arm/kvm.c | 13 +++++++++++++ target/i386/kvm/kvm.c | 18 ++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4f2abd5774..f89568bfa3 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1296,10 +1296,6 @@ static void kvm_unpoison_all(void *param) void kvm_hwpoison_page_add(ram_addr_t ram_addr) { HWPoisonPage *page; - size_t page_size =3D qemu_ram_pagesize_from_addr(ram_addr); - - if (page_size > TARGET_PAGE_SIZE) - ram_addr =3D QEMU_ALIGN_DOWN(ram_addr, page_size); =20 QLIST_FOREACH(page, &hwpoison_page_list, list) { if (page->ram_addr =3D=3D ram_addr) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index a9444a2c7a..323ce0045d 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2366,6 +2366,8 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) { ram_addr_t ram_addr; hwaddr paddr; + size_t page_size; + char lp_msg[54]; =20 assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 @@ -2373,6 +2375,14 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, = void *addr) ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { + page_size =3D qemu_ram_pagesize_from_addr(ram_addr); + if (page_size > TARGET_PAGE_SIZE) { + ram_addr =3D ROUND_DOWN(ram_addr, page_size); + snprintf(lp_msg, sizeof(lp_msg), " on lost large page " + RAM_ADDR_FMT "@" RAM_ADDR_FMT "", page_size, ram_addr); + } else { + lp_msg[0] =3D '\0'; + } kvm_hwpoison_page_add(ram_addr); /* * If this is a BUS_MCEERR_AR, we know we have been called @@ -2389,6 +2399,9 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) kvm_cpu_synchronize_state(c); if (!acpi_ghes_record_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { kvm_inject_arm_sea(c); + error_report("Guest Memory Error at QEMU addr %p and " + "GUEST addr 0x%" HWADDR_PRIx "%s of type %s inject= ed", + addr, paddr, lp_msg, "BUS_MCEERR_AR"); } else { error_report("failed to record the error"); abort(); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2f66e63b88..7715cab7cf 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -741,6 +741,8 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, voi= d *addr) CPUX86State *env =3D &cpu->env; ram_addr_t ram_addr; hwaddr paddr; + size_t page_size; + char lp_msg[54]; =20 /* If we get an action required MCE, it has been injected by KVM * while the VM was running. An action optional MCE instead should @@ -753,6 +755,14 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, vo= id *addr) ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { + page_size =3D qemu_ram_pagesize_from_addr(ram_addr); + if (page_size > TARGET_PAGE_SIZE) { + ram_addr =3D ROUND_DOWN(ram_addr, page_size); + snprintf(lp_msg, sizeof(lp_msg), " on lost large page " + RAM_ADDR_FMT "@" RAM_ADDR_FMT "", page_size, ram_a= ddr); + } else { + lp_msg[0] =3D '\0'; + } kvm_hwpoison_page_add(ram_addr); kvm_mce_inject(cpu, paddr, code); =20 @@ -763,12 +773,12 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) */ if (code =3D=3D BUS_MCEERR_AR) { error_report("Guest MCE Memory Error at QEMU addr %p and " - "GUEST addr 0x%" HWADDR_PRIx " of type %s injected", - addr, paddr, "BUS_MCEERR_AR"); + "GUEST addr 0x%" HWADDR_PRIx "%s of type %s injected", + addr, paddr, lp_msg, "BUS_MCEERR_AR"); } else { warn_report("Guest MCE Memory Error at QEMU addr %p and " - "GUEST addr 0x%" HWADDR_PRIx " of type %s injected", - addr, paddr, "BUS_MCEERR_AO"); + "GUEST addr 0x%" HWADDR_PRIx "%s of type %s injected", + addr, paddr, lp_msg, "BUS_MCEERR_AO"); } =20 return; --=20 2.43.5 From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543749; cv=pass; d=zohomail.com; s=zohoarc; b=UDqsROPMpzdrtDh/MC3sWUcS/9DXyPAgU2kFs5X/m+v4Sjrh22oUQ8l/WAQdx25KlQbtxT3gKuzWx0ECM8Q7yF7SB7/h1mP0EnFHjyFLh9aFR7ntjV8sy5DHCiFlnZ4pEsA7UD9th1/20WleiCMbqbtlwPYQMSYZ2NVTCsxZi7I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543749; 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=w7i5Tk1RbO0VXPKpnPE2xZgNZswwBA3qWAl5VM6sOXY=; b=eUfojGKgAIaCNZsevFFiCuoarQeDjKjMNTxpZ3xFO7SzoOev6fIyDjvuDNwOpmei9VA5FdCK19JQ/putWhQ2HXn/cn/BJVD/RExv86h7u9YzONfOgAeBlDuMPZYT2OfbEUvWg92Y9BX5M7FB+TQqoZKLzMWoOT+z7+sV7npo89k= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543749386966.151376631669; Fri, 10 Jan 2025 13:15:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML6-0000Xy-UU; Fri, 10 Jan 2025 16:14:45 -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 1tWMKz-0000V2-Mw; Fri, 10 Jan 2025 16:14:38 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKw-0002Vj-Ce; Fri, 10 Jan 2025 16:14:37 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ALBtBc005923; Fri, 10 Jan 2025 21:14:24 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 442gy5tqy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:24 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKIpLB004868; Fri, 10 Jan 2025 21:14:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xuecwpwk-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:23 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:22 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:21 +0000 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=w7i5Tk1RbO0VXPKpnPE2xZgNZswwBA3qWAl5VM6sOXY=; b= HiiCGrtCNgDDXAi+fz6LUbZa3O3zZTZOjJjIXFs4G9EHbKobg68fVgldc6DiBO4P 6fc5dob8+gWfddMnmGtSo41c6VsvpNUUetr6MSGCMUKxySZU4JU5MuZntp6Cafhd gSaSCv/1gpmx0cccSlXhyuCT3y4m83cQbe8dGZeDLzrhzMU9a7EDOsxV4OcbrXFu 7LciHfCGPYWQL8bEwilltmyFu+Xo4iq0xlkGLiSzmo3VqGjMxmAVrvvqjySC00/C HUAge/Ibbj/Ip7jcqfgu8E+u8GN8vfqdfmCsT6APHDBLsV1l0hwZPB4qo/Jc2rEW fNUNyeEeQpoF6etqIdfMQw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WqW3T/z4oAB59yDGOrXoHigZXKDf+eAFanqnxYqBgOi6AG4WVcNMi7yiq65JJmEoy3wb8jvXHezrL7vPdTc8e92znH869h4NW6QOvrhXcVQgcq5CHoMdoquND/uaGDn1bBaMbo7ZBTFbwZikeiOEm13VTBErARsnmygEyaRkvu+akjaDDCbaPj0q2Rjzp3Gb/FeptEeeaGSpABgDFYctCAlQePYRQ31puOj5of7nFi4ygJoc4bwJCVi8rCrjiv1cGnnJl5BtzFSBbhLILIk/K6t0GMm6oRussfJKqc1tXA3lfj18yINFMKEQDLPhg8F9Y9SGcGWCUqz3yBkrGrtFsw== 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=w7i5Tk1RbO0VXPKpnPE2xZgNZswwBA3qWAl5VM6sOXY=; b=DSb0goLeG3yjbOOyPtVWujwKgMYbZi048JXw/VDpXt47aJoQZLFHSMK3al2u/g/8zcQYaGkGjqIDpMhcE37fcQEXJEAHgZnnSL3bwVHWybkV+1mJW6YMZdPytlvLjW8j571MNXaSWKijU/3rT0M7j6SyL72EDFMbLWrDDGE6SbLNNOxsSu/ERKdXCOdxga9uzPVYprpqppEEWgb8oSq+wcEFkDjam3B9/zUYET7Q5OhJCgSrcerWk3Z7clmX4K7qb0eGgLP8ZMxX/qc+5xvzYNLcSc+TWelhUf2Rqt3qa03tt57h0HmyCSUax+PQvudI6MQw0XoJyKTFCYxTxuJX2w== 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=w7i5Tk1RbO0VXPKpnPE2xZgNZswwBA3qWAl5VM6sOXY=; b=T7ZN3ntJkuqQbAJOQBLcGBLyLG8bN7GVMw+kAAHK1qUcVcs/uaj+OeT6craTeffn3BcneZ6lDvTUxx318Tl9T4A8wxAGY8EBvEQN5jIW8AnmBC0lcymOW6t9joKKeX2+XbL6IXDzidqoQ/+qnpmRUvTwoZATW5a2tIvUfD3C6M4= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 4/6] numa: Introduce and use ram_block_notify_remap() Date: Fri, 10 Jan 2025 21:14:03 +0000 Message-ID: <20250110211405.2284121-5-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BLAPR05CA0043.namprd05.prod.outlook.com (2603:10b6:208:335::23) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: 917fd33b-46be-4bce-9ca6-08dd31bbc0b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|7416014|366016|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MNakKXsV2fpE3ZY7snFBxL86TWzIAHZ1RUhlZJvl6VRnWakQCvDU/V9Uvbj3?= =?us-ascii?Q?VH26oL2/M1w7CwWzTCLAAtWgyJqDXYCX7KzkjlD8wY5mYOkhcmABo3rQAsP6?= =?us-ascii?Q?xQXk+hJ6NeatPm9CooLn+nMxx2sHbI8HNbRPZU6n6xpAZT86pyGGgrhPiolA?= =?us-ascii?Q?anWx2UkmTEP++41AQSm0GeGltKX26lmur4faHqL3IWIijFqU0abQmKt+KU/G?= =?us-ascii?Q?iYjszH+qYmCLyCo2evbQekwUvoDStnMsYoqm1582k+1bTzPUFVN+UkmmL9nX?= =?us-ascii?Q?VglxqOO/zO52hiMs3uj9/QupqEfXYh4PXvkzRz54riOFOP3Xxd8JelM2uV4w?= =?us-ascii?Q?ZUajAZD9TQdCJFvGyQ7Qg+96EKskciSmiceGwC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sHxl7XLHTvOuBFGEvuA2ptSOVC1P4yMR6KRqqueT6QtAPalgiOv6HzZIkn5?= =?us-ascii?Q?AtNA//4adasa/2Hw/IhsQyrMCgZMDbkMiIdrKKZ5wQpMPUbLNOjlTXVUqoCu?= =?us-ascii?Q?gTQEoLo+kVOUFJTdCBcXfoUHn07F?= 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)(376014)(1800799024)(7416014)(366016)(7053199007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Tc1NchbPcSoK8C4YHSNj/F1IhWlH4fB66FQTcEuOyBJ54oN247ud6vsurGwi?= =?us-ascii?Q?B9JYY7997B5I+YekJD6evDR0e4A9iaJCuhtd6MYcllP181AczUFH9aqiT6S5?= =?us-ascii?Q?wb1alLDShwhDtztJSbGn1rMHIamOX2gnjb5MKGKOuIg+2n1SOHxhLken3EcT?= =?us-ascii?Q?CsKhnoBrHNQp//8omn9RSbvkqKvfLfNeiiqZ16USXgRR3109sxWcGuuODPSK?= =?us-ascii?Q?0LGDKLLb66pJlnp7LflwH43eFq0BeVEBmWgy/icWNwhPUFobfNUwwMs0CvQ7?= =?us-ascii?Q?+v+W9wVxzXglRTAE/pO2PDgPnB9MXiTWLoC+bA9oelyciI3J3YVzXRSHxjjF?= =?us-ascii?Q?uDFdJc/wsEbowghDpS/e0X7CApl8ORn43rG4MBXzTwkGTO2N5JwKOnTSztYg?= =?us-ascii?Q?TfA8Toh1qDd3UhYUaH/jlZvxs9qXo9fcppbK2o1xUGKXdbxn8+ccEkdfgdmt?= =?us-ascii?Q?PYlB775XpzkF7oqn64GfJ62qSlc0yFWigA920l24KuCdTlLcql9rqnmCqBwJ?= =?us-ascii?Q?na5XZDJIcz5EiO2MO2n1LVOjL4E161t4rf/kCSupAUs5tgBNWSJg6vEMIsbk?= =?us-ascii?Q?7JptLunIumRZbizhQJ8mTOyKsvZKPHKMDmz+OosMh7lbV/21XqqIXbrDZIQY?= =?us-ascii?Q?fWseDsBye1EGOdvPLOPtjau0UNue9rC1G3594RsFLpxF6Q5pygvh4/QSBpmN?= =?us-ascii?Q?tw2P2pOCh69thosUG8FNJirrW425C1jMleYE+OYenaznkON9MSDIYS2yl59T?= =?us-ascii?Q?ir+JTAfCIstoFrE2VtFF4CB6E1j905LTHlRuD9pG3yC8wzQvaGrLzCsVIO3e?= =?us-ascii?Q?/gybWtrlLvyl2HUOJHJfCABlSCqnRd8wo6w3YoW5WFRudOcaF4LNySQQo50Z?= =?us-ascii?Q?zASQR6OAePVvKEOjet7Shj2Misg386c245kRZ9ork8XaCsAxu1BND5A4ACzv?= =?us-ascii?Q?7CfcwbV56iPMen7bIZ5B/PtDyxOKXHv6Jr1volX1LC0zFKyiDHdYcUhoeedy?= =?us-ascii?Q?RN0c7Gcos9LbvPf/dvgH/HWtw6m7B67Q3YlsWxNPRD7+3rFe3A4eUqfE96gE?= =?us-ascii?Q?6aujcZFi4yGsJC7l7KkjXFIT8klX4wmPJYHHleYxsOGppR0CNLoq/hA8mB/v?= =?us-ascii?Q?rz+k2aLCXnMFxt4oVENzYWFor94WbcRxu27sZe9MOdQyOp9l/wEU1uBALIaJ?= =?us-ascii?Q?yVUeWI/7tmc7gsuZGBshTxrS2YnUrXlroH8pjkuLLazVbwgBT9XUw/iKE0yV?= =?us-ascii?Q?/q7DSgLSg9izWQiAPAP0fprASk1FkS9KFbvyMRaSsqy9p+nLe5uALuUNsvKI?= =?us-ascii?Q?kjUVhDnusiYVooeZ7c4HmHIKuviNGWWmiRz7PzMOfdlHvEhJljIYbTZ8s4BC?= =?us-ascii?Q?1lKLim/KRmInGMcLc/U2kawyiT/mipC16bSEyL655Xxq8sA1/J/XzFtlmOnf?= =?us-ascii?Q?3LpLBv+2taIZvs8o98lr7xe0wMWrmguSAi0n9iNwxxpjI3i9WH2+CuWc4X35?= =?us-ascii?Q?l1VNnVPAMZmCUm6uLNOU+zJ2gSP3kU22l7NgH8cU66iH2naJHuicZairWQyJ?= =?us-ascii?Q?zlJeK3E8K6qw/V756Q9vHTGxqQC6lsq/mtm/fbzT1STwvRhFQdz0BASOZ87x?= =?us-ascii?Q?yQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4DQ6omdP8uN97dr0zDXzGJY2rA8CFMHohI7ye8bQIdnZ1FnFsS1JA0zshpExlf5CZvEsp0qH9fEKnSKdEAXQcgk+r8WbjIQz1Vz5OBvN99UW9GAaxLrHZ7pu+vvcn8ef9qw/OfV7MvhyLf7xeICUBJkLrnM4LPfYPPwRHs0xRnPFKJ8BO/fnvCId75NjFuNIuG+UmOZKE8GT/k9sV/E8CQVE/giPFUotclc7wQuvduR4IreoMq2JPN2TguEzefZdikLa7cZO1uhV47Fh7+MZ4YjzVs+Zk/dQw/t/fvT/jPxZkZyMmMXmFCHAcYIk9rVq+jWXdQwW51fr0wVfNRZCCEYxpAMz21nwKootAhCsp79rcXJ4KhpBfi7GmpCIwhua3E2EASHNTwRD0X7nUrKgjraVD3cm6zGRYO+Bf9cndwTqkVJK22ZZc5PInLsNqiapmD5yVB60qx6FG0+anBWSeSI1Cw963JQBK6td/mgEb41ZbXtr5rSWs0yPyrfNnp4ztE4L1pfOqYSEhK/SZVZnmCc+84rBL3PwKiDOGQA9wJ4LN+hMU2o7vzmpuiLERXqadR6cBSv+mXu3t3XN74lh16gLM0gcK0JxefCijSxYKw8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 917fd33b-46be-4bce-9ca6-08dd31bbc0b1 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:21.9285 (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: UKffb7yKWLsY5XGyXGsbW1wRMXmLOO6LrW2/EXhBq3EggsZ2xo8fQlouv7Znd0jmuORoXLX8JPgOTMshwq3ARqrEB1dPw7ux+GjByF25dHg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-GUID: rVC1zRBOjc4emBH8_xsV27Dev4FTkc8_ X-Proofpoint-ORIG-GUID: rVC1zRBOjc4emBH8_xsV27Dev4FTkc8_ 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=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543750148116600 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Notify registered listeners about the remap at the end of qemu_ram_remap() so e.g., a memory backend can re-apply its settings correctly. Signed-off-by: David Hildenbrand Signed-off-by: William Roche --- hw/core/numa.c | 11 +++++++++++ include/exec/ramlist.h | 3 +++ system/physmem.c | 1 + 3 files changed, 15 insertions(+) diff --git a/hw/core/numa.c b/hw/core/numa.c index 218576f745..003bcd8a66 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -895,3 +895,14 @@ void ram_block_notify_resize(void *host, size_t old_si= ze, size_t new_size) } } } + +void ram_block_notify_remap(void *host, size_t offset, size_t size) +{ + RAMBlockNotifier *notifier; + + QLIST_FOREACH(notifier, &ram_list.ramblock_notifiers, next) { + if (notifier->ram_block_remapped) { + notifier->ram_block_remapped(notifier, host, offset, size); + } + } +} diff --git a/include/exec/ramlist.h b/include/exec/ramlist.h index d9cfe530be..c1dc785a57 100644 --- a/include/exec/ramlist.h +++ b/include/exec/ramlist.h @@ -72,6 +72,8 @@ struct RAMBlockNotifier { size_t max_size); void (*ram_block_resized)(RAMBlockNotifier *n, void *host, size_t old_= size, size_t new_size); + void (*ram_block_remapped)(RAMBlockNotifier *n, void *host, size_t off= set, + size_t size); QLIST_ENTRY(RAMBlockNotifier) next; }; =20 @@ -80,6 +82,7 @@ void ram_block_notifier_remove(RAMBlockNotifier *n); void ram_block_notify_add(void *host, size_t size, size_t max_size); void ram_block_notify_remove(void *host, size_t size, size_t max_size); void ram_block_notify_resize(void *host, size_t old_size, size_t new_size); +void ram_block_notify_remap(void *host, size_t offset, size_t size); =20 GString *ram_block_format(void); =20 diff --git a/system/physmem.c b/system/physmem.c index ae1caa97d8..b8cd49a110 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2238,6 +2238,7 @@ void qemu_ram_remap(ram_addr_t addr) } memory_try_enable_merging(vaddr, page_size); qemu_ram_setup_dump(vaddr, page_size); + ram_block_notify_remap(block->host, offset, page_size); } =20 break; --=20 2.43.5 From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543739; cv=pass; d=zohomail.com; s=zohoarc; b=Rblc9eSJkSKyGFHV6OFRgaXZqE3stx3+Vor4tfg8lqfzdKwOU6t4Xh8NUEowqSGui3K1Po4AIJVxaKckJMT/S7NFTc4r/WJeSyaueS6ISTIxYSWrxkSZXa6A5tZqbAd7qLCBBRE85o+qknRln6HmMfP/e21Wqd0OiqLpjpjifGw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543739; 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=K+SxdrdX1InTxo5zQE56qa247cTBfeTJ3jhGnfvxBow=; b=ipZEkqnSVsLyDmd7E1Dr4S/XnrZlKQm6zCLDkUUlMMgB40y4fUgk8AwFJw5zL02mUeC1cbH4A9Y+jLJirLevkbobtjUZZNdHMdm8ccYAYpfiZxVYbKXoftyR5tMCTeJdd5XzJjLUkHbAXZsttOMXvoETj6HXUTW/SPnSCZQcrGE= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543738991182.97527752542794; Fri, 10 Jan 2025 13:15:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML6-0000XO-4p; Fri, 10 Jan 2025 16:14:44 -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 1tWML1-0000VM-Ax; Fri, 10 Jan 2025 16:14:39 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKz-0002WL-Ch; Fri, 10 Jan 2025 16:14:38 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ALBqWH013668; Fri, 10 Jan 2025 21:14:27 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43xw1c3qfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKUL48027457; Fri, 10 Jan 2025 21:14:25 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2048.outbound.protection.outlook.com [104.47.70.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xued5mxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:25 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:23 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:23 +0000 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=K+SxdrdX1InTxo5zQE56qa247cTBfeTJ3jhGnfvxBow=; b= f88xScYA+7IlLEGACmOzAAk+catnPLUNjICpuTY1gzl/FoHS2XzZbGIenbeQAob9 uTSfqQomZXIvoJCq3EG43mWf2NJ5uGW9koikmALOyrZdVy+xLr0GbEJmh4gu7xyz 9wvqkUD4DY632I/A7uMs6e1k+E0OcisI/rAxoXx0X4ct262PjNUWi5HdE2nskLke TA49pJoBA+bYREwlfvzoYOHLoXpXQtWvHjUAyzzCwImLJnZQ36+f2At2K5iEdWLc 8gezKd44nLEfcz6uykC3rU74gxRIzVqlNwH9FqsUnygwQAJoLknE/qDz47BqZVSW S/h9cQDpjIldka8y7ZNq6Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tnz773+lV5hRiLGEgVVtceUQHCOxrtbtAeWVVpc3hbTjsLvnxzyYHJF30foTsy3n5JXlTF3jpUwqQw4O5zT2B1cMQLDLUo4yB+z02q0JBHSyuO0cl7tP7F+vnKNFQ3NsKLlJt/R8Bvl0VIphLXVwxstr60/Lx2RFARVd228Ly7mkgwNzjGlSYRfeVXzC/HhuyPkFrMLmdU4L9S99pcs9z7Ci2xo8iyxLypedd+Vg6g/ZHsMJrb0nw739NFB18jFNyFMAips/Bj7gh8GsAJGoqQvSjdZqrkj/GtmMCBstnZTzNUSmpiBDBfnVls6U2htItd5rf6EXiY7+skHS7eKdNg== 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=K+SxdrdX1InTxo5zQE56qa247cTBfeTJ3jhGnfvxBow=; b=md6z3WASetaguBJ8U2BXuzgJnVFn9FYiRclsAPtV9Sj5EBrQEqJMBVj91sD+18D+O0k2TzXwyURbmUmhNSuxo1YBBTvwFQBaGmsyovgM2FrE8VXvhKDSXDD0y/Pc9Pam6bg+flVz897hH5W8sukD+8ooy2eSO7m6FPxcAxgE/rER005Oc6UQIZREFvKm360NaVfajxvidU/vA8Vpx146k8AXAwsxhC1RWuNbYTtSdNu6S4A1rJGy4tY8ZSdjEKpgfjrwfrfgcc75hDM9Psjr10lIpYPxEW9rB940oVeL45pUEC2VpI8S2UhFbacL0X2HYh2TTbXI9AhzoVq7Gly6OA== 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=K+SxdrdX1InTxo5zQE56qa247cTBfeTJ3jhGnfvxBow=; b=dACU2C/SZWYVPiL5xa8o27b21nKH2cqNg014FkV3vgs67ddO60SC3qcqvN00hZy3+R8DX3koeRoPEWt8cbzWO7shQXeLCChxPGZQq00s2wKJRS3LQdJCghQlteav1cMy+sn9HC2ORmCZq2Hp/dbj/qTW31sM94KOVwxysBjoa38= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 5/6] hostmem: Factor out applying settings Date: Fri, 10 Jan 2025 21:14:04 +0000 Message-ID: <20250110211405.2284121-6-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BL1PR13CA0242.namprd13.prod.outlook.com (2603:10b6:208:2ba::7) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: a47fc1a6-29ae-4821-645f-08dd31bbc133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|7416014|366016|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yvV+zdeAGhhwfHGOhGR3xVXSwby9/MAVnmA+1PyvFPbnVBWZ8S0l6JbLkdKr?= =?us-ascii?Q?BylN5uN/gdx82ez6VcQqFqmKQzgasEd0/WNa9AwKTka9LayGGqRc1Z78KlGX?= =?us-ascii?Q?R7qjUUhy5qWM9C4FCwTtGDFsheA6Fi0BW+n88p26zjMJ+LPY13Lq+LXmQ/eF?= =?us-ascii?Q?8zibT7UY0oTBvjj6daTH+QNpHUNej9GpPakYpagipO8TqI0V6l5Meo3ZQYPz?= =?us-ascii?Q?uYIUAqqcLj+UFMNYGQP1zJvkhzVX1ryXUS3m0CVzshJ+UfkQn1KF4vkO+HdW?= =?us-ascii?Q?jczHaKhqV35lz5NzIjEF18DuYJJeWnsq1RDj22TB9CXaPsJvVPpq6azL2DYr?= =?us-ascii?Q?U5w1lwVJ41qcTfX1e3KeXuMHN2c13dDWHZG23TocqDN12ZGibOAOhcjHgQ+g?= =?us-ascii?Q?isGB9W0zBYX1KNX+WnSIbGmjpv57bbPo5zQzR9tG8HNEn/GfRVGzf2xZ1qdG?= =?us-ascii?Q?buWripukTBNtZ5LQTutLwdonnhL1S4EZKrZKDe/ccgpCf5wchUKg9Bhk+Y9R?= =?us-ascii?Q?C3Bm1HZu+XmqiU4al4pcTVuLFLb7ibV7T//Mp8Pfhm0ns8C9OaN/xFhWbre+?= =?us-ascii?Q?a7WWzyf2V4DSrmZHGMQg04cUWLFl2WJLK1QVhnK667dRHO8jlSDg1VxCuNZA?= =?us-ascii?Q?ymcfMXrgZK+OiVVIiHGEyHFjYMO68GoiuKsXmPDUavB086EbVmXQpp5d4seJ?= =?us-ascii?Q?RSL7OI21zvcIS9EeAKQrcyxa/angU293JulrzToXd9u+AWZBEXDWwHFUwV2B?= =?us-ascii?Q?fjBmMkLmdVl7DUBmPSsH4cCguOFkAbqvyhspffrJInu+ugJi4/UtPgMRRAwb?= =?us-ascii?Q?ASVs0aa5U76Un1yFQnrvB/3iTcLk+pqxZ37mw/+BN7A66HPBDRqSgwA4r0ko?= =?us-ascii?Q?kQjhjCzqLxxEEo+Ljvbpyd1pKixqbsTEGVJRez6s3DbCr89eFQxNXLcsuTpW?= =?us-ascii?Q?/bZ+4z1C9QruCTvihkw3WruvbrP7Jpw94+ErD6upw99mMtwQBRkW9FenxZEX?= =?us-ascii?Q?FaIfny2Mh+4W6NQyk9Q/q5CXhn5A0voDIvJkQNbutPE0Xz6CFfEThS21Zsna?= =?us-ascii?Q?Icnw/iZWboDIQ+N9lOCIhJCaARfsCbxVLnB8dGOIKlwXxCwYHNikM+8geEiU?= =?us-ascii?Q?p1VqDzhLWlnSWB+irj2GNKUpDCi6MD9zQRCkfi9z/2Jj9Ptq/F5aZqQINEZL?= =?us-ascii?Q?RVuGVkuVRa75sT7+IjeCfv1w3k7QtcC/GOrklOp2ZwU7dniTErF+xqu2Wnb3?= =?us-ascii?Q?5QqaqBF1+DuoVMbTplNmypQ8x5FKos7606wDNUkx0oA4pS4C9R1vLFN34qIW?= =?us-ascii?Q?9urmj/p8X7X6EGw4jIppSFilpiHKnDETZ4spCsyCgbXejSW3tdGPFdNhP2RV?= =?us-ascii?Q?QJ5TydACzt3Q223FGctVNyklEpwz?= 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)(376014)(1800799024)(7416014)(366016)(7053199007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yMNyJSXcjG3i1mGs7+fU2GaPYo6sbv79aPrC4i+dq3itOCFXLg0Rz/uilCYI?= =?us-ascii?Q?bDsySVBVgwb9f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= =?us-ascii?Q?lQ/OELfa+2awDFrApFuZ9XptcoDXH7tei2JrLLSokRSDYIP9dwgRLyYjy2qa?= =?us-ascii?Q?saQJwx7hnBYVvlAR/SUgyD5NzF1eAtdECJ5/+CwKOm7BN2qxSx2ZHCxS4Vq0?= =?us-ascii?Q?42+j7R/LJSwduQA8mEWZLpj1/ytLG58gvKMnPIYItmx5BlJXo70/UCDnH/OY?= =?us-ascii?Q?LU1fBELWGsj5thh6D2MfHBDcLM5lD41iqU/zpetiCQTX2VtgkuzeWDf9Eo9f?= =?us-ascii?Q?ywu6+Ftab0zZUUvcTDfzI88dJr6SjKRbbX0TqX66x1+SIPpzkbemk+qOTgqG?= =?us-ascii?Q?kzy1ln5ffJlureoW6lBIGpc4zzpSons/eQJjyqfZZeQLP+8TisnKf7ofxec8?= =?us-ascii?Q?D14QMIlrfZzWsssA6QHxn1gxiVcpTPft7vp0F6MwL6/YfiPijUrha5tfufQB?= =?us-ascii?Q?cCUHjLtlxxI4xRzZhH4LTL7ibbDPnf+4SHw23FQOlAGmCvDPp+d+Dnid7Whx?= =?us-ascii?Q?E4VTFTTYsNRmTKVKJUJ+GP9zwkkc/VFO18gGbakkVAgEZek+e6Xz5Mv1bn62?= =?us-ascii?Q?e39zkxU/ibByLMEsJz8m80aMRzrxG7uG1SiQeOtbsLbVZn4a6bb2g5JPSzZO?= =?us-ascii?Q?hKr5jnt1nWsOGU1j+cfnb8cGRrMQ46+LIhtTKde48A2FGDj6xXyajrqFwP2u?= =?us-ascii?Q?iQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rSW7NpC8fN3QINjuBjdbEYbvQaAIFhVrjCWdTGErNUWa6qIGGZTQ/+18MjBB5oPJXzV3G2yuLTX/4BvJfepfdt6v3R9BQ4emuXb54Ov1ZwH0lD9Ab/CNeOF6l1E8fpqTqkUDRLhuw3l1WWjIf0jRLHK/EIpvoxfZ1zky9LP7kxRtY3tTfqElsA9++ghsZtBv4MoK3MLcQVp7ymfuKddqDZFLhvbpQZfV6p65wfXJB84ecc9ixsDJyC48IoPTXVFQ0k0tv3Z6sMCG7FEmoj4dRZ1dMrpgoHPrG/IHVa2LQzZjPJvgWliI+mbH04EtRPCEQ4bF01VK5+64RXrkw4Bl7dlJzDgWu0vhVZINYwVmKetIkrUC05IHrH+0c7TZwVn/gkG/lvZAIdRXJILGHvNPAjg/4H0KqPZEpyhJS5kemrpP52zXaKtiMLIJ4V25JIGiveUcpOZd+ymPaqRN9/iClEs1TMt5jW9H7wMjslsY/5N0Z6VbBo0XhMvy1r4AZ7hkz9+smvQrwbQGfLveJpT20+KOAyaozGWuCEhvpdqICGjHZieAUNZMaQ775LlAiVS4+1U9/dr5mJUY08Q/HwHIPeum3MhThsbYCaF8ErZI+bQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a47fc1a6-29ae-4821-645f-08dd31bbc133 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:23.1131 (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: G7BuYs1RyIVC3aHBZFLtmpQr9fZq9YGx/P8ZhsWxCypY0BLSbEgoo+t2LGm7gLmz9FQ1WIVh1+ehp3CN9RQnLFnR4/3xnZ/q5dkUwJJbBXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-ORIG-GUID: 3JXPAq0MZ4yX0Vf5SWOI_1hDPx4r2I1L X-Proofpoint-GUID: 3JXPAq0MZ4yX0Vf5SWOI_1hDPx4r2I1L 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=205.220.177.32; envelope-from=william.roche@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543740104116600 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We want to reuse the functionality when remapping RAM. Signed-off-by: David Hildenbrand Signed-off-by: William Roche --- backends/hostmem.c | 155 ++++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 73 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index bceca1a8d9..46d80f98b4 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -36,6 +36,87 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND !=3D MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE !=3D MPOL_INTERLEAVE); #endif =20 +static void host_memory_backend_apply_settings(HostMemoryBackend *backend, + void *ptr, uint64_t size, + Error **errp) +{ + bool async =3D !phase_check(PHASE_LATE_BACKENDS_CREATED); + + if (backend->merge) { + qemu_madvise(ptr, size, QEMU_MADV_MERGEABLE); + } + if (!backend->dump) { + qemu_madvise(ptr, size, QEMU_MADV_DONTDUMP); + } +#ifdef CONFIG_NUMA + unsigned long lastbit =3D find_last_bit(backend->host_nodes, MAX_NODES= ); + /* lastbit =3D=3D MAX_NODES means maxnode =3D 0 */ + unsigned long maxnode =3D (lastbit + 1) % (MAX_NODES + 1); + /* + * Ensure policy won't be ignored in case memory is preallocated + * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so + * this doesn't catch hugepage case. + */ + unsigned flags =3D MPOL_MF_STRICT | MPOL_MF_MOVE; + int mode =3D backend->policy; + + /* + * Check for invalid host-nodes and policies and give more verbose + * error messages than mbind(). + */ + if (maxnode && backend->policy =3D=3D MPOL_DEFAULT) { + error_setg(errp, "host-nodes must be empty for policy default," + " or you should explicitly specify a policy other" + " than default"); + return; + } else if (maxnode =3D=3D 0 && backend->policy !=3D MPOL_DEFAULT) { + error_setg(errp, "host-nodes must be set for policy %s", + HostMemPolicy_str(backend->policy)); + return; + } + + /* + * We can have up to MAX_NODES nodes, but we need to pass maxnode+1 + * as argument to mbind() due to an old Linux bug (feature?) which + * cuts off the last specified node. This means backend->host_nodes + * must have MAX_NODES+1 bits available. + */ + assert(sizeof(backend->host_nodes) >=3D + BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); + assert(maxnode <=3D MAX_NODES); + +#ifdef HAVE_NUMA_HAS_PREFERRED_MANY + if (mode =3D=3D MPOL_PREFERRED && numa_has_preferred_many() > 0) { + /* + * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below + * silently picks the first node. + */ + mode =3D MPOL_PREFERRED_MANY; + } +#endif + + if (maxnode && + mbind(ptr, size, mode, backend->host_nodes, maxnode + 1, flags)) { + if (backend->policy !=3D MPOL_DEFAULT || errno !=3D ENOSYS) { + error_setg_errno(errp, errno, + "cannot bind memory to host NUMA nodes"); + return; + } + } +#endif + /* + * Preallocate memory after the NUMA policy has been instantiated. + * This is necessary to guarantee memory is allocated with + * specified NUMA policy in place. + */ + if (backend->prealloc && + !qemu_prealloc_mem(memory_region_get_fd(&backend->mr), + ptr, size, backend->prealloc_threads, + backend->prealloc_context, async, errp)) { + return; + } +} + char * host_memory_backend_get_name(HostMemoryBackend *backend) { @@ -337,7 +418,6 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) void *ptr; uint64_t sz; size_t pagesize; - bool async =3D !phase_check(PHASE_LATE_BACKENDS_CREATED); =20 if (!bc->alloc) { return; @@ -357,78 +437,7 @@ host_memory_backend_memory_complete(UserCreatable *uc,= Error **errp) return; } =20 - if (backend->merge) { - qemu_madvise(ptr, sz, QEMU_MADV_MERGEABLE); - } - if (!backend->dump) { - qemu_madvise(ptr, sz, QEMU_MADV_DONTDUMP); - } -#ifdef CONFIG_NUMA - unsigned long lastbit =3D find_last_bit(backend->host_nodes, MAX_NODES= ); - /* lastbit =3D=3D MAX_NODES means maxnode =3D 0 */ - unsigned long maxnode =3D (lastbit + 1) % (MAX_NODES + 1); - /* - * Ensure policy won't be ignored in case memory is preallocated - * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so - * this doesn't catch hugepage case. - */ - unsigned flags =3D MPOL_MF_STRICT | MPOL_MF_MOVE; - int mode =3D backend->policy; - - /* check for invalid host-nodes and policies and give more verbose - * error messages than mbind(). */ - if (maxnode && backend->policy =3D=3D MPOL_DEFAULT) { - error_setg(errp, "host-nodes must be empty for policy default," - " or you should explicitly specify a policy other" - " than default"); - return; - } else if (maxnode =3D=3D 0 && backend->policy !=3D MPOL_DEFAULT) { - error_setg(errp, "host-nodes must be set for policy %s", - HostMemPolicy_str(backend->policy)); - return; - } - - /* - * We can have up to MAX_NODES nodes, but we need to pass maxnode+1 - * as argument to mbind() due to an old Linux bug (feature?) which - * cuts off the last specified node. This means backend->host_nodes - * must have MAX_NODES+1 bits available. - */ - assert(sizeof(backend->host_nodes) >=3D - BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); - assert(maxnode <=3D MAX_NODES); - -#ifdef HAVE_NUMA_HAS_PREFERRED_MANY - if (mode =3D=3D MPOL_PREFERRED && numa_has_preferred_many() > 0) { - /* - * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below - * silently picks the first node. - */ - mode =3D MPOL_PREFERRED_MANY; - } -#endif - - if (maxnode && - mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags)) { - if (backend->policy !=3D MPOL_DEFAULT || errno !=3D ENOSYS) { - error_setg_errno(errp, errno, - "cannot bind memory to host NUMA nodes"); - return; - } - } -#endif - /* - * Preallocate memory after the NUMA policy has been instantiated. - * This is necessary to guarantee memory is allocated with - * specified NUMA policy in place. - */ - if (backend->prealloc && !qemu_prealloc_mem(memory_region_get_fd(&back= end->mr), - ptr, sz, - backend->prealloc_threads, - backend->prealloc_context, - async, errp)) { - return; - } + host_memory_backend_apply_settings(backend, ptr, sz, errp); } =20 static bool --=20 2.43.5 From nobody Sun Apr 6 03:28:17 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1736543737; cv=pass; d=zohomail.com; s=zohoarc; b=N+kjC4xbfYZXdclxNyY4mp2Xy1JbYgQ+cS0GYwY2nC3vfl9HN1/zYxn879XXtr2schXW4sJCz/u5kVmjkEQRRWnpjuhfsvafbb90HIE3fl6PTa23OaoFPMtq/xUQTDcxoE0kV9s1L8Hz48TNr2OznVDOGV2LvNghvYEnO776pyo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736543737; 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=wkMs6C7sK8sOJ2wiBqwjDD3q4UylJA1RmKTNBANxBA4=; b=T3OPpEbubtlIXe8Vyvx3RhWlhZDtfo1PGDU67inOXDcpTO+P1yS2DCYGpCrvgbFQjye7gfIXo3X7crh6Nvhrgd2ZWZNP2zVJtU9GHCMrJCNCG4zj5llwBdHoDKzvpWRCOKnuBibzTcLR1Cp8U4BqotMfG8USyvAk/oWWcs+qDXQ= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736543737597521.4366229329531; Fri, 10 Jan 2025 13:15:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWML2-0000W3-P5; Fri, 10 Jan 2025 16:14:41 -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 1tWMKy-0000Uj-FH; Fri, 10 Jan 2025 16:14:36 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWMKw-0002Vq-Ce; Fri, 10 Jan 2025 16:14:36 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ALBxYe029153; Fri, 10 Jan 2025 21:14:27 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43xuk0c34y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50AKUL49027457; Fri, 10 Jan 2025 21:14:26 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2048.outbound.protection.outlook.com [104.47.70.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43xued5mxn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2025 21:14:26 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by BL3PR10MB6113.namprd10.prod.outlook.com (2603:10b6:208:3b8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Fri, 10 Jan 2025 21:14:24 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%7]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 21:14:24 +0000 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=wkMs6C7sK8sOJ2wiBqwjDD3q4UylJA1RmKTNBANxBA4=; b= UsdsBT6DYxi8SCD3YhXzuzVLPIHNfep0btsfqdOy6GYWKknRzyOinmMyDpTaMwqn ssqcj4VlTYkbk2XEEyDsRRycocxGjt8A9Sprva+iv8qdN2roADL40CuPARehldk+ DYN3DWkRozy7dtg99cNfizXZCkbJUUIG9gh/3hQcbUdVEiPKjosQDN8BtycQEC6E 7TtFUvfTsEdjqiR6WpvE3Ew6aOZxcFZ4doGDAGcvcXEiobQAFT9Z6Y+YzOwVWQjA ZEABfaYk9Br7BensD3s953fHP51pjbRfxOECebUY/LkOIroxiZXfmKvmMa+XVTRC pIBQ6ZcvsYxYXm2dncJELQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=knDHO3wXVPctYI1qm2/d1SmwkudbAGdVbwVyzAP2u6hwzMUBv0N2Cn6clCDTb/i6bMtCdy1qClcZpZPF4HCs3jgulEzErr6VMPXS1KzQvOaGf3mvkUfP01ZQR2VsfvgML8czI+7OceH9Ylpa/SynchuxNsktuX21KS4OGDfrS5sg4KcyvjD2YLq7L6QA5dvMNYjhIjEcqpBWvEqCEAFiVOz4LzthAmvIdQsDEVThjl/vb1JWk8QSqIR+4s+C9JWAV0bU+Vzre64GYDU/DJPYtmX+BfJa2Fo5UVWTbyG6adAzB95xu93UyHmbTNPIuKl4IAmgjPwlhN2EDMLHYSPb2Q== 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=wkMs6C7sK8sOJ2wiBqwjDD3q4UylJA1RmKTNBANxBA4=; b=svxIaU3sj2gLu+hO6p15j8QVgXSdX1HaIR7VHl+g6Dx1RaSgQySdFQKLCvLfcjyFGVGPcUus9mhRwtHB4wOMjfTyo1dmYhNnGKvNwvaNcF6VZoWM8rE26w+3laNtojMSENoQ6iD/7+F8Df57XJwRy2/pCTawp8yB2neySsNyRyBPYFV8YmxrsWjQV8/aLNSxev8E9P8EvofAs7glV5hXgAi5sYzVTYY4n94Uci4v1aYQJd5N6jERgsy2iBCsjhhvVFYwD6EgOd49dxOcjIPf6d+lKhEmqWdREHxH0k2o6pOK9VPWtBYKwLtMovCem97T4+fSKQ6iZfLmikV/0JI25A== 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=wkMs6C7sK8sOJ2wiBqwjDD3q4UylJA1RmKTNBANxBA4=; b=m+ELgm+pteZNydPt1H5fUBJsCIg3IEZtH/+zOCGqY5lMk1WEXx5nQ/4/kVjAxJpRgD61Slm+RmL4uyER7vTAO3HqS1+yw45j++OPiixPtFLoM1YE0VjFZ/OylmtHpEBTtGoxtF8QvPl0bGL+ds5aQpBRXLc7UrdQgH6U07kqm6U= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= 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 v5 6/6] hostmem: Handle remapping of RAM Date: Fri, 10 Jan 2025 21:14:05 +0000 Message-ID: <20250110211405.2284121-7-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250110211405.2284121-1-william.roche@oracle.com> References: <20250110211405.2284121-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BL1PR13CA0257.namprd13.prod.outlook.com (2603:10b6:208:2ba::22) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|BL3PR10MB6113:EE_ X-MS-Office365-Filtering-Correlation-Id: c293fe0c-6b39-46ac-de1f-08dd31bbc1f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|7416014|366016|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XntNov/0NkoXMF0w3NBZfzaEhhIR+vKklU/52b0FV432syXSGC61/0HqCk9w?= =?us-ascii?Q?acpg/2SiCkk6xBSp0WeGG8TIiIwBJ6iVu1jIkI8oeCNyL9HmJdvUme7NFhBT?= =?us-ascii?Q?UvQT6MvVlyWKdYwQ7F3Pw9IB5KpXyoaDRsJMuKm/nDf0gcYRizUR33LldKav?= =?us-ascii?Q?jFQdn0zHTrIpmgoicWoZS6l2+eeO9OGSiK2UJpv9zBSMTFDFM8IoulbL40Eo?= =?us-ascii?Q?X7d17/5jSjWzF8gMyqxYo22rwCiIHVEUe7UJIPXpgUh2zHJTcw0WZKa1dpUp?= =?us-ascii?Q?SGYMHahNq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-ascii?Q?XvtBJBiqkb4MrdqTXgXN0bLlqocotHzsNFOYA2ZZemaEzyGJLd9m0SFaCy8K?= =?us-ascii?Q?EuIMTJB05dqASiTiXq5yKKPYU/tyd14B8i4ZuLRu/20JocVW7O6N283WdgHC?= =?us-ascii?Q?8djNymDM4vmJeOgkdppAzOkKwGH8YnkKoxrHZfZWG7CbWu2rgmcTTQhnYlxk?= =?us-ascii?Q?BBaV4yGO2JWFr5Lkv9KYEm13orAs?= 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)(376014)(1800799024)(7416014)(366016)(7053199007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?64+ou7+DUKGHErgYyTFf+IlP1QZWeM1Ce8dr+lNzFgbaDDZ88AiV/6SeOhHN?= =?us-ascii?Q?/xJnLiT2QzkVD5sAKpA3vmrD2LIluYPNRPeA7fY6dJ9InStZx6iZ8rslbDBQ?= =?us-ascii?Q?PmOWUksASOhNAdLASoyRX7lWUGZQmiNFv3892RPpBBXoQ5haAxZuMatUBOtI?= =?us-ascii?Q?0V2Rn1ZZyTeQ9Cdij+l3mFcz990bIZnVuh0d8dOntJDSJTjl+EYgcDS7JUyG?= =?us-ascii?Q?cbNw8T20KltU72yPMvjams4+1GvInw5BcShREtvauyODyweSHtKuISrzFPwx?= =?us-ascii?Q?oMgjDcdf+I8zcunf5eWYQj3xVIr0O7Q6PaWERJFeQC9dzuV0YMJwk3mu5UKs?= =?us-ascii?Q?13tznu/kB47V0UPChUVSsP96v0cNOGTpjei09As4yKvJVjsm9VeXYlfOWr/f?= =?us-ascii?Q?FnAYvWbMOFoCLByEyqVWnSZEMiJv9vH8oJQ8XngIuD30dOj0dFMmiP86in9o?= =?us-ascii?Q?aq6a+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T65JpDkJ0Hc03n0+exdM2hSbsc?= =?us-ascii?Q?Kp+RoKLcPIe1Nz4OAaDNUqJj/LyonLGfCX7s5I5g5Q3nN7hQ/HU8WjUclpmh?= =?us-ascii?Q?GMCd7Jq78pX4PzDdjPEHJAriu6rEe8+Ow8N68C6gUbSHl/5rRQcxNordffPC?= =?us-ascii?Q?ht8IbmONkBq/veaQim4DUfzPnb7jCT6Ro9Hc1jPMR7ims1FyW2KuYgillQok?= =?us-ascii?Q?/NH5Gs/lmarGnNAL4R2FK4Dp+7i6PS6FdsQo+8VJloTEoih5TwizQyFiqh4C?= =?us-ascii?Q?nQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ThzyUfUVsp5j8bzmjghNQh3BbKy5AC4KykcMM2I7KuPHW0nyY4mstJe4+zxh8JSAz047iYq+UVBxzbbi2jaPeaaxzWXquSwrp4AEmkVPw3EJwv1kj4+yRYXFPYUM75tnze/kA7tA62rPb3zZwQ7sn55u+KaD+08t6MNYe5PgRmxjMmz/CCdRddJ96lHwCrz4mt1bEkiPbxmCIcyoQbD4YPd/K64X2jSJ4tXjBpOqDgCl67guzbCuzOIIZtkQCm11Mi9CPYuVcsz7xzOAM7HZWulihgWmvM476kEY3En11qCYRE5FPnVEBWE3AzYU5WSXRV6ur0ZdGgQ9d2dmaboUN7fZHRStPjXUa5zXtnI/YxQ4bgG4DW0MkUHDIKZWSodikN4MEdRtvLURlalDOvVqwwdk6Bqs+XLdIHKgUvEy/8D8r6SBIFtkdsx2+Eanl29QHTE0OJut3n9KXx6cJxV4m/mpKLL9NI2LOfUty9qhZJkRhNFENgkQWicObdxUUAxh+81lyLcTuqla3OPgndCTal2OTR6ZTGCx+mT9RF1y7aoqwcARiCiiAfq0EgLBVm7Sglhb3vQ4mlPDjfWcx/64zg3fhG9CRLuYjXCTvK8dVW0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c293fe0c-6b39-46ac-de1f-08dd31bbc1f9 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 21:14:24.0900 (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: SEYuU667FoIUe77J1Hu3ck66SZiSDjJoehnJPgcu3oGLqLIIzE9izS8WQ3rLuWGet+OY4RqzSWVnb9zP3IotCHQQZd1uS2nUfDjp7Daf85o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6113 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=2025-01-10_09,2025-01-10_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501100163 X-Proofpoint-ORIG-GUID: tANY9DuXCRva5u45w-eaQ_bEXLJMBqE4 X-Proofpoint-GUID: tANY9DuXCRva5u45w-eaQ_bEXLJMBqE4 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=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1736543738070116600 Content-Type: text/plain; charset="utf-8" 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. Merging and dump settings are handled by the remap notification in addition to memory policy and preallocation. Signed-off-by: David Hildenbrand Signed-off-by: William Roche --- backends/hostmem.c | 34 ++++++++++++++++++++++++++++++++++ include/system/hostmem.h | 1 + system/physmem.c | 4 ---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 46d80f98b4..4589467c77 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 =3D value; } =20 +static void host_memory_backend_ram_remapped(RAMBlockNotifier *n, void *ho= st, + size_t offset, size_t size) +{ + HostMemoryBackend *backend =3D container_of(n, HostMemoryBackend, + ram_notifier); + Error *err =3D NULL; + + if (!host_memory_backend_mr_inited(backend) || + memory_region_get_ram_ptr(&backend->mr) !=3D 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 =3D MEMORY_BACKEND(obj); MachineState *machine =3D MACHINE(qdev_get_machine()); =20 + backend->ram_notifier.ram_block_remapped =3D host_memory_backend_ram_r= emapped; + ram_block_notifier_add(&backend->ram_notifier); + /* TODO: convert access to globals to compat properties */ backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); @@ -379,6 +405,13 @@ static void host_memory_backend_post_init(Object *obj) object_apply_compat_props(obj); } =20 +static void host_memory_backend_finalize(Object *obj) +{ + HostMemoryBackend *backend =3D 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 =3D { .instance_size =3D sizeof(HostMemoryBackend), .instance_init =3D host_memory_backend_init, .instance_post_init =3D host_memory_backend_post_init, + .instance_finalize =3D host_memory_backend_finalize, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } diff --git a/include/system/hostmem.h b/include/system/hostmem.h index 5c21ca55c0..170849e8a4 100644 --- a/include/system/hostmem.h +++ b/include/system/hostmem.h @@ -83,6 +83,7 @@ struct HostMemoryBackend { HostMemPolicy policy; =20 MemoryRegion mr; + RAMBlockNotifier ram_notifier; }; =20 bool host_memory_backend_mr_inited(HostMemoryBackend *backend); diff --git a/system/physmem.c b/system/physmem.c index b8cd49a110..306e71861d 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2205,7 +2205,6 @@ void qemu_ram_remap(ram_addr_t addr) { RAMBlock *block; ram_addr_t offset; - void *vaddr; size_t page_size; =20 RAMBLOCK_FOREACH(block) { @@ -2215,7 +2214,6 @@ void qemu_ram_remap(ram_addr_t addr) page_size =3D qemu_ram_pagesize(block); offset =3D QEMU_ALIGN_DOWN(offset, page_size); =20 - vaddr =3D ramblock_ptr(block, offset); if (block->flags & RAM_PREALLOC) { ; } else if (xen_enabled()) { @@ -2236,8 +2234,6 @@ void qemu_ram_remap(ram_addr_t addr) } qemu_ram_remap_mmap(block, offset, page_size); } - memory_try_enable_merging(vaddr, page_size); - qemu_ram_setup_dump(vaddr, page_size); ram_block_notify_remap(block->host, offset, page_size); } =20 --=20 2.43.5