From patchwork Sat Dec 14 13:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908501 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27742374CB for ; Sat, 14 Dec 2024 13:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183986; cv=fail; b=bdWvFE1y9MIACL1LbBuVfYh4lg0dyGn0vjhVFphiuUIJlwF2JgDymDYAXHWOxUAS5wC/M34K1bMwelEBRtWdc/BO5+ajIrNe0tfdrsHFnyqoWV2hljS3Yy27V1ZsMkJKRZp/DhATsp21UTIfu5TLid3UHz4Ds/NQ46nAXW6fKww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183986; c=relaxed/simple; bh=EbzyNHwRCivtQRmBlowFWrIrbXV2RjfMA0swM/OJmtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=LXHH6MRJkxMNNscsTJ5DRFajsuTmiiZ1neZvppOIQauoq4FLe9z0i5O4SrPKtUrp+vUKqMS5oDHVarriWxyn1JLYHZxWRuN8lvU16gQ/ieyxZKF5LFpbQfchgEdQgK9y1/XpA8kvPwffAzx1CTcH3htfrviKMLvPx2dn8R0Q8Cw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=BFYE2DZp; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=K9BNOeGE; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BFYE2DZp"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="K9BNOeGE" 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 4BEAwEQD025593; Sat, 14 Dec 2024 13:46:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=D6njwfVDxDhYFFDjxoyIbiLbxpAhu2aeoLrNdWp/R2o=; b= BFYE2DZpIFMTNeaMR+PdKm7zvMG0pIrbsO0RlAW7IK1/BUSm5CEE8S8dU1Vjvvs4 cSaMD524L35ud5Bd8cfCR0hV9akTWTHY97pX6MpVex3K2smrFyliV8QgO7cPbPTC MQ749FvhKdlBowQJchRFnJv5iJzOXp7qTSJ0M4qFmzDQfjWhTV/eGl00YtFgrnLl S2MOrrjrAtzveaDnn+Bet4GX4P+cbUB+5eS3X7/mzC+/mMizLraf2yXMMp+msZlo KDtYBaFxbwt97fGB7+vqKPOE9qZ18vGzKyUbhPuwp1hK0OwIrjC+szLjJlSCcOFO vjG4vpTBZLDQA6CYf3ro7A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0ec0gu6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:03 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BE9bCIP011038; Sat, 14 Dec 2024 13:46:02 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f5jx7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nRvOvhqcRpnc5rwmyNHseybDSat6qr0eonWuAmCfWzSXfYCxWXvyoiK8y4rmJjaNQOqvUyFlwqXtwuAl8W1Y4Ml2DMhIwDmZlhmuI72Qg0gjBlxAm1pnhJmy6X3m88Rtr39UQYlJ5XFCL2caBMfYm7PrGv5YLNGxr+K4S597ZfQeTh93YLv8/PDFgw5UWM3z5Pvlo13FPOYi+NFKw1SaUVg/jQfEsNvBCUSUdcCy52Gi7Rvo55vsfLSHOX7nuuV+RKH5E9o7ePUrPicTG4ULuOIg1K8garXprNJ+M/oZucZ4DJvqkGMxJfdMPfrqyAwOUaoHMPWTAfxzC7GQyisPSA== 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=D6njwfVDxDhYFFDjxoyIbiLbxpAhu2aeoLrNdWp/R2o=; b=EaJaYo/o25tjWa+LupJqRbvyK27DycGLP9Kx7NATQSDw+KcvAGZ3rRUq41FlkNVypFEV9Wa2XoRFEekFlEBm0mE46PNhgk+P8I3Gpuiq3HLjovG2RMYsMCrdKbARSYOdccwjRfDyH1LkTpkAojS542Ck4pHETVLQLi5Oa099DU+Cl/1/hqh/oYPgItLMU5Mw/lF62Ih7ilL1grlfIYCPYmHJ426coECzCHRLH845PFR3awEDg3Viu0vuljHZVC85bIdatTp/W/MyRZmn1JfVw2jcAQMFYNRJr0BKeHt9SYPbnASZSbmWnyMEJ3giH3uIVQVQpyxe1S7A+Z8P98U6uw== 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=D6njwfVDxDhYFFDjxoyIbiLbxpAhu2aeoLrNdWp/R2o=; b=K9BNOeGEQRbA/668W8CxgoYlvEo5yycCOXz7cx+32Ty+OzhDtNPx8pymWbuxtq526Jlqitvg6+yxu986qPM7uRCw9BslLv9miuxYqOjdj/36r3dNf1KbdO4g3nzkB556Df4zCGvKJzy9ZnHPAv7h3Fsr+sFgxGU3W1I91aHk17s= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:45:59 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:45:59 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 1/7] hwpoison_page_list and qemu_ram_remap are based on pages Date: Sat, 14 Dec 2024 13:45:49 +0000 Message-ID: <20241214134555.440097-2-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: SJ0P220CA0016.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::23) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: ade26d55-d98b-4939-077a-08dd1c45a46c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: u19TGTSrNgW/rkr/tRzzQQVS/wHpX9te7N73NRa9cllRwUdtk6JS4mF8++buJHCo9yUW700j0nCByn0qPtEqSrI8qVgqJXDTDSnpfoeBNthCUaZMJ8LIEfoj4jCTAOyxd0pBLYOic7zaX5tapiOZbgBp1XnFj64Dg2pht2pFidA7FsixyGElHVdMedi7BEoyQ17IZj8JlbB9GQhC3jcLip3jKhkJJjoCMQtkQ910hWz0h3T5Juscl/soB0quL6SL0VrLKR/IOiBV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5YbhFY8gKi2FxNzvh2xPbFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NrOTnPeFOVKgkeOI+9s4XJBgV84yRFskBkJEVBqHzkuOd60pdiQaeC6AmoXUfQz6nPbsE2x1kKP9BAKFGjDNKWt6E24P+SJc5Ir4onkGTqgMzqM7nScgUu5FENJekM9nWkKctFigLKT4CBp4nfli6m5MJk2qCG2YTe//IgbsP02CRFldrdr3ymgjLfyXh6iniOlyEmAwbu3yChB0rJ/MlAl18CswM4oacXvhpQbvDQJhKMdMaSrCtU9yHJX2bVrPregSaHZS2BJEd0dUcbNUmrMjUpNzzuaJVZBCrbKTTTCNxVfR0wbuSVzel79lUJN0csRXqo0qdTkbUGXJLUlGJelDuSRGL7O/cZSIIQb79LCmOHxyjfz5Kp3fkyYPz3tNN/0f1lgiQKp9tjmyucSxjvddzbqKzhm5XTXsjiU90Ue4wVADz2ngoi2+OqJxH5p2R03QNikt3twWeftcO3ryoCCcrFoYE9NdrRKoMnDQ+7XD6zr6GtkHmc6qxrQeQL/88wkZ0WgEEisPmkFXI7kOTn2r9f8/xiGl0J+/wB1B//tpHBzY6k2c4E0htOt/1JKtNngtVgWofG153SCp/9HcfR0AOPu+1MWIbFcqr2KjJs7+nMkLUgpqZxFM2BwIXl/on0EQy9pbbPN4O1/iVcFtpO1qxu5FnyXXMFJhOIVa5dLNO0964DxTMqYBsrSGyDrDNzuqxpr6HjG8OvvEvyCrrSsjhCmRY5BiqrGMkWoT2UOjbJIZg2NLeU2E2Vvb1pSjbGBdABCGDcE5Qo8U0Sd3sWuVl1h1bT1Oldi/DnA5CatthDpOzGvoQZgYiQxIEHrIHCTCOAnIm058c5uYA+wfioNwnhcdEFUqtKxomdtoQGoiRd7FZ7YmngHISg+iMQnMnikl60siXCPL3n5MKrGmpUhmJERZItre8GJrzNLGzQ1UZpHiFGRl5lghTtTjViJ9jok2xect/cEPnXNwvwggVfjGdveqOlpS1zHlU/iCyHsNht6jDtzQvUe4MuYUvySIEFTXoXi71oyDFC2WqzlpTOQYBn6gpiuDKz9n8D8hVkrZZHccTpRgkDK/LbXbsaskVSY7i0TFal1EpImLLdc7NNiAYFNZUqHpPAipjQnWp4kkr1UhtHUn2hna86WmaZXOhnbBK4Ky98MLV3NFePpi6ZOb/yOfHyZNhtsX9JnPL2EyWxXenY0JwhniPFp6fAGptezzX7KDDxL5P9OoLVgRhIEXjmjtM09C8PUmot3KGqhBzKKElVT8fzHMUirnxIj925JF7MMT+K43NE1VS3Ld6F+GxGx4DQRtF6r5CT4i9P05dUOCafy0J1KaROwETB1vjCrVONBy+iWSDVccXmzVNBViKhati3jfSKj5A/Sf88aXfPm/flAuQ26So1DSVqmSr7s4zIkoPpYVkbQ34u8jpw/NYTd/qH9FLLOkWEeEs5VrGPNI7kfxI/J7fh+eB0rbAPuLF7KLksPfSHWPUquYH+WALC3Xhdl1CcjuiI30QLMLPpv3raT+RyttEp1lHarsDihR6IKC8bg9I1aKzmA7kspC2vdeFwGYLEblm2yf6S1X/V1Qu5nfUz3fnbNlJg8b8gJfv/3kj07d7F4rEOpZwQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zUSdPcZkCJ+Nl46aT/pi8UTGwIuyd9uErlVOaFOywFLpJAdG5ia55TRVNucIjrNxfgnRv18J2I9aMiog3VsKOO7SokDMOBCxTw6ZvasWSAEgfHCuX3fuod1AWX94XgZvFHRMapMDhigO0mxvUz54RzBDLnQ2UDOq0w8WdqgQYoRiv6ZuHejeGZHDPpUShFr7m/VNtti146ILndYi7MKbYffRXSpUpIO8PVhoEr6eiesogXk7kk2q2B1uPpEWCwfRveK9ypqLhmQ7AjgTRndmXwoaqvXyGHp4aqDVqpKjTBN5y0ehQw/HLtnsmCb5LpkCD2hnPQZmeSAkCXoStYr4aF7SSMrAQUq4qv6LnTePic02F8YMddJzZv0ZqgvHaZ8cJDbUPM7ZJPSDT3IvptslVleNFEk7/gK+keai40DCfQZLY7mCi9V+wD0iwIAd8tNkP8GGCDyKZzNNb/mo8cKo+FQlY/SX9qgOiHGabcFsrsEUp/gSrzbL0/SibLi86zviJPb0I5NcbV5hJV1kQ1V0RHhCkIPVH6YUckNsV7thVWoIfb+FmxYfWau+beZEc7PyMV2sADVxlCXf8wOuvOQ0KjM2Q0iAGEH2PXNkuLsojbI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ade26d55-d98b-4939-077a-08dd1c45a46c X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:45:59.5183 (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: tA671FqcUndgkeGfkQONgZEikCvimqhhC0foRtW02Nw77v3FHgntFRN73JtxedaWWURotakzurliPTf7wyqOJwKfqaA63J1Ywmxmh/8zmuc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: -esaKWJxFPL6xg6gjw9-wb67M9jygvJj X-Proofpoint-ORIG-GUID: -esaKWJxFPL6xg6gjw9-wb67M9jygvJj 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. 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 801cff16a5..24c0c4ce3f 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1278,7 +1278,7 @@ static void kvm_unpoison_all(void *param) 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); } } @@ -1286,6 +1286,10 @@ static void kvm_unpoison_all(void *param) void kvm_hwpoison_page_add(ram_addr_t ram_addr) { HWPoisonPage *page; + size_t page_size = qemu_ram_pagesize_from_addr(ram_addr); + + if (page_size > TARGET_PAGE_SIZE) + ram_addr = QEMU_ALIGN_DOWN(ram_addr, page_size); QLIST_FOREACH(page, &hwpoison_page_list, list) { if (page->ram_addr == ram_addr) { diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 638dc806a5..59fbb324fa 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -67,7 +67,7 @@ typedef uintptr_t ram_addr_t; /* memory API */ -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); 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); /** diff --git a/system/physmem.c b/system/physmem.c index dc1db3a384..2c90cc2d78 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1665,6 +1665,19 @@ size_t qemu_ram_pagesize(RAMBlock *rb) return rb->page_size; } +/* 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 = 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) } #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; RAMBLOCK_FOREACH(block) { offset = addr - block->offset; if (offset < block->max_length) { + /* Respect the pagesize of our RAMBlock */ + page_size = qemu_ram_pagesize(block); + offset = QEMU_ALIGN_DOWN(offset, page_size); + vaddr = ramblock_ptr(block, offset); if (block->flags & RAM_PREALLOC) { ; @@ -2191,21 +2209,23 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) prot = PROT_READ; prot |= block->flags & RAM_READONLY ? 0 : PROT_WRITE; if (block->fd >= 0) { - area = mmap(vaddr, length, prot, flags, block->fd, + area = mmap(vaddr, page_size, prot, flags, block->fd, offset + block->fd_offset); } else { flags |= MAP_ANONYMOUS; - area = mmap(vaddr, length, prot, flags, -1, 0); + area = mmap(vaddr, page_size, prot, flags, -1, 0); } if (area != 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; } } } From patchwork Sat Dec 14 13:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908504 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1487117E015 for ; Sat, 14 Dec 2024 13:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183990; cv=fail; b=dQqUdjmVUbPVOyBuSEhrbELy+euRVXjDJZfZiOXFkfjtZfGypXQPYJht13CgD9ne5K9kWtu6djIbY695CnnsMBnQHd1xdJ+YoyqlhJUteShcLVQVKe+NLBHAuw8mXxPMzCdM2PcmtPzrLuhkMtBOy6Ci9rr25AS/87UmOGQRa6Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183990; c=relaxed/simple; bh=zS/jQYauT8BL8/Cc80hpxNF9L+NLDJawb3OD1R8JoJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Qd8s2OBCq0D+xYG3Hu8yhDzCqmtAr+2Eykqzcj4Mj4/0aESNkvRXVmgQdwIoAxiyXJ6PGzkkIU7t35M2PpM2+D0RkU7wPT5kiGt8JdZkRVmQVFUonrCgkBZRwkxYQQCaO1XZxYxYitqTLODhcWCCWlyHOnekmLQoOAWecjbm4Do= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=BHL4rdyv; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kiZJbGr7; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BHL4rdyv"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kiZJbGr7" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEBSN0U028037; Sat, 14 Dec 2024 13:46:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=CPzAcY6OV5ZKPJE2OpZitDgEjWpc4olbj0hZFwGGVy4=; b= BHL4rdyvb+ZAte32UTdru+pKjfJipAqkYFgQ68wRlGXkwxqymOBKrsfsqEXGHmgH /k46yfd+KA72hKbsQuzO+fRGHpd+Gk1maX8QvFwP5Pl/VbGL7Th7YeQyNYj2+bWP 0SWkSvlA8BqpHml7z0Cg2V8bFf3e3nrAqAx1lYVrgLB+JF8//cTQYVHliZLsIxql lSHpwnu0/VIIpvRUWoHIBmpYLTKd7noeSYH+OXpdSBPF2fxuRvcJ4bUYnd9CX1w4 q1tPi6TJvDiRULD1HvMFAgkbUrvRxthVX6N21iwxkgrXRPegpFzFTqyXk4DmbMVF j7zMYnf637BSCgtucwO1og== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0t28gmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:05 +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 4BEA1I9E006344; Sat, 14 Dec 2024 13:46:04 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f6k075-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T+tYICUn6F1jlnTc0+jRJXAjfpo9Xzj98utV6P/uJrZmssvrIHn1QZVcsgJdebtchBSgjlWV/ybRxRSmfOew4EljGjJQSnE2ecZH3qu08CK1n58IICOSCcr+YesPPEPLjD7MNfqxR9kB/G/ZqJGeNK1MALFY4DMBOtS4iTRjpMqiHXegqIQTiIKKaxDyOIpliybBjc3PlECnTqi4QaRTUyiM03L8vvV/YCa/jMyhdcvlGfzXtp6EDCCxFTANJ8AWHt71qHd5yAtrKWQN0nSXwSK0vKNxmdW1h+Fy0kAWLZQbLG8ZMjfMUVhT+Sqm2I4sfVp8KF5fgVcJ3Y8QsFW13A== 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=CPzAcY6OV5ZKPJE2OpZitDgEjWpc4olbj0hZFwGGVy4=; b=P843tr0LPEbePebzSHCJHjj7dTfz865sMn67oRstzjZCDr9/DXZ7I05GjkTYco8NxEmb29F+bGswBu8v06+j+4eTeM3wBibdECf/7439XxcKNTrTO7IQwUltnGSVhuRMrr4bZqIs+7Epq2iwkMX6XeJ+JaOtBolpTI6QH2mnop2A/OQqJBhsZFubp91/2YiKj58nFhTBSUXXVVIeihl268KlpthH8Tlz6pHbAGv5MzacOqjpVtbwXi+N4+l68N5ZehblwLHIxh9WCt5Qucepan4lH6/WYUGqMEbjC2sM7Idanqpbo4qSD1XIqysPwZIpafiKawRKrG9yjzLmS9z5hA== 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=CPzAcY6OV5ZKPJE2OpZitDgEjWpc4olbj0hZFwGGVy4=; b=kiZJbGr7bj5A6ChXaF/UNRiul0RyE1FERii7vcWFyd2E2WjwzCVGbY4eMd51c4HyfXlSsskY95uc2BBk5ZAsSqX6sFzKU0tu3HAZ5lDEQrahx8pfdOz6wYrgXREFfn/UhIsfyMgF64T8gYRZPDriRlfaO3vDzY1dk9KFVDOEWVc= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:01 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:01 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 2/7] system/physmem: poisoned memory discard on reboot Date: Sat, 14 Dec 2024 13:45:50 +0000 Message-ID: <20241214134555.440097-3-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: BYAPR03CA0016.namprd03.prod.outlook.com (2603:10b6:a02:a8::29) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: 473ec113-e89e-40a5-ac19-08dd1c45a5b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: Tb51+MJt2RSdHV4SABVdxs0LLGKg+v3/yk/qg13XcDE82M9VF4uHaxR9eEvUe4yN5fKDV7ZtssVX2/rFwJsNJ7CAhKirSKUN5RdsKxjBJCE68ifhGN+jGXPK3qDh1YX00d4GMmLrfhLDoH6kDP3PqXwQxu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2pGV/mzYe/zYsAKrmOMKLQOgH2EMLrrQ8V30uq2uWyzRKBCp5VHuu91fq90SjjxaVO2KwaATojS/nwLkkACtgNtYY6j6sP4m1uJ57maDVvg2AbLm0kZXFw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kynvIpnwy1T3xHHggLEVJaA2IcW7nC8xY31dqrTtK6Sm/o0ne5FCOxEEZptzAUhawhPiqSiM1MJqnUr4CsXSH4+WUuWBcmIfua4XyDj/uypP2SbbwX0dQbtOqkVFCoYtMD5xAV/uBUKPufho7DyYYsbokZEf/nr5ed7+CyVWaEYIaw9Jx4q3HQXXRhEKgIr3qMTI22r/vC0sn/WY7vSlAb7zAgj5Jfw/Hm3C7/gvRQNievz+bkcswSsSGAPRvrqOZAISViQv+loSBVyeOHsMDX6xj60ESt0+unHaHhC/7WYKegLPN1h0kXiA5S0RS4K3jWzR9DeJ1CMO4I8oFgrD6bQxXlkrZhkhf+crp++ay5CMosyn8kvrbkr/JJ9ZQ68SHWQxO+/UFAcdKszKpHdKJvtol79t+OTQY+W10uZj4xApzzOxWHjI8odcXT+2aD43zcB5fwqup5uERlHafoImuVBYhqK+yNwC2kUZMGDXlEMjX3OYmoaSxAt0hYOfWBl0xLDnfGnWC48w1QCrpw4jSo+0q8x7423sHrLXyUqcH2qHaia4qGCO/MXMxFOlqxicdsH6O7XDIs/A2MHt3Sj/JjRqDirb280u7Uxijcyxr9SMGnVxQm+l7wnaUPz1HWkUxOFrDYS1TAS04Rv1CS8PMVowh/pKRvJJ9Pv/tXsRSYcehB0rEOTI23H7ENvYhhEddriDWgu/YiXS5BK3pQN1TJaStFPIW63AfcRODxI2DbsyOODl78Pq8fq7mOZSLUe325gqd08CyVuybeXfuRSb1umP097BAOsSbiNAZP7sdli5czA1do7aZb+jzU9sUJ/4xljxjTW3M4a+2wS83ZNE/pBfd1QH214b99Gjbb+dKBmk5YZ9gyMx8id4laqdtT0uAgRQgmCJ5GNPHS9QrLFIAbJWyFUtpo+5kyT2P/Jk158op7UP/ui2h+OPbi9L4Svdppmg3R63k2QTu7GKHfKmzQSf8UslotgC0U6cTOVVgNLq3Q7JfRvKM/BJ/pdVeoYauaATJ8MszYI6w+Xfsx1bD277aKdhZxTerr5qy3Nzwr8tcMihxHkIEu7p//AwFO+4QmNbl+KsIASr1GfBUxuGNjDMixjbkRL5b8zMyAs59uJWgIChn/Q4+KOC3kVU30dxMnvzOi0eCnKE0/ZkPO/y9O+w6qDBulpP4Wc6I6vHXhbwekZ+DmD+sA38f+v05VciJInXJj0x5xCyhXQJMuuvUqUdjpkysh8/5XqbCdO325Fv+UwFQisnuUWsuB2ygdPz9ZMSyblf6fBQLNtrYrCgqnkzcP5gkCZMMN6XFnQMir8h/ynd+Qp2/8Dj9AzF5iqnid1gZfJnmj3EsHR439+zIIwH+5onXx+UQXlm+SFx4OWaDgOwJW3XY32Y+QBT8ZnwVTOPxlrESz48HMD062JQjaVDA+/hBSmXOx+8aYspR2FhkbTd/kmwDP+OBgmbdp+bjPg2fZI7GzQybovxursuyq13i6zuX5q/KlnPO1yqAXwp1c1SbnOJsyauvcldrxxsDFxOft2Dvbejjgu+F2w98vBaLiuTDe3ypII4a5cABOR9pPcPFPSWk+jRoMp0W+wFrWgSfC024VNSo5qNU3IL4w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ghodUF1GsJ2MrEmD8rp+FUP48mDoGQ1SJ10oMS/u2NLe81e9NIE3A3v9sssaTUhiCcT1aLPK3npo1pSJKVE1564DJZrX77h5UUEq1n+QH7lUazW5s18edyc0uzFx88IoeygbFKYhY5iDwgxecmRHzSP8qlBlPZwGyOtttCpo7vJlZrnNXkBBiB7R7ty2mNSYm11486y5E7QFPSJGDR3yBYjPhIV8mRt+UUGQT7VOhO0QsUrtF3jtXffsln8PesF6F+H6FV4uYxvuO5dqcTTNLRPTt2TF7waG+zP6fxaKLa3E3ToTFpYyfiFMhHcIdsWSb+5PDWyCbgSP0kfNK4j2GEWzhGLVDunCbqRxx5FrodZll0YgnUBYGKKskXmabAnm22jjEZz8ya3OD32C1Zx2LEtxtOgX8g3BeTlIr3ohavmkrTtsTPakFLKYFe3rRiqOYfZn5DClhqUmDQ6/GuVLnBQ/ED3t6tlayf8xKEQOb5heeUnWDIPoqpQDXaCvY/JkemV9nHbX5lm+30nKVXnGn3cheCCxv0PyEAsI3af5M0GibmDlq8xEaP2sTbmyAwh4PsXR0pOil9+Jix8qXgbdiAr8EeHs4ZW5NLjO2TEAOMU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 473ec113-e89e-40a5-ac19-08dd1c45a5b3 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:01.6441 (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: OlXwzxO8YKsXBTGaZieua0YTZgq4ArIGvzMIDMwvxnHBhIW7gCPvLyS5fXaNQzAljC4nbXHMk5MOOy2b1/Kp2tr0B2b/Gg1dyrFoTnXdteI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-ORIG-GUID: YLjYG196WYm5vUT5_UPrDPP35B_K2yUG X-Proofpoint-GUID: YLjYG196WYm5vUT5_UPrDPP35B_K2yUG 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 | 63 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 2c90cc2d78..b228a692f8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2180,13 +2180,37 @@ void qemu_ram_free(RAMBlock *block) } #ifndef _WIN32 +/* Try to simply remap the given location */ +static void qemu_ram_remap_mmap(RAMBlock *block, void* vaddr, size_t size, + ram_addr_t offset) +{ + int flags, prot; + void *area; + + flags = MAP_FIXED; + flags |= block->flags & RAM_SHARED ? MAP_SHARED : MAP_PRIVATE; + flags |= block->flags & RAM_NORESERVE ? MAP_NORESERVE : 0; + prot = PROT_READ; + prot |= block->flags & RAM_READONLY ? 0 : PROT_WRITE; + if (block->fd >= 0) { + area = mmap(vaddr, size, prot, flags, block->fd, + offset + block->fd_offset); + } else { + flags |= MAP_ANONYMOUS; + area = mmap(vaddr, size, prot, flags, -1, 0); + } + if (area != vaddr) { + error_report("Could not remap addr: " RAM_ADDR_FMT "@" RAM_ADDR_FMT "", + size, block->offset + offset); + 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; RAMBLOCK_FOREACH(block) { @@ -2202,24 +2226,21 @@ void qemu_ram_remap(ram_addr_t addr) } else if (xen_enabled()) { abort(); } else { - flags = MAP_FIXED; - flags |= block->flags & RAM_SHARED ? - MAP_SHARED : MAP_PRIVATE; - flags |= block->flags & RAM_NORESERVE ? MAP_NORESERVE : 0; - prot = PROT_READ; - prot |= block->flags & RAM_READONLY ? 0 : PROT_WRITE; - if (block->fd >= 0) { - area = mmap(vaddr, page_size, prot, flags, block->fd, - offset + block->fd_offset); - } else { - flags |= MAP_ANONYMOUS; - area = mmap(vaddr, page_size, prot, flags, -1, 0); - } - if (area != 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 + block->fd_offset, + page_size) != 0) { + /* + * Fold back to using mmap() only for anonymous mapping, + * as if a backing file is associated we may not be able + * to recover the memory in all cases. + * So don't take the risk of using only mmap and fail now. + */ + if (block->fd >= 0) { + error_report("Memory poison recovery failure addr: " + RAM_ADDR_FMT "@" RAM_ADDR_FMT "", + page_size, addr); + exit(1); + } + qemu_ram_remap_mmap(block, vaddr, page_size, offset); } memory_try_enable_merging(vaddr, page_size); qemu_ram_setup_dump(vaddr, page_size); From patchwork Sat Dec 14 13:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908503 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A3A41940B0 for ; Sat, 14 Dec 2024 13:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183989; cv=fail; b=g1qcUQBeEBKjQLCprm29BqWFMzQSeUQ6R7cZcR+GEGqIvyULfIyJoKw+a7US10Tp5FGUJC6h0Nu56aeW4iikgU2CV6YAkiRkFfYyrv2NR2iyN/LAyONoapjLkijf71HdPCL7fy/ITZXaZ7x407Eje7bx75yKVtXrr3d9zlM40jg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183989; c=relaxed/simple; bh=oiB/ESeuUgC/Xr5waVMiOY7sQov7/Mh8zMg3E2i/zTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=dMu3zmB1OCtU2hgfBIrciJ4bmNYL8zoQcNQgNqTaxyBxApU1X6DHkmrz3902u26+EQd/1XuwpvsiCk7UNV+qxGfUHFgvl2B+EnRcbMApx1eGBoFvq5Uvk5ZyAcqLoN+zwKxEKP3FEYv6CB2piRD/8R19HvsAP8vOZgseHh3Jjzo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=U2bT4TL/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OtlDpJy8; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="U2bT4TL/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OtlDpJy8" 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 4BEAXNPw029756; Sat, 14 Dec 2024 13:46:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=U6mctM848n0Yl1rSK24XuQE3Ix9mH32JqdfBFct/Qek=; b= U2bT4TL/SVeKUF41rOa+lJYK6cbGaAD0m1quTtOSJYBEicSMOIbeZNkZWVfzxJO1 rLR/m6Gkyyy5EYz/JwwvnlKHbu/Sbgul5Ny+ypwujbmUhgA+PXhHEzKDPkIvCh2m XIw/14oTdyOizDnWnDH8PPrprTYYERsNTCipcAh5yfzvD7rWuq1iUzcGKhvOE/YC CDUwGH7dYfFNXTJqN3wxyVug7u7YXm2iOuGx69inPMY5I+71JgQNsiW/tWz/hgDW TkXF4oGsUJeSSKp15QqI7JpJr4qQ43DfdB8OAt53UMGXrRTIt54lqhlarNf/0IdC dZCGiGDhgGccyLnX5DyrDw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0m00gh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:12 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEAHq7F032785; Sat, 14 Dec 2024 13:46:11 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fbu0px-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bEu1BreJLSeI0zV+S6ysN4wLmUMC3A+Vk2Yw9mxUVlsi8llSeV3yI5AdXF+cQdzH6mUMd+KDk3ZXwH6cCZY0wm68cus1CdNvZ+Lkptrf/c4bpYUwjO6JhLJfvhhFD+qtTBZeU1I6o6tSlIlbMgspGHeuSkinJkdo4hy9pW91r7u5Mar2xD/Zmo9j9N61OXAjw8oTOlTL6q6HZwyuFQURxsMKDs1riCSvw2vDR2toUbNn+fcYoHkfUIYzNBEXFuq8L9C6b4IIxAQ0B8CXE4p/4Zi3vCiOf/obo+edrKW7pziORBFk8E9vPp8U+xWSBZMA2Iciqk+OfLFIdBWyqqg2cQ== 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=U6mctM848n0Yl1rSK24XuQE3Ix9mH32JqdfBFct/Qek=; b=T64nxhzAFx8yrbPsdUe1Ue76eKQSa+lx/3R44jHUjco0UmaqKSCQND8AqDM98h6XFXlZbEU12Dxcy0h7G0KN9W5+X7Go9OXTtJl32Q6hcCHd97SQViBi5Vgm14oW86F4g/SNnZ4z5EDIpTjnpr5ujYNGqYtDgNSakfUU4cLZJuaa5Q3kVN4fozFgNRt/RTjt7/UkDHG4UmBkonmBwheSHCcPfaNdDpOF2T5x1ZI9mpoVW1iz0b5LSokKBfRcMDPpmAYXmPZ6kUsfK34M8qjdYlhERbtEZ+J/7z9zlZn1gdrs6y+ceVK3dV+VUv9zIcmyqS0DOqpFhpKIE57Y23dfSg== 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=U6mctM848n0Yl1rSK24XuQE3Ix9mH32JqdfBFct/Qek=; b=OtlDpJy8APh861HqmlO/9rfDkn9G2F/EnL6ChqoY3w4ZHyh+SNrNMAPf598aH64ajdt8nHhOMZbj3vJoWl/4QukYR4uLsf56Iyq4AxkS5GRZ1hOQMimIUGf6yqXQr9zYHjVsIG261C1jq5CHjAozISADfv/9wyUhtL0V3Oy8G9A= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:04 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:04 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 3/7] accel/kvm: Report the loss of a large memory page Date: Sat, 14 Dec 2024 13:45:51 +0000 Message-ID: <20241214134555.440097-4-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: BYAPR03CA0018.namprd03.prod.outlook.com (2603:10b6:a02:a8::31) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: 86686eb3-118b-4f1c-3b70-08dd1c45a72f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: I6+E3mFqhmPdSjssLFS0YzI6YIaiwqIeOji0m+ptCltUXoykUDmEaLtbQ4oB5a6mhszDQHVhX3lHgLLfZGFm3PuSKD64EKUDk+lhoy9BzgUXiINzk+OJXKb41+pRwRngZrdTiSu9gQzA2XTlvxTUv4HBvIl8CJnoiyqiXAENWgKpiewpCSz5tCM93iooH09RRszkuqLsPacs3SQxm8JP4046KiWnKOIdKvAyZ92/UCT/smDVvm16wL0GR6ELjimojggYF62a6xs2U/5BGkELMAovOQPLiFkvuX6AEenNj+wtT4496+NweK1w0JokydoprgLIb7ba1na7sefvKg93V9gr6/SpDFMZ+oJFveGQVNarkcM3km+baYEgo2b8UtxDJvF+NlSAjrH9W+a81sb0DeBnxn63LqZKfZC1wlDv7gWYBGM9vtZ1AHTF42HBQIEmBsUfN1nWmbdIqimlYM2WXMUyLKBhYQ3KKkEu6S2n99SjjKf73v8y5YxlgllAyFp5c1gX+huLoNoLHJf+RuZZKsVO1TnMMOVdzVW8O7deOyYKdVNE7h3ECzVffAcJWpOOmz3KutlQWAlE8gXIZCa7ek0C413O1EYJy98LplEtYFpysvlig8SWZ3AKzVrkamQPh0OXFxwWAWqEwFMMl82igAh/+jXFoTdQ19Otz423FUOgMK62nHsxulhA8RT8DKY1mdaO/FCRO1IJfDfeZNKLmzHM9ZQA9zXZhpXD1ITRKqPr8fn36sjjHVyq05Q2oaNUoGkfD22W2n5iPDfqlrzvD2cV7JSpIe+qMEigYr+11E2gqfQ4gGkTQ4ZkqGueOvqJ8slQ5lZlZciklBRt3ZbCjYyBxpkbtoLa7i90Ftnge+Qhp7u799h27w+IEvzCe0EOl6xehADNKDOdp8YZYp2bI4vfE4HbGy6JmXqRFKIQdc3KZK3I1rPOGb0gKj8mWd+H2kvDqdJOdQrsasLynwKPKc6T5HBMHLpAP5mqDFLYrfZfNZLE/THREwUpMdLWFOle1gAa711YiW8prmzPbkum7G1vs9514FzgIVvyzphQQbfXqFBEw9qDkdwFIau/rlHR/15jEnkRPjo0DLun1UgK3XkIGByQbmGOoA+Yz6ICvtoP5WEjOE9sh5ABamO4fiHdNgkJp+kITHk5Phsah/3osq8HYaCmBc6oOCXqGc/6mk89+OVlpRSFHCpEzy0QSYomkk8wjb97TeNQUQ9Vdf2LLONZgbvTYSuxyjzyl2g0WBSF/1PaJi7eZoPluMBTTDjrqIuUT14gyFmu9yu2dsfbbHRT2aJgpuDaf/LuYooCHhhQp0uwDWtw3nf+Pp/ZGUH2r+OnPLvGDTxuoH9zjjaQ7A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s2606bq3duWUyoQSVAdj1lqGYJyiX9ufiL1vzF1NSft7aXo0JU2P/mrj0nglx5lSVIRbCOzSPJQSg9yOG2f8qy2AWAG73kFGAPjiHQnEWNw6T/0ccI3BMgoTs8RpUjCDhqt+J3UrzJ14oko3LE4vcgHkFE30YgBWMtMVdcz4uQhRysbzi1jCLOW82N5KhTCBOzLKcsl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9r2Rx/Hs7ncKD7qoJmkz9hraoO0ivPp6NBLBNNtbeiyWortiO39qxBrflVDrAhvnw1PenSZ718Cv5/qFB6Zsf0eGjGYmqTrHxCOV4K96azUxesXVBydcjEV5/avrOxHlDv6kRclN4p6pFyF8daXhFOar+NrXhJkxJPhwO8g2iHYE/vDiZ8q88fWuySe5r+Dr3YRghNrbg2g9zJ//VV5WxhfmHLMy7RhqzlDWNjIBlFnWHlOxpxqCaQyKbAdj4VsL64cZZdcecRx3yOqYFuBgNU9apaRdYPGWGN/gvA7jnJbEi4JhA3yDg4XN4Fmlz3sWNAodERSgzaMEQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: cLqo+3WHmw2BsqE+ZuuQe4V1jde8SI0jJaY0CXJZ0cVX2hK31UvOF3TtJWN6RFc3rW/feenC/z1ggjm8w/arikCL96mHR3nTY9oDj8CWFc9LJDIJCHOuP4m1Ely/PTzycekqvrjCg/0VqrP9+pAz/P2UzpoQrNHOJISF6EC/L9vV7xGMAwIWfLtftI8GIqSrV/js/plJ+gms874cJ7+lz2ZT5yMBHhvxobfSIPxuCNcwbR58yC9ggjN5u9K8ZeY536puYURh7Czwi6KSPm4FVBTAzsSVl+V2lGeHedrcoEhl0WZS9x2gTWZRsxXNFxv+ABDjMzRrEVbSoDtJlcGlCmNBQcRj+M9qOFmxYmCPZeZtUcOe4XrtsCtsB0UWqV2bMEM8S3p6zXNeRvPrMc2FIfSiYdMiIrCB7Pl7y+EQFD/9F6LSIaLTN/hOlFNDeUnb3PFU7jJWkfIMspb7s0IF5vuKJygYHGWqXIh0kyhjtrGKoSq9A0WrsnwXmdLHs8+Dtmg+DbOvTVwibhTrs22/pBRohsaTF7mmd2oGeK9RhMKqWpcZgmwAIhlOSKvUZwMzcayIacL3hCG9OBxZ/MNCNqDz/ExYsiurIzbj3+MA6OE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86686eb3-118b-4f1c-3b70-08dd1c45a72f X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:04.2055 (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: 8t8rWoRFOyiIcNQUTo3VHb4fGC6eS5EGLapPl91Lj34+AY+db5LHfIPORZBpyR9vit5e5x3oSWRyiQN4OlKjiGjoWBEOMxwa7yJ5yEbl/68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: Lp4OnKD73M0MaYLYg2G1uVd282d_a7My X-Proofpoint-ORIG-GUID: Lp4OnKD73M0MaYLYg2G1uVd282d_a7My 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@ADDR 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 24c0c4ce3f..8a47aa7258 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1286,10 +1286,6 @@ static void kvm_unpoison_all(void *param) void kvm_hwpoison_page_add(ram_addr_t ram_addr) { HWPoisonPage *page; - size_t page_size = qemu_ram_pagesize_from_addr(ram_addr); - - if (page_size > TARGET_PAGE_SIZE) - ram_addr = QEMU_ALIGN_DOWN(ram_addr, page_size); QLIST_FOREACH(page, &hwpoison_page_list, list) { if (page->ram_addr == ram_addr) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7b6812c0de..db234f79cc 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, void *addr) { ram_addr_t ram_addr; hwaddr paddr; + size_t page_size; + char lp_msg[54]; assert(code == BUS_MCEERR_AR || code == BUS_MCEERR_AO); @@ -2373,6 +2375,14 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) ram_addr = qemu_ram_addr_from_host(addr); if (ram_addr != RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) { + page_size = qemu_ram_pagesize_from_addr(ram_addr); + if (page_size > TARGET_PAGE_SIZE) { + ram_addr = 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] = '\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, void *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 injected", + 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 8e17942c3b..336646ed61 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, void *addr) CPUX86State *env = &cpu->env; ram_addr_t ram_addr; hwaddr paddr; + size_t page_size; + char lp_msg[54]; /* 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, void *addr) ram_addr = qemu_ram_addr_from_host(addr); if (ram_addr != RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) { + page_size = qemu_ram_pagesize_from_addr(ram_addr); + if (page_size > TARGET_PAGE_SIZE) { + ram_addr = 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] = '\0'; + } kvm_hwpoison_page_add(ram_addr); kvm_mce_inject(cpu, paddr, code); @@ -763,12 +773,12 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) */ if (code == 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"); } return; From patchwork Sat Dec 14 13:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908506 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14C2E17E015 for ; Sat, 14 Dec 2024 13:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184001; cv=fail; b=Iz+ip+UaLESB9e3HdNSd2tJ9gFzpSjqk4YhgFDJ0IRILP5vl3aqdvM6V3KqeFWlQ9iOqUO1e1ecy+l4EeEiWxWoYGoA4fzuxd53Gz03uIDv09tC1kujr2kP0uNpPX+cqNhBfh9OR1XWwiButvBKvwhUJug+hqIWFghJmYrl/UYA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184001; c=relaxed/simple; bh=Urmo2db6dCZgk3OahhnFmGxkxZyUuEYImTt4Z+DByN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=eP1ASBz8So3Xv8N7H6sDa2PMuJn/wgsZJnab58uP+YdOEXptvVf9WVntmFVIng6Yo/xKmp8okk2T9w7/MktNEk5x2ls0OCfKN+3b9r51Q5eMpCfPLRx8YoAKFJgSUemGzbAh8dDG0gMFGe0qt8BUZPXp/28jyM6ULzNySrhxFn8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=JykCFxXd; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=nr0QE0cM; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JykCFxXd"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="nr0QE0cM" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEBSN0V028037; Sat, 14 Dec 2024 13:46:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=XNRyM619BswnILIqXLgMuU/prXvUSII/sdhBcI+9Y4U=; b= JykCFxXdhTiDIeCk5gD/YRQUA14zeO+SvVtjIR+OrgFfraw0SG28TG4JU022ECWx HCfisjBgzGNcHNkj3Bb5yZuiWddVCoLofrtHZIxiTMuaN48tz9EsFBxf2dPl8Knr zo9CaAsQdbMTfgkAZvNunlyrCgguLN0CE2qkHhwYDi5+u5vBnP1it6nobnpVDIsd F8bBmDR2ZJyibEGRDuvqhQYyZajMQvFo2tLu/zekOoWHonKF6Pgt8UfiOKYtqKz7 NaTWxzR5AYItref60yxDXwcCLN6XSkPlYbSSndjYfQATGeX3/97B4R2FS0WyQ17t 9TaQCZK3hojJi5sqAQVuwQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0t28gmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:23 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEAHq7G032785; Sat, 14 Dec 2024 13:46:11 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fbu0px-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C6b13odjys224mT6WVWbJOgIcOzWdYplf/YXPAoq+jWOAFJaLI6V+DjSmhaFEgqueQdet84plI2m15qMVUbks7U8liC1+JMSg/2fIyiPgMiL2DkuxQNvQEZP4j8k+TlwyTMaSJBrdJjbxFIBhUedhxvXSCP/haiGbEtydOMXvK9fAXsuJXxP2frSBFU7ciK2KmlIVGBYmrFqFEsQW9JsgAAJ19uOpvD91ZpLG6euiU7woQLJ/PZ8gir+2ZYMgVlWvRN+P9PV13MNTrMrKHNPU3uWfT9wCY/lGrTC7kTX4Uzb9uwRBiMo9x9mIT+wv5OmPsU8LbTgJsJxHUrLf1lJ9w== 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=XNRyM619BswnILIqXLgMuU/prXvUSII/sdhBcI+9Y4U=; b=Rm/tlSovJ3OA9TUOOebSeoVKKfPmKQVkQYBqj+VpKVps1w6hiu3VE7NAqwxLagLi2/fsOKJnrKliZFZZY1UbkVTc6KouxuKAtYBxnUN+yUCqpkoS53rQAabYt/fwpcUZrj6Q67sdSXfMM+tNdfDBHjpgd70KjKdcTcRw4PAhcCpuZZ7I2WRamuG8M+IfwuHaixDrhlRqiPbvskexN1OaD2NVLq4s7vxTRhj4V4xzl/wuefrq0tlhVxDAgSGlN7RtbXXPkXLyQdI4A+ML++QX2HJaSUTJHY9XHYHyAMP3poXXVa805gs/WjSD0TdDM2+Rl3qI2KysMHb+BdaE+pVvJA== 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=XNRyM619BswnILIqXLgMuU/prXvUSII/sdhBcI+9Y4U=; b=nr0QE0cM2xRFOaqb8fOQVrPCRKuL7oskmAmTi5H7nzKwiZyKAzvwaq72dq21VBA6Y5k/s3ghyWmardZ/SS6Ndt7d0H7OMb+6zV2Bd0pilYx6+YoavB1kU+I2jLlGGzHHAlXe50R/IAvJPmDhN8vRTwFchdfOu8KTQMYJvCaMitw= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:06 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:06 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 4/7] numa: Introduce and use ram_block_notify_remap() Date: Sat, 14 Dec 2024 13:45:52 +0000 Message-ID: <20241214134555.440097-5-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: BYAPR03CA0031.namprd03.prod.outlook.com (2603:10b6:a02:a8::44) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: c085a29b-4b11-48d3-6174-08dd1c45a882 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: CNHoNWPKO/t7bRqEHkNB3Qm8tmHnUcqC4wSdw8yRC8sLy98GtWhZBxfEvTq9wHS03yHqfADyO/8UK0p/3nMP+XRQToppUXk8resAM8XE/3/5zmAljCYGjRbg9tFBrEx7yKxZiT+VlAgfOih5UB5rSxB2vNigUid+FmvaAvI5x4NQlENmBVDQ1vLc+XQd5hvCdIRcsJf8isTZglIsVdmDM1BhMHpL2dqWlr5Yk2pKvOfSsNv/SAJoEDMAmCMKer+16RMiOHcOQMJW39YQzU6dDMfA0f4V3eqZqY9/ZbZ+u1E+jmH1Z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== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y6exoCvfbF+kuLiH5z6/47j3mSqut/B08IdiBNNL5vuOECHz3gGOqwfiOhNYKhFI+u6VyCIQKm/vbkyLJwlolBv5htSQIOBwUGQI2xlAVhJXL7tUTcBMZBGA4/+elnO97SO8p30NmQlEDYkyJ9Qi2zO6u0RvicjPEUX0TG9Z/DZg21pIwlZQ49d8V45t78RMLaCm42iph/oDZWCFpLf2Dp0zErIY2MirRvrtFaePpohUM7tBQwAcOtwJUY0ol+94KiUJNtnrVGlwHKvFn1AcdtyJfWUKDu6sJLQ4wCRuRbRw5MVdVWWoojzNET3iHGy7gqaT3DA/z8HoJPIqmQUzlT30OL+NY9ZhIu69jt9aSopKR/mWW2ksANyJ43VJGwuVEA4270PxJJtNeZ+cZIyr+my5DCK8Q2iK0eXM/RIYcPYbw52cbO9Kc44sNi4BLUi027bndGyh8h7+k9lyDNlA8hhjQcQh/O4LLGgLZyp1t6EYBYWUNcsEqsxx/my7oiiQxuSFT/V5GQ4eD65otMq+fJdp4FNTaEZLAnNWfNNMDLnJbU2wDv14IEmCtrFIkOHIea6RdPvFwrPSRmWmSk+HgGteE80iWzWv7PFvw0puQNhSnm1xvkID02GzlZndtymd2uTBaEgVZMYFCJSfHgG3Xsg1sle+u0ko7nWtrvY0ragURvSFXdMC3eL11jnxmvM8uFo5XEYpPBjFouJfuZEvmJAhGp7NXndBf0pc4RH4x2CRFnd2K2UYMqFcjdIK4F/JA3lsw33sEXrLPkD1tZTK5TVuSxbEY8t1syWZVPtm0boDLR75v1IWtDUmHrDAMlne7LgO/bfLFsTGe9KbttQxLY+O08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xlVSb8o+935oQ+ukqw5XnQZU4xSovQR6RcTlUwOARBu38QwqOW/ogFbkNMNueAdbFlDiII0MWfdwFLdZEoJQNd21EXZadelPgRxCm8wZx15484QVAXcAkEL+7DHr+tu7mvvKoH3npT/bQ23zFS2wfowVlFNPfAC1+T3r2vGMCSrvvIE2EOWw/jpWaQfUY8eeQC6rMb3tvFfu7eIN39VIywUTqrMUMBhzGJhU2uhqWMfEQn+zuaR4XApasVIO+blO0sfpRwtMfJ2mjvfpavij1pujGlzVxUyL26v6s0O0wdmrG1TiC8iFjaGr+ZkaQbBtSu/A9Ypni+FNRhOWN/dR4zmr0KhtxdcRXOUErAWChXb3sPjRtOFCE0Pu74= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c085a29b-4b11-48d3-6174-08dd1c45a882 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:06.3514 (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: SnBOsJMjVXUJsg+VSIHfQzZN9HXZPAM9JHrwkLiuNZr51JgF873HmMfWdYk0GhWxkrwXVqlyrDjJqSGwGdjDMYa/MCE28JNE7539TngZ4bQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-ORIG-GUID: h2BHmj0Ll6fq-_DgQgMnpkFftLh7zSSB X-Proofpoint-GUID: h2BHmj0Ll6fq-_DgQgMnpkFftLh7zSSB 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 1b5f44baea..4ca67db483 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_size, 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 offset, + size_t size); QLIST_ENTRY(RAMBlockNotifier) next; }; @@ -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); GString *ram_block_format(void); diff --git a/system/physmem.c b/system/physmem.c index b228a692f8..9fc74a5699 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2244,6 +2244,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); } break; From patchwork Sat Dec 14 13:45:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908502 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02778374CB for ; Sat, 14 Dec 2024 13:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183989; cv=fail; b=L4JzxtMAgv/RCaf/0EN5G4CctTuhwQGvQvtc1ZBd9mlkPA5+AymFAHlrbJ05lC3SUt2bYE7rcFaZmvCh1+YPBYkp5sUjE0fmEXhQTVkbPLqACaSv2gTfHt0twZEahnJnAorskBlfpKkiW2ogsatdNsi/SN7HfBhALvH/wp2aKi0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183989; c=relaxed/simple; bh=nOoEfpB2IGGp8YvQIcXEUIHcBF9AiD/lYg9oz6SIVBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=htxQhxYeVn58Wa/qoondkpXWRY+vYGhguq4gyXbZfeeXG8fP4pbM4UyWHBd15dYogSEXqIOls84T4oVuDDPu/eScFs6cM10f6Wt7hs/8HoFKou5L6FZ2Dm9jumhRbIvZPvU6Yrq8rRmW1gewRT8syjGd1J/aNmToj6r5eaF3Jow= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=j23i0IeG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ArmCv8/e; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="j23i0IeG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ArmCv8/e" 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 4BE5mOYh019978; Sat, 14 Dec 2024 13:46:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=tMm7sfsa5tMZm+9vPsMqJy+JU6H3ZOklscSFRUBodPg=; b= j23i0IeGK1ElwzWidUwFKp9gC7l/3HsKfE5mgRsLxRgFzBP5tVsm7LLOB43aXHLd 88t7UXl4TSSdSKa7rHTcWLUd7p7I6SGr2AVH4rrApfX/9DZLgCpu05EDo7SczwxT 94nzzbQ3l0DRnLEXmmKL8QpTcNfJFCR9qHG/MRlgYL5Dc63+OqP2ZYyDwbthDvTg TR41ZU7ZYTE01CCrtlo1zY47vXfXfyNSK2DjPotDBU2t1AFqx5y9WnonYS/7Rh5X H3AJ1s8Bz6OCHzqR9dvolnA6Pa0NQsQ9uZbr043aDC/75a3V5M35X4fDLDqzB61R IONhMLKzzLgAB8NKlYioUA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0xarfk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:13 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEAHq7H032785; Sat, 14 Dec 2024 13:46:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fbu0px-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fOnpJBUUhsm5VL+vd8oK0uGK5yQpAXZhDLl+wwPlKpspesi/N8Q6quyXPPK/2FZLWEq5KnPrg8gZ4yxC/ggkrvZbyZ05UdJPDky2Dc4MbqhYyUMgh0vtT5llpKh0J9xbcZPbA2o+lZ/7faJPwkaladRaoFFjXH0nDx9YHi0sTA5Y8DnGd/OXH4/0pa8+e6NoigantmpS6Dzn1zt/kKY7XFKEDNVOND7EaRRj0OXIpFRyQw69u+YJrwcCOs9jSKiIqnLrdeE7PAR9od5CyJFxknub5mOfsW6s4zJ/GVgqSpeh/AuKIykHjBtKTtV8XT9uhhKhK1OQ+DSPQ2saWnT0KA== 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=tMm7sfsa5tMZm+9vPsMqJy+JU6H3ZOklscSFRUBodPg=; b=fxinawElQFQdJ0HdEhtQMh3llGLzh5gaNMNwpNjd7/4a0OO2lbRnCJoaUYf2fKE8AInyCH/vPMZzJOgrtPQB5IZmMKhdgmD5AxaPp3585cPfoz1CK8iZTXnIp5Fvki6sQJCqYrl8qJ672DaqHqxncR+V3J5HAIt56S2wC5Cz4GA+0zIrVHvcHWviC2eX6UUbhFLc1LJrsqhuJvmkbU+mEV+/pVOnIm3XWbsjOUbjz408yPye9IAbBxMhZd6o9gQ8A8E9QyC+TMJ50ElEKT0jsGDWdscGBQ1lm5EnGg8fK5qEXmTEFXLXbV4/QeZG0JVRjX7j8DhUKrEM89PT+7+wJQ== 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=tMm7sfsa5tMZm+9vPsMqJy+JU6H3ZOklscSFRUBodPg=; b=ArmCv8/euiqMM6mwQ1gRo9mWldkCGnW24a2z6I/qNCrMfkxvG07Ui/eOtymxExD+02F7xAefSDInWMNBbLsX9wmNewVCTwlERNjdoS6sFYFk3wrE9fj8z9PNWNUl6asvDpRMe+P2EcwEkDJgPBKSdA0ma5PSnxXWEMzzYr7VXak= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:08 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:08 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 5/7] hostmem: Factor out applying settings Date: Sat, 14 Dec 2024 13:45:53 +0000 Message-ID: <20241214134555.440097-6-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: SJ0PR13CA0104.namprd13.prod.outlook.com (2603:10b6:a03:2c5::19) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: a201c0f3-0344-49a3-aab6-08dd1c45a9d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: iNwoRHxKJ4LEC1MG3EBQUEvQF5jbb4hlGXY66YaYd+D7cZhbsFMw4aJjGvu6OlQC6bVy7v4povyuAPkf+lAY2TcClqgMMdzA6XjUkuEC4yyCfNxsRKK4gWeBm3gfk6NxPY+ucThkU3J89xvfwo/p29foPngGduEPwrbNv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XXN8mFfi+wVsGT9cGkg+7z9maLx/tGoqgCPXQOXvsGsMpo7HBJRH1h3daJ8LT6zh7bmpYR0c3BDRejhfPcZEsmBLTmVyWYdG8jaACLzDaknt4+8fZeKQyZWz+KlA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dW4ObsNZsB+H/0lV+r/hiO+QdUhq1G37wrXndBUwuEvQtxMZrunxgSailiesQIkmSx+46w+ELp1UrQk3g/gB199usDkbbzkzo3ATZhZY8IRAsjWXG15zX0RcCyFuL992/C/7wGMRfOqDLvuqJVleNMfk19LaADJpD38F2e+CTkcesxxZDZRBSiiIOpqXfj52RpwG0gnI+69zjyTV4Su5/Gz5Mk54OifPMUkNw18DqnBZ9D+6SgLaP8mBHI6odr5r/utgSQAn1xb6Qjq9S6r39E11eyAST5IrMnolgKNycAK3weTsxRjKkAsoVF/rUAd8DV/SGV0N1SP7dXRxuleJNFBO3n1/gdvjtH1lnFXEr8SlMxNXoVMiT/G3JJdghYINXkEODBIN7l6ba7jr/+2g9rl7t9yX54MZsocMQMUP0sMBw8BXpTVadroBtlza7uplIVjr2jL/AdnD6rext6nACt3ff+UPxIkx/MLjW9IUSY2hL8FJNGGkam8yUzOJXbvcq1gcpdWzGvyW1hB9Kzdn5685G/Gn9kqfCtiRlggWlHFhovI6UBqZoNI5+Fb3kNGYeo8ycOSr5II7dUE+cWNpxk+Y4uxe9/tfC2fV3dVFry9RqiUNOJRhMCZKB/bS+DXCDbvN/Fu6TrhxZQxMmSKQbqbfCHVKpH68YRoh0ZpBT64ij1FseMAiff2f2POQsvlsA98XnHIEPcDB23lCv4/OTonMeYskxD/csE51UWD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yve9MbULxgzJw6slU4rGIqjyPym7XU441hVA9AYDYNPM6LBM3Gixrp5OVBZrxbrXHQMHXHfrK3qfqiR5w4P/AKMjPvZ2zmeZdbHDXobZHLBRHMSGIfeo3JdgNDlfipFI0bQMg4xsrAxZ9UNQf9xD0bQ7atRwiMKK37FHGnY4G3XmJTVQrYDIGa3LacrsDjiroc/ngwkFMDfehBbcRcTIKRYCc9SnJH/uVvbQH3Cw4Gn4Z5f2A2tdWAOtlNzzkcVWMwJuji9H8nZc1C1Unu0wujxXHPd8ZGH8Kv61Ld4uSqjv5KFbDPduqVM5lGrG+/WsEh6Cb191Mxdym7gtu/iRl7rjE14zRhb10wza94x3ECQd8kgqjzO9T2EOQV/N7BB5cYXBAOuyd4zdHpaCFmL2ErbcWDt1UOTevPArgPfPKSpp9KOkMyrjyrkN+KyY2HhTMB7Vfgu77FYpCmxQ6V+UL78IQ9cGOSMvi6lrueRU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a201c0f3-0344-49a3-aab6-08dd1c45a9d3 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:08.6078 (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: fgo3/qY64DKea3JGRMy5O7L1yhGLHJQsAE1u4tL6SVHMwVAitQPJr5dWFcaNcbUHwJJnVp/z/w/Xm2TSepKTiRmfSVFpdbcpGGDXrAT8Y8w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: ht-mitOSnzYUjs-LlczVuEoI1G_Rqoh4 X-Proofpoint-ORIG-GUID: ht-mitOSnzYUjs-LlczVuEoI1G_Rqoh4 From: David Hildenbrand We want to reuse the functionality when remapping or resizing 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 181446626a..bf85d716e5 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -36,6 +36,87 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE); #endif +static void host_memory_backend_apply_settings(HostMemoryBackend *backend, + void *ptr, uint64_t size, + Error **errp) +{ + bool async = !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 = find_last_bit(backend->host_nodes, MAX_NODES); + /* lastbit == MAX_NODES means maxnode = 0 */ + unsigned long maxnode = (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 = MPOL_MF_STRICT | MPOL_MF_MOVE; + int mode = backend->policy; + + /* + * Check for invalid host-nodes and policies and give more verbose + * error messages than mbind(). + */ + if (maxnode && backend->policy == 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 == 0 && backend->policy != 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) >= + BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); + assert(maxnode <= MAX_NODES); + +#ifdef HAVE_NUMA_HAS_PREFERRED_MANY + if (mode == MPOL_PREFERRED && numa_has_preferred_many() > 0) { + /* + * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below + * silently picks the first node. + */ + mode = MPOL_PREFERRED_MANY; + } +#endif + + if (maxnode && + mbind(ptr, size, mode, backend->host_nodes, maxnode + 1, flags)) { + if (backend->policy != MPOL_DEFAULT || errno != 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 = !phase_check(PHASE_LATE_BACKENDS_CREATED); if (!bc->alloc) { return; @@ -357,78 +437,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) return; } - 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 = find_last_bit(backend->host_nodes, MAX_NODES); - /* lastbit == MAX_NODES means maxnode = 0 */ - unsigned long maxnode = (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 = MPOL_MF_STRICT | MPOL_MF_MOVE; - int mode = backend->policy; - - /* check for invalid host-nodes and policies and give more verbose - * error messages than mbind(). */ - if (maxnode && backend->policy == 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 == 0 && backend->policy != 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) >= - BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); - assert(maxnode <= MAX_NODES); - -#ifdef HAVE_NUMA_HAS_PREFERRED_MANY - if (mode == MPOL_PREFERRED && numa_has_preferred_many() > 0) { - /* - * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below - * silently picks the first node. - */ - mode = MPOL_PREFERRED_MANY; - } -#endif - - if (maxnode && - mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags)) { - if (backend->policy != MPOL_DEFAULT || errno != 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, sz, - backend->prealloc_threads, - backend->prealloc_context, - async, errp)) { - return; - } + host_memory_backend_apply_settings(backend, ptr, sz, errp); } static bool From patchwork Sat Dec 14 13:45:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908507 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53651990D3 for ; Sat, 14 Dec 2024 13:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184005; cv=fail; b=RiJ79ECu2P7uRMhGrXh9arI/pF2k85hJFZTNC5yS3egALy6763JcLaEd+i5GyEJdMFfTcXvQaSQI1PHdKC18EDH49dZWp/vBbfGcpEkZ+ETL59GWrv+C9E5+/wS52fLoj7VmopVCbr7KoGjimbWfaHgdQVZR9SkPTFru4Yjs8iI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734184005; c=relaxed/simple; bh=xm7pJRNdtClbqmK64xXUGbItCXn1o4SYhEEftIzeee4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Yhul6xyJL7g47BJKho2+sxKW2dR4kMGGuaAvxQ+BiGTPxVsOHDI9acYQFIJ5QocSTGjkVaxSmdadtHz/f23IIFYBpLsyuSKlVHzQ4J/pvB4mjJtjXIQc960K8FO5bQrH5JIuiYFGrMgyjbrSFivP/bB4GmhuuOF3uVrz/06M5yU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=SfagUYh/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=YgpxIid/; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SfagUYh/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="YgpxIid/" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEDfrI6028739; Sat, 14 Dec 2024 13:46:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b= SfagUYh/eSK5LNJIlB7YwQX9wlelsvkNh7CULSsM4VJe95Rm96PL9UAfzjxEfaV4 QQgSQCHLcGHdpfhU62NUOp2bCHMmZCyoAEEH9a1S4K+LfCzh4YWcQQH+1QzuM+J9 brsFbs/GlH8cGPf3u0RTt3Zyz+hlFS9cpoF2HoAPEfjmGcTX+IDNXhytjm9B55pI 1etXLBXxivUgGmwLtZ+Bch92m/N3M9qgDjdeqmqoVM/wLqORNbyw2KoFhdjOd+bv LhNo7noyC8Hs8YjiR2OVO5Uzi+zTfisakEAB1wywMqWquKj/TLUbOGk/1tXQ0UDI Yrf3oMgqpVKf+KaNQF5w1Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0ec0guc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:27 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BEAHq7I032785; Sat, 14 Dec 2024 13:46:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fbu0px-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BP6rj7xqKG8QIHsYCn6VvMDoyo5PIuqnlKZlCQyQgpRSJKayZc66J5EcH0Ffg2ziTWmyK5RT8vgWszTTIYcOOTGgIPVJDlfOw3gMeRhd9Ve7aENspB1THrFfh9B6mPU8Dtw9y85YwghqyBkGgDR3TBVvfa1IR9peTkVMZU3NgjCgMyjWrWNTTQw9Y0QPMkvcyWIbcFCp0MxCr2xaEbEK4msL5lihf87loOwwj3vB3T3VDEcSD1/Ab/PSJsdhRH0g60Prcyqto6JHIfa6epnVvVZhHitkucB8xr28iNsc69Gy7nPbmK6d4rWXWKdeRFdkPOnkF0Vy1CcyFKgTRx2yWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b=Th2xft1ZwPf0sDyRcM/4M6n5+HCrxmnVp+/5KiZYcsK+LsEZ1LTZS1FTvAhDZTvCx4UNglbTmpaX3kN856QTtVXZO2VtfrsGN08i9p82d2Mrc37WyZPAKM6P6ELv7EcY/Q7WBScz5lTYPbuWyKh6pwLKqbiVsHEo8+IH7StH140PCa8k8GgubqqQdIu/iNJkZSG6WH0Et2DdAx/KFT8iGzOt64vdzaYaUEfDf2YdHEhf/su/mWz2Rfm3CBcVdP71do/8+kLh62eThRlKlFEk2LnPzVkf9pKQVGR3r4RbnuCDsKFs14D6ZVGWxBS4vLQO1FIDLmlGH7MrSau0B4++pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uLhbKhI5RH66g6X1oJem2vCjv5om1/AgyTDM5B2oaik=; b=YgpxIid/B+qeUrKRjjzjnNQLca+cjecY6pZTqzdHTeO/vz2eXy1IUOHjhx78jgc4cqJ2iJER845XkWgCtaDVHHX6J/Acgn7gPwhDE6eP6CiJevXzFgdR4wTLT5ZisHc9CqQLee1xTlRmEubTDF6nvOgEtd/hMd8o8v7/5OdIEJk= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:10 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:10 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 6/7] hostmem: Handle remapping of RAM Date: Sat, 14 Dec 2024 13:45:54 +0000 Message-ID: <20241214134555.440097-7-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: SJ0PR13CA0096.namprd13.prod.outlook.com (2603:10b6:a03:2c5::11) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: e0f87c67-f638-466e-7837-08dd1c45ab1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: HI4H8nxD+pEyd9PVQ+e9mwv/dHN99D2ju7TcemZwuJBHRXaZKcP+vf6dLkDyHwCSfx1R+N8Ocf6haYLFrj/488B5hVGfRmT9m58Lq3ca8ZN6JkDa8rvuz5RW4QmJ0sQOl6Cx2V+R+5PfJl1F4F1S4vB7Vg/b8mmqN93hVvZWv9/eEvj2Y2LhdtJhn6maxwPWBp7ixJLFVgjqY1NooJgqGd/lm+QyXrM5zReRkDlHJoGQy7np8eFH1JlMUMDFC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f1VO0MTxeYq6HMx3kTcp3OSq7R5SQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kRFP41Du6QAr7Iezlzovj5UNHX3xz2nP1TTzbSqcVAONQbmKhxeCFQHcR8jDtHgMk/gY/5ZM8l2+dDysTyrHwLF+Mk5TC+kub+LwWYWURf3o8EI7WnYQPcHUW6guUnHczJIXdG0aP10MlPn+rwNd3psvFf0N34jPDrmVRqSm7STrChPjQ1grXqIKsjoqz1XWqEzYZr72Ma++JsO0RV0qHjF9CLXUl3vnbrmksnBltEHUDPhh+1gBklubMF7Shd24PLzT5mqiO3e3qkOZ8HygVYPrkm0yvHA9an4RnoWwpcC2puCldIAR6YbBBDQGCzBl6+9vpBonpPQ9Zx0bceBZqVjTmIyqCr67/wjBR9lEv0Ahh1oSZ5a/ELhgDmQRw8N4aEzB9fPBkGXyzQpwQf5xlkF75WBvTCBtXLT4OaayyJgS8Z6e+qVPnvKC3A3bhNg0d6NKRxCu33SXT54lDejHOFLxpWxMbXocLQCc5PnXBhkR3iB8nQvwJSkAwVVdRWBWT0thPJ7DkE6gLP29QPs51G/kea7+XhJgj57JdVGVLb44/ycFucmXbn57JzF59CioMbw7+o2Fn8otnHY3Hla0OU/e8xMySstVfOhAU71JUGVKFZyO32/OOoagyWJiqetqNlWUHzGrTP2QIBu//aIEqvRJF/JyeksPNYpJbsv2MvEAe5nqg2E7cr2EEc/fiji4AThyJQCXy8VQxYcvmlpXjQnGtnwXY/PY+hRmUILGUfUkBsEtRM4fMarn1uAmCRhs1tCNoarxIigQUm8HvoWSatGgEqpcgXB/KoVF7rPVlbnLk7W5X88Z3Y0X5RNr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IuGZuvqMTIyaFGEBiEk7UudSBsH+TZ37rdOSzzFwEUNXUfRXNqqfmX8QNrZxr8c9LLPOksTxIsKKc8FxAfwgD8AapzOKBXb0vdzkCjqjGXNX3+DUnbizmO1ipKoFj+Pj2Ilu8hqwlelUnvAP9+qP0a0dXqliZYM8Hryjx/z3ViA/hOWA3LA9rIM7iW23xRAA4kHLaSA1Bqnd9y61RQhcweOAeNFKxUHryFj3HmLmbUM5ofZtLLFZ0sIQLTVsFiLj68k5ixCvT+WzPQKT655Ohr+mQgJK0AwIBT2UBq6DRDsHnTHYWQexj1pkmFIJOIu2aZjIPiJS3kMuI0XwLhpbTSAPTq/11hw6qMZPyvGJmfIbMIbYYFVBXbXMKDFtsIttc3ZqxLraQOIr4VwWSQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0f87c67-f638-466e-7837-08dd1c45ab1e X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:10.7303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oxW8/U6B14Jjsn5y2lZwhY6ofRS/38NI0Z5jEnyyKZWoEHrwECwQz8AgZdfhoAVqiOLGGWOlvMcepVLRu1ESPkF6nb6fH3U69WisY6IgQdU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_05,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: 1Oqh_ytNV5pxRKI1eBZ1fujzkbwU7Xyw X-Proofpoint-ORIG-GUID: 1Oqh_ytNV5pxRKI1eBZ1fujzkbwU7Xyw From: David Hildenbrand Let's register a RAM block notifier and react on remap notifications. Simply re-apply the settings. Exit if something goes wrong. Note: qemu_ram_remap() will not remap when RAM_PREALLOC is set. Could be that hostmem is still missing to update that flag ... Signed-off-by: David Hildenbrand Signed-off-by: William Roche --- backends/hostmem.c | 34 ++++++++++++++++++++++++++++++++++ include/sysemu/hostmem.h | 1 + 2 files changed, 35 insertions(+) diff --git a/backends/hostmem.c b/backends/hostmem.c index bf85d716e5..863f6da11d 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -361,11 +361,37 @@ static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v, backend->prealloc_threads = value; } +static void host_memory_backend_ram_remapped(RAMBlockNotifier *n, void *host, + size_t offset, size_t size) +{ + HostMemoryBackend *backend = container_of(n, HostMemoryBackend, + ram_notifier); + Error *err = NULL; + + if (!host_memory_backend_mr_inited(backend) || + memory_region_get_ram_ptr(&backend->mr) != host) { + return; + } + + host_memory_backend_apply_settings(backend, host + offset, size, &err); + if (err) { + /* + * If memory settings can't be successfully applied on remap, + * don't take the risk to continue without them. + */ + error_report_err(err); + exit(1); + } +} + static void host_memory_backend_init(Object *obj) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); MachineState *machine = MACHINE(qdev_get_machine()); + backend->ram_notifier.ram_block_remapped = host_memory_backend_ram_remapped; + ram_block_notifier_add(&backend->ram_notifier); + /* TODO: convert access to globals to compat properties */ backend->merge = machine_mem_merge(machine); backend->dump = machine_dump_guest_core(machine); @@ -379,6 +405,13 @@ static void host_memory_backend_post_init(Object *obj) object_apply_compat_props(obj); } +static void host_memory_backend_finalize(Object *obj) +{ + HostMemoryBackend *backend = MEMORY_BACKEND(obj); + + ram_block_notifier_remove(&backend->ram_notifier); +} + bool host_memory_backend_mr_inited(HostMemoryBackend *backend) { /* @@ -595,6 +628,7 @@ static const TypeInfo host_memory_backend_info = { .instance_size = sizeof(HostMemoryBackend), .instance_init = host_memory_backend_init, .instance_post_init = host_memory_backend_post_init, + .instance_finalize = host_memory_backend_finalize, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 67f45abe39..98309a9457 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -83,6 +83,7 @@ struct HostMemoryBackend { HostMemPolicy policy; MemoryRegion mr; + RAMBlockNotifier ram_notifier; }; bool host_memory_backend_mr_inited(HostMemoryBackend *backend); From patchwork Sat Dec 14 13:45:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=E2=80=9CWilliam_Roche?= X-Patchwork-Id: 13908505 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A4AE17E015 for ; Sat, 14 Dec 2024 13:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183994; cv=fail; b=Y/6doOibQLRdlzIIRIfGv8NMVWoI8tSdD4z2JOrniQIJucaUDLVEsEFw43EpQMsLwuUI64cW2nif4oAfUtk1wnBDuUOeHFw2uPamimjf+g01haAIpoQ8v1Hngu+uIWyLR5GeQvqXyzrMyJzjrm83P5uHoPEgMDQ5KHlDAuj/PCk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734183994; c=relaxed/simple; bh=nTu6Ih4fddF4setJZi4u3grJt/KekHADjzYeyEi/iHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=hIP7NhwGm79x6T3pw4UijQwUrCPJz9XQbSBGfS4Hf+fRtsUWOiEo+2awLj2NuAttZ/oBGk6Fviw96JY3FS+15lREU/OLv1CQ9elP0MPYaFiHwGzC2DbxuR+n4YEpDfV9iyQm/y1AVvzEOk3SpsowrxaKBE7TPQd53HERD53ZMW4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=RpzvG6OO; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=m0JwvIG+; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RpzvG6OO"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="m0JwvIG+" 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 4BEBbI5p021285; Sat, 14 Dec 2024 13:46:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=RrWIw0kV19NHzktD7QkQk83ZP1g/4GS+t/YLHCNKnng=; b= RpzvG6OOURE/iqOdjiY7eRcOuTv2Nz01NVicytIzAbqu4kIfMKbJm1st8trfTS+W 6C20zpkR747DitRD5Aqu0EWeKWHkL80hlN7/eYmhqqY0wRsqrgtSitZ+5XDfV5dj gRdgArAnC/EYmof05g6TQl4FUOY+VTcKsMDL44OZKdxzN5cmbuVjBVmDL6jKVsmT zbm+lXk4dv4ZKwFxYWea4Gs4WXYYE/Y1XZNIrwZwihqy4DAg2mNhLsQYn3jEBTVE B+BfYJgqPM7oVjw4CH2CTzZS4LkfmOILRy1aPyEJTPI+2f7luwbX5rJgq4DYFJL8 u+c5cvf5EUpeMd2SicRe7Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0m00ghb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:18 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BE8wA69035387; Sat, 14 Dec 2024 13:46:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f5ka6x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 14 Dec 2024 13:46:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cVWw1B+oMwtylncA8MRVAYaeT60XY2vWuPYw1hCMVNIWj6a2oIWyrM8qSG/JlnXtfmQVUztkDwyQ3GUCRb7Pfxpd+85zbAuOxQzhqZQxoAlvrsgTMXL1e+kZXmewU8HZhFdAV8xtGTNBw2OhcyeM6wq5+dcEhWoEMkvn8DYQClCXzTUt3o/J3GjW3NByvrzNHOniINDi9sbd26cpCZnb6YmDI/htTgNHbAcosEmYASgrqtkTytQvhIStHkZNK118rlb1eAtHRqqBfK1HMo5AEgncK8EUWBJtC7LrYy/jAmkS+kgvlGgSAYRkM8Aw9VCrfUicSb2GkXCq7t1ftFEucw== 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=RrWIw0kV19NHzktD7QkQk83ZP1g/4GS+t/YLHCNKnng=; b=U+Qxu2dcjl8RcBQE1RKV1ytW6uLbXeKVknztSIzdKJ16VAyPEdjAC/oeFr5g10bbLpmxxVCsmhgRY/6XHO9sKptoZzdtw0Lw0/In0X/BH8xWZlnr2kgv8Lmejtvz+eGwtr94KtYbEUzxRi78N8s77aITr4/qUB78P/OvB8YYhOmvCtrYcyXLlW5w09KxD4ggGaVrNIDY7m43pi4wYaAGssANlGZh8bzG1ufso4TIwKXhjzuunfcMzG6Q+yX3Hf2IrUD9nsrE52UdhwihOVExLJX1qvic2hv1h6wa8gO7NgMzIczbWNKlLWPh+uRnkrI/YBmtYGEQMzk8EXQBieZbXw== 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=RrWIw0kV19NHzktD7QkQk83ZP1g/4GS+t/YLHCNKnng=; b=m0JwvIG+wyRqRtxtdTSe1+Jvah5GQd0Q7tdy0MYw5HdQVJoz+tIAM+mniuRqG/GVKoMrt7cCCx3RfkUweHochJGHkznB9UQNtQGRnOJktr1UOSqP2trDXwY3YdiNZm7UJgmkqDtTynKVq0noOMgYhqsmjG/4YBZ4u/y2+OuK1ws= Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by SN4PR10MB5624.namprd10.prod.outlook.com (2603:10b6:806:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.19; Sat, 14 Dec 2024 13:46:14 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%4]) with mapi id 15.20.8251.015; Sat, 14 Dec 2024 13:46:13 +0000 From: =?utf-8?q?=E2=80=9CWilliam_Roche?= To: david@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: william.roche@oracle.com, peterx@redhat.com, pbonzini@redhat.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, mtosatti@redhat.com, imammedo@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, zhao1.liu@intel.com, joao.m.martins@oracle.com Subject: [PATCH v4 7/7] system/physmem: Memory settings applied on remap notification Date: Sat, 14 Dec 2024 13:45:55 +0000 Message-ID: <20241214134555.440097-8-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241214134555.440097-1-william.roche@oracle.com> References: <20241214134555.440097-1-william.roche@oracle.com> X-ClientProxiedBy: SJ0PR03CA0341.namprd03.prod.outlook.com (2603:10b6:a03:39c::16) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|SN4PR10MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: f28c5bfe-4ebd-4dfc-cfb1-08dd1c45ac9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: nEp36dF8hGVn9aT+KFgPiqbMgVkQGY2oBToso/u5Ra8Y9L6MMhWdITZSdg+RDXeWHEflq1CsUHwZRe5eb84t67/swfo1pstuZihH97Bl+otBAVmeiYCsP44Y9T4rMIv0nGHSk7lhsHvrDT39PiPSXb9Pt9JiwSCFLB0wCJkKYWoqEIKUFQTYckyecoJCHXbfmKs4F/Q8+jzCUqRIEsw9ANcAUhiGrBkazxcVmUd5LtQA3Bx5kcFSBp8KCDkeFeryIhLVg8WvzGB/KTixuXLQDlJViDF+Hc7GAsFERXyTLRj64e0HYXzpBQDXevw87LmDJxAf8zbr37rN3cJbnpYwItGMJhCDvEKJfmdd5JlDS7Tm8e7OfdrXBSDjlaPSxvCdviY6vDusjOvyN/PhWbpL0l3MCx6I5Vj+iEhg5/32zMVu/LN/CjHKvrok1p5z9aKwQQWfsKIZWFdzGx1GETDZiFK/7qDlSs722w+LOyD/GdNrCT9+BiX+GtJtznkeQK8PBpGbxCXOeCVboEw8kBLYVUrj3OFJZFh17zCbvefwKUPCZB6fpmgj+R4/BIOtP8Pttp+Q5jSnQrGUcV5DrRUFeMCq3N91GFHD2gqd2IZIK5r6WWn6m/0dwU6vBroFPsEg4JIDlQzcMFuC+s+KgLSQe3wT9yyaWk9BI481LC0WuASUoBFDVgk/jSIVisHVCsQHo4phT+qFOy7GHrrsGk5dlDuiYr5jR1yGRJB4UOTlv1j0Tj7yuIfStpVlsYT9ZXX3u4uBHkVFX7oyZg3ZgqZ+9LIfBoBh77OMK2hqNqJT/Z3m9zXQO8qws/69QErYLW30aBPLzjwter+AFW4AuVgDDH2Xwt+w6dVl8Ase9VQZ+vQ6AYeVoxzcl/fqVmqYGUhhe8rJjDdi8rvmtm/dhXoqeLkFQ+xjsvDbWk2/hrkj2R/YyqzHpHWZ0o5IQI/Ubni+vi2ZgFQSdbCWZP0aRQm0mAtaObE2D+8gF2atbeJ4qrJ0Dl+Lf8efvcaknOtkpSLEs5Y/6XOArbOom9QFHUIifgXQuD9XBwAxTuMIRaEQgxdWSGRNrnnB28cDv0cTVs8dwgkFnNQDSMDFNrG+6u80leV6Hw0sj8j7pXRZC3WWJaO2FkjYU1jPEs3bwYL82+GVQUU5LE7Szpoq1QwQczp4BmSi3KGiEUid+e/iTqm1c2aHl1IQQnn5ug0NXWVbxCv91zjTRexH5CbsA9fFhGSTl4gcPhwlRKyqcWWawADCylfxwmH3es3RcZDZLbYLY97bH4uAX9UPACwXAyh3YM9O8Y8FnORy+ucrMMQvP+av2S4UpWDVd+h0bPh/8GRVSy4ntouw4+uW5JGY4pQogOfS2w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR10MB7329.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZYTaSREjBt/2t+L4MmL6hxN7Q04p7gbznySnAgP+SfzYNK5QOkS85agbFN45uJr9XbDqseOjm9WgVqHhtcgXlHkcjbYIGS/ycxGPbpSI7iIhvvi7VKLvMua5doGL///SDfj1dpzqtELDilUHxHT1kCZM2l4oxxKK13eAVcbe4Je/iNbTdgb/jvMIHLCKLxC9DDsNQ2wsZmj1DFdyY+g7x3xs0ex1dleHccaWpKW5glDDRh+ff3JqqQF3NazV8D09iceJQoOwT9FkENs0FzU0nSAf0a1e7tKFrkQSc9lJ+A+Vdcfayj4l47jJVrXEQVrfOej3nontZpSyVnvRlRY9YdrR528djrkbckRlgASTdidW9GvB88Wd5yUPJ2SQM2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iAop1yPswV58Li9zlnRr8R3/7Xl9gjydolDljxjb3/vVahu7WEnfbRHYJtcprwAivWwXOkWUWkqZLm/tDvC4JCM3K6wSYlyh07YMbp9/jiGv4HWWqby94YOaZKq/gVr1is19Sb1BHeZ3yrufPFyoxLbA+TEsTpLC+g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YVOLyL+bdeW4hhUDKNjj9AhWeouq+UReLecQYxyv/4NpETgg5j8Zzc98Nn09KXW8383QuxcCtPCAutpkTZ9njGAWnfD2H4gU6GwFMaqQKEW9W1/7psU9fj+JrgzkU6wPEBZ2wZ03G0YvGp0kR4uLvBpG/FZ+MP678nw7H7cclQ81h8lLyvI1IgGBI1suiZ/gP7fMMVK0350Xq9VaHRyzIgERO0+yupE9rm4jEcI04dqYpudHLgxWN7x6XEN79XjPU14jnVlI9Ncg4FUmOvqYTdX71jJBq60ERtQFrM7QtI5KAOYNg8rG3nBUPjUy7x4GlO7RuyBgvx2lahQEKJjz9phJK8gzwFiUxgSVLvTf5wUkMRAq81zYLEDUPl7KgBhhkwdVVdom354KUEntlEWv403kzvEGpZVjgA5Nd7fbuucrw2lFHgeBYddtzUAWadxsqvdHTu1IakW9sbibA7CsfnkAjJHKHFMyC7rUFjgccmvyjAtrP7q/mOVxad/8kktyo4TZ1EeazBecijNqj/uduY4aI4dGKrjJMGmfXKAAkVXovm6oaG9zw6DVwqD4Kn3XjIH7STC1KSkJTaXrUz/gftQZJjCx1nDgmJXwsqIF5Cc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f28c5bfe-4ebd-4dfc-cfb1-08dd1c45ac9c X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2024 13:46:13.1900 (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: 9ePS13kWbM6VbwZ6+2Az1DZ90yNLVZDkmOmzu4DvtURE1vDZ+F4wRbwtvypmdJjPDZ8JhvlRUGeyZI5MBIPVD2Odxligach4p5Z8/56OBjM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5624 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-14_06,2024-12-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412140112 X-Proofpoint-GUID: Y0pMNL544rpQWZZXi1aFF7PuZw5T1-7r X-Proofpoint-ORIG-GUID: Y0pMNL544rpQWZZXi1aFF7PuZw5T1-7r From: William Roche Merging and dump settings are handled by the remap notification in addition to memory policy and preallocation. Signed-off-by: William Roche --- system/physmem.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 9fc74a5699..c0bfa20efc 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2242,8 +2242,6 @@ void qemu_ram_remap(ram_addr_t addr) } qemu_ram_remap_mmap(block, vaddr, page_size, offset); } - memory_try_enable_merging(vaddr, page_size); - qemu_ram_setup_dump(vaddr, page_size); ram_block_notify_remap(block->host, offset, page_size); }