From patchwork Wed Dec 14 19:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13073499 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 8DA2FC4332F for ; Wed, 14 Dec 2022 20:07:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 326B78E001B; Wed, 14 Dec 2022 15:07:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D6E58E0002; Wed, 14 Dec 2022 15:07:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 150F38E001B; Wed, 14 Dec 2022 15:07:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 01F088E0002 for ; Wed, 14 Dec 2022 15:07:09 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CDE8C120E9E for ; Wed, 14 Dec 2022 20:07:08 +0000 (UTC) X-FDA: 80241995736.07.A1788A1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by imf24.hostedemail.com (Postfix) with ESMTP id 84CF018000D for ; Wed, 14 Dec 2022 20:07:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=kOxijL+y; spf=pass (imf24.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.41 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); 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=1671048425; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ioS3JfXIHvi53uaP/Fbu2qHHPrFAosADMMkceWONob0=; b=SaIaNR0ocqcWO+ldY2Q3nK2ShOpEmESgIjChclouA558sqjhoNgu8BhI+cmDfMaqp8V+hQ qZBDMwx4AWCe/a2Y5NP4MhxAbnbVyKrh0HFeV0adsifgAKmBStjfKNWkgiB8mUths6iOJC kccqXzvveT9Yc/71KNK0feToPV+S0zw= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=kOxijL+y; spf=pass (imf24.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.41 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671048425; a=rsa-sha256; cv=pass; b=RVrZj9MTNiEocM4ZKey/+LzVBf26DRkL1N4MFiVYa3/ld3jbE+j031ovGAbzH8EHnOPMwc eJasFPhexV8hmZYYXzH61vad4VEh5L7O9zpv0Y0O6ycvAZ8q0sQ0jlNrLl2rBp5nIgTXz4 64KD9VrOgV8KEGXOyBO7yBh+zxhSd8c= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cbQLn+VJnHIjl9WVgBRxskwSZndsejssP2IWZp5LuMB5kB8ncDyoq+F+DbbQTaeoZ5oCyvNrtYHzI7KszPR16LLP6YE2eUvZfOBKCJyJuDoDi9H4z485BvB9GAjyQNVTXAYC1SN+qkBWkPLbRWTppZIDRJY74Jmfz03kc5ZxKuHkG1smu5bCwVxicnvbMojxsrgFrrSAJQcWb21Oq416DPVH0AF7tDHL1y4hRTr7e6WaCJOnXh27Fr1K2nFdgCGKWXY5zjcBoDr3/ZmJ2skMdFaOkPlbNlDDgoMjO+CIJ5bTQALp/ttFcBSojUiMMRhoCv+54EAhBPyYE5xrbU1Cqg== 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=ioS3JfXIHvi53uaP/Fbu2qHHPrFAosADMMkceWONob0=; b=TjH9FYCbaNzDbRX94foNLuCxy72qpM+HbBMjNrnsUawqek4MT8mBUChhM/8YdvT8xnhfCkfiB+unHoEnFgnI1nFK7cAsfVaSxTiiTEWg55CFActPjAKx5vRznIdxnHSeoLncx3yHyS4/CBu6VeEe1OMvOGvWZ3o4ooW03T/inAiaRbJZ2hlyo0yhUx3PyKM1sYWuIzOnZpoMUIAit/SzNa2wTGX4Y02YImVsOj9GsdbA2oMmux95b/oIgRr5SZRZk9sh1WYzHAS4Iik1l2EnSzTGsAoB0m1/NyErNThsIH38NLo1qP+JThgfX5yeCJPaDnWjarPr832QizGlw9FX9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 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=ioS3JfXIHvi53uaP/Fbu2qHHPrFAosADMMkceWONob0=; b=kOxijL+ysI31uYr3jlgxDE+wAeZ5wxatP97v7RjdEBWcqWb7o0YD3QjYmlIk0WxXLvvAy+z2kYL+lYfE6NeLpbS7nZJBZmwdkoCECmGvolzL9mHfGu8OiunZ5UTrPWMR70VDxxXaUau14u8aH2JdRSBXj7wytBPFX06xD0wmmSE= Received: from MW4PR04CA0083.namprd04.prod.outlook.com (2603:10b6:303:6b::28) by SA0PR12MB4590.namprd12.prod.outlook.com (2603:10b6:806:93::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 20:07:03 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::2) by MW4PR04CA0083.outlook.office365.com (2603:10b6:303:6b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 20:07:03 +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 CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 20:07:03 +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.2375.34; Wed, 14 Dec 2022 14:07:02 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC v7 61/64] KVM: SVM: Make VMSAVE target area memory allocation SNP safe Date: Wed, 14 Dec 2022 13:40:53 -0600 Message-ID: <20221214194056.161492-62-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> MIME-Version: 1.0 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: CO1NAM11FT085:EE_|SA0PR12MB4590:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cebb3d1-104b-47e1-3ac2-08dade0ec461 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lP7wMEXnyaSdlL8IKDf50YW5/Nma7+flujihY8HEpHwwOQDVgzIeS5OMSo5R04LDbH26iYBZUiY94TxvRWWCIZwv3Sh5bzqouPkpPnF5VGE6MnAkgAWUSVOoWVHP7d5qiCxT21hS4CyZ8tpGITb/tv54na/eTsaEfII+D/kx+sX+u8MAkda4lauQZzdnLvySsvaSl6YwCeB+NKcfCqmoz70RZcgGiOM2zmHnH6J1acFTnDsSuMDPGMKLYO0qWoiKudCbNr7u8/CuEcdMGV3LQ639wGmmbeK/lk8Oy7akxGh9DS5gZZTBkcsiNrGaVXB+k4+K8TM6TGTeNs3etFtNhrhxP/otSiv/nUG+CUZrEd+ei+Tkijk8o6E5xEh73FHVISMdOgcmKWDUz2p1nbeZceS7vzPa1XiKcT72jB8BtGMsnuKHBiX5r0XsXwC1cUGGL6nYuGtHwC1oZg0sJGUPDBe2suV/JHvhGBjBh2BAT1fzFDYomZ0pGwJkasHTqz6yNCNDleO3lD2n2Q32n931R11Q38SQjgbQk8v0EE4O1Mtfp/Giofb2E2W6FP+LQUgnJ4L7DHC/HHwT0zDexuuZZqNuLLBqe8c/HE2g0C2qoCmf+UHQWmh+u9L0fHva+nHmfkTGSr/z4ackX9fxeVHeuAosqBHsueqIr3x78MveizGeSyNE31YPP8WQp1UxyO2nMiQ/GPLHCDPlay5sDu/q+cyTXMr+9WvxCXj7/WzgxzM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(6666004)(316002)(6916009)(54906003)(478600001)(336012)(2906002)(47076005)(70586007)(186003)(7406005)(70206006)(4326008)(1076003)(8676002)(41300700001)(2616005)(16526019)(426003)(83380400001)(5660300002)(7416002)(44832011)(8936002)(40480700001)(82310400005)(36860700001)(26005)(86362001)(82740400003)(36756003)(40460700003)(81166007)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 20:07:03.0398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cebb3d1-104b-47e1-3ac2-08dade0ec461 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: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4590 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 84CF018000D X-Stat-Signature: obropzh5zasn9pruexfyieset9pod1uh X-HE-Tag: 1671048425-969794 X-HE-Meta: U2FsdGVkX18ljJ1xQjUey7ANGUyQMbsvegrnXph4XXmApox5VLO7cf5VbbxermW80uCjaSuYJbe+54qs06kP5MhutJXfTqqbWquATBX+RqaQsbVNyxZWleyqnZ4USh5YwL4bbBvLQmOz37AF6m4tWDbTqiRCxEQ2iqlvbxw88XbubvVWPkAqWANGJzvu63PXX4mBxkSMFh2iNY5DorRI1rUA3Be66ac/Y5Yr8bRvlU+Q31p3Yj/nvEP7JGkTK2flaa0I2D1IZoHusjL69BNnZ3qJFv8T9RfiLvWuFpSrfAmFHyS3cm3AM4o29Qt2Xdf9wBg/MCJR8mTjKmatA4sSUDhQm1N/lyo5PrDc9zkDpqye6Mjwz3VIiTGdDZpHkQO3H7yt7v5g2ny93UtMypH0R9cGmAimCeAezDeadkwfm8+WurvFZmJkiaDIb1wSNnLYma6bKEVE26S8Wsib/+Af/WHa+GDZ6rsG7laDM9BWJB3CfsuYaRCyylZWUTnaaWa3NBsUdB75MlkbYgBvo8r5fSdY/kYAm24kqNGpdTRF4X/ouS7lqlW7SDg3e3db6ZjLGj7KpGUHQPD5W8uEu8T3ibZh9l7BrJrMvH7U1Xj8VNlpJYmErlXXo+7CE3vrLmXTHziNOVIOwBEvokRjp78otgTUJnHkW4fMxKfUa9u1odMXLXMs4DACoYGegRQVs1LWikenBbQGv+gZeX8Z6yj4q+pEMUPdCOCUj2DE5r7H8DD2F7cUyYqPNjzUSJv6cc+hkZGYkV6gAjxbks0S5YDF6y/jsBrXgMHzvl9md/fUlDtEL/hC0SynLEzj34lAq6EbxwemSJKGFXcmRJZ7OBzwbp3iInqJUkue97t70272ibnlUbzx0jBaG9iUojF/s40jNCpbp0pzi3YlvvwZ0KpXltJ4NbZhArY//pEPMUHIuYHjIPbT4lG8hYnXqzbZ5lttBDJpgqVIc3fCjyvvMKa aJ074URv bZ/o6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ashish Kalra Implement a workaround for an SNP erratum where the CPU will incorrectly signal an RMP violation #PF if a hugepage (2mb or 1gb) collides with the RMP entry of the VMSAVE target page. When SEV-SNP is globally enabled, the CPU marks the VMSAVE target page as "InUse" while the VMSAVE instruction is executing. If another CPU writes to a different page in the same 2MB region while the VMSAVE is executing, the CPU will throw an RMP violation #PF. Use the snp safe generic allocator for allocating the VMSA target page which will ensure that the page returned is not a hugepage, as it is already being used for the allocating the VMCB, VMSA and AVIC backing page. Co-developed-by: Marc Orr Signed-off-by: Marc Orr Reported-by: Alper Gun Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 543261c87eb3..1d4a723d5def 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -653,7 +653,7 @@ static int svm_cpu_init(int cpu) int ret = -ENOMEM; memset(sd, 0, sizeof(struct svm_cpu_data)); - sd->save_area = alloc_page(GFP_KERNEL | __GFP_ZERO); + sd->save_area = snp_safe_alloc_page(NULL); if (!sd->save_area) return ret;