From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959330; cv=pass; d=zohomail.com; s=zohoarc; b=HgFAl/seLysZsl86giRLoGh7CTJUmwNKrI5JCUOJRadS0oRk1Re94MUcZscIETKYoc1AgqO60jhPrkyx/FOL7AbpebJEE0Dz8Sxf2JW2UZnF+w4nVXiSQDzqbViEgGU76/P1PXJXTtRz/sKiScqr83f/uJJN5wgwb1+G79nNTdk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959330; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nvKn/wDBAxD1e10wUSGS3PLbmwSD8bBz13dZQCFyI20=; b=k3Rk+UnebrovHACPPwN0QpQpRvXu8lYg4G7xOsJCN9ZGFUf21/DI+YlJ324ZxiQd2O93tLG9/QpnhrqxbLJOiGi9LVe+D0t1AOJVTLVxe/xbBCmmzXWFCkuRInrCv7c+IaBOCnddO8dVfYmgUkGUY5LnPPJ9vBgqmOAs5/ZOt6Y= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172595933024034.76008912264501; Tue, 10 Sep 2024 02:08:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snwr2-00069G-Ax; Tue, 10 Sep 2024 05:08:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwr0-00067a-Ql for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:06 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwqs-0004HY-Vk for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:01 -0400 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 48A8tb0E031012 for ; Tue, 10 Sep 2024 09:07:55 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41gdrb51s6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:07:54 +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 48A886Qw034160 for ; Tue, 10 Sep 2024 09:07:54 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41gd98s0dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:07:54 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:07:52 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:07:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=nvKn/wDBAxD1e10wUSGS3PLbmwSD8bBz13dZQCFyI20=; b= C452c+3DsxTE4O2lLdSjUrwmcVbt2xoa/1cpjsjy3B75D2NGu7W2g9yXga9pqLIb 4a3WPyuZ1Y46U3FNqj8KBNvAd8iqAmT4j1PJpXfIMAC6jkOehqNAyEOEL+kDaU3b REjmRDpSOL4a2lpglAjGa+7/epJE2ttb3SCN0KVsT+nn/iNcOun0vAUzj8Y+BLpg iw+TyL9fyvZlO3bLN5dZ0nrWBE74kYh7AAaXpNdiM1Mixo+Z6MKfty+KqulXgzqF HqrnQaS2LgzNumETvJcG3t/wNlPHKE1hyownfR+9NlDWmKaJECJf1PTcIZSkQ0WY VO7ey2DGrXPVhGhfbHxS8g== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YSXVX1Pl5+F2LKfnhI/MZ/YOK77Y/7WDxpiIZYzxO7a+a9+DfiQS1ceJqIC/B++ljACfwD1kRkViezH2WW/xJq6hDL0zMbI8IEV0YJzEgyIVoXdWsPe9cka0KzoRQMrkaOX8nOmvNXMjXtaIdZZOOCnNN3PBhe4PSZ0/fip8r0P9ocGQpoL1kWGWeqN2oHld90LzBmdnsOcGEldGTOcapmZyRkUl5W1PK5GtpbJmI68lhXUcu+VQAWzwhHyjxxjZMgvHh8fTLQzMEbiemSeqvJLFo6rT9AgVPHX/vUpMy7Sk5sgfytq0+UUiv1V935+d7s4KoJo282lTyDv8I38lDA== 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=nvKn/wDBAxD1e10wUSGS3PLbmwSD8bBz13dZQCFyI20=; b=OBcobv4ZpZSDMs4o3JpvF7g0tOdK2ADTjNcXHsX+pQJcif5FlONAehk3QkUCvLm7aChQna8IICXjjPqoqZQ/kL8FRlhVkSQ28qoK8YUKHH3a+ACk5uJpVn5aBvU4NJIaGFo4ahfoiogYrKYZOfR3vFlfysOYM+Q1epGSECCkBi6tbM9zqiG7LQUMd2sWnXIrudOGfYOgDk2ZXm6Etsx6AIvv7s5W4lGuxmHrba59HJKz3VjPYn3F19i18OR6Ch8IkAYY/WcZ71LwAnSOZte7obLfyncqecJRokziDcWmfl2BdkXEKNlFI2cEX6my7PA8L7ZlxaqsjuEJMGhebsg5MQ== 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=nvKn/wDBAxD1e10wUSGS3PLbmwSD8bBz13dZQCFyI20=; b=SqYaLN7AcxKIUG52V53iqgt4r9a1XEeTgyHbuR1NevY/3TWoN1I4Qwv+AEWcfixzxI+DL6M2/zCeX9H6wFLSzNk1uuhc3lkxXc6cms6AyAJhVnpBGrGiIYD23UOnvwRZhaip+1AJ84psm662owB/T541zv/bIyon83FsRvB/sa8= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 1/6] accel/kvm: SIGBUS handler should also deal with si_addr_lsb Date: Tue, 10 Sep 2024 09:07:42 +0000 Message-ID: <20240910090747.2741475-2-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0002.namprd03.prod.outlook.com (2603:10b6:a03:33a::7) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fcf6905-33c7-414d-8c43-08dcd1780cc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R6CbSpa39ZZTQ82PokK60i2yCbZkBpK6ZDXAzjz57G1snGwaufNyD/KyAUpM?= =?us-ascii?Q?e+UE742GdUdzLf85TvUMHHsBGFLhA85EnVacq513OSLZl4jvtn8r52xeBwjq?= =?us-ascii?Q?6aY/SSuav22sT0rYCnwyi0Q9nUYmnw11PoeYk5guh0PLnZbbdo0c5hjEHBsJ?= =?us-ascii?Q?9Y6VihvuJin9wlsrvqYHFM7cDCNJisLfMGLIJRwQbYRnfD7mZlf19peFKNeH?= =?us-ascii?Q?thx22mVnwNemMF8mC1TQ4it6F+Sde9SrRkbihvw0GZvg3972LkZUBLuB2kHy?= =?us-ascii?Q?Dci63nnyLuRxgfv0I0dejA95DD92TAU3C0DGk0j48G/6LV2KynBuPqceZM1X?= =?us-ascii?Q?PwhR+Kqa6HytldtCRrByL6uTfXkd5vcPQfzTknHQe4SrrKyQaS5MBzQhUVsZ?= =?us-ascii?Q?JCNs8rEcp/njbKuYSlB6RNTNnjXEnLKrf971HYACTaiWrPUfRoVJx9NPDXQB?= =?us-ascii?Q?cIYred6n344Onvd/2kAeqgcEMAnxpFnWYDxN5PbtXh3fXhasINToQkptJVtl?= =?us-ascii?Q?TR3t0V6vCdVz1fX4F5pTgx61mS6/qaD3DWMvyJydebt2fiOB8i+XYk2+ta9W?= =?us-ascii?Q?5Rh4eRVYklTVEiJpS3Ss+lOceH6Vju0jkI5kbQcvUHgDykzrTzhfUt1CcdyK?= =?us-ascii?Q?xqzqO5rSbIgroAdEgVFcXL3rnuLwCb0kOOl8QUZDNHtOJvhit7qVL9jRwb9P?= =?us-ascii?Q?7JFbn06JPFNMwYtEVSxig+2wGbBL+Xiez/enwxXZKkkblBZjCA55TfYvRYAc?= =?us-ascii?Q?b6i8w58vhLs12u/55ZP76axvaYpJUjWDfh7cvQdqSwh1BLQXULkbWNPPQFc5?= =?us-ascii?Q?jSvbIk2p4ohuave/oEf2pQ4OCbyHBwZePdcYF8s4TlMez84T8z58VV8Nx9M8?= =?us-ascii?Q?WaCSsHwWvF0ngUtRQvL/XL3mCYPQClVrzkshousfRu7vrUcpWM70B/ubz+BU?= =?us-ascii?Q?a4wzPVYpCVv3TYO1z6FERESesH+0JslU1nijQD9xH6F25WkdhTNi37cv6kKq?= =?us-ascii?Q?RU1xvWYgq/uuKwcm+qFRLBK6b775dmAS2NMTYv9pZ8vJK2DXWkGy6rBdlR1c?= =?us-ascii?Q?L8JDX+VXJffYUn4hDkFougZ1HlRLPmznL+uQDMmXL1Z7GiUZ50EC/f3yPr4K?= =?us-ascii?Q?9/H2yO2/4T2Cgqi1e1Ed8w0xzw9Fvre/0nhN5uRu92HDIxELklUh4E7AqJrN?= =?us-ascii?Q?JJMVFdEFtXXkbT+5oZffMfUeZsQEBH1TgRgQkTB1/FvzPiZILB0UTYtFqTyE?= =?us-ascii?Q?DalhF+VpzMMT1ZfUvIN1pnwyvjs8+b+J6jHKk6IXEFKb8DWXh0zwjEwUeP4K?= =?us-ascii?Q?hTvR6eBvAPvPOl/V0/fVBzzl8aO68/3jO7JVM59fopaolA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?W8FRydjQzJXd+ufc5qD8A985h1SioqZmEQ3Plyc1uVATBXVfaXMyPX59QuuP?= =?us-ascii?Q?To+WqildX/cYXORDjgXEu4/6NdD4tkTGwQJfglUeO8syAsRtWwZuh5t9GKxW?= =?us-ascii?Q?uYHUiszg2PjmmgAc6Ex+zPbCDzpzWlMbhxG/atBzEZwMPlw8u5IY2lRsMEYh?= =?us-ascii?Q?y0EhHpoU8q3qvncvL4jEZ7tZBOcbA78DBB2w2/M6BSRxH88WJzHhOF6ZQKBr?= =?us-ascii?Q?rtWMVMbncoKxAmLieaLWqthlYEKXN9ExdoS6gFixkHf1fVUx1rvqpQXBBevb?= =?us-ascii?Q?S/nA+0UsvTkhwyWjbLBUjw4IIHUi5nKQhmWAf3MkGfgQOrB8dgOFtqpEIDKD?= =?us-ascii?Q?vfV0+V2hSskUYr2HfLJkvpkdW507OvwSo+6tkXi7JsbZ6G58gj3CQ/HAjHUx?= =?us-ascii?Q?Ngz9oTtVvoHm6oAKjFY0waGtO13RYKxkbW4yzEM5iHRmEvpGQBLEDcF0C7y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QbRdoQ7Z/OiOVHYsMJLsnyG?= =?us-ascii?Q?s6+E1D/f0ygf5YglcWE/R+OWeL8M3Akl8RWXzt+FGcry0PEgmP/xDcfekmVt?= =?us-ascii?Q?id+Lc5HMJJLB9zn6y9+i2i4aXq35v7bkbJYz7DDx1wzAbI11U3f/hPtUsDUg?= =?us-ascii?Q?ala5dZmIhfP3aLqu6GWlNtVWRP+yTBsiIq9N4fR9MLtnnPEo2Rz6ZThyUrok?= =?us-ascii?Q?5B6mVBK40YJhdnpGB8hGix0kDiyCkW8cwZhg67wmrcPoRpxzAZm5jJetknuW?= =?us-ascii?Q?Hg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: CHqRjKUo56GLyMS551n4q9trH5NUUtjnJJKWW5KpURzKAkH7kUgiTAKOkDim7X3CIe8iHoU0HQGdMuQZjANVIoUdKpkP/O8H4twiEacTJ/9R1kQEbNh3UtRdYFD9558VwvHTJggQfN6JHbaqYVl+n/TNF2KdHSoBiXdeK3RcMfWEgD4n+9Vt3VBZovYNOus4CUD/7+noSDXJZN6WjC3cymEbygzQG8qw6E6MHVpwrsHbjkLS8rq/KTZQvTkEqfwIIIXVO1gcWBQsrqBIuCfAco1IgFYhwUZfoD40u26Y8ll5XtPgXA88S4V+2sXWVW9/0naIPncO3ezzm+rue/jG4IK3z++wvOw/mK6CBYE8mfXXu6tQ/IbbUbVI7ZqTXUaLzAlkVsaNX9eNq3Svyvyj7id/ZFBhCPNhKXnLORt7BB7BYup1KvNd2iZI+d9lbjaclQmzI3CDWsfoyQVbSqY7g69xlGXlIhwtqvE9ve5Zpl+BfEoHHN4vYSJplZEoefcZF6eCVOAxLUVzFd4mevwXYgsT382RDrnjzdQYtMcyBQPqUpMhRHxQeATvzlNNLV2QjWVcqqIFmImPmwBBYH1jOoo5qUz0TrlKqaIVQHIQK/A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fcf6905-33c7-414d-8c43-08dcd1780cc9 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:07:52.2326 (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: yqcM0bF43BxkR2UWgQpLZd039vDlqSxgbtIzYNWdXC7ZJINMehWmVk/eR5dItQb06zEpYcUnc/mpwAW4nrx+GPPti3EvD1ZNhXfGm64NGOg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100068 X-Proofpoint-ORIG-GUID: c8xcuTEOVAU27wWlkckkBijY8atiXZn_ X-Proofpoint-GUID: c8xcuTEOVAU27wWlkckkBijY8atiXZn_ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959332857116600 Content-Type: text/plain; charset="utf-8" From: William Roche The SIGBUS signal siginfo reporting a HW memory error provides a si_addr_lsb fields with an indication of the impacted memory page size. This information should be used to track the hwpoisoned page sizes. Signed-off-by: William Roche --- accel/kvm/kvm-all.c | 6 ++++-- accel/stubs/kvm-stub.c | 4 ++-- include/qemu/osdep.h | 5 +++-- include/sysemu/kvm.h | 4 ++-- system/cpus.c | 6 ++++-- util/oslib-posix.c | 3 +++ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 75d11a07b2..409c5d3ce6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2836,6 +2836,7 @@ void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu) #ifdef KVM_HAVE_MCE_INJECTION static __thread void *pending_sigbus_addr; static __thread int pending_sigbus_code; +static __thread short pending_sigbus_addr_lsb; static __thread bool have_sigbus_pending; #endif =20 @@ -3542,7 +3543,7 @@ void kvm_init_cpu_signals(CPUState *cpu) } =20 /* Called asynchronously in VCPU thread. */ -int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr) +int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr, short addr_lsb) { #ifdef KVM_HAVE_MCE_INJECTION if (have_sigbus_pending) { @@ -3551,6 +3552,7 @@ int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void = *addr) have_sigbus_pending =3D true; pending_sigbus_addr =3D addr; pending_sigbus_code =3D code; + pending_sigbus_addr_lsb =3D addr_lsb; qatomic_set(&cpu->exit_request, 1); return 0; #else @@ -3559,7 +3561,7 @@ int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void = *addr) } =20 /* Called synchronously (via signalfd) in main thread. */ -int kvm_on_sigbus(int code, void *addr) +int kvm_on_sigbus(int code, void *addr, short addr_lsb) { #ifdef KVM_HAVE_MCE_INJECTION /* Action required MCE kills the process if SIGBUS is blocked. Because diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 8e0eb22e61..80780433d8 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -38,12 +38,12 @@ bool kvm_has_sync_mmu(void) return false; } =20 -int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr) +int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr, short addr_lsb) { return 1; } =20 -int kvm_on_sigbus(int code, void *addr) +int kvm_on_sigbus(int code, void *addr, short addr_lsb) { return 1; } diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index fe7c3c5f67..838271c4b8 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -585,8 +585,9 @@ struct qemu_signalfd_siginfo { uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ uint64_t ssi_addr; /* Address that generated signal (for hardware-generated signals) */ - uint8_t pad[48]; /* Pad size to 128 bytes (allow for - additional fields in the future) */ + uint16_t ssi_addr_lsb;/* Least significant bit of address (SIGBUS) */ + uint8_t pad[46]; /* Pad size to 128 bytes (allow for */ + /* additional fields in the future) */ }; =20 int qemu_signalfd(const sigset_t *mask); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 9cf14ca3d5..21262eb970 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -207,8 +207,8 @@ int kvm_has_gsi_routing(void); bool kvm_arm_supports_user_irq(void); =20 =20 -int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); -int kvm_on_sigbus(int code, void *addr); +int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr, short addr_lsb= ); +int kvm_on_sigbus(int code, void *addr, short addr_lsb); =20 #ifdef COMPILING_PER_TARGET #include "cpu.h" diff --git a/system/cpus.c b/system/cpus.c index 1c818ff682..12e630f760 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -376,12 +376,14 @@ static void sigbus_handler(int n, siginfo_t *siginfo,= void *ctx) =20 if (current_cpu) { /* Called asynchronously in VCPU thread. */ - if (kvm_on_sigbus_vcpu(current_cpu, siginfo->si_code, siginfo->si_= addr)) { + if (kvm_on_sigbus_vcpu(current_cpu, siginfo->si_code, + siginfo->si_addr, siginfo->si_addr_lsb)) { sigbus_reraise(); } } else { /* Called synchronously (via signalfd) in main thread. */ - if (kvm_on_sigbus(siginfo->si_code, siginfo->si_addr)) { + if (kvm_on_sigbus(siginfo->si_code, + siginfo->si_addr, siginfo->si_addr_lsb)) { sigbus_reraise(); } } diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 11b35e48fb..64517d1e40 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -767,6 +767,9 @@ void sigaction_invoke(struct sigaction *action, } else if (info->ssi_signo =3D=3D SIGILL || info->ssi_signo =3D=3D SIG= FPE || info->ssi_signo =3D=3D SIGSEGV || info->ssi_signo =3D=3D SI= GBUS) { si.si_addr =3D (void *)(uintptr_t)info->ssi_addr; + if (info->ssi_signo =3D=3D SIGBUS) { + si.si_addr_lsb =3D (short int)info->ssi_addr_lsb; + } } else if (info->ssi_signo =3D=3D SIGCHLD) { si.si_pid =3D info->ssi_pid; si.si_status =3D info->ssi_status; --=20 2.43.5 From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959324; cv=pass; d=zohomail.com; s=zohoarc; b=kv2sc6bMPnWEbNMuMw5tcqc6tjTGUYRXcGdtBF1Ek8Ho4kJYH86KwH/gpUeAoHlzVqd83iiUoghTfbovs0AMzlnoMGLA2RQXSzDikMBLKvxYlGPJUtuaxyyutgpcAcDfEd1C/yMaysG96In/aMFHUJP5YoEelHT7Yq4euXMK4ds= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959324; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lTEL6i972hm0brpxKiBCC5Jh/AaomVcIwAnTkmwuThc=; b=n1ygC9v479gy35RxNZoHboQuuAqr1EoruU7ecipEPggzSD3WrByNXzf1aTT4LbhtZbYOeq6tIw2KP0Nyxh6/rlcAE2xLIZLti1kgife7bB2jU2h3pWrlREVOdRT7d1b+SBboSrrwjhQyWBOiIO5P6Yom9cOtv3IAxrlZve1GPEA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725959324733198.58648386648815; Tue, 10 Sep 2024 02:08:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snwrC-0006OO-Ba; Tue, 10 Sep 2024 05:08:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwr0-00067b-Qw for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:06 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwqt-0004Hf-6i for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:02 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A8uEWS003988 for ; Tue, 10 Sep 2024 09:07:57 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41gevcn1b9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:07:57 +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 48A7giFs019825 for ; Tue, 10 Sep 2024 09:07:57 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9esdc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:07:57 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:07:54 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:07:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=lTEL6i972hm0brpxKiBCC5Jh/AaomVcIwAnTkmwuThc=; b= LY2kmDN8nLq7iyA0nwMbX2jxE7pGFV7vOw033IcKjQg9B22wJqn8vWTRC98ysNmd hYReeMGVaKnOWYhVueD8Y2mu30SA4HrZ9FGxIAgUcGOou0FBjem1QUOvOH1Sygci NJ9aseSezDYPGtGSvMVnyjXYkPzWVbbxbWEJFgdM1D4gy54qJpamBLE8nQF03EIU u7lL8l/SoeTmZPhviaBrK29wzYyuT+vtddU01IGT/6Zm8rvNxp0WwinTP5k62P2r YZ2fhFj0ZLJ/e+yuVzWtynYQ1Gj6mragYcpkwWg+/FiQ3juuFB9/oevw91pJCm5T MwG15K0Cco4ZBnH0TI1aOg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ER0bIrNJNLZoyRP+J6XAScN35mdL6+DWMgCqwKOM1emzv9agwikwTnQWI/YuGoffY8Gc2nyQJuURy9Yjwazv7Ifl5AkgD31sjzSdE1zfS/yz35bz8clxKmwHs0g/5Un88Q9CtM3Vx7uINLjdwWFIWUqO51mfAqNAIrdSgqAHQRCBqPBBym1kFWkhaqQiXEcvLW0ApANDoHGdX4KxKJf7h+Jvfrnd9EotvI6ZBOWXDkgN8qaFK0Y/YUlxS+mn3Kp8k05SAPMSZ7if8xpsYghhoq0sx/mAXM2PUlWl6nnexPyTilUXJppN6v9yqh1sRTFkeqVFta+rnsPdGXXJSfKPkA== 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=lTEL6i972hm0brpxKiBCC5Jh/AaomVcIwAnTkmwuThc=; b=sOYtN7tOU617TrCsWgV8J0JcsbdvMjzokAVop12/r5eeqoAtbExqwhUD3LJaZognEyH2lRywVfEo3A7vE/4J49ecCO/+WTYlXbwG/qP0ogqztqk0UrAlvjqMFlX0ns0Awl+I1hxV7w98YGbegzZc0EzpBbhen6woOXjdDJe0+P0Di0BjAmpdcpBYecnWAHD8P+ztQxHBXeNPNJZPoMjpMFVgIh7StvD3QgGKmUIU8GRGTeMhZkjekuEZB9joyXWVk1x6O6RDUlKDngAR0lD/CgwdTFt2luoSleatDMaWWPz4AFFdMrCBm2bX68QLTqHl7Rhbh10BWBHAujm9KkGszA== 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=lTEL6i972hm0brpxKiBCC5Jh/AaomVcIwAnTkmwuThc=; b=yU696/foQWjpkiYBz68Hn0ggIfpYJo/lwOareuG4nnwUrm+0MQAcjKXQoyd/qF5clX6rTR9g+0BfR+MBn2nkpfEgHMkxgc3J2Ln6THJescllrEuF4LJzJeTypF2wkE0SkKpN5u0ga4UTeMvNZ4Y2mOpQPZQbJ+hcGHiz256kFRM= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 2/6] accel/kvm: Keep track of the HWPoisonPage sizes Date: Tue, 10 Sep 2024 09:07:43 +0000 Message-ID: <20240910090747.2741475-3-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY1P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::17) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 4caa6945-3fc0-44f6-bff4-08dcd1780e26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DXpgbSNdZGSBudWcq2XfMht25kCCnJxCpTQk3Uhv6vkSNRHXiQtKKJ3MCP7T?= =?us-ascii?Q?5C4G+PltlDFsAgz8gSLU52+6q8tiMuSASeOa+89nz5oJR4HEYNkAwN1+Gr30?= =?us-ascii?Q?4ob5RaJEM5YBh1wlA5NpjkLy9Jn5ovMtihXHINYj/WNkFb3gAxfq2kwpzQf/?= =?us-ascii?Q?YaZsOwHmTTB7zR/LoVwwH6diHjjgDDwxXicj4WlXUEgh9abZyb2NXgwM/mjr?= =?us-ascii?Q?vk4P3fEjUhw6lfITAKVQ4GybyNH4S2ezSnm5DlE6I9QitvZ9vwourYYunIFb?= =?us-ascii?Q?P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jjpCHzgqcUGZdmJG9oo?= =?us-ascii?Q?5uY5QNPcF4/ksMcjAfNn/jBGCPj4DZp0lCLi622Vg9b3WB0fhCrccwAdo8MS?= =?us-ascii?Q?Ac6Jm1lUuXDa4riU+oQbRvA7iSZnzHHTMBvJjKHZLu034KAZmrppzFJSd/P/?= =?us-ascii?Q?E08PRuvQPd5UMMk5GINkKUTOswXbiQZQsff6V/iB/Z8nlA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Aqhq+R/HFnig7EFL+HH0f5mBZBdHfFcTO1D465jHhbwOkCz0WlrTvHGwMmDC?= =?us-ascii?Q?MDI0DaCy8EE6OiYTu3C6ahcUi3aRMhTWgtJeBJ67A9OeNGlOmR9zk7CCEYuu?= =?us-ascii?Q?n1IWwKSwyEFO/yD6iIIFPIU523wlwEd5KfyO3l4TvbaTfw187vsJWw2gr8oo?= =?us-ascii?Q?GkBTvcDP3D+RMCXzobzN+8SyQT9+Y3KvOd9Ogo+UdHpLQejSEgCTVwK5jtV+?= =?us-ascii?Q?7eYxavbLiXFEAB9rFt3R0nUlDM2HKA8T7fDN+soZ5SqdXRLWBlIi6VOcSihl?= =?us-ascii?Q?oVi4m3/hftlJSDqMSIHo9blPK10VKoiKS6BrB7ZL7Mo1WbgPM4wc1V5NKEGx?= =?us-ascii?Q?U9ZF0c2Poynj6CCRwjvCA/hCZP8dhWSX8EDMwZbObH+hl+gBfNzwt5+W3Wcn?= =?us-ascii?Q?6nmIAPOHj9KFlkXxDHD6c4uR9nDwelYGYJeuimgykyEu0MMGHGCpOct1tgbh?= =?us-ascii?Q?6ykr8f0B7wbJj6Sh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FIWjU4Yx8wcrLIp4Hz?= =?us-ascii?Q?i0D2VKN6BDdP0SKLmxmP3aQaT7RxEsVTk/zs7ELJu677uYCDzSoN+pg+6OzC?= =?us-ascii?Q?ZJer8iX/tWS38ZLQ/IcioqbrTup+cWhYjiZnoCFUP97eG/Bz9AkYXWEwKalD?= =?us-ascii?Q?l/SiIs54hLLR1MsTP8r2nbCJ3BdtNZoCVKI5kDEHnhsF6UCEd3sNPUU06dXn?= =?us-ascii?Q?Z244f2njCLhod6OyEkK/imJNjBq/nTUWXZlnDewiajytvslzSsTkVp92kzb/?= =?us-ascii?Q?MQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: O7ADp0MI2I4COvJahpyOnp2brwXlooHs3CGRCaGWZf3IuzLNh4l5Ag/FNHiSusalHYzhaLI7A9XDsK+dqhrWOWr4XzanJNeKrwPKFTPEf7XSnlWl7Gn9MPw+yHSxFelqJBS0uH+RQ4jUmtmPkfJ+Sm+bt2PfJHAIuqfevAdxRrgp5pW3tQzn3m8n3ivZWGCTqulu0y+wXyVt6vU3visom687dH/92qqFSG8/rT/YDRIEIQxguGtFA3KCpUPFRNaXvXLdETQzz/cK3huI3Vr+TiANqEwMiL/VpMYYOVX2XYx+JqGTfDIH90Yi/qGOWntAMzP3OsCwiJ7CRsJfnOgE87HOO9skEiajYt/FGJQsWm+0/rbKAlbdOir9n99L2+/latW2/QCrmWGY7si4VS0NaVgtTZmImtZjasFJR/f9hAtIEz/ZAo3Q/yh3raDPJKT3Yd3dtKlu6QLv7BTSLHNkgtI6bs7yImV8VvN9S7UycqmhWWPEv077Bz8lYYxaOoGVUogutvu/vo41rP2PQWSmjzI8sqA+nKQ25QQUqcwYzi8g8nGewfPpGjj4KfDJcoH/CZu705/ZWtfxAyDshedPRpVOUIolDPejx3WPVdb5kpo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4caa6945-3fc0-44f6-bff4-08dcd1780e26 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:07:54.5060 (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: GOSZQ8UfLlR5Q6QZvjMPJILjrGvLebHVdk9kLkvbAG9I8wqB6j62uYWpx1i7ODJh4JVd3BoJ/aexwZCkmnJZv8iWB69oMAj9FEyTJ+2hLC4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100068 X-Proofpoint-ORIG-GUID: 5NHfYzZ4zghzv3FwKEz2bQOv-tfE2E95 X-Proofpoint-GUID: 5NHfYzZ4zghzv3FwKEz2bQOv-tfE2E95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=william.roche@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959326528116600 Content-Type: text/plain; charset="utf-8" From: William Roche Add the page size information to the hwpoison_page_list elements. Signed-off-by: William Roche --- accel/kvm/kvm-all.c | 11 +++++++---- include/sysemu/kvm.h | 3 ++- include/sysemu/kvm_int.h | 3 ++- target/arm/kvm.c | 5 +++-- target/i386/kvm/kvm.c | 5 +++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 409c5d3ce6..bcccf80bd7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1200,6 +1200,7 @@ int kvm_vm_check_extension(KVMState *s, unsigned int = extension) */ typedef struct HWPoisonPage { ram_addr_t ram_addr; + size_t page_size; QLIST_ENTRY(HWPoisonPage) list; } HWPoisonPage; =20 @@ -1212,12 +1213,12 @@ static void kvm_unpoison_all(void *param) =20 QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { QLIST_REMOVE(page, list); - qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE); + qemu_ram_remap(page->ram_addr, page->page_size); g_free(page); } } =20 -void kvm_hwpoison_page_add(ram_addr_t ram_addr) +void kvm_hwpoison_page_add(ram_addr_t ram_addr, size_t sz) { HWPoisonPage *page; =20 @@ -1228,6 +1229,7 @@ void kvm_hwpoison_page_add(ram_addr_t ram_addr) } page =3D g_new(HWPoisonPage, 1); page->ram_addr =3D ram_addr; + page->page_size =3D sz; QLIST_INSERT_HEAD(&hwpoison_page_list, page, list); } =20 @@ -3031,7 +3033,8 @@ int kvm_cpu_exec(CPUState *cpu) if (unlikely(have_sigbus_pending)) { bql_lock(); kvm_arch_on_sigbus_vcpu(cpu, pending_sigbus_code, - pending_sigbus_addr); + pending_sigbus_addr, + pending_sigbus_addr_lsb); have_sigbus_pending =3D false; bql_unlock(); } @@ -3569,7 +3572,7 @@ int kvm_on_sigbus(int code, void *addr, short addr_ls= b) * we can only get action optional here. */ assert(code !=3D BUS_MCEERR_AR); - kvm_arch_on_sigbus_vcpu(first_cpu, code, addr); + kvm_arch_on_sigbus_vcpu(first_cpu, code, addr, addr_lsb); return 0; #else return 1; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 21262eb970..c8c0d52bed 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -383,7 +383,8 @@ bool kvm_vcpu_id_is_valid(int vcpu_id); unsigned long kvm_arch_vcpu_id(CPUState *cpu); =20 #ifdef KVM_HAVE_MCE_INJECTION -void kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); +void kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr, + short addr_lsb); #endif =20 void kvm_arch_init_irq_routing(KVMState *s); diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 1d8fb1473b..753e4bc6ef 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -168,10 +168,11 @@ void kvm_set_max_memslot_size(hwaddr max_slot_size); * * Parameters: * @ram_addr: the address in the RAM for the poisoned page + * @sz: size of the poison page as reported by the kernel * * Add a poisoned page to the list * * Return: None. */ -void kvm_hwpoison_page_add(ram_addr_t ram_addr); +void kvm_hwpoison_page_add(ram_addr_t ram_addr, size_t sz); #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 849e2e21b3..f62e53e423 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2348,10 +2348,11 @@ int kvm_arch_get_registers(CPUState *cs) return ret; } =20 -void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) +void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr, short addr= _lsb) { ram_addr_t ram_addr; hwaddr paddr; + size_t sz =3D (addr_lsb > 0) ? (1 << addr_lsb) : TARGET_PAGE_SIZE; =20 assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 @@ -2359,7 +2360,7 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { - kvm_hwpoison_page_add(ram_addr); + kvm_hwpoison_page_add(ram_addr, sz); /* * If this is a BUS_MCEERR_AR, we know we have been called * synchronously from the vCPU thread, so we can easily diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2fa88ef1e3..99b87140cc 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -714,12 +714,13 @@ static void hardware_memory_error(void *host_addr) exit(1); } =20 -void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) +void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr, short addr= _lsb) { X86CPU *cpu =3D X86_CPU(c); CPUX86State *env =3D &cpu->env; ram_addr_t ram_addr; hwaddr paddr; + size_t sz =3D (addr_lsb > 0) ? (1 << addr_lsb) : TARGET_PAGE_SIZE; =20 /* If we get an action required MCE, it has been injected by KVM * while the VM was running. An action optional MCE instead should @@ -732,7 +733,7 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, voi= d *addr) ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { - kvm_hwpoison_page_add(ram_addr); + kvm_hwpoison_page_add(ram_addr, sz); kvm_mce_inject(cpu, paddr, code); =20 /* --=20 2.43.5 From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959333; cv=pass; d=zohomail.com; s=zohoarc; b=ME0peJ/tB/iT2Wiy+61ltR/05kwPbys8M9XNRVegXb81v4cC1gO+mOdWX4Lyt+OqIYKzM6wNEeWbx6yN7Anbvkf6G2fdz3PuYG0T47Bli3mpGF3hN6q9WBd86EqL0RKsw4ZFMywrAG5Yu7mJjkLyeeSWn3v+AIhpbVUzSHkEm3U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959333; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iUpJfFkmzvcResM42CgeM3OXvVIAkS6DqN2a6mWjScg=; b=mKwO6g7LFyKoeygLRZxl1Sp2nGRTYM9SCYNxNxC5euQR/qS3M9MGbWRbesmPMbu1phzeWxmZXE9K7VrO4/DfEdSixSPJ2T08Tr5Z9VIPqJQx6EEwPAkLYjfv8z2Jab7LDZPAwpUGNJ99veQVkOT23cOtBCXQM6a+pFPBVS+Z03M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725959333788891.8927438076371; Tue, 10 Sep 2024 02:08:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snwr9-0006Mn-FS; Tue, 10 Sep 2024 05:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwr2-000690-1L for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:08 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwr0-0004Hu-CB for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:07 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A8tZNe002423 for ; Tue, 10 Sep 2024 09:08:00 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41gfctd0n4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:00 +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 48A8j1T5006205 for ; Tue, 10 Sep 2024 09:07:58 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9898dk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:07:58 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:07:56 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:07:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=iUpJfFkmzvcResM42CgeM3OXvVIAkS6DqN2a6mWjScg=; b= FMbE3HIOMm8HBhWuhhfHzAj53rFgU30ytjYemz29q9Xx8+x4lxskKQnzzfry9ah+ U9H4soCC/yOHVkCz8RwJu+kNfWuukAmYK5WUS8TDxmH61nbxAgN/fJZP5YGL4rWf 2ksUr6HqxQ9jlaKGGTzx9yfigOyrIuzCQ7RKUj+iKwmCRbChING088i/jJvQ200L aQwHT3dWajpJQ/nW1qiz3sU5uk7iPe2nhIkoTL1eNZT6aF5sOk2BU6S70KC7yNZo O1ha3/bZmSmMn40Y2C3P+akvTjp16ENvXLNuwWVFhJ+2LWbyLZ0idRZSIJuRTThQ Llcc/SuyBC48MmI4yf6piw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ljuja7oc5Ezh3JCGAq27UPv1l7HS3feANmX5Gk1PDwMA/jLu50MPIdy8Y8dJ9cIjqkd399Ef4YhstL05/M1HzrKOEwB4JQM5fx6r6QxhqB1Fuyn1Kr3J1yLQSvkwQWMlDUDyXaiewH9T1lRA2O+V5awp9gQRu8rOx6UtLNFH6ifZIFGZIY629Pw52eHEw8HlcsxYGPr0J6E+UI0hgIa/nl3UvgrgmCnB0XqOkrh6I/ufkMAxFx1dhYUrUVYcZvJGS38Cm3ENkRDzAA3mU+e/TcRqNcosfqDQ1j0uSme8XQUivuNBvQYiurMAQZ3e7tHmATA/20ZPi29iPPhmEUwnJg== 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=iUpJfFkmzvcResM42CgeM3OXvVIAkS6DqN2a6mWjScg=; b=MqaqikAQYywd3E7Wmd25p4EWt/f92Ufc0Nq/cdIPk7ObUlYrAI9FlwEpEFG6Qg+36b8stHXeyyk/apMeOF1+N9MsSnUFpc9JzCH9ImlQ+WJFgcQYT8rFRsMipccylTwHs/kVYmvrw9F8UZaR2C6c4/P0LDnhKyYr0U3lG5Q+AaiNwPnCuD1JFWsh1WKzSC0MJBmcBZaYwnwbroJVESR1/iv4InAyXYM5tFmX9+OXwJnBf5+0Q6aN4dSR0j+WQSJKhUFKeZYIMdtqjWUaJ8r+0pigbxlCgaTvkUCFTafX0kuMr7UsX9ZTUEW8jBRUx4VJz2S+Z3+0kFvntP8y9sCeUA== 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=iUpJfFkmzvcResM42CgeM3OXvVIAkS6DqN2a6mWjScg=; b=zX1fKwNu4hDWFpQO9j1g+qK4eTFvJz/gP4gYPQaiALxKB9wuEr3rHC8HiTPNi0ok9ABrwiAYVllSFc1suewXSBPxSJ1FBOg+nnlOf3He5DmBxGFdwrAsVDhUUN/xVA8fkPISB/SqIt3GFUyiGqDQXC/v8buhp5jBCIgwo8RNVIk= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 3/6] system/physmem: Remap memory pages on reset based on the page size Date: Tue, 10 Sep 2024 09:07:44 +0000 Message-ID: <20240910090747.2741475-4-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 258c3698-79e9-4cee-36cf-08dcd1780f70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Eg8FkcKCsLL8jMmOd7zUdDVAU0lSLAGJGH999dLg1H4BG9TZkHlGSUWzhelW?= =?us-ascii?Q?8D0xspavkqiIkCnqenLSV7kbJWCTGw+WZGLGaQYpeQ7nHbWnuvaSsFvLBMoV?= =?us-ascii?Q?tgkkbAuWjdf7HecBvRNo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q?TdO3ivM370baB549ZIobXaGS4FzcRo1u9Dades26r9agG2P35zxnzAJ4YFh1?= =?us-ascii?Q?mneZD5owvb9u0iEnWQwIfo3hGpjIGTR4H0SeqwAUXsNSxFwBifhqdhs0wI6j?= =?us-ascii?Q?k/KyXPNI+pWyh7Hrgix0xMQ2XgunkEk1Ajd0+a007V4LiFXAVIjoRJfm8+NC?= =?us-ascii?Q?8sXOsNg0okJLgHBnAn/4yRgQAKLNjn+36vwC+IPoAGJzBaPzeo/bLoXHBQlz?= =?us-ascii?Q?h4arXeSHhG4m2OsKy1JCmx8RlPtnPYs82mnLIXhasRgMrNBUy5Pa7dAYc4h0?= =?us-ascii?Q?b81ylh5PVNGagteyCDlgNoCzNhb7usd9gi8Qe4nSEuBnTw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8ainwrLeFVwJGN/fWTwraYnFKtUm0+/BB8NG/h/0GYwTEMLon+3vv1quhFq9?= =?us-ascii?Q?/Q4F2UW7+y23+XgyKlztcespG7ez1cBUiSTNPy+HZCW6zbf6ckHpP9dWI8WP?= =?us-ascii?Q?rUxcdkJjMPKrftD09k8G5Qsib8KvXerIrAjHfR0X325P3ta7BffuhaAvIo26?= =?us-ascii?Q?l1MG8PyQx7yZhkb8AaRKa7RDuy/Q8RfGIRPUUmd4h+KBb6YAX0oF57cmQydT?= =?us-ascii?Q?y15+bP+Rtm8yJ2bcoPQX1vzRjqBU2RrWWjBIqeK16n9t5efxKKBX61iByf2n?= =?us-ascii?Q?aVdxsn2kGqh9u6dMNCWWoRV3eZ4bbpRZQ6NHDEq6D8K0gZ/LlybT5o9CBMU8?=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8izv3wD+xSJLWuw9h8BTIzmhuWH?= =?us-ascii?Q?Oz0TRtF9nUz+lta5siJGZf32G4JECcNFEG4s5a3YDDhbyqk0TaZz0Q6ivHMV?= =?us-ascii?Q?J+er+dqppjaEbHARE8xj/ugh6A8D2ZKuH70h2X2nJhFeOWgaGaFxxasDPAFZ?= =?us-ascii?Q?WcrJ52gYoYyC7daqR6DvmE/I6JePr40uH0xF9ao0EgxZQ/iCJQXNyN1C+oUz?= =?us-ascii?Q?ORWhDf5xNt4o6fCkajSAx2hn0tdh7AOW5q5yIxN5c0Zt/Jg75sssLLRwgYX5?= =?us-ascii?Q?7l2EqkT70kdDAQJ8y5anl04/qHjXYU9ssHZeTbHV/MAJzVnshIZLWN76zPL9?= =?us-ascii?Q?AufAgUBCtabGI4kz1X36n+JYFZPSJISh2WROZAFipfL71OBvKzsRSIVWD/J+?= =?us-ascii?Q?vQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ppi35nugdvttUINiZ5K6Ymd9y93r0gJgbUO/ENwRlsYLWANGQ3R6Pqg5Eau+pth+36eTdxkA49UckMZbJIAgG6YBoJbnFX7DRbOxtOTe1x9/IbwWR1d4Yhk+/lLifUJOaei5BiiTBtmgwVM5pY3yjXPnwDFvSpbZJAaMurnX8VHQNBlo+hCPq4MxEMUyzK8LgCef4DoD9hPdUZ99E45n0qZXQSZ7QccdBa81q60sXTyh1kzC45RZL8ZS2faOEJhp+jeKIZ7mq5/jqOVfw9kdQWsw+2P+g6g4RTvHu5NZEO/wDe01a7mtJ7Vb2jaN5NUez7l1zyuAAoDpPvUqu7E1VIKTZX6WFREztlI71uh2i63oORl0rWc9bgLlsaBqvHHcIFhkKicjUwEFTIx2uk9AaYQyd08AsnoVHonL9GNmn7vIIZD0T/5aaARpbFAYaB9AF0zvh7kNwaUu08PXlJ/9cU7n0oLozveVY6iRipnmcd3DvRwxKCrRDYUYIFE0mjUS18HW5ADh+YTepoSdl0GD+SRrbDu5NM2slctd/fcOJFb6p9E7AxYAbKA5F2dVLoE7J9T3+CBjYBILy9U7imH+cQJ+4MgEQzUrCyz7JNN+ajo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 258c3698-79e9-4cee-36cf-08dcd1780f70 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:07:56.6808 (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: wqQxxgEBcSx4MjavdReb9lj3voFqoXsKVf6HSkQv6SvQku4lmcki1r6pnLH9d1tBGzYFLWQnFrOGOVvL2RZ3yC44Q6SeKH2o3g6hfzdTxmw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100068 X-Proofpoint-GUID: NncZa5EChgctiqQ09YiMqhw5G_r9Dbti X-Proofpoint-ORIG-GUID: NncZa5EChgctiqQ09YiMqhw5G_r9Dbti Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_PH_BODY_ACCOUNTS_PRE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959334451116600 Content-Type: text/plain; charset="utf-8" From: William Roche When the VM reboots, a memory reset is performed calling qemu_ram_remap() on all hwpoisoned pages. We take into account the recorded page size to adjust the size and location of the memory hole. In case of a largepage used, we also need to punch a hole in the backend file to regenerate a usable memory, cleaning the HW poisoned section. Signed-off-by: William Roche --- system/physmem.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/system/physmem.c b/system/physmem.c index 94600a33ec..5c176146c0 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2195,6 +2195,11 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t leng= th) RAMBLOCK_FOREACH(block) { offset =3D addr - block->offset; if (offset < block->max_length) { + /* addr could be a subpage of a former large page */ + if (length < block->page_size) { + offset =3D ROUND_DOWN(offset, block->page_size); + length =3D block->page_size; + } vaddr =3D ramblock_ptr(block, offset); if (block->flags & RAM_PREALLOC) { ; @@ -2208,6 +2213,14 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t leng= th) prot =3D PROT_READ; prot |=3D block->flags & RAM_READONLY ? 0 : PROT_WRITE; if (block->fd >=3D 0) { + if (length > TARGET_PAGE_SIZE && fallocate(block->fd, + FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + offset + block->fd_offset, length) !=3D 0) { + error_report("Could not recreate the file hole for= " + "addr: " RAM_ADDR_FMT "@" RAM_ADDR_FM= T "", + length, addr); + exit(1); + } area =3D mmap(vaddr, length, prot, flags, block->fd, offset + block->fd_offset); } else { --=20 2.43.5 From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959364; cv=pass; d=zohomail.com; s=zohoarc; b=Qn4g2Yw2hoQ+/oDuFKv+6EwPveq6iEhWV8+yO4kVOEv8aR489srFP88wQ32rdlR48xiID7AW/i3EQkKXBjmET9MPRv/ofjbqbi9JoB4Jc6b0Gb5rXtrEQ5mIhpwbeUpSqFqyJ/k4YiRD4qmATmJHfAK2c9DjDXQWNue/IfBMpp8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959364; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=liLEVMlOxr9MKo9jga2VkXBGye4xwDKxHC6nl8W5hQ0=; b=ij7UgaR3U/nptDGvLczrhdaNYbXVvqHyMxEFrd3k4x+BUd2XLLBS2RsftpNQfVZEhyj8wSaY6Qy/fSJRkU+jQ34F53+PiTfois2517tu1iB0sSH4Fr1hlGWsYXn+ktXHnsLgrEiEB8SoVMDWeh/2IoA+UemCeV/Ap0LbaYiNFkQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725959364407924.961933927778; Tue, 10 Sep 2024 02:09:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snws2-0000Xj-2c; Tue, 10 Sep 2024 05:09:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrX-00082T-Io for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:46 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrS-0004J2-Tl for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:39 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A8tX3p008899 for ; Tue, 10 Sep 2024 09:08:30 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41geq9n07s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:29 +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 48A8ao8Q005070 for ; Tue, 10 Sep 2024 09:08:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9898f7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:27 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:07: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%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:07:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=liLEVMlOxr9MKo9jga2VkXBGye4xwDKxHC6nl8W5hQ0=; b= dCzVGeWOOerQi+3d9Xljw+CMcd0A2yD+cBrA5emaqmgQ49bd6v6dLgn12hi7AHnU 6+McOcYHUwbN8csKI/W1xuDiJm6hc7wJUEXzFVT89NnSdVOpmLmOjg+lslRjHPUp R2z+GQz5WqNgT36TAvtmtJDycGaP8I866uo89wFINFxOxuTalPsAwZ0jrGG6r6ZH cnHwSjqiOg9d+mm574aqFZ4HsofYl49t71HWe/aH25Yr53UWEDfkGhNqhqX+Vako /Y7T/uLVTYV2DPSb87Y1uMvIY5gdXOR4W4+pDzLDgQNCPBFkGmpf9/7ZJkib1tvj +Gxqg5kce5kYlty9aCdwqA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FkYeC7kzX6T824Ydx/cBoQWe+xy6T/SIgzrmxxji64fdoaJLA78HE50i3XFzoZn6YIGZeD/UDXw5nSNY6df2K/8gFh+dXxlOeuX6WRDRICbR2gC3hJA2jNVOADH0D/iTHaoLu+YKs2gMfliu7QmNlyVB8mN5bdXaDDp9+x63P6BUAJoBTeR3M2cwTuB54zjCWtOqFmxvNzrYxTX88iDzYgaZNBZhS+VEKZ1yAtRAT/Duuk22duJOu8K1WRi9tluydq1bEKpkO9PcYR7wTLdHWGMoVKD5s4jzlV2g7KbxB9UNEg3NKppc1BeI/lxJRK4FVoueSJUcxXEWVxj3AqfLEQ== 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=liLEVMlOxr9MKo9jga2VkXBGye4xwDKxHC6nl8W5hQ0=; b=eB+VvMTODSEIbC2OSj8St9lVrrMhX239nXCRK7qTK7Zq1Zgq4AAVsh8+o6OA4d6KBMD4aTHV/qfVwVlJGPsUJK57l0MSgZ/+h/uXiUUM4Qr7Xoo+j+uuPI7RJnSrjyiC3gkoFpz49RuCBqmeUPSPqwldah6zBHgWIBG6IZLSEX0FLKytz33phWjyVlVoVLBlc5VXo6oTApBXxakvZE7doNghmmqbajeg68tXoaDfa0ZqpBW2XRkbahMjhCr15q6w8i1eN8pBrd2qxcC1396czrJNlcHm6f5UcXL3AzrS/vqWHPNh+jKjszoOD8w0dllqOc5WZZZ15YyEIW+MOHgP8w== 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=liLEVMlOxr9MKo9jga2VkXBGye4xwDKxHC6nl8W5hQ0=; b=N12FsnwJi0G8G0vqj67W2bloEVXZuXRwCVxGpb0B1KTBIHsYXwTnABSQ4l9k6gR0+S83CjI2MN19JI/s1hU77/sJZcIFUhDa1zajE+6CvBC2erNLGU/lM1ILNFcWQ35EJCn6UaQEzth643eY0KRhLOyLqaWyoHCwlK+b9bRC57o= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 4/6] system: Introducing hugetlbfs largepage RAS feature Date: Tue, 10 Sep 2024 09:07:45 +0000 Message-ID: <20240910090747.2741475-5-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR13CA0090.namprd13.prod.outlook.com (2603:10b6:a03:2c4::35) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 5413426b-1433-4693-3529-08dcd17810e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Sjv7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jx1cnwotwoK?= =?us-ascii?Q?z6MnFq0zOl05FitA5Vu1Ga40SZiwc7i41t+ZynFo9GSE26HksdxtOTbsGcP1?= =?us-ascii?Q?Vt8zvK76ALolkWJVN/2N0FlHa2rdXcdKlAOLIRkUM/w24LCInEjZQCsKMNuz?= =?us-ascii?Q?zq2o4H5LcYpPL5CGWVa5y3sMrWJ/9f61lEisPJC/InhxMFqClmHA+1c9u995?= =?us-ascii?Q?ghlxaYi3NLcfuTPaFcnbiLLB55O0qX6g6MldC0vc321hytNt2Wq63XzdORni?= =?us-ascii?Q?1BFWzeUtO0nBtoCgUs/yBJO+/4RMJxvX0YSQvaUVriIK4pN+kE355EfY60Au?= =?us-ascii?Q?tyEB8QkaY5aR9cAMZ9jzslZY/SNbYPGNqzB13B92FdJUaYwKmq0oljKlxPGe?= =?us-ascii?Q?AF60tpyBtpBHDmhyh1mW+MZWEjHcR6NmuEyNnoj5nlpqDfrAS7dHPMtj/wVV?= =?us-ascii?Q?gcMk1r5iEW8GvRYvRbL5V7dM3Zb5CXph/2qmtbv058VEIQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?oHFk7eC56sHQU3MhEsV8HTFICi2QPVDJPppZjqiSEI+SkRjxFWB8TfNPU4Zk?= =?us-ascii?Q?KcneXkDTZGSz6veXuwIIEQTfHRw/LP8V0z2RtGeCNCYyV8miWDkzLKlm8uzV?= =?us-ascii?Q?kIXzVhfiMitBVPMNIKQAWD6ylDvP+cP+ZcJOPzUISs4fDkfyjFVm14ffDPGh?= =?us-ascii?Q?wRpIRj3BpLXKpUM/Bh9O+dh1MGDTEIFPOjHW0oq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FgTK8zuAge38LFEI0IflomVFvevBfTnZW3y?= =?us-ascii?Q?WMD9D0Hx/M+zIOqaNxd7Qdy49wTuXkzDpOWDmDrptLAgS0gr2qxKeT10/uYa?= =?us-ascii?Q?K67/Bt+4/k1TS61OHlVXvEqyxxy/gu/HKF95t6MiUzXVfAqM0+w9Gb5VW9za?= =?us-ascii?Q?y8fxhI7RxpuMM/srBEQdSDPXSvsvZtdcTmv16Z+hY2IW1YAxsRNn6bapHjiJ?= =?us-ascii?Q?9sLaOSrDhlDZGH035yVtK/05bxaKiLdll5IjetYnhTTbjYGIvUF2lfMOYlYJ?= =?us-ascii?Q?8czcyqG0NcaeaI5Xu+Kp4RKAghpCWlpyl6R9c951KOAywHTlj137I33HhIyd?= =?us-ascii?Q?Zpt3EGt4hkURJ0ADCzSTD6aQ/FQ1mBok+tk58uolEglyL8rXsp5iIew50LZM?= =?us-ascii?Q?rZRHcNr7TEseAsFJH4S2NTN1mg6UOZZUr4Cr6ClZdklI+e1uJHAPznsm5P6N?= =?us-ascii?Q?EIzI4JQcJgcT5voHovdygApIB9Dsh4C9/DdIU6kjH53UfayV7EH7Gx/pXq23?= =?us-ascii?Q?QQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: a6EnIIEQdC52tj5b5h95jcqafrzhusY8twKge3tKO0id+olJNi/WaCf5QsikmxF1PFvbpvmQXykUxpda/JQoQRetxn3tYAjjQVVCKCi/Nj0tio2WoOXCYhI5RZGTNUIajRxP0RUvbQait4M8lFezu610v/aZUrXJl5tqblEjCXhv6X3+Rbdzpr0C53Ovf05cCkwdFdnd0zjruhK4XJAVR1xId0U3+uv5bgRRzC8oKc5C/RmvtrPlP6Hxrc+eSUSFJDJHjIDzukocbAiYl0qtMquxfd7b3DBQBf3ALHcTiiU7MYZWmKPli2y9RGYLRy/MNoXa57hzuetrR/M0U/9zXI8xkX1uniCF0lLPZtm25eeZjLzQRDyePzlJsmwzZIozKcr87w5I7g/bmrVfoSOiuokdtTgsFPprH6qNt/EETZPfnpEcgv1LQpHAHVtJb7r6L/DNE8JEPsMFu6iES2JFJv6tnsaLQyOG0AP5oOseZFQslexFs1zBIXP9sLQyJ7fLQws1/eRVPSX6P8xGZDyTx8plNeTOwC2E2HP7HqMQoWf+izZvMsewVAHQiSn1TaaQp75gZxrqkYobCYX2njXLUHq91i61DM3yygiwUauVgtg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5413426b-1433-4693-3529-08dcd17810e0 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:07:59.1141 (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: Fw253IoQYyN9ib2J1IVej/qkFkbTmnNXQgp1CAyonrnb1PKQ0JnQmsLodr0k9WSLZzt4m5py8ozHYSCI+OLNy8byHVvWHi8qxVlf+3lc0gE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100069 X-Proofpoint-ORIG-GUID: esnLY6orywVAZ2wcO01N3OUYV4kDZQ3N X-Proofpoint-GUID: esnLY6orywVAZ2wcO01N3OUYV4kDZQ3N Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959366712116600 Content-Type: text/plain; charset="utf-8" From: William Roche We need to deal with hugetlbfs memory large pages facing HW errors, to increase the probability to survive a memory poisoning. When an error is detected, the platform kernel marks the entire hugetlbfs large page as "poisoned" and reports the event to all potential users using SIGBUS. This change introduces 2 aspects: . trying to recover not HWPOISON data from the error impacted large page . splitting this large page into standard sized pages When Qemu receives this SIGBUS, it will try to recover as much data as possible from the hugepage backend file (which has to be a MAP_SHARED mapping) with the help of the following kernel feature: linux commit 38c1ddbde6c6 ("hugetlbfs: improve read HWPOISON hugepage") The impacted hugetlbfs large page is replaced by a set of standard pages populated with the content of the recovered area or a poison for the unrecoverable locations, reading the backend file. Any error reading this file results in the corresponding standard sized page to be poisoned. And if this file mapping is not set with "share=3Don", the entire replacing set of pages is poisoned. We pause the VM to perfom the memory replacement. To do so we have to get out of the SIGBUS handler(s). But the signal will be reraised on VM resume. The platform kernel may report the beginning of the error impacted large page in the SIGBUS siginfo data, so we may have to adjust this poison address information to point to the finer grain actual poison location based on the replacing standard sized pages. Aiming at a more precise poison information reported to the VM gives the possibility to better react to this situation, improving the overall RAS of hugetlbfs VMs. Signed-off-by: William Roche --- accel/kvm/kvm-all.c | 7 + meson.build | 2 + system/hugetlbfs_ras.c | 546 +++++++++++++++++++++++++++++++++++++++++ system/hugetlbfs_ras.h | 3 + system/meson.build | 1 + system/physmem.c | 17 ++ target/arm/kvm.c | 10 + target/i386/kvm/kvm.c | 10 + 8 files changed, 596 insertions(+) create mode 100644 system/hugetlbfs_ras.c create mode 100644 system/hugetlbfs_ras.h diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index bcccf80bd7..6c6841f935 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -57,6 +57,10 @@ #include #endif =20 +#ifdef CONFIG_HUGETLBFS_RAS +#include "system/hugetlbfs_ras.h" +#endif + /* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We * need to use the real host PAGE_SIZE, as that's what KVM will use. */ @@ -1211,6 +1215,9 @@ static void kvm_unpoison_all(void *param) { HWPoisonPage *page, *next_page; =20 +#ifdef CONFIG_HUGETLBFS_RAS + hugetlbfs_ras_empty(); +#endif QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) { QLIST_REMOVE(page, list); qemu_ram_remap(page->ram_addr, page->page_size); diff --git a/meson.build b/meson.build index fbda17c987..03214586c4 100644 --- a/meson.build +++ b/meson.build @@ -3029,6 +3029,8 @@ if host_os =3D=3D 'windows' endif endif =20 +config_host_data.set('CONFIG_HUGETLBFS_RAS', host_os =3D=3D 'linux') + ######################## # Target configuration # ######################## diff --git a/system/hugetlbfs_ras.c b/system/hugetlbfs_ras.c new file mode 100644 index 0000000000..2f7e550f56 --- /dev/null +++ b/system/hugetlbfs_ras.c @@ -0,0 +1,546 @@ +/* + * Deal with memory hugetlbfs largepage errors in userland. + * + * Copyright (c) 2024 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include +#include +#include +#include +#include +#include + +#include "exec/address-spaces.h" +#include "exec/memory.h" +#include "exec/ramblock.h" +#include "qemu/thread.h" +#include "qemu/queue.h" +#include "qemu/error-report.h" +#include "block/thread-pool.h" +#include "sysemu/runstate.h" +#include "sysemu/kvm.h" +#include "qemu/main-loop.h" +#include "block/aio-wait.h" + +#include "hugetlbfs_ras.h" + +/* #define DEBUG_HUGETLBFS_RAS */ + +#ifdef DEBUG_HUGETLBFS_RAS +#define DPRINTF(fmt, ...) \ + do { fprintf(stderr, "lpg_ras[%s]: " fmt, __func__, ## __VA_ARGS__); \ + } while (0) +#else +#define DPRINTF(fmt, ...) do {} while (0) +#endif + +/* + * We track the Large Poisoned Pages to be able to: + * - Identify if a faulting page is already under replacement + * - Trigger a replacement for new pages + * - Inform the suspended signal handlers that they can continue + */ +typedef enum LPP_state { + LPP_SUBMITTED =3D 1, + LPP_PREPARING, + LPP_DONE, + LPP_FAILED, +} LPP_state; + +typedef struct LargeHWPoisonPage { + void *page_addr; /* hva of the poisoned large page */ + size_t page_size; + LPP_state page_state; + void *first_poison; /* location of the first poison found */ + struct timespec creation_time; + QLIST_ENTRY(LargeHWPoisonPage) list; +} LargeHWPoisonPage; + +static QLIST_HEAD(, LargeHWPoisonPage) large_hwpoison_page_list =3D + QLIST_HEAD_INITIALIZER(large_hwpoison_page_list); +static int large_hwpoison_vm_stop; /* indicate that VM is stopping */ +static QemuCond large_hwpoison_cv; +static QemuCond large_hwpoison_new; +static QemuCond large_hwpoison_vm_running; +static QemuMutex large_hwpoison_mtx; +static QemuThread thread; +static void *hugetlbfs_ras_listener(void *arg); +static int vm_running; +static bool hugetlbfs_ras_initialized; +static int _PAGE_SIZE =3D 4096; +static int _PAGE_SHIFT =3D 12; + +/* size should be a power of 2 */ +static int +shift(int sz) +{ + int e, s =3D 0; + + for (e =3D 0; (s < sz) && (e < 31); e++) { + s =3D (1 << e); + if (s =3D=3D sz) { + return e; + } + } + return -1; +} + +static int +hugetlbfs_ras_init(void) +{ + _PAGE_SIZE =3D qemu_real_host_page_size(); + _PAGE_SHIFT =3D shift(_PAGE_SIZE); + if (_PAGE_SHIFT < 0) { + warn_report("No support for hugetlbfs largepage errors: " + "Bad page size (%d)", _PAGE_SIZE); + return -EIO; + } + qemu_cond_init(&large_hwpoison_cv); + qemu_cond_init(&large_hwpoison_new); + qemu_cond_init(&large_hwpoison_vm_running); + qemu_mutex_init(&large_hwpoison_mtx); + + qemu_thread_create(&thread, "hugetlbfs_error", hugetlbfs_ras_listener, + NULL, QEMU_THREAD_DETACHED); + + hugetlbfs_ras_initialized =3D true; + return 0; +} + +bool +hugetlbfs_ras_use(void) +{ + static bool answered; + + if (answered) { + return hugetlbfs_ras_initialized; + } + + /* XXX we could verify if ras feature should be used or not (on ARM) */ + + /* CAP_SYS_ADMIN capability needed for madvise(MADV_HWPOISON) */ + if (getuid() !=3D 0) { + warn_report("Priviledges needed to deal with hugetlbfs memory pois= on"); + } else { + hugetlbfs_ras_init(); + } + + answered =3D true; + return hugetlbfs_ras_initialized; +} + +/* return the backend real page size used for the given address */ +static size_t +hugetlbfs_ras_backend_sz(void *addr) +{ + ram_addr_t offset; + RAMBlock *rb; + + rb =3D qemu_ram_block_from_host(addr, false, &offset); + if (!rb) { + warn_report("No associated RAMBlock to addr: %p", addr); + return _PAGE_SIZE; + } + return rb->page_size; +} + +/* + * Report if this std page address of the given faulted large page should = be + * retried or if the current signal handler should continue to deal with i= t. + * Once the mapping is replaced, we retry the errors appeared before the + * 'page struct' creation, to deal with previous errors that haven't been + * taken into account yet. + * But the 4k pages of the mapping can also experience HW errors in their + * lifetime. + */ +static int +hugetlbfs_ras_retry(void *addr, LargeHWPoisonPage *page, + struct timespec *entry_time) +{ + if (addr =3D=3D page->first_poison) { + return 0; + } + if (entry_time->tv_sec < page->creation_time.tv_sec) { + return 1; + } + if ((entry_time->tv_sec =3D=3D page->creation_time.tv_sec) && + (entry_time->tv_nsec <=3D page->creation_time.tv_nsec)) { + return 1; + } + return 0; +} + +/* + * If the given address is a large page, we try to replace it + * with a set of standard sized pages where we copy what remains + * valid from the failed large page. + * We reset the two values pointed by paddr and psz to point + * to the first poisoned page in the new set, and the size + * of this poisoned page. + * Return True when it's done. The handler continues with the + * possibly corrected values. + * Returning False means that there is no signal handler further + * action to be taken, the handler should exit. + */ +bool +hugetlbfs_ras_correct(void **paddr, size_t *psz, int code) +{ + void *p, *reported_addr; + size_t reported_sz, real_sz; + LargeHWPoisonPage *page; + int found =3D 0; + struct timespec et; + + assert(psz !=3D NULL && paddr !=3D NULL); + + DPRINTF("SIGBUS (%s) at %p (size: %lu)\n", + (code =3D=3D BUS_MCEERR_AR ? "AR" : "AO"), *paddr, *psz); + + if (!hugetlbfs_ras_initialized) { + return true; + } + + /* + * XXX kernel provided size is not reliable... + * As kvm_send_hwpoison_signal() uses a hard-coded PAGE_SHIFT + * signal value on hwpoison signal. + * So in the case of a std page size, we must identify the actual + * size to consider (from the mapping block size, or if we + * already reduced the page to 4k chunks) + */ + reported_sz =3D *psz; + + p =3D *paddr; + reported_addr =3D p; + + if (clock_gettime(CLOCK_MONOTONIC, &et) !=3D 0) { + et.tv_sec =3D 0; + et.tv_nsec =3D 1; + } + qemu_mutex_lock(&large_hwpoison_mtx); + + if (large_hwpoison_vm_stop) { + qemu_mutex_unlock(&large_hwpoison_mtx); + return false; + } + + QLIST_FOREACH(page, &large_hwpoison_page_list, list) { + if (page->page_addr <=3D p && + page->page_addr + page->page_size > p) { + found =3D 1; + break; + } + } + + if (!found) { + if (reported_sz > _PAGE_SIZE) { + /* we trust the kernel in this case */ + real_sz =3D reported_sz; + } else { + real_sz =3D hugetlbfs_ras_backend_sz(p); + if (real_sz <=3D _PAGE_SIZE) { + /* not part of a large page */ + qemu_mutex_unlock(&large_hwpoison_mtx); + return true; + } + } + page =3D g_new0(LargeHWPoisonPage, 1); + p =3D (void *)ROUND_DOWN((unsigned long long)p, real_sz); + page->page_addr =3D p; + page->page_size =3D real_sz; + page->page_state =3D LPP_SUBMITTED; + QLIST_INSERT_HEAD(&large_hwpoison_page_list, page, list); + qemu_cond_signal(&large_hwpoison_new); + } else { + if ((code =3D=3D BUS_MCEERR_AR) && (reported_sz <=3D _PAGE_SIZE) && + hugetlbfs_ras_retry(p, page, &et)) { + *paddr =3D NULL; + } + } + + while (page->page_state < LPP_DONE && !large_hwpoison_vm_stop) { + qemu_cond_wait(&large_hwpoison_cv, &large_hwpoison_mtx); + } + + if (large_hwpoison_vm_stop) { + DPRINTF("Handler exit requested as on page %p\n", page->page_addr); + *paddr =3D NULL; + } + qemu_mutex_unlock(&large_hwpoison_mtx); + + if (page->page_state =3D=3D LPP_FAILED) { + warn_report("Failed recovery for page: %p (error at %p)", + page->page_addr, reported_addr); + return (*paddr =3D=3D NULL ? false : true); + } + + *psz =3D (size_t)_PAGE_SIZE; + + DPRINTF("SIGBUS (%s) corrected from %p to %p (size %ld to %ld)\n", + (code =3D=3D BUS_MCEERR_AR ? "AR" : "AO"), + reported_addr, *paddr, reported_sz, *psz); + + return (*paddr =3D=3D NULL ? false : true); +} + +/* + * Sequentially read the valid data from the failed large page (shared) ba= ckend + * file and copy that into our set of standard sized pages. + * Any error reading this file (not only EIO) means that we don't retrieve + * valid data for the read location, so it results in the corresponding + * standard page to be marked as poisoned. + * And if this file mapping is not set with "share=3Don", we can't rely on= the + * content on the backend file, so the entire replacing set of pages + * is poisoned in this case. + */ +static int take_valid_data_lpg(LargeHWPoisonPage *page, const char **err) +{ + int fd, i, ps =3D _PAGE_SIZE, slot_num, poison_count =3D 0; + ram_addr_t offset; + RAMBlock *rb; + uint64_t fd_offset; + ssize_t count, retrieved; + + /* find the backend to get the associated fd and offset */ + rb =3D qemu_ram_block_from_host(page->page_addr, false, &offset); + if (!rb) { + if (err) { + *err =3D "No associated RAMBlock"; + } + return -1; + } + fd =3D qemu_ram_get_fd(rb); + fd_offset =3D rb->fd_offset; + offset +=3D fd_offset; + assert(page->page_size =3D=3D qemu_ram_pagesize(rb)); + slot_num =3D page->page_size / ps; + + if (!qemu_ram_is_shared(rb)) { /* we can't use the backend file */ + if (madvise(page->page_addr, page->page_size, MADV_HWPOISON) =3D= =3D 0) { + page->first_poison =3D page->page_addr; + warn_report("Large memory error, unrecoverable section " + "(unshared hugetlbfs): start:%p length: %ld", + page->page_addr, page->page_size); + return 0; + } else { + if (err) { + *err =3D "large poison injection failed"; + } + return -1; + } + } + + for (i =3D 0; i < slot_num; i++) { + retrieved =3D 0; + while (retrieved < ps) { + count =3D pread(fd, page->page_addr + i * ps + retrieved, + ps - retrieved, offset + i * ps + retrieved); + if (count =3D=3D 0) { + DPRINTF("read reach end of the file\n"); + break; + } else if (count < 0) { + DPRINTF("read backend failed: %s\n", strerror(errno)); + break; + } + retrieved +=3D count; + } + if (retrieved < ps) { /* consider this page as poisoned */ + if (madvise(page->page_addr + i * ps, ps, MADV_HWPOISON)) { + if (err) { + *err =3D "poison injection failed"; + } + return -1; + } + if (page->first_poison =3D=3D NULL) { + page->first_poison =3D page->page_addr + i * ps; + } + poison_count++; + DPRINTF("Found a poison at index %d =3D addr %p\n", + i, page->page_addr + i * ps); + } + } + + /* + * A large page without at least a 4k poison will not have an + * entry into hwpoison_page_list, so won't be correctly replaced + * with a new large page on VM reset with qemu_ram_remap(). + * Any new error on this area will fail to be handled. + */ + if (poison_count =3D=3D 0) { + if (err) { + *err =3D "No Poison found"; + } + return -1; + } + + DPRINTF("Num poison for page %p : %d / %d\n", + page->page_addr, poison_count, i); + return 0; +} + +/* + * Empty the large_hwpoison_page_list -- to be called on address space + * poison cleanup outside of concurrent memory access. + */ +void hugetlbfs_ras_empty(void) +{ + LargeHWPoisonPage *page, *next_page; + + if (!hugetlbfs_ras_initialized) { + return; + } + qemu_mutex_lock(&large_hwpoison_mtx); + QLIST_FOREACH_SAFE(page, &large_hwpoison_page_list, list, next_page) { + QLIST_REMOVE(page, list); + g_free(page); + } + qemu_mutex_unlock(&large_hwpoison_mtx); +} + +/* + * Deal with the given page, initializing its data. + */ +static void +hugetlbfs_ras_transform_page(LargeHWPoisonPage *page, const char **err_inf= o) +{ + const char *err_msg; + int fd; + ram_addr_t offset; + RAMBlock *rb; + + /* find the backend to get the associated fd and offset */ + rb =3D qemu_ram_block_from_host(page->page_addr, false, &offset); + if (!rb) { + DPRINTF("No associated RAMBlock to %p\n", page->page_addr); + err_msg =3D "qemu_ram_block_from_host error"; + goto err; + } + fd =3D qemu_ram_get_fd(rb); + + if (sync_file_range(fd, offset, page->page_size, + SYNC_FILE_RANGE_WAIT_AFTER) !=3D 0) { + err_msg =3D "sync_file_range error on the backend"; + perror("sync_file_range"); + goto err; + } + if (fsync(fd) !=3D 0) { + err_msg =3D "fsync error on the backend"; + perror("fsync"); + goto err; + } + if (msync(page->page_addr, page->page_size, MS_SYNC) !=3D 0) { + err_msg =3D "msync error on the backend"; + perror("msync"); + goto err; + } + page->page_state =3D LPP_PREPARING; + + if (munmap(page->page_addr, page->page_size) !=3D 0) { + err_msg =3D "Failed to unmap"; + perror("munmap"); + goto err; + } + + /* replace the large page with standard pages */ + if (mmap(page->page_addr, page->page_size, PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0) + =3D=3D MAP_FAILED) { + err_msg =3D "Failed to map std page"; + perror("mmap"); + goto err; + } + + /* take a copy of still valid data and mark the failed pages as poison= ed */ + if (take_valid_data_lpg(page, &err_msg) !=3D 0) { + goto err; + } + + if (clock_gettime(CLOCK_MONOTONIC, &page->creation_time) !=3D 0) { + err_msg =3D "Failed to set creation time"; + perror("clock_gettime"); + goto err; + } + + page->page_state =3D LPP_DONE; + return; + +err: + if (err_info) { + *err_info =3D err_msg; + } + page->page_state =3D LPP_FAILED; +} + +/* attempt to vm_stop the entire VM in the IOthread */ +static void coroutine_hugetlbfs_ras_vmstop_bh(void *opaque) +{ + vm_stop(RUN_STATE_PAUSED); + DPRINTF("VM STOPPED\n"); + qemu_mutex_lock(&large_hwpoison_mtx); + vm_running =3D 0; + qemu_cond_signal(&large_hwpoison_vm_running); + qemu_mutex_unlock(&large_hwpoison_mtx); +} + +static void coroutine_hugetlbfs_ras_vmstart_bh(void *opaque) +{ + vm_start(); +} + +static void * +hugetlbfs_ras_listener(void *arg) +{ + LargeHWPoisonPage *page; + int new; + const char *err; + + /* monitor any newly submitted element in the list */ + qemu_mutex_lock(&large_hwpoison_mtx); + while (1) { + new =3D 0; + QLIST_FOREACH(page, &large_hwpoison_page_list, list) { + if (page->page_state =3D=3D LPP_SUBMITTED) { + new++; + vm_running =3D 1; + DPRINTF("Stopping the VM\n"); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + coroutine_hugetlbfs_ras_vmstop_bh, NULL); + /* inform all SIGBUS threads that they have to return */ + large_hwpoison_vm_stop++; + qemu_cond_broadcast(&large_hwpoison_cv); + + /* wait until VM is stopped */ + while (vm_running) { + DPRINTF("waiting for vm to stop\n"); + qemu_cond_wait(&large_hwpoison_vm_running, + &large_hwpoison_mtx); + } + + hugetlbfs_ras_transform_page(page, &err); + if (page->page_state =3D=3D LPP_FAILED) { + error_report("fatal: unrecoverable hugepage memory err= or" + " at %p (%s)", page->page_addr, err); + exit(1); + } + + large_hwpoison_vm_stop--; + + DPRINTF("Restarting the VM\n"); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + coroutine_hugetlbfs_ras_vmstart_bh, NULL); + } + } + if (new) { + qemu_cond_broadcast(&large_hwpoison_cv); + } + + qemu_cond_wait(&large_hwpoison_new, &large_hwpoison_mtx); + } + qemu_mutex_unlock(&large_hwpoison_mtx); + return NULL; +} diff --git a/system/hugetlbfs_ras.h b/system/hugetlbfs_ras.h new file mode 100644 index 0000000000..324228bda3 --- /dev/null +++ b/system/hugetlbfs_ras.h @@ -0,0 +1,3 @@ +bool hugetlbfs_ras_use(void); +bool hugetlbfs_ras_correct(void **paddr, size_t *psz, int code); +void hugetlbfs_ras_empty(void); diff --git a/system/meson.build b/system/meson.build index a296270cb0..eda92f55a9 100644 --- a/system/meson.build +++ b/system/meson.build @@ -37,4 +37,5 @@ system_ss.add(when: 'CONFIG_DEVICE_TREE', if_false: files('device_tree-stub.c')) if host_os =3D=3D 'linux' system_ss.add(files('async-teardown.c')) + system_ss.add(files('hugetlbfs_ras.c')) endif diff --git a/system/physmem.c b/system/physmem.c index 5c176146c0..78de507bd0 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -82,6 +82,10 @@ #include #endif =20 +#ifdef CONFIG_HUGETLBFS_RAS +#include "system/hugetlbfs_ras.h" +#endif + //#define DEBUG_SUBPAGE =20 /* ram_list is read under rcu_read_lock()/rcu_read_unlock(). Writes @@ -2061,6 +2065,19 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, = MemoryRegion *mr, return NULL; } =20 +#ifdef CONFIG_HUGETLBFS_RAS + { + QemuFsType ftyp =3D qemu_fd_getfs(fd); + + if (ftyp =3D=3D QEMU_FS_TYPE_HUGETLBFS) { + if (hugetlbfs_ras_use() && !(ram_flags & RAM_SHARED)) { + warn_report("'share=3Don' option must be set to support " + "hugetlbfs memory error handling"); + } + } + } +#endif + block =3D qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, offset, errp= ); if (!block) { if (created) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index f62e53e423..6215d1acb5 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -40,6 +40,10 @@ #include "hw/acpi/ghes.h" #include "target/arm/gtimer.h" =20 +#ifdef CONFIG_HUGETLBFS_RAS +#include "system/hugetlbfs_ras.h" +#endif + const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { KVM_CAP_LAST_INFO }; @@ -2356,6 +2360,12 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, = void *addr, short addr_lsb) =20 assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 +#ifdef CONFIG_HUGETLBFS_RAS + if (!hugetlbfs_ras_correct(&addr, &sz, code)) { + return; + } +#endif + if (acpi_ghes_present() && addr) { ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 99b87140cc..c99095cb1f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -69,6 +69,10 @@ #include "exec/memattrs.h" #include "trace.h" =20 +#ifdef CONFIG_HUGETLBFS_RAS +#include "system/hugetlbfs_ras.h" +#endif + #include CONFIG_DEVICES =20 //#define DEBUG_KVM @@ -729,6 +733,12 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, vo= id *addr, short addr_lsb) */ assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 +#ifdef CONFIG_HUGETLBFS_RAS + if (!hugetlbfs_ras_correct(&addr, &sz, code)) { + return; + } +#endif + if ((env->mcg_cap & MCG_SER_P) && addr) { ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && --=20 2.43.5 From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959400; cv=pass; d=zohomail.com; s=zohoarc; b=G4zYVA9jAqJgmUi6p6KGfPa+zRowBQaj7vjzLeIVxBRlMtnrMv0T30PlYUXl4wKfAoaaD1OYaCwi2QpMAt+x1gy1aSP0bKxKAIcgoQSF+GGMS7F4GKtRhhPiDPpUYmNw9kBSjOQMfYNOJGv3SYLLJ88E3uSQ9w24iKv9XhhrOcQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q0iQvauBKftLkn5wPQYkulRxXA4ngQtig5Bo3welgzw=; b=SIAVsIcJN3yyU3qK15KlnhwsTzWyYm8hK1zRu5kwerza8Dp407kLYSH8ccaxTvXqTdLT2ix/1mWZdrtpQcQC4mCkQDLjx1P1Yh1nKzWZp3Xt2Na8Ds0ZN39Z6B75uA/jFaDKEA9SD7Y4lWvkFGLzjJgUqN28tkz2O865QyOY/2I= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725959400600121.32785752467112; Tue, 10 Sep 2024 02:10:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snwsE-0001I8-IT; Tue, 10 Sep 2024 05:09:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrW-0007tn-2v for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:45 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrS-0004J6-SB for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:36 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A8tZZc008924 for ; Tue, 10 Sep 2024 09:08:30 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41geq9n07t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:30 +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 48A8ao8R005070 for ; Tue, 10 Sep 2024 09:08:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9898f7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:28 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:08: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%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:08:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=q0iQvauBKftLkn5wPQYkulRxXA4ngQtig5Bo3welgzw=; b= LyiXyyVpqkW8uEAY+WsyiOALwnxc/YQBCHddAkXv/1hnoknSpB/EfEo/UKSFGymR gOh81K4/LlUUH8llyS/kNVG/R+ZpJaepgf+zofhDbAqVM+9k77dMMm3vpUatBbNc xS+kucp4u02SuIGWDSn5iRFBu00ox+lPmdJqg5z6dYjMIZ6S5nBJ/iKUmOihi2Tv qlnDK3xSZ8UEqtawLvS9JwXE3OZh3ZLaGCSGZkOvEKvw/8dT2z9/dWiNezQmmtw+ UmDoEJHq+cUUb0cOJGHlNn7Ndk8nywb/1ZaA8i3EQ0NCxHBzlGsOxGwyxHS27Dr2 zbef0cFtHixqCDE9lud3DA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KiVEkCkR5hKZlqiQU75FNykR8/8p7IA/ODBeC2o7nlVUNpTrSIMrdvJNRBkTAPkWsjaqa/+z3ovPgeWjwr8wsutXQLzoZfoMtjv+Gnsp7D6GGDHCjO6jM05RdNED2iF0TqOCyhi/CLp1FUAHS43+bawgziaQusGfyDqVNuCo+Jo2CXkp2FJEmHBA2RfAUEW2XzgeoLuHjTdYDjCzEt9OrzagR+c9NGGrEv2nFHowZ3NwxHdT6Tsm+ZQ6OUHh+jP0mZWWqczn0QsRzsQ7sgfMf7Xemjo0HK6lgxAsl2k3ZmfqenUQcj6edUEdMUbY/Tucx6USFYrMfi8gRA9MYr1HcA== 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=q0iQvauBKftLkn5wPQYkulRxXA4ngQtig5Bo3welgzw=; b=f0yg0j5CO/4NBemRyzkCAjWLJ/T5SCwEbZZ8+HZymtJ644cRLj6qE87uzqaKu5hqBuHAfA4ZE59ndcjaLHqX/RaldqUSXvwdGokGRW7HIKF/j9L8j3DGvwAVGAvaVuiTqxW31jF7dLwhoxPj1IQcUdAKmCQ1Ye78YUJUzNciE8mO0Aqleu0zf0da3NHlyZiWpyRvMsZcaYTtn5xvL4KcPeuuGHQSKuwJGfPFM1cey/tUlm2f1lJx40WyhTZ2OOXLj6gMLSLqGGNh6y5cybO72FwKgF8LAKfhFeJSRTIpgSAz/2jb05BDqt9GrB8/+Z7KeJlbjzAEV1FK7SmLPEYMBg== 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=q0iQvauBKftLkn5wPQYkulRxXA4ngQtig5Bo3welgzw=; b=mmuMckIFeXpcpDLW7Vunks/1pEfzkLfrcbGtHtYuj1l9oT1lbgxg0vyIiMSfFt16Tzip5Qhzx+gvua6JEvKYLdUpEhuO0DeuGVeDmHChMWpeiitGZ4WuXu64EZsvoQJs3X2AD9hBjz5nsoNNgCzKT27D7o2gr6beRiF0KX61sHs= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 5/6] system/hugetlb_ras: Handle madvise SIGBUS signal on listener Date: Tue, 10 Sep 2024 09:07:46 +0000 Message-ID: <20240910090747.2741475-6-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: dfc37579-713f-4073-a76e-08dcd178124f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4aC0e332yH5bykxnoYaZ0ENvAwfsePqd+xKkHQGDzlmc18xq4UJpplx/OT6i?= =?us-ascii?Q?ePfoiz94EtcWLOyMf1UtWCAFlZ/DO1HuAgEdwiN3CyIsHXoVWXj1xrn45U1g?= =?us-ascii?Q?yCue4V9xkaYOYbaq4OyhNqU7cTnSew1RuovmtxuGAAN3/Pd8xpVN9NgNmBmz?= =?us-ascii?Q?eL2T17jOu5R/S46D3spsPxlfwkPOH2aD5N21KG/utUXttzJ4p1cH3uWwmilR?= =?us-ascii?Q?0EGbdBkiNtD5Z19qHoCYAOGRpoeC1/w8pDPxToo/aiRXXekVB4/zic+U6kAA?= =?us-ascii?Q?IKzqmOSaYx3XloIOikqiJTjzo/FtsBD6YiAQw+1u1T/DqfwIcS8bXHUG+0ab?= =?us-ascii?Q?ae2RlxP1a5V8+LLV+3mn497c7M8DACzD++cqVdW8Yh1oBfA/wKqCrVMnY1Ab?= =?us-ascii?Q?WGOmIYG1tg9itnLNCftSNELfcn+OUj6byX1WpCKiY/kX+1kwmTd2+G9C8xoY?= =?us-ascii?Q?/4LoB70RhhY53l92srn9X0qeFx9ZjOEcZ+TtU40mui3UFH1slyeJIffz5vVx?= =?us-ascii?Q?/JdhYdPvphQwuQcjy9ivNUQd1jy+gzNZR3OPiIEYRA72G7I8ZiPqaNVOVGVE?= =?us-ascii?Q?ssnmZGo0qFn36Pscd5OwMEPidEELmsQh2oiGHnKj8FEBeNmrVPVMpUw62VD0?= =?us-ascii?Q?oW66bvRSkV1FoY9ck/ZNWq2rDOa7d8KcHwnY/1h3ZkcisdpERiZnXvOB8eD9?= =?us-ascii?Q?gTBhIjQP4epHSmEL6W8FJ7pNA8eNP4PXfTYnlmgLqAi2vXqYAhYjFweNKfHO?= =?us-ascii?Q?sypWq5SaTRHGCVOt3/AS9KPrVakroTauCTPvZAlHVMhvhSVSzvKUF98bPj0B?= =?us-ascii?Q?V/bxEEU+EILs9AMgulHva4nnQ2jeUlB8Z7IG0DOptPKvUMb0ACMlbNRgnWqh?= =?us-ascii?Q?dx78MEYrWRKnXB8n1jNl4/v/q7GvbqUzEp2eocPn2VKnO6eZR6TWTgc9CHFu?= =?us-ascii?Q?QrWD/yYjZSSnevH8i4qFJzYz4WdvZW+OMYjye9f8X/i2cV3iFQS/NsEm4vLE?= =?us-ascii?Q?a6BcXzWVBwXf0JxfWMlMdPhc3EQ6Ff0jMlKbPzb2XTkqxtTDm1JB7ycQskn3?= =?us-ascii?Q?xQuwkyib816+Y2gjUsAk0j/vYFw3fKNhy1t22AtD51g2QISDq88vvzmaACj+?= =?us-ascii?Q?HLndXpOI9YskQtDciVqvDLq+eMaiEeaSBDkrZqypi8lVtm7OBsyZoOV5rNV8?= =?us-ascii?Q?1EXuIH+74CQN3wVCxhhTkfZAHFlelR5ONoegensYt4tglr/Qpyk3cBfUNV0x?= =?us-ascii?Q?Kw/d47/x3LqQvobr+56KDAUUZmTiQ1QqIAZTVfrWnve9cfZpI4yTMWylfZFL?= =?us-ascii?Q?O5AMRS/JQDITCQg/AprDURkZvnUCtMk0hdeUFzn22jihfA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7Hfwcb35aQsBKMLbCaSlam7wKmfYbYhxA0jpeBMnUKvmJxQUOvtEJpZeP8em?= =?us-ascii?Q?oytZlN7uecC1micYyEzG4vAxek15jVGBzO1CNwD9o78snnquCbdxBaSH4KNm?= =?us-ascii?Q?M8HfaYkvXlee/JXgPfKZ79MqZRQJB8VUcHfAwoVzSmFG5GXNRWFetzXXnsDT?= =?us-ascii?Q?ZkTpcp40k5kjIZVxeOh65kalyelbuAIZkgHwv7/63dX9Q0T9ICH85VgZmqPU?= =?us-ascii?Q?fVHq8WQa972hBLc39Sxe+5Kj3XaH6mP5ngdwSUS/WgwNBsRm6z3kS5VYgdbu?= =?us-ascii?Q?aX9KTGrjf8FL2c3t1qYoIR8Rw7+1knezpjwUrojljJ5aPp9IxK9pWX9Pe8LM?= =?us-ascii?Q?I1XYm63n352mtWit5l2R3ERvRT6l/3qZiWsTOEj+wBWSX+Y/LOjWFHwBZxqZ?= =?us-ascii?Q?Yzs0DyeOZ7Bp9Unf6Yqw3y0v5RqylxVSH+a2KCq+FQlLgPJIbUxYWZbmswUz?= =?us-ascii?Q?hnj8fNCNVYziIJXRhydECwcqJiwG2KKi/s/U+6rJ4lPyRE4dxiHc4vq9/lhL?= =?us-ascii?Q?8/7E6zJACEVZnbO84EuTp0HzAJt75CMDaDrNSWVAa5UEbAF6JEJT7apPtA/m?= =?us-ascii?Q?PRB54d9kOt4p3+zJtrqnURLSKRbPNCsYnJjUWQw3znA6AbwThTypChJ6QraI?= =?us-ascii?Q?GL9sCChRX+iQM30daEbewKPdq2aS/Zr/R7W3zTKr7/CFz2mkHl3HtZrjbGGQ?= =?us-ascii?Q?X7LngFHSyD0d4mOAjXejPhr5KcdD61Gr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Q=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2utK5CsBJETOaN3R5ooy1XT0TN4vPuug8E0UuwfbGkv9METXD8WLd5dZ9vF5kmSL/GNygsQNw4ZPVa4IvrOD4OR3tVcNvy5FREGd7CO/ppTwNja+NIIiht3NSfD7SpUMcFKL6ITPlGeqnEejqzMLJJoRpHRJIujKeXwqKb92rDWw+jRKImR3k5lHzVsAgryi9B/2DgXYlqJjC5QRoXFI17vsn783m8HsYfFgZE5DDLYCmbaf1NTS+ISM70dJ+p1ucPPiu0dUUh/u19Slc4LRIi6YYevH49YiL+TFgycBqJ8Chlo4RT6BZfuUYozXB+axsItEObJ8VebTu/iDpTKrKZXQ9uWeut3Yiz5x5Fo0B4Wjcsfh7/tSYSaLb6gFQ5ZjazOLM5cAYTjn0+b1qEFhjIhHfIJTco4KmLAHUPtmq/Kbl/309NE473PdNdbgkH/k1aY++3F6n7lExIa2PsXtYNBjCLayHIT0/qACNFboeLrJnnycQWdvbGanY5QzQruwkwui1FfMyqOQOEvzyRG6V39mUQdLMANJ9gW9UIW9yJS2wAmOBB5+V2xxt1gQc3+2LlPcZbFluhaXltNJmLeV3vWQZdUsuEGqJOKdAE879MU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfc37579-713f-4073-a76e-08dcd178124f X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:08:01.4935 (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: 23FVuucykByfGD2BhHoEqrfMgNlRcx7vnab+NIob8RInmdVd/CEPDh8sS1L24NoZCwSSumdrgtjADKjgnYsuZvoH1Ef0FN+nIh8vNaqbye0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100069 X-Proofpoint-ORIG-GUID: Dd-MVO7QG7l2cATmoJ_eteIDhZuHQn55 X-Proofpoint-GUID: Dd-MVO7QG7l2cATmoJ_eteIDhZuHQn55 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959403086116600 Content-Type: text/plain; charset="utf-8" From: William Roche madvise MADV_HWPOISON can generate a SIGBUS when called, so the listener thread (the caller) needs to deal with this signal. The signal handler recognizes a thread specific variable allowing it to directly exit when generated from this thread. Signed-off-by: William Roche --- system/cpus.c | 9 +++++++++ system/hugetlbfs_ras.c | 43 ++++++++++++++++++++++++++++++++++++++++-- system/hugetlbfs_ras.h | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/system/cpus.c b/system/cpus.c index 12e630f760..642055f729 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -47,6 +47,10 @@ #include "hw/hw.h" #include "trace.h" =20 +#ifdef CONFIG_HUGETLBFS_RAS +#include "system/hugetlbfs_ras.h" +#endif + #ifdef CONFIG_LINUX =20 #include @@ -374,6 +378,11 @@ static void sigbus_handler(int n, siginfo_t *siginfo, = void *ctx) sigbus_reraise(); } =20 +#ifdef CONFIG_HUGETLBFS_RAS + /* skip error on the listener thread - does not return in this case */ + hugetlbfs_ras_signal_from_listener(); +#endif + if (current_cpu) { /* Called asynchronously in VCPU thread. */ if (kvm_on_sigbus_vcpu(current_cpu, siginfo->si_code, diff --git a/system/hugetlbfs_ras.c b/system/hugetlbfs_ras.c index 2f7e550f56..90e399bbad 100644 --- a/system/hugetlbfs_ras.c +++ b/system/hugetlbfs_ras.c @@ -70,6 +70,8 @@ static QemuCond large_hwpoison_vm_running; static QemuMutex large_hwpoison_mtx; static QemuThread thread; static void *hugetlbfs_ras_listener(void *arg); +static pthread_key_t id_key; +static sigjmp_buf listener_jmp_buf; static int vm_running; static bool hugetlbfs_ras_initialized; static int _PAGE_SIZE =3D 4096; @@ -105,6 +107,10 @@ hugetlbfs_ras_init(void) qemu_cond_init(&large_hwpoison_vm_running); qemu_mutex_init(&large_hwpoison_mtx); =20 + if (pthread_key_create(&id_key, NULL) !=3D 0) { + warn_report("No support for hugetlbfs largepage errors - no id_key= "); + return -EIO; + } qemu_thread_create(&thread, "hugetlbfs_error", hugetlbfs_ras_listener, NULL, QEMU_THREAD_DETACHED); =20 @@ -288,6 +294,19 @@ hugetlbfs_ras_correct(void **paddr, size_t *psz, int c= ode) return (*paddr =3D=3D NULL ? false : true); } =20 +/* this madvise can generate a SIGBUS, use the jump buffer to deal with it= */ +static bool poison_location(void *addr, int size) +{ + if (sigsetjmp(listener_jmp_buf, 1) =3D=3D 0) { + if (madvise(addr, size, MADV_HWPOISON)) { + DPRINTF("poison injection failed: %s (addr:%p sz:%d)\n", + strerror(errno), addr, size); + return false; + } + } + return true; +} + /* * Sequentially read the valid data from the failed large page (shared) ba= ckend * file and copy that into our set of standard sized pages. @@ -321,7 +340,7 @@ static int take_valid_data_lpg(LargeHWPoisonPage *page,= const char **err) slot_num =3D page->page_size / ps; =20 if (!qemu_ram_is_shared(rb)) { /* we can't use the backend file */ - if (madvise(page->page_addr, page->page_size, MADV_HWPOISON) =3D= =3D 0) { + if (poison_location(page->page_addr, page->page_size)) { page->first_poison =3D page->page_addr; warn_report("Large memory error, unrecoverable section " "(unshared hugetlbfs): start:%p length: %ld", @@ -350,7 +369,7 @@ static int take_valid_data_lpg(LargeHWPoisonPage *page,= const char **err) retrieved +=3D count; } if (retrieved < ps) { /* consider this page as poisoned */ - if (madvise(page->page_addr + i * ps, ps, MADV_HWPOISON)) { + if (!poison_location(page->page_addr + i * ps, ps)) { if (err) { *err =3D "poison injection failed"; } @@ -402,6 +421,19 @@ void hugetlbfs_ras_empty(void) qemu_mutex_unlock(&large_hwpoison_mtx); } =20 +/* + * Check if the signal is taken from the listener thread, + * in this thread we don't return as we jump after the madvise call. + */ +void +hugetlbfs_ras_signal_from_listener(void) +{ + /* check if we take the SIGBUS in the listener */ + if (pthread_getspecific(id_key) !=3D NULL) { + siglongjmp(listener_jmp_buf, 1); + } +} + /* * Deal with the given page, initializing its data. */ @@ -498,6 +530,13 @@ hugetlbfs_ras_listener(void *arg) LargeHWPoisonPage *page; int new; const char *err; + sigset_t set; + + pthread_setspecific(id_key, (void *)1); + /* unblock SIGBUS */ + sigemptyset(&set); + sigaddset(&set, SIGBUS); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); =20 /* monitor any newly submitted element in the list */ qemu_mutex_lock(&large_hwpoison_mtx); diff --git a/system/hugetlbfs_ras.h b/system/hugetlbfs_ras.h index 324228bda3..9c2a6e49a1 100644 --- a/system/hugetlbfs_ras.h +++ b/system/hugetlbfs_ras.h @@ -1,3 +1,4 @@ bool hugetlbfs_ras_use(void); bool hugetlbfs_ras_correct(void **paddr, size_t *psz, int code); void hugetlbfs_ras_empty(void); +void hugetlbfs_ras_signal_from_listener(void); --=20 2.43.5 From nobody Sun Nov 24 07:03:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail(p=reject dis=none) header.from=oracle.com ARC-Seal: i=2; a=rsa-sha256; t=1725959371; cv=pass; d=zohomail.com; s=zohoarc; b=f3WA+r4xVggy7aFMGfFw69T2DckM6/XdBbMXS0JCaF7c089wW30xtCHNkpxRk0yoR2AZBLmMs2sivcPwmZTETgspmt8fZUlD4mEBad1sMqYGtM0CsGfrfnWpXZit6f+T2YdE138kD4gZaf5A0WYXtWQMgjja6xD1NLYkZjxFEuU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725959371; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6zRKVP0wxYzEad+yxt0t268SLIx2OcpPGkov/2Pn12M=; b=Gn+qIaTOaM+xW4U4sZlJ3hy606Ym05Tx7IVvotq13ohMVfFm3n9JRYgszjJx0VDXGpIzsibXNmq6Y2cJVM9+aTIMwIN704+iBTqiOhKF8tL8UuPZOOfG48FHXe1/D8/eVxNbatl/UjmwAF6asSrg9QMMHqNVh0Hc7syYBZrbjj8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=oracle.com); dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17259593714139.459951480604218; Tue, 10 Sep 2024 02:09:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snwrq-00006t-15; Tue, 10 Sep 2024 05:09:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrW-0007to-0m for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:45 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1snwrS-0004J8-SE for qemu-devel@nongnu.org; Tue, 10 Sep 2024 05:08:36 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A8tZZd008924 for ; Tue, 10 Sep 2024 09:08:31 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41geq9n07u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:30 +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 48A8ao8S005070 for ; Tue, 10 Sep 2024 09:08:29 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41gd9898f7-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 10 Sep 2024 09:08:29 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) by CH3PR10MB7163.namprd10.prod.outlook.com (2603:10b6:610:127::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.16; Tue, 10 Sep 2024 09:08:03 +0000 Received: from CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23]) by CH3PR10MB7329.namprd10.prod.outlook.com ([fe80::f238:6143:104c:da23%5]) with mapi id 15.20.7939.010; Tue, 10 Sep 2024 09:08:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=6zRKVP0wxYzEad+yxt0t268SLIx2OcpPGkov/2Pn12M=; b= J+eu4MyxSGPSsKyWxa0N9XO9Goge9HlAdkuzVFMXYT++hGQQkBpT7EOAkTYeDi3Z GAWEKZdmVPfMGHy/B7SHEYTi4zoKZVURxTJ1j5kWw9i/SYIxWa0hjgNH2poq5ECF mcPG0Y5EwcxKyab05XFKnAmbXMi3EhNKJMdNZgR7Z17KjARypg2ohoSuxJ7XKILx 61pdygwFceS868AtiRc3IyVE5r8dwjZlwu/9ZzsdyE38/NAE+GCBjBwpriQFBtFO KPrE48eIDffNAEmplk901ya8+jdP6h/84ZBzjWTE2WSlzpKQTXZgdKGINNgmPfel LfhiPI7akl9BU8AOKst2sA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eYBVtjY4xfdtG+fdZLCNlOHTdZ30UNRcwOT4Nqj3eYG7YJSZleYpT+/TNt7pmrNWiaGTKrPbuZwn8BFycNnOlC9NrgdlOkMwQkEGpByUdn6ARAjR95VX5GLx06myVQobCXFZDExkXBIe1lqqHpngavTPwijysw3fukvcPjn2DqN0PVc+7d0SXxqZzjq/1jRIT/YkdLdbTHpV1CigkIZW0bPIBoYMf/gvPg4XmQ+bpAud9wTj3wr0PGPtW65NYHWYjpt74t4YMkI0t2FENDlXgNDCqlR6u0f0HzHhcPICSgQE/JjcKrDSv8ohjW5d5SIR2IagjcooE2Y0vR0whJSJug== 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=6zRKVP0wxYzEad+yxt0t268SLIx2OcpPGkov/2Pn12M=; b=flSU+nL7PbJlk50SthsdbLb4Cs57mcbHboFKkJgX/02PWEWp73QOJV0yX7mZt54BzfW8wnHaeVpPcsmPK3K54KJbko7lsqqGZ+20BcMNeT0ulaFc2bbYFbBiUSjKu1WULrNXLxCDdTxPBnX5IGBRuKGw/r6o5z6F+qG5pvF8dGrWYjvekebpreY9TO06P6T+AUahGY65HfAb5jWpBHDFyc2thBJ9ZXdI9lCDCdKpUzJnrrImLm6L0VqmVlgSLJrNfsu5JyBRl5eZBuNMc5+zuxDrpx3GDH1I7u1zFTzr6t1N/gQADhCCgw4aRM2BYmcQD4F8XC79d4BENnf0s1AYqw== 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=6zRKVP0wxYzEad+yxt0t268SLIx2OcpPGkov/2Pn12M=; b=yZ53M1QSnzc6uGfhb3lsovdFq9CvIN8HDpXnoYXk1ckQhNiuXPW6cTAQ3E7l84SB31nLD8zvWz0sH/NZDGA01xID/ziTG+V9li0bwhnSc2shvG3FSUmPqAmqSExPsVoG31A+NQksBAbscdMmWUMT3Lqa5LlFm9b5TEhyQOAiAYo= From: =?UTF-8?q?=E2=80=9CWilliam=20Roche?= To: qemu-devel@nongnu.org Cc: william.roche@oracle.com, joao.m.martins@oracle.com Subject: [RFC 6/6] system/hugetlb_ras: Replay lost BUS_MCEERR_AO signals on VM resume Date: Tue, 10 Sep 2024 09:07:47 +0000 Message-ID: <20240910090747.2741475-7-william.roche@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240910090747.2741475-1-william.roche@oracle.com> References: <20240910090747.2741475-1-william.roche@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0077.namprd03.prod.outlook.com (2603:10b6:a03:331::22) To CH3PR10MB7329.namprd10.prod.outlook.com (2603:10b6:610:12c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR10MB7329:EE_|CH3PR10MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 688e1f75-be63-4cf4-1aaa-08dcd17813a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?P9fMdBl8LiogQHjdVms+rCv6hqM2mQfvOyTdpMWQJq6RzIFrylHmi3jy7CfZ?= =?us-ascii?Q?LHyCu5n/fgtSu0VFk2LjhA/ageAXdtJSHF/Xj8ggYiOgKIt95vYfUsgNaMzJ?= =?us-ascii?Q?GaUkIvhblWQ+v3mOTZ/phZQ1CKkcGtbxpjfqk45AMgjLgV5VF0renMCo3pPc?= =?us-ascii?Q?ntjNdLk6QVvzN5R07aOPSsv0y46CA/xK9zpsNwS0nhn0zibgcwouLd0IwQpK?= =?us-ascii?Q?iIw/8LRQEiOWX0m3qEWrQQbZUcELHRTDWTnseZpdyUEGSVXyXPlu+4fGSiUN?= =?us-ascii?Q?ty3GWDVpv5VK0lflxnSq067NoFozM0K63TOk7IT/4NOOiYBhycbbq3dNHwlO?= =?us-ascii?Q?MFf9yYpaIWm6WdT3WTMQ+otawDG/TtT8aTK3cF/1RVRyr1lLPs1ZJS2+I6Dv?= =?us-ascii?Q?iTGXITRlnicD7UY7SWJW8rW3k4YhsXy+eDo6v5pBQ/53D9M0XlyT2yiBK4hI?= =?us-ascii?Q?5xxgu2JJSk/kjzmJ7GTjH8AZNsL3BYnl4QlSSo5yA/FtnFclnQZ5Zb7y1UZ1?= =?us-ascii?Q?K8nI9OKPKAt/Cf5CV568b32h9z8MlaXfnCL4pkD9Qc4fGrqfuo9K/En+iBlS?= =?us-ascii?Q?hVIevI8iXRE5dGOmOHO1vxruaKs+XJV9oOQedtVQWi/6Q8wpp8BSTzO3zZpd?= =?us-ascii?Q?0V2OPqpdKtO5SD3eorh/qWd6zazKlAtE8/H3vxkNAIkBuev5h5BPQ82fEHyL?= =?us-ascii?Q?We7nwu7fH6ggjDqLQ2HTcrYhBlMP4vhkEUc39DFSNgWhDsD2kVYlREqkn69i?= =?us-ascii?Q?RREApKXrWF/TKTHVu38OVr858Y1wG5WWm9Hd2z4Q9LppB0LnUzd5gfRVxXlN?= =?us-ascii?Q?ywkdq+r8bFm0k8nz08MQhEsKAcuqFEoTG8zbwYDwNeqaImWO5n4uPEAar3Z0?= =?us-ascii?Q?QBDkUO672JVLolxz/g77RwzLY63lwjTnYPrl/L/zTl6/U+6z9T9swyuELIcE?= =?us-ascii?Q?h8nvsvxF4KjmZC423KkTrBwTMJxXzKQVbYwDEX6+W/e4zhe/QU3NqkimJtNZ?= =?us-ascii?Q?yDPjDVJ5UfNlOX+GeMiu7Q7SlH/Ydy6t9HdM2ucSbzkzCHxdvekFbLGTSuv8?= =?us-ascii?Q?rJrOFKe5bMgRaBwaVMwCX+FTiM/haV0zuhoj6sDgQvV0MdDK9cNOjeNSyUOn?= =?us-ascii?Q?/mwkL/ORYS7JbYXbJujScoy3nIfsRoypzSzRL+RNHwPFnI6nx5dCHCMDK2G5?= =?us-ascii?Q?5jrCshlMnlMHt4cuTE7S6E9dZGL0Zky2Ld0rqtDD3zU1knr9IrAtbP814iWW?= =?us-ascii?Q?8+YF5fXm7+fg1qLq0cMLXphIb5OWFXpq+1bV0pyHSKWT23HhN0pTlaXv28zn?= =?us-ascii?Q?jzNlfuYw0Py7pJI+SVKZwlHEUgZ6VUdufZ0wujo9Ck9cxA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR10MB7329.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VQeIBgPrtpIEGgH7dXpjIG5aQnQTLbTzc1aq9tAYWohHKxHYuVzi/HwsPJN2?= =?us-ascii?Q?gld3tfjviUzhmQOkHmBN8DaSkYDPyddm9nLmc8/SqueN/A/hLu9wURd9+XKY?= =?us-ascii?Q?aAtCAFXeDp1wqv7596N5miVQOJAepIm/R9n379tfBl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tqyKQ+4pm8LMG3BXM6zndZHuR3PV2sE/DdKFS/?= =?us-ascii?Q?0+sqRmezX/0iW5nV+6fftdH0200e6CzeublS+tFXaRsk9GJ6x7QaYewZHTCV?= =?us-ascii?Q?4/b2R+wpIrhmj8CEP/GbzjxRF5r+b5cwpA9DD7haYegx+imToikFq5XUplxD?= =?us-ascii?Q?vTDIa1sCVgZo0bGzV9bth7WHeRbaStOQPlUYtGEVRNV6l5TQIs4WaGWcCq6O?= =?us-ascii?Q?4g3hH2DVGqoub5o/DXGL1sIu2F6a1C7nZbmBEb+tKC33rjLEgyxXaIneq41n?= =?us-ascii?Q?MX+rX7uJj5Mb+3XcAJs4DARwbWlrm15FGTPW8zoyIFGwEoh3qVGCQnZk80Vz?= =?us-ascii?Q?qL9iXxDsSd3wsCo8Rv5zVBkuLNFIc37tUCT5oaDIDF/GFYCwRLWdDyhYc4+i?= =?us-ascii?Q?99tG3n7m5u0HBDcCbCQec2ABSAZYrX2NMVuXNbmur7ZB27GoFwF+gCv+gJPn?= =?us-ascii?Q?0A5PmxHhfsk4mMu78mAvgIzp1H+N3uSATUHd4af6AOQzNJUDYSalG/iVivVp?= =?us-ascii?Q?RGBMWs5BH+M6OEvCy9mO3ypwSOrbh7GxZzFIxplZ+5xoAAV3N9va0AFBJD/5?= =?us-ascii?Q?yw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8thEDtHZz9snR9Ca6XKpUnK8voXvl1JuCkoVuiJWOoruKexN1YoySPS2TkgJTMFRzZl66CdEir1x6QbWjJ+CUJ+6URNeXNGJ1wbYd4o8wdaqdtKMktybd5D+7jnJtqxffbQLNpl8ay0pFYC7mpLTrLvb5zABrSGZG5lPNs8Ec3zZlecHqGYk2rHV6akUpj7aM4x7oY7As09IDWGHLLkHlpi23sZuJdxwMWgg4HXStLxnuy2y8nz52KpRWIb0rXXx6G+01lAWUZGpgCNU3fU5um3qOKAnq9jLU/ukBOC26GOb7acOIJHZK1qmRBZ8i8i3NFv6BCbjyyxLXEZ2LkJ4lwx4U3WYU070iUtzaqdbDPd4SYQYiDuebaGroJkbjE3gwi3mY/faWLekDzaEVmekgjrZIjmoHLyvXh7srOIec2THtuEKCWJ0VA9DcwAQG5LZIpf6AffNEY+TbCMCevWaeNkmY4QfcaIQZ8J1xjCJ/Q3xXjwhA81TgKUZKH8Cpm4omaawVP99YeFl3R8lTK/g9x/a2rnZ5OKCAuNxSuV9pgxKruaZ6cH2Px5RklZv/HixhxUbp2/LpTWLtB//gCEhZYQH4Dw8/61Sj8ggq27TmpA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 688e1f75-be63-4cf4-1aaa-08dcd17813a3 X-MS-Exchange-CrossTenant-AuthSource: CH3PR10MB7329.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 09:08:03.6984 (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: YTUme79k+Z87R7F1dcoNYO1GAdfiY9AYvKvo+lXYBC8RTyb2OfKbifQjChWoSHTIJZSzpJIRJ470xyOLFwhazIpsCs7seqlZ6aLOVRibEzo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7163 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409100069 X-Proofpoint-ORIG-GUID: eeTNbU0ywurDNPkBxXGxFsXOKpMMuoEN X-Proofpoint-GUID: eeTNbU0ywurDNPkBxXGxFsXOKpMMuoEN Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=william.roche@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.onmicrosoft.com) X-ZM-MESSAGEID: 1725959372891116600 Content-Type: text/plain; charset="utf-8" From: William Roche In case the SIGBUS handler is triggered by a BUS_MCEERR_AO signal and this handler needs to exit to let the VM pause during the memory mapping change, this SIGBUS won't be regenerated when the VM resumes. In this case we take note of this signal before exiting the handler to replay it when the VM resumes. Signed-off-by: William Roche --- system/hugetlbfs_ras.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/system/hugetlbfs_ras.c b/system/hugetlbfs_ras.c index 90e399bbad..50f810f836 100644 --- a/system/hugetlbfs_ras.c +++ b/system/hugetlbfs_ras.c @@ -155,6 +155,56 @@ hugetlbfs_ras_backend_sz(void *addr) return rb->page_size; } =20 + +/* + * List of BUS_MCEERR_AO signals received before replaying. + * Addition is serialized under large_hwpoison_mtx, but replay is + * asynchronous. + */ +typedef struct LargeHWPoisonAO { + void *addr; + QLIST_ENTRY(LargeHWPoisonAO) list; +} LargeHWPoisonAO; + +static QLIST_HEAD(, LargeHWPoisonAO) large_hwpoison_ao =3D + QLIST_HEAD_INITIALIZER(large_hwpoison_ao); + +static void +large_hwpoison_ao_record(void *addr) +{ + LargeHWPoisonAO *cel; + + cel =3D g_new(LargeHWPoisonAO, 1); + cel->addr =3D addr; + QLIST_INSERT_HEAD(&large_hwpoison_ao, cel, list); +} + +/* replay the possible BUS_MCEERR_AO recorded signal(s) */ +static void +hugetlbfs_ras_ao_replay_bh(void) +{ + LargeHWPoisonAO *cel, *next; + QLIST_HEAD(, LargeHWPoisonAO) local_list =3D + QLIST_HEAD_INITIALIZER(local_list); + + /* + * Copy to a local list to avoid holding large_hwpoison_mtx + * when calling kvm_on_sigbus(). + */ + qemu_mutex_lock(&large_hwpoison_mtx); + QLIST_FOREACH_SAFE(cel, &large_hwpoison_ao, list, next) { + QLIST_REMOVE(cel, list); + QLIST_INSERT_HEAD(&local_list, cel, list); + } + qemu_mutex_unlock(&large_hwpoison_mtx); + + QLIST_FOREACH_SAFE(cel, &local_list, list, next) { + DPRINTF("AO on %p\n", cel->addr); + kvm_on_sigbus(BUS_MCEERR_AO, cel->addr, _PAGE_SHIFT); + g_free(cel); + } +} + /* * Report if this std page address of the given faulted large page should = be * retried or if the current signal handler should continue to deal with i= t. @@ -276,6 +326,15 @@ hugetlbfs_ras_correct(void **paddr, size_t *psz, int c= ode) if (large_hwpoison_vm_stop) { DPRINTF("Handler exit requested as on page %p\n", page->page_addr); *paddr =3D NULL; + /* + * BUS_MCEERR_AO specific case: this signal is not regenerated, + * we keep it to replay when the VM is ready to take it. + */ + if (code =3D=3D BUS_MCEERR_AO) { + large_hwpoison_ao_record(page->first_poison ? page->first_pois= on : + reported_addr); + } + } qemu_mutex_unlock(&large_hwpoison_mtx); =20 @@ -522,6 +581,7 @@ static void coroutine_hugetlbfs_ras_vmstop_bh(void *opa= que) static void coroutine_hugetlbfs_ras_vmstart_bh(void *opaque) { vm_start(); + hugetlbfs_ras_ao_replay_bh(); } =20 static void * --=20 2.43.5