From nobody Mon Nov 25 05:10:49 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=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1717443480; cv=pass; d=zohomail.com; s=zohoarc; b=W1STahCV2eXhWxobJRxE5RSA4m47FdNSsbwNQ6SqqD5STASjSng5Pz6WIGcB4YhiQydty2nt/Em/9HhVZ+k+GnQJm8w6pgGdDk65/CGO8jNdd0nfB49l8OInC7/dqWGFl5WXjNGiou7gmRQirHbgb/qAqojzWnJdSw9VWCPgo2g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717443480; 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=sJ/yxlfI+MYw2SqT7bhpFIrqH/sMjF6JC9kMtdptEd0=; b=CmGx7JpzeDGjts8vynV8Oim1d48R6J1/1WRrterdyjjl4wyzYyQgVd0E7+jsjrULT5Bl+qBVh6716nAep9DetGYy+Db++W0I8UQwYlQEgAIb3KeJZyTWeZM91WJzeYLCkDMWgDnCwq2hUGdMY40MMp3iZBzcHdbITMIrH0itSeA= 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=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717443480041627.6609385385149; Mon, 3 Jun 2024 12:38:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEDUH-00040U-Gy; Mon, 03 Jun 2024 15:36:57 -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 1sEDUG-00040J-9Z for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:36:56 -0400 Received: from mail-mw2nam12on20624.outbound.protection.outlook.com ([2a01:111:f403:200a::624] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEDUD-0003Cf-0H for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:36:56 -0400 Received: from CH0PR03CA0317.namprd03.prod.outlook.com (2603:10b6:610:118::12) by DM4PR12MB6182.namprd12.prod.outlook.com (2603:10b6:8:a8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 19:36:48 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::f) by CH0PR03CA0317.outlook.office365.com (2603:10b6:610:118::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Mon, 3 Jun 2024 19:36:47 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 19:36:47 +0000 Received: from jallen-jump-host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 3 Jun 2024 14:36:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IWT5zwllyPm1RHbzVanLbmYP65Vf8IPPbmCbTDnyGXOXb54Rq0xGqyVYtVI7Yd9E/3X1f5vaHde5R5F4IJWXCBcPhpzTowdpQMjJyqYIAxF2pjMXGS5xfqCqwnwjlxu7zm/0Xitl0tbta7CC4DDDptVPnT1U8iwlYvqXCEN9HZtvUD7YCvQOOXbN8XTtW655ei58cqZaVC9x/MnWLRmqJ6Bp19qIfGbE1yLvbFSZ7SQ6og8VePxHuFsNuwqmKTfWCYvYpFSkXY+WDUeYzhZdqqIFtS2TaCsbC4i3PH29q7sFyGE6Fs/1KjRKpLVScE6QmY+i9Nlirb3Wc+Y4BdEc/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=sJ/yxlfI+MYw2SqT7bhpFIrqH/sMjF6JC9kMtdptEd0=; b=mUxj3PuEupvpr/yYxTIup60/T+12iXbP+i5h2+u2ljWmInke6KHJ/augPa5oIaBv2p/qK4Au13WGurGXrIGl0jH0N74IBoCdfHBy8BQq2OJErdyBU7GVod3DiMC2OyzdjbnWu8Isza7W+FCj9JNH3t5DUmM0RJHwHofrN8LGXQhlhQs08OJHaCkR4Yy3bGvtk1rDm6BLRZ9I6nI++/mRh/L25+gRiD1TZTRZVRjeXFjeoar033P51tVMgHbnqXHBfIivyzYY8ws/2BGH2aaMLNgLhcVnxBtJQ7vuUcLYzqm2ewwu5LNLbFwslOSDebIOLpEbuaNPeT3fJ3REB+3X0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJ/yxlfI+MYw2SqT7bhpFIrqH/sMjF6JC9kMtdptEd0=; b=YtFJY0C/1ycwRzarATZHmONZfpjDFPgIE7I9hdSCB6tPUGGhHM+UI0kLlaRne5wN6MPN1FGuwNf0jDHCccW6NwDDP9x15twXY9dyCugzi/rDMaC1qIGEb2PJCatRskPuzfOonRsaIire3wjRD7OziHgeZaZbpCc8QDb1ZGmBpfk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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 (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: John Allen To: CC: , , , , , , , , , John Allen Subject: [PATCH v5 1/3] i386: Fix MCE support for AMD hosts Date: Mon, 3 Jun 2024 19:36:20 +0000 Message-ID: <20240603193622.47156-2-john.allen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603193622.47156-1-john.allen@amd.com> References: <20240603193622.47156-1-john.allen@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|DM4PR12MB6182:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f01490a-859d-4b1f-7240-08dc84048237 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?S17f+BSKbQ4hDYJX7dcXt1g6vQV3XzpkLN+J+ge0jGKkj5u7HI4U9WaVVtqD?= =?us-ascii?Q?xqWLjG/v8BXlywndSsD6DDFzC2k/csl32zr5PNJ3/cOtE3jlcXVfgyIEErf2?= =?us-ascii?Q?HISwM9/8fckNB2PbI4odX7CPE4K93gUVodhGw6gVMrqhPVZAkS7tHFsJf0xO?= =?us-ascii?Q?eTneCU78HIJZhZHQnLtCmp5zz+f6+9TG4HzyClK7PM9cReFjEQsnTr7JPkJr?= =?us-ascii?Q?X87sajRaORXuQvYF0xRylqa4HQbedbfMfXGFTNCdFYI8IfdxtZz5B6OHN1Dr?= =?us-ascii?Q?6PUPJsNOBSH5Nx9v70qswhqF+v+sK8Bz1iwl2d6IuouNR1UOV0Yk0G0JCCNo?= =?us-ascii?Q?QqKB7GIa8JbQJAmz73SyEESZW+oGbtEbmmOJCn7Ij8ZUl+WVn3YIuExx6NWh?= =?us-ascii?Q?SewrC//3OwJCH/7cN6cFyDMwDfPvnFWz+MKpK92KvdXWFjW3vlwW0LmAPJ0S?= =?us-ascii?Q?izwJpYQrpCQwebF6e87oqNra2dIWrb0/5qeMBWs4gd4c3ol/tBoEi4EOxEkM?= =?us-ascii?Q?Ki8bnqihkWTmzsF6oLFv78+OGaZFZG+nj6YmppsIZhnV7jCMv7fg0zMCLia5?= =?us-ascii?Q?SO/ZzvCj6nPVMS7uJmch3kQGfOwvwHfc2mpnATpJsd7M371KBAxw7jgUahsw?= =?us-ascii?Q?3lZ+vpTVmKHgHKtcWaT5Mmv0bTn1qxQ7EDFSAJKUnl1QYNAK50ZmoiBIoFQa?= =?us-ascii?Q?7buskV//sQfUQcew1Ga91nGDmiAMkYOTiTRvIhQlzY0SkAHnsIV+TE+LuYUc?= =?us-ascii?Q?OOoMHlZzGD/M4UjRpDp02aL6kvm9kRaVxEJpLVyd6s/u7M/zWxhDy3jaRxTV?= =?us-ascii?Q?lTPrQXpjgZMUjyiTf1amEL/TnRWkL6C0frj+rXvyLCiYbYCxOJrCePYJxBpv?= =?us-ascii?Q?1OOrI0NmUAQOR1a/c2OpyOAUu+YObrIaT3Zp1OoY8A/537pUq2bvx9FO3Pir?= =?us-ascii?Q?V+DzUnbdxFpd9CPDSdtdvFos1sixyk5WSuZgpe2/VBBpofYs3Xsauxv67CtL?= =?us-ascii?Q?gQKnPuQp4tz9T5sAIb0nWzKDJVovfJoVHuAvh7gkI+Rl5w5LFW0xMrHcAr0H?= =?us-ascii?Q?jMEokLkqY776qHpVaJpIUqnkVIuUquXuzbbLbd5skpsqvqZ54LQIqWgM3lJh?= =?us-ascii?Q?a3BWUzsILshJK1EhdoENB+YpeRA+I9+I3cL9K6msvCx5SRrx/WeMPoAcsQ7g?= =?us-ascii?Q?vg0uHuG4bLhHQBo7up3cS7F+pa4OWeQIMd8P1M6xoBmnlS208PJzuCOfUxtl?= =?us-ascii?Q?upBFuXblzPBhMBbkQW86o7PbLz7GLBlwpuwcJhofWjOkYi0rBCOnICGYCpR/?= =?us-ascii?Q?o00cQbA2DNh5Hz0rO7vu7/lMFgsXIxPknJxcF1yHIW1tnx869bb8Nna7p5Lp?= =?us-ascii?Q?RjBNJKuRfF6hfZKSCtxz6/W60AM9?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(36860700004)(82310400017)(1800799015)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 19:36:47.8550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f01490a-859d-4b1f-7240-08dc84048237 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6182 Received-SPF: permerror client-ip=2a01:111:f403:200a::624; envelope-from=John.Allen@amd.com; helo=NAM12-MW2-obe.outbound.protection.outlook.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @amd.com) X-ZM-MESSAGEID: 1717443481521100003 Content-Type: text/plain; charset="utf-8" For the most part, AMD hosts can use the same MCE injection code as Intel, = but there are instances where the qemu implementation is Intel specific. First,= MCE delivery works differently on AMD and does not support broadcast. Second, kvm_mce_inject generates MCEs that include a number of Intel specific status bits. Modify kvm_mce_inject to properly generate MCEs on AMD platforms. Reported-by: William Roche Signed-off-by: John Allen --- v3: - Update to latest qemu code that introduces using MCG_STATUS_RIPV in the case of a BUS_MCEERR_AR on a non-AMD machine. v5: - This version implements proper support for AO (deferred) errors. For deferred errors, there are some differences in the flags that need to be set in order to be handled correctly. First, the UC flag must not be set to allow deferred errors to be picked up by the machine_check_poll function in the guest kernel, mirroring baremetal behavior. If the UC flag is set, the injected MCE will be sent as an interrupt and will be handled in do_machine_check which currently is not expected to handle deferred errors and would need significant modification to do so. - Both the deferred (AO) and uncorrected (AR) error cases set the POISON bit. For the uncorrected error case, this is expected and properly mirrors baremetal behavior. For the deferred error case, this bit would not be set by hardware, but is being reused as a convenient workaround to give better behavior in the case that the MCE_KILL_EARLY flag is set in the guest process. See code comment for more details. --- target/i386/cpu.h | 2 ++ target/i386/helper.c | 4 ++++ target/i386/kvm/kvm.c | 39 +++++++++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index dfe43b8204..ddf53937b4 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -365,6 +365,8 @@ typedef enum X86Seg { #define MCI_STATUS_PCC (1ULL<<57) /* processor context corrupt */ #define MCI_STATUS_S (1ULL<<56) /* Signaled machine check */ #define MCI_STATUS_AR (1ULL<<55) /* Action required */ +#define MCI_STATUS_DEFERRED (1ULL<<44) /* Deferred error */ +#define MCI_STATUS_POISON (1ULL<<43) /* Poisoned data consumed */ =20 /* MISC register defines */ #define MCM_ADDR_SEGOFF 0 /* segment offset */ diff --git a/target/i386/helper.c b/target/i386/helper.c index 2070dd0dda..6f6b0f02e0 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -91,6 +91,10 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env) int family =3D 0; int model =3D 0; =20 + if (IS_AMD_CPU(env)) { + return 0; + } + cpu_x86_version(env, &family, &model); if ((family =3D=3D 6 && model >=3D 14) || family > 6) { return 1; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 42970ab046..810f586a59 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -582,17 +582,40 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr,= int code) { CPUState *cs =3D CPU(cpu); CPUX86State *env =3D &cpu->env; - uint64_t status =3D MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | - MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S; - uint64_t mcg_status =3D MCG_STATUS_MCIP; + uint64_t status =3D MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_MISCV | + MCI_STATUS_ADDRV; + uint64_t mcg_status =3D MCG_STATUS_MCIP | MCG_STATUS_RIPV; int flags =3D 0; =20 - if (code =3D=3D BUS_MCEERR_AR) { - status |=3D MCI_STATUS_AR | 0x134; - mcg_status |=3D MCG_STATUS_RIPV | MCG_STATUS_EIPV; + if (!IS_AMD_CPU(env)) { + status |=3D MCI_STATUS_S | MCI_STATUS_UC; + if (code =3D=3D BUS_MCEERR_AR) { + status |=3D MCI_STATUS_AR | 0x134; + mcg_status |=3D MCG_STATUS_EIPV; + } else { + status |=3D 0xc0; + } } else { - status |=3D 0xc0; - mcg_status |=3D MCG_STATUS_RIPV; + if (code =3D=3D BUS_MCEERR_AR) { + status |=3D MCI_STATUS_UC | MCI_STATUS_POISON; + mcg_status |=3D MCG_STATUS_EIPV; + } else { + /* Setting the POISON bit for deferred errors indicates to the + * guest kernel that the address provided by the MCE is valid + * and usable which will ensure that the guest kernel will send + * a SIGBUS_AO signal to the guest process. This allows for + * more desirable behavior in the case that the guest process + * with poisoned memory has set the MCE_KILL_EARLY prctl flag + * which indicates that the process would prefer to handle or + * shutdown due to the poisoned memory condition before the + * memory has been accessed. + * + * While the POISON bit would not be set in a deferred error + * sent from hardware, the bit is not meaningful for deferred + * errors and can be reused in this scenario. + */ + status |=3D MCI_STATUS_DEFERRED | MCI_STATUS_POISON; + } } =20 flags =3D cpu_x86_support_mca_broadcast(env) ? MCE_INJECT_BROADCAST : = 0; --=20 2.43.0 From nobody Mon Nov 25 05:10:49 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=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1717443480; cv=pass; d=zohomail.com; s=zohoarc; b=KDLb1NweJnzZJkK0TFY+93m66e2lVB8CdAJvhBCgMoFp1XJb+PXDoPn4ejExoZFkpIOVLlsgNq1WpRuUlOcEROThv3uuNKruGOMwNPyom8vUhb7wA0/rHirvsTqtw5YytdTgS57yQI84UdLx06cYWJFARPtq2otdALN9o5zAZ/A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717443480; 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=MDl5FQ5dDCW6omHl6rK6uwqC+sTDf9tQz33JkuJ40Sk=; b=ck3wIFZ8nkOOvwanNQcyDutqjhyDsFDEV5N/Y39WNTjfE+pXqTol3Wv3CNZtJR0VwlNjPl1KoCqR1TEWdrMSIpFCI5aRuh4yQvneyi22OlKohlvAc0VxLUfH/4vELCsAoGpNMR/LZ4YWQa1kf8vZYzBLscB6PewNWRQcBwIZHvo= 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=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717443480511952.549804811317; Mon, 3 Jun 2024 12:38:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEDUL-00042b-J3; Mon, 03 Jun 2024 15:37: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 1sEDUJ-00041P-EJ for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:36:59 -0400 Received: from mail-dm6nam10on20625.outbound.protection.outlook.com ([2a01:111:f400:7e88::625] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEDUH-0003DZ-Aj for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:36:59 -0400 Received: from CH2PR18CA0014.namprd18.prod.outlook.com (2603:10b6:610:4f::24) by MW5PR12MB5621.namprd12.prod.outlook.com (2603:10b6:303:193::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Mon, 3 Jun 2024 19:36:53 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:4f:cafe::de) by CH2PR18CA0014.outlook.office365.com (2603:10b6:610:4f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.29 via Frontend Transport; Mon, 3 Jun 2024 19:36:52 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 19:36:52 +0000 Received: from jallen-jump-host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 3 Jun 2024 14:36:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oa1/umJq/AE4LlAaL53c6u+HM9CfE/TACYcVwglnoblNd/K3LyKn9PROOQkoWBr/YG09fLGhWjSR+3vDnKwekQBH1GUVsqNWIQBhauOcffpONd6w6aS3/3GM9rgdDdMpXZJmhWalCEryTZxohJlEEU5sD7JVFBnduw6sN6iLHj9HgrONyIvDEdM2PyCqCAwQ4cDA+IkUVpGDhEDjrk+qk/HZOwZitY1rfVRHrovDgzCf/LcocJriAPQLHlsAnfFzJhTjtA7Zgju37cnXKQoMSUpN5RDisA9a9GmV9eDkwbhxnAMqwDu+xgqCaeix8NTYKZeAd2GerSH361e27MICXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=MDl5FQ5dDCW6omHl6rK6uwqC+sTDf9tQz33JkuJ40Sk=; b=iLTw8qkabqDsc7rJvYdgioWPJ3eJUGuEuVS7PjCxeGBpQ2l739tCBEnVAS0ygW6lswlZA/kk6odmeNWQPBBtnwyDBkYG7SyPHuVoMrBp1+QGC7ZMAFn7mlevwSi/SLU+8BzXeJqro3l+V0JZyhpv8egDMJjfJhj9VxZlHPZshT4+vgeNYGgjvUMyQPCChWJT8A+4e3daw0th3ljn+cCVYXofj1dFjYuXWLjNIhbHZu1aWfzEYzVHcWNBYIJSdx8pxGNy7Yu3WIGlRiGGmncNNO8RhwTcgVhU5PoItej1ros796Ts/+jknhYjXpLsWA2JKtL92LAXpCml/jl4gHmmYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDl5FQ5dDCW6omHl6rK6uwqC+sTDf9tQz33JkuJ40Sk=; b=i+K6606jOwnXoxyo4JJJ/gPcNPmhOWvBmKOdYKvCiCIH3HTAC1lreTBdIkATi08m+p7GNmDGMp88+gWfF8h3vOGq2r3OGgs0hgsgSCVpuYe7w1lJ/JB1U8YOVskQyjnLHSpFdPeJUYubuBrXMzYjfUIIkm5Y1Z7xhaBVxSHP/pU= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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 (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: John Allen To: CC: , , , , , , , , , John Allen Subject: [PATCH v5 2/3] i386: Add support for SUCCOR feature Date: Mon, 3 Jun 2024 19:36:21 +0000 Message-ID: <20240603193622.47156-3-john.allen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603193622.47156-1-john.allen@amd.com> References: <20240603193622.47156-1-john.allen@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|MW5PR12MB5621:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f9efb95-f4bc-4106-e9bd-08dc840484f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?AxsU78ggt+pR78A+D1AiOHh7+nwcTTfSWstVU+Z2iqfHrDF/w8v0TcIGpPbd?= =?us-ascii?Q?5o499BToJ537VtMDRv+bogKZcqTj80Gz8zzDDrO2iqedFv2NRZld3DzHBE7b?= =?us-ascii?Q?m85a+e4+6LwjiTeWmaTE47AsuV8ZDAxbJgrxr6SefljRtockx7DWEYWktZIn?= =?us-ascii?Q?IY235oFQeamRSrPfepx8gVVUKeviPSGfIaK/f18Bo/803Nag+0JEa1bhNf0x?= =?us-ascii?Q?aao30ZabebH4Ajpi2M7xq1sxOuTWyvQsgcGJltnZer+LnOpCPzWNqr2Yq4K4?= =?us-ascii?Q?Yq0E1AtxaijkZ616I4TMoZwlSxXDryjrQrQALFNVjrfiu3acgcv+cebCwGc+?= =?us-ascii?Q?dIAenFhzZWjehfbqe9AXjdXRkn5dGY0708u4xhh023uZ5gqehdoHq8KgviBA?= =?us-ascii?Q?k0/BX/CecxKJUxJmE9cuuBlEMecsVYChVi2uqf6sfLFoIWnKdyAo8PHlKJqT?= =?us-ascii?Q?SWzS4yHqBforVKi75Vn4O4dRT0zp1jKMId0bemE2MMOtYqc88Ka0qZncnUWz?= =?us-ascii?Q?+tFM2pAIr4dW/cdhlxXlEqaLStM0oA6CsQJDC5VyKWz5k4a5q58MvFdL/JfO?= =?us-ascii?Q?xr4MIwo+KsHktMTL4E7KYcgi5D9rlZ5v/aZahy2RGLrMZD84PdSryiHEmGYJ?= =?us-ascii?Q?CZp0ros8Gf7oJiIkWARZLOVYXj9lIjZgSlkFKj1ECdCl3r9AmDXE4VEiQ6I0?= =?us-ascii?Q?za8UDF+PJZxTVvSRPADlfnHrSRnq0WiOaC3W1rm+TBnS1T0uJ7so3k7LRwmP?= =?us-ascii?Q?QHuhsUER3TOWsVc8u6WUTkdGeRk1o+rm8oL0CmFSlxyKsFIavTIn/wqgbfZx?= =?us-ascii?Q?o6ehA6k0EDLdcG9rxAjBw+6we9g7HBcAyG+r8sKlOdc6S9MEG2teI91GqUK7?= =?us-ascii?Q?LoJkbWmPtMp7Eu5fAX00xVJht4L41qCdc3UhBooRHZQV+CVFeqGqj+uXs9pT?= =?us-ascii?Q?w7OThkuMPTBSkpCDT4zKuAPX+MAEaxCVNoCYfZJpcXInCnq1K0Vf9pXyIG3s?= =?us-ascii?Q?0j0fbSoMqXrTjpQsXrDzMiTE+zHu0vV4ydrbu+ycbzf1m8DsiKrsDpcJzZNz?= =?us-ascii?Q?P+DxPGx3G0LuJsmM/BXi2OtrokHkvwu5grRtsifGtXy0YbmfDeUSwG81QEVH?= =?us-ascii?Q?1iMpcRBf70HtI6jnDccTrrrE+2tEv1N3ZRGwxSmbBurHwjNlaFP9pNJURJFa?= =?us-ascii?Q?XJiyL3QC8oPZWIzd8ykKTXK0oyaejWRltAjZwhtt2TtLpa9VeqM0oYtphSaf?= =?us-ascii?Q?JQxPy/c2VdZWY3OFslga7trVTEfRYpKfPMIsYiiJ4tx59SXZ9OCkXXYger/e?= =?us-ascii?Q?ZDKmoEJ8MlAESSNttV341JCHlUDAb4iSVNsfknaxeddY7mGSP+qXyCDB989m?= =?us-ascii?Q?s6c2UY9BlENP+IV8XliMVXuGlqGH?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(1800799015)(376005)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 19:36:52.0524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f9efb95-f4bc-4106-e9bd-08dc840484f5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5621 Received-SPF: permerror client-ip=2a01:111:f400:7e88::625; envelope-from=John.Allen@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @amd.com) X-ZM-MESSAGEID: 1717443481510100002 Content-Type: text/plain; charset="utf-8" Add cpuid bit definition for the SUCCOR feature. This cpuid bit is required= to be exposed to guests to allow them to handle machine check exceptions on AMD hosts. Reported-by: William Roche Reviewed-by: Joao Martins ---- v2: - Add "succor" feature word. - Add case to kvm_arch_get_supported_cpuid for the SUCCOR feature. Reported-by: William Roche Reviewed-by: Joao Martins Signed-off-by: John Allen --- target/i386/cpu.c | 18 +++++++++++++++++- target/i386/cpu.h | 4 ++++ target/i386/kvm/kvm.c | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bca776e1fe..5fa2dde732 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1032,6 +1032,22 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { .tcg_features =3D TCG_APM_FEATURES, .unmigratable_flags =3D CPUID_APM_INVTSC, }, + [FEAT_8000_0007_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + NULL, "succor", NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid =3D { .eax =3D 0x80000007, .reg =3D R_EBX, }, + .tcg_features =3D 0, + .unmigratable_flags =3D 0, + }, [FEAT_8000_0008_EBX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { @@ -6556,7 +6572,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, break; case 0x80000007: *eax =3D 0; - *ebx =3D 0; + *ebx =3D env->features[FEAT_8000_0007_EBX]; *ecx =3D 0; *edx =3D env->features[FEAT_8000_0007_EDX]; break; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index ddf53937b4..5dd41e3d69 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -607,6 +607,7 @@ typedef enum FeatureWord { FEAT_7_1_EAX, /* CPUID[EAX=3D7,ECX=3D1].EAX */ FEAT_8000_0001_EDX, /* CPUID[8000_0001].EDX */ FEAT_8000_0001_ECX, /* CPUID[8000_0001].ECX */ + FEAT_8000_0007_EBX, /* CPUID[8000_0007].EBX */ FEAT_8000_0007_EDX, /* CPUID[8000_0007].EDX */ FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ FEAT_8000_0021_EAX, /* CPUID[8000_0021].EAX */ @@ -953,6 +954,9 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord= w, /* Packets which contain IP payload have LIP values */ #define CPUID_14_0_ECX_LIP (1U << 31) =20 +/* RAS Features */ +#define CPUID_8000_0007_EBX_SUCCOR (1U << 1) + /* CLZERO instruction */ #define CPUID_8000_0008_EBX_CLZERO (1U << 0) /* Always save/restore FP error pointers */ diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 810f586a59..384b702fef 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -476,6 +476,8 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint= 32_t function, */ cpuid_1_edx =3D kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); ret |=3D cpuid_1_edx & CPUID_EXT2_AMD_ALIASES; + } else if (function =3D=3D 0x80000007 && reg =3D=3D R_EBX) { + ret |=3D CPUID_8000_0007_EBX_SUCCOR; } else if (function =3D=3D KVM_CPUID_FEATURES && reg =3D=3D R_EAX) { /* kvm_pv_unhalt is reported by GET_SUPPORTED_CPUID, but it can't * be enabled without the in-kernel irqchip --=20 2.43.0 From nobody Mon Nov 25 05:10:49 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=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1717443480; cv=pass; d=zohomail.com; s=zohoarc; b=ivUsRAZCb8TLhvVj6euVvGm7wk1o8KzSNoYaO5myIog8fykDV3/eV5DPWXOlnVgGiMdmENXfu95jhh3THFUH2qHvCIOfpf2e5XKi6PoufWylMgEEqmta5KuWDbgMTOibNRrr2bcFxIu5ESud+ZIIHPtS8bzSOqoVnr9n57Tx6g0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717443480; 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=/4Hbi3YIubbuokjUvp7e7NkkTWrJLvoNA8UYFbv/640=; b=Qigs5GS+isL6QgEwEny5C1rY5UfsGsitITtT7hJUIFKqad4Mgoa2Sa1WQbtzc/n/LdRJv94h/5yinXziOhU3qKzpRJHh9nLFk8gqPZeNgjhoaNjf2y7aQt0Ff9PvkRuDa7ydH6D5Zj6Q96eySxFeRhGpplfQSCrgChv731D2JWg= 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=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17174434799661002.0309152260074; Mon, 3 Jun 2024 12:37:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEDUQ-00043E-3H; Mon, 03 Jun 2024 15:37:06 -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 1sEDUO-000435-L9 for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:37:04 -0400 Received: from mail-dm3nam02on20600.outbound.protection.outlook.com ([2a01:111:f403:2405::600] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEDUM-0003Ge-Ll for qemu-devel@nongnu.org; Mon, 03 Jun 2024 15:37:04 -0400 Received: from CH2PR16CA0005.namprd16.prod.outlook.com (2603:10b6:610:50::15) by SA3PR12MB7923.namprd12.prod.outlook.com (2603:10b6:806:317::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Mon, 3 Jun 2024 19:36:58 +0000 Received: from CH1PEPF0000A347.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::27) by CH2PR16CA0005.outlook.office365.com (2603:10b6:610:50::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Mon, 3 Jun 2024 19:36:57 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000A347.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 19:36:57 +0000 Received: from jallen-jump-host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 3 Jun 2024 14:36:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZCQY92CxH8rHcdjksmid3/tvlKzBZop6PabvHbgaVPdkp1p/26mwCqEEkmX3vU6oVkhO8yuCUbFSrlA67qLrN5maYjtvz6Ct71hwHdhx2oIWJrSUv+frntVz9IWSeNokHE7O/m9lj7fMRqbd/PHZ8eD59IfjZEWG6t60/dLCRo3ZLOG45wGMw6DrWkMAd+EIzNXvFiy4TPgCxiA/uXSibby3/xfqcp5pDthDJlB47nCU4GBNijm7oe1qThoI1YzH2LzKluoYZQg+02lvJ/bd5pjdsKTq3DS+fl6droelquw9woAu/8YOYKGetMJnxULSh9NQxlT4U91fgdJFlY+dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=/4Hbi3YIubbuokjUvp7e7NkkTWrJLvoNA8UYFbv/640=; b=L1DJpBfhSktV/KUnrNW6YTosuWJ91XRjjonEF89kAEdA37HDWrfrH3le56IVzR1HIyu9CQOBE4t5wrvgbKVPWsusr4sXY5im0qe/6fjekW6m39fgY8RnuLi7NWz8IzYY7NlRSILJP/cWW//oPlHiLOGAIgPaH9+gwF9+eXkjJJnjzOkrCcqpSYME9sFpzaFymjXMVQOa9mLX+oZ2CHti8xyallZMymWqLEPSDeY9YJPUEpi6dII7YugDa2pQftSRYLuBoieei/SvJRBiATlNxLSPPqRfNqR3gxfMk05TtX4ZMdKhGLxyEpq3Q4lI40Uwo3lF2UxM+jrqXKSm61pWVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/4Hbi3YIubbuokjUvp7e7NkkTWrJLvoNA8UYFbv/640=; b=JKn+lnbFMNs9bTmY6JRIeRqYmvCC6pyKaC+0d4QmBPdet+3OQND4V5juCNgNVlL1bG3hNdu/H+q9R9ZG+7ACCSogmxSVGuW1onnHR8TIXt2vsBDbiX59ZZSG17lizpSnMIIEp20iNN761nAQmCAVkcRc2cv5k4QMIHTKmjJPgvU= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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 (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: John Allen To: CC: , , , , , , , , , John Allen Subject: [PATCH v5 3/3] i386: Add support for overflow recovery Date: Mon, 3 Jun 2024 19:36:22 +0000 Message-ID: <20240603193622.47156-4-john.allen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603193622.47156-1-john.allen@amd.com> References: <20240603193622.47156-1-john.allen@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A347:EE_|SA3PR12MB7923:EE_ X-MS-Office365-Filtering-Correlation-Id: a2c53cd8-0e19-4187-301d-08dc8404880c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WIayh/4YaeJBpIgyf+XbFVkpp2j+znunVDaK9k9gmCsDZKyYwfSKzyWROaG8?= =?us-ascii?Q?752ssc9qEYxQ0tQl2SXjpVc8nNCkNIQ0dofJltLKUCdBFBMQguMKH9C24dYM?= =?us-ascii?Q?YLjTB02m6Oc77ssRrMNdsukC4eLPTJvs1iYgZdT4DyhQ3oyIqCVIbMcUHEjh?= =?us-ascii?Q?8DXBcdKc0jqiv1xB9RqU1tid7jGfvDRM3bIwqoXY22tNxXn9QjgyktglhLwx?= =?us-ascii?Q?LE4V/kNR2Wt1cOaR1/K04aQOm51rYJL7fp59bil1lL6MPhc2+NdC5/XLNBI+?= =?us-ascii?Q?z7mKvQ7Ka0vAQEaydWOuY94F97B0f17POydW65dkM7Pm/EVmpniJHX4+yETc?= =?us-ascii?Q?u3rPDjZCQ6uCleoWfcPHL1rN59+bPKhxm3Vf3noAbk6KshUWXOISPFKEp+Bs?= =?us-ascii?Q?TxI9DMqenHhaR6Mo5ndWtUYEG7Vze82PQei9g+r9X5h/de3I9jTWxaIgM90B?= =?us-ascii?Q?JsUGsDg0DMUl9w9yHc4cVVjEW6mMdiwNRv9cqdcfVxn8Oz/XKBlwWSoMN4cG?= =?us-ascii?Q?7Tlf2M0WtIrFX1UaH9rsTKeFgD3WsHS3cxER5f5ekEIQKYc4GV0Qw7XpZqUz?= =?us-ascii?Q?fJn3JzXp4BTLkQIhbM4Ot5p7lamVAoBH5vqBXAG5ICY0ISJ6rcRjHedm1/IN?= =?us-ascii?Q?Qb8CdJ/G6q0VKQVCgETgEl7lIr6EBBPNmdSYoLVCLe1fUtJNcP/rtVKtLNYd?= =?us-ascii?Q?vvlLdAQOALE9jGSodZ+yjBHhi4AdRwCDoorBTEni7oGbj8fZQpIxYpWTKQ7v?= =?us-ascii?Q?fSKBVpdtY+ZANcj2nfPq8MzCVAVKGYE0F6o/+EmiI0tGqgIB869UGCrvukTY?= =?us-ascii?Q?+BVbfylIw9eOY1UxnclZNfiwAsIkUV4vGp75GnPijLXzgzCAjR83bhhcZPL9?= =?us-ascii?Q?Dp6Lpy2phutp3eFpnm87uZE5JiuKF1ZC+7n7MXwlMDC8eoRyT+78QSTShguz?= =?us-ascii?Q?4soI3ahLA05E8nw4TOxivgmhZ/mlkrCm6Tkm98u/KDOkCypxL9Yfid4e7/am?= =?us-ascii?Q?3CdORDwo6sA6wwnTY+cKoTv3u81q0rqIaxNTo6KErc38zE3qSMlVLe9ng1jg?= =?us-ascii?Q?jjVBKQG+OxOkLKqiA07kcQaMbzy6qVD3AmfrA6CDwlW9xAtkztumxeC3AhTg?= =?us-ascii?Q?ula3t1zuFw6/kmb4GpW9DNhCQAGEZFTQdIifGKiNeP6ucmq+7uo+14D5F2Js?= =?us-ascii?Q?qXArrqNSNagbFYa3SkjzdPwM8pEIV+It+0zWxYwI5R2P5BTxBLJlIEnj/+Gc?= =?us-ascii?Q?yhhfmX8xR0SJm1fQqknwJQqB54LU+LslFT+gnAUHtqzQUSqJFW0TvqZTt5N6?= =?us-ascii?Q?LfmCdx6HqNzcVg/v78Aq4619aeLVzJX6nY4Ymw5E+SHm/N9yNzQMBOk2YtCH?= =?us-ascii?Q?kHAbwychmsNqkjtbC7d2OPOZErhAMe3M0jRCL/GzOIm9wd7ynA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400017)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 19:36:57.6378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2c53cd8-0e19-4187-301d-08dc8404880c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A347.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7923 Received-SPF: permerror client-ip=2a01:111:f403:2405::600; envelope-from=John.Allen@amd.com; helo=NAM02-DM3-obe.outbound.protection.outlook.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @amd.com) X-ZM-MESSAGEID: 1717443481500100001 Content-Type: text/plain; charset="utf-8" Add cpuid bit definition for overflow recovery. This is needed in the case where a deferred error has been sent to the guest, a guest process accesses= the poisoned memory, but the machine_check_poll function has not yet handled the original deferred error. If overflow recovery is not set in this case, when= we handle the uncorrected error from the poisoned memory access, the overflow = bit will be set and will result in the guest being shut down. Signed-off-by: John Allen --- v5: - New in v5. --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5fa2dde732..5385b26d4a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1035,7 +1035,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { [FEAT_8000_0007_EBX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { - NULL, "succor", NULL, NULL, + "overflow-recov", "succor", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5dd41e3d69..d56cf631b5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -955,6 +955,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord= w, #define CPUID_14_0_ECX_LIP (1U << 31) =20 /* RAS Features */ +#define CPUID_8000_0007_EBX_OVERFLOW_RECOV (1U << 0) #define CPUID_8000_0007_EBX_SUCCOR (1U << 1) =20 /* CLZERO instruction */ diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 384b702fef..796d5e9e38 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -477,7 +477,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint= 32_t function, cpuid_1_edx =3D kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); ret |=3D cpuid_1_edx & CPUID_EXT2_AMD_ALIASES; } else if (function =3D=3D 0x80000007 && reg =3D=3D R_EBX) { - ret |=3D CPUID_8000_0007_EBX_SUCCOR; + ret |=3D CPUID_8000_0007_EBX_OVERFLOW_RECOV | CPUID_8000_0007_EBX_= SUCCOR; } else if (function =3D=3D KVM_CPUID_FEATURES && reg =3D=3D R_EAX) { /* kvm_pv_unhalt is reported by GET_SUPPORTED_CPUID, but it can't * be enabled without the in-kernel irqchip --=20 2.43.0