From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4579C4345F for ; Thu, 18 Apr 2024 20:03:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 614416B00CE; Thu, 18 Apr 2024 16:03:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59E0D6B00CF; Thu, 18 Apr 2024 16:03:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F0946B00D0; Thu, 18 Apr 2024 16:03:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1E1CA6B00CE for ; Thu, 18 Apr 2024 16:03:24 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC1B112122F for ; Thu, 18 Apr 2024 20:03:23 +0000 (UTC) X-FDA: 82023727086.20.043D3CF Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2048.outbound.protection.outlook.com [40.107.102.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 198971A0020 for ; Thu, 18 Apr 2024 20:03:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gdHx1lqI; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.48 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713470601; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mWUZwqBM7GZGVd9g4qAU12o35H4l74rP3aHiyiVwwp0=; b=XPl1vhOB+e7K4k+PPJoiaduGSi48AnpopGNHgqGySwXtlLwnF8h0NylAkyDlt3hZ3Tc5Cv AEkDNnApJPUGECNOCkML5So+DknFsnEGcuP4FQSVXJKdhfvy+MLhn/CrpFpL6T/kxzZdSf 2nnBSVyPpPljWZ+L+pflc1iXxlySIx0= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gdHx1lqI; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.48 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1713470601; a=rsa-sha256; cv=pass; b=bAOh97W5imeGh1yQ7o2M7HvvQP+lMTZQgJ0NXPEroY1/U/0Yc7tB9eTU6wiS4HAolkLjHt cd8/B2QFyCPmcHWiao0vZJ8GtEjRNk67Oh5TArZQxQfGNaBJ95c2W/sm9pbo1s12s1cY5h cks7pPPiqdhZDLi0NF2AGV9/xp6Pezs= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AGhP7uiwuD8meaSLEgq6eNWYi5WcHZWypPagBUFVSB6RoU4F8MDVMjU/LqaBcTkfsyhjGIZ/U9Yb2ph9tpIH1ooYxXbS4XEq0Om1QvXpoW3+NRxW3klq2fHpzJzhxx8OJGY0p4TeFAQdGfBz9sutQ2KoZPB9T/DUS12t8qOvp5vNXwqTSO+m5JlCfHAP/UcT9TD2KDNqQckfPBhFL7vMR9+PhDTAIjz4/278HnfCNybIcN3tQo7VZVkS5eu4vGryX1HjPQ9tU/f+4bRWmJ4scOTRXQQWvd1dTzz0rOo31ZRE+QkLx4QmmmUDaH5VU5DSJsJg4ZTakG/5R44EoGzSOw== 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=mWUZwqBM7GZGVd9g4qAU12o35H4l74rP3aHiyiVwwp0=; b=Qblz3eH4nNts/lZFkkD2NsrPGjD6zbYXMfHW63tVzAK1S4Kh5APnXj5YLfA2mxSpFbrQmC6IRtiBV6+DxJvnhBFF58/Wr0YFzRWVEKnfgxkvL+wjJ2WLJU0z+NahOYQLEm9IddyO4Y+EFIfe7OhxOYc7oPaTxQypr+cysdQCghrC0feEmCTEH0g7SshmOpoEf9cdyluh6x5DR5FMjE//mrCVsAygkeVP+ERqIjk+8rgV7nxvUjekbt0qKHZN512arkYPlOt6jsxiDoDLqITkaeUKiB9Ah5rEXoeC3gxj8dzvL6x4GnsKgKFcI88GfhNfZRbVnL7eS7q0l4kNE0Tt5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=mWUZwqBM7GZGVd9g4qAU12o35H4l74rP3aHiyiVwwp0=; b=gdHx1lqIxigYH474PYgDlI2vDqyZ4z+EKe7BFPoKPEKX5X2nrr1bvqNNKXE74hH/uJjeWkeFgoTpxDrjrvMrWiEI7F/kK7/uC7DvCKkS0P0JSAUyb27a0XMCS21mMqnDeCMy0KBuPj3JXOE8XsrTa56QqlmYFi+gPIxZcfEj9Es= Received: from MN2PR18CA0001.namprd18.prod.outlook.com (2603:10b6:208:23c::6) by DM4PR12MB8521.namprd12.prod.outlook.com (2603:10b6:8:17e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Thu, 18 Apr 2024 20:03:15 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:23c:cafe::19) by MN2PR18CA0001.outlook.office365.com (2603:10b6:208:23c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.26 via Frontend Transport; Thu, 18 Apr 2024 20:03:15 +0000 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 (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 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Thu, 18 Apr 2024 20:03:15 +0000 Received: from localhost (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; Thu, 18 Apr 2024 15:03:14 -0500 Date: Thu, 18 Apr 2024 14:57:54 -0500 From: Michael Roth To: Paolo Bonzini CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v12 22/29] KVM: SEV: Implement gmem hook for invalidating private pages Message-ID: <20240418195754.h6gl5qd62kas7crx@amd.com> References: <20240329225835.400662-1-michael.roth@amd.com> <20240329225835.400662-23-michael.roth@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|DM4PR12MB8521:EE_ X-MS-Office365-Filtering-Correlation-Id: 4012ab85-c981-4eab-f4e6-08dc5fe295a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzpMOCb/tgZpKgq6eE8r5BNSDeWJt2o4Yg9Smzth5/FJTwpiH9MUp6rj2xRIpTur8IaHEL2t8TNyNtzefBdWy2GEiHzQrrRn4Ealkm2QYHQZaLwn75B1UmfArVMkQPSe2JwgUmYf5+DefztPZcBJy9i9kWRfZad+oKrN4IxwwrX0Q/6rmEwtVMBr58tx6lJrVX9qVXcXWifnfG4mD5obuq9/UpA3kvecnVVp6nPkVSnDGqeqeM1R0FlVj4Mw/JpNdVVy9cqp2mwn59jGGrhIGcAIkStv+4Z7qxXVIxUz0PqcEOnpAO5hSQUA5SgBlDPNNqEly5phg21cyF7JCP+VFoQ+8sgAIKm60VGDXi7tfxUBbrPmdM/VrZYSwaHftz9FuhcQiNEEWb48XpSU4wmU++xVIOGVxDLRm2ZBNrSuw9U0qbZlPo1iljG2IK78NasMFznlpoMI1uE8GqDxpO9mzi5iHWtuDCdP/gGC6r2BAxbmm/wjwBNz3jTHgHhMNHzF90Tln9RnatyEwVCev+X0bA+ZXTViPS1FdY1hLS6X8amjSs4SJ5J41WQA6D4EpeF+9tUKYfYkOsz/ICI+8dEjFVqsgRqHZQSqQwv91E6O3ZOqa47pQzMnp5790v1mHdPj3SIyq7Gso/nE30kX6UPNFvACqv2lsGxNh8Q9JtULXFkrmSg1g4QHqYgX2TBRW7DFMQSj/oGcM1aY9QLJGK97fg== 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)(82310400014)(376005)(7416005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2024 20:03:15.5937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4012ab85-c981-4eab-f4e6-08dc5fe295a2 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8521 X-Stat-Signature: 85hkarwzfrujredwrq4qtqngosdg5gpd X-Rspamd-Queue-Id: 198971A0020 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1713470600-756818 X-HE-Meta: U2FsdGVkX18VVCDTvYtKDxXcO/dEQFfN48wnQI8H17OcuxsuJXUluttsTSzcRSFQgNBwogD2rtVgAkwbHdN4HI0hrWJzGm3OTeKRZx5n2rEkyBEcWoM91wVZ/EQSeH4HQ47OqvJLqAtCSJK8VilXcLtlZ7JmUAiAAxzwoIhbn2LowFSwwslTZ+PxXaP2dAmAM4Eo6o9lhkE5XC89Yg2ghkq3zGsEQY1Fu1OfumTQks88O+RzXbLqdEWzDPKtkrf637aynwQW+KHZDRnJKIIS0KNZ1QrTFIE8YHWHfdoroIALBIHvRbhnaCEwNq5zQkG1hx3yPQLMPYf/TXpT2KJfnDS15OjsFAJjUqWb3LCgFTsT7dZxEmQ0Q3UlQev48JBckUKkqUP62VK8tnY0yZhcAhFmuomX9lWGG/YNaC2ppef4MkISab5Qt9DECfxn5RSk3rU6ZTNlwbSOCb3ikmfLJ+AgcDVz1/aW0GYehjOAwbLc/UpgPSgmKLtQIWkQYF51+i8OKzv1IqZ7Xp0PPWVHoNCDxqZj339Pr4K8NSfEEPbnm+LPgzWDNM0MnSH3GTwO+N/oDGOtFm2RFq+CPLI67dWm7gZkUQhS/eXSCca1DUjCE3c4wvtuk66/3njngYd4FYSzkspcye8XUOb3MfSb8yg4CPl3FP/j/2K2a3TfKeOvNzhSakwI/OQ0p3WAZnTwRhiaRtolRsbMUU21zNBsRtHD7CPHTl/5yqdBunAx+Y3uiMAN63rrey9faJX3JbXHCCmmPGcf1yoTufwqlvbMeu8+8/JODwa20EhJtMr/Ik3uGktNBjZwbH7zTRTGz1n32hgmwonXI3ysTzFvQVhHVEkl54m4DNxA9ZBCiah8ShA8Fa5J2saT2+aB9ibu2t1L40rpM53zkj+c/j2fTFAi5FJLnelKJRFuHHT10jSlQUI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Mar 30, 2024 at 10:31:47PM +0100, Paolo Bonzini wrote: > On 3/29/24 23:58, Michael Roth wrote: > > + /* > > + * If an unaligned PFN corresponds to a 2M region assigned as a > > + * large page in he RMP table, PSMASH the region into individual > > + * 4K RMP entries before attempting to convert a 4K sub-page. > > + */ > > + if (!use_2m_update && rmp_level > PG_LEVEL_4K) { > > + rc = snp_rmptable_psmash(pfn); > > + if (rc) > > + pr_err_ratelimited("SEV: Failed to PSMASH RMP entry for PFN 0x%llx error %d\n", > > + pfn, rc); > > + } > > Ignoring the PSMASH failure is pretty scary... At this point .free_folio > cannot fail, should the psmash part of this patch be done in > kvm_gmem_invalidate_begin() before kvm_mmu_unmap_gfn_range()? > > Also, can you get PSMASH_FAIL_INUSE and if so what's the best way to address > it? Should fallocate() return -EBUSY? FAIL_INUSE shouldn't occur since at this point the pages have been unmapped from NPT and only the task doing the cleanup should be attempting to access/PSMASH this particular 2M HPA range at this point. However, since FAIL_INUSE is transient, there isn't a good reason why we shouldn't retry until it clears itself up rather than risk hosing the system if some unexpected case ever did pop up, so I've updated snp_rmptable_psmash() to handle that case automatically and simplify the handling in sev_handle_rmp_fault() as well. (in the case of #NPF RMP faults there is actually potential for PSMASH errors other than FAIL_INUSE due to races with other vCPU threads which can interleave and put the RMP entry in an unexpected state, so there's additional handling/reporting to deal with those cases, but here they are not expected and will trigger WARN_*ONCE()'s now) I used this hacked up version of Sean's original patch to re-enable 2MB hugepage support in gmem for the purposes of re-testing this: https://github.com/mdroth/linux/commit/15aa4f81811485997953130fc184e829ba4399d2 -Mike > > Thanks, > > Paolo > >