Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3512933pxb; Mon, 4 Apr 2022 19:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLAOqqU50nsuqWegWN2QCioGRNzzQzm3T698ENJova+rX00347+jkmuj0VV3J+xkZJ7Ebr X-Received: by 2002:a17:90a:c3:b0:1ca:54c1:a684 with SMTP id v3-20020a17090a00c300b001ca54c1a684mr1402986pjd.148.1649125510676; Mon, 04 Apr 2022 19:25:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1649125510; cv=pass; d=google.com; s=arc-20160816; b=Kj4BSbqODczmbnFeveS59kptyBSOasKZqwRJci+4UOoyLj8vOY618DcKH7scYxLhb7 pY3ZyaXYXxSYUtdGRC4kcmq4K+NOGqqkpA6hpUgJygXiaBtjOOY0MjYlYmAFwpkkH5Rd 9x6AwUlaGoi71OmEQbtBDeTbkl+gxNtVZrw7bhTKx9s0Yc7EVJzviPVff+O/EFAm4wjN Wy4q4PGdvw4aigzpp6px0mLx4W9dmjl9qzok95eM27IzlQWQTV8gWnfivoladUu8QWnQ IZlP7oUfMgPf1GOHlVB7OofgZKLNkwo/Hn9BvbN8voktPLiFq5TS+a1sJpAd7jTyXQS7 m2vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=tYYuW2q0FeeSJQNUPL06Tty5wYOslgn5uc4yEpu7swg=; b=W15nhO21cXIA8KfN93dsehfXXVJWkRfqA+TYUgP605LlvbP2je+3vi+I4L05cUvGav MDRXrQEAyCn+6l41V5NIdn/RuMNdPlC/oKxr6XCSJk9BBfQmeyXxCThXF6geEwl+kIjA Wfg0khilRANDN+1kgggsY6jBppWnYfzJVOaOerysps28QOx8xHQ8ARvB5dTDfwtPYsQV DGBjz6cd4h1h3BTpb+pPab25WMVAZ1Cyc+YR4qExQ/UwoY89IRtOQfT4lECtTqgnq+6y XNi6EfxJPtJ0n06FXSUCw8zl9QIoe8PSCKyJe7JooX/p4ky8NfDx7y+o14cownT5TFL6 GqYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=o0ApAh8+; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d10-20020a056a00198a00b004fa3a8dff54si13100246pfl.11.2022.04.04.19.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:25:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=o0ApAh8+; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B3A2CAFB04; Mon, 4 Apr 2022 17:47:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235792AbiDAQQ1 (ORCPT + 99 others); Fri, 1 Apr 2022 12:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350510AbiDAQN5 (ORCPT ); Fri, 1 Apr 2022 12:13:57 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B16CD303; Fri, 1 Apr 2022 08:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bxfaL1NTm+dmgH3TM9Dbw2/kaeOrjHUgCdrk8rhtnRGLE/FlMzfuvFHDviknPS9NU3eSrx+/lVNlO0KvRv9zpKQKhfuT0K+L5ost/zy2S2H4lpQlThyVGNlbAiiZWgWF/LBd0/bK1ODHs99obZ/DuNiRni1XDhTOiBz1aRCw8K0ItWE7QGjlEOhDtT1DYkGlqGk+gQg395P2edYWubCJojvfvpkvlxndJ/EvzO2ougr1m8pXywleCR0dSipv5etFuT7X5rCxBoL7q1NLiP2kR6R+zbWvzhFQAnUbYV4MU4w6Au2VjGK3wP1zjsugtHHQaOJFGRN1wlRvH2/spA4cUg== 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=tYYuW2q0FeeSJQNUPL06Tty5wYOslgn5uc4yEpu7swg=; b=g7bEbHNC5/Wt8luMdjSHQfAFM6Bq4ardcbhStvU6781WMTbONWDdDAh2o5c/JnmXur5L15KhlDtxhI1YBHDjPHa66DS3ddYoNqDJbcnihPQ51Mtd5ShUAknUYpSMKqmXLRmpCLCiZvfU4xIG90wtmolJBJ4JdC6SZK+1gfIj+v9jDNsJKqC5/Ga4+MSsfMtuMzkaXFnyMAO7nHTttTVPdUn7ima2gstZCdoB8Ag7+O6y96raHsfneZkXICvxcPuGjkQ7nvRx2SHrj4epFIhoN41Cn8VJMTaQirYVCzkdFbgF23mOygi1BxUSp2NbAXTEYCuHoFGhKmOW2ctXli7MXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=tYYuW2q0FeeSJQNUPL06Tty5wYOslgn5uc4yEpu7swg=; b=o0ApAh8+02/PJNnGCWJiZu24yETPAcY3YHjGGIicYOJn3pcIBoP156Gr7Ic50WYaQu9vvnXwmcjb23Lu06srpwfR7uSvWmbyTXv+771aFCIEA2rOj80R/vC3MC7TLhVHhvFuFJHzrDVE+3M/rLA6kJ09Q+umtWMWtIH9riog5XM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB2470.namprd12.prod.outlook.com (2603:10b6:4:b4::39) by BL0PR12MB4755.namprd12.prod.outlook.com (2603:10b6:208:82::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.29; Fri, 1 Apr 2022 15:39:45 +0000 Received: from DM5PR12MB2470.namprd12.prod.outlook.com ([fe80::8547:4b1f:9eea:e28b]) by DM5PR12MB2470.namprd12.prod.outlook.com ([fe80::8547:4b1f:9eea:e28b%3]) with mapi id 15.20.5123.028; Fri, 1 Apr 2022 15:39:45 +0000 Message-ID: Date: Fri, 1 Apr 2022 21:09:31 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH RFC v1 0/9] KVM: SVM: Defer page pinning for SEV guests Content-Language: en-US To: Sean Christopherson Cc: Peter Gonda , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Brijesh Singh , Tom Lendacky , Bharata B Rao , "Maciej S . Szmigiero" , Mingwei Zhang , David Hildenbrand , kvm list , LKML References: <20220308043857.13652-1-nikunj@amd.com> <5567f4ec-bbcf-4caf-16c1-3621b77a1779@amd.com> From: "Nikunj A. Dadhania" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0023.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:97::13) To DM5PR12MB2470.namprd12.prod.outlook.com (2603:10b6:4:b4::39) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0ab4bee-808a-49ae-fad1-08da13f5d8a0 X-MS-TrafficTypeDiagnostic: BL0PR12MB4755:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SeglIF9kSlZCmZ4YO1g6HKjvNyDdvYSrNNeKtM/VNO+JBK3mVl1Z+h351I7Htz0StpYTt5Y1gNlzb1XmRf5tzYHUYeSlXBhQeRXtggF6GcHCPUekrEuLg0rcN6gg2Adb+e7Gx/pQ8tCmdtfU+uX7C9TN1k4fevKzKcPyRYZJUiOsQij888FY4yrzvjuhC/vkhDyH4hBpZeaKDmSbBPVpmlXkekVifcJeOccLHBYiZVscdtGIsxJ9oJ+4EpcT8VHx4iMT+zpWSfQG2Dks7/aIAvn1aMQvBBb2Cm6hXiepiXb81IzfeajsDezrjETCrllxmXjhNHdGgJBHsGLnLRJbgeiKC0K6CITzmEb0NsjKb+NuYoIOhxj4EehJ4dChmM+k5T94fSmobFH2szsHWyjVd6OYgcXrlyJVIffCW4wji1bBXI6Xl16A+akx36XF2VkQUVTsx/tJkN6vQHMYsFrAvxDrRWGoIwd1wdnU+73xJCk5tUDTKbPrb9QqGGcS13pwC450wds6kMLWPrxvHI8gH4bIIJn3HM+4wsH3TIdgWKzIicsdixllywQ7u4IlErSwTYmHDFOka/Atc0EvUFT2dwzrTFUJqcdMbKDzPY/0UaNI1fbhfBBQ9vNzmSr64e2QmSBF50mCcc4mEzJm6udBrZLCQKYjWqg/L9PWhNonzy0klfCydotfBnswv/j//fw1xgObmd2L4reStpjlNUbOhWs1OpdYO3U3HthPqgzOfnplFAMjLllxmOPW8r6dWjVd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB2470.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(83380400001)(26005)(186003)(2616005)(66556008)(8936002)(8676002)(66476007)(316002)(6512007)(53546011)(31686004)(31696002)(6506007)(36756003)(66946007)(6666004)(2906002)(38100700002)(6916009)(54906003)(7416002)(508600001)(5660300002)(6486002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vzlwa0tGZnNRWHgxdFhlQVRhandJUnY1NjhsbUhiOEdsVU0wWFhGQXR5cEFy?= =?utf-8?B?ekhrZFRtSDZNQWx6bVBXVytRUzBMSktKODUzOUplS3ZHWlZrWVFoMm5Mblhn?= =?utf-8?B?MTF4aUxRa0ZTZUsxVk9ZL1g2T3FEVStkeFVHVFhoREpsVlY5QUQybXlKbHMr?= =?utf-8?B?SUdkbkJBQXNmM3Yvd2hPUHd0dDhCNGJvNWNvMVhTTDZORmRXeG1zbGRLSXho?= =?utf-8?B?UG56dUtyT1ZVeXJncDdrZ2Y0Q3dMbExJdE1GMTBUWWp3cDJoNXNmdXZsOUpG?= =?utf-8?B?OFozTy9XQmJ5VDQ4MG5jQ2ZLdUZYLzR2YmY3OUUySm1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= =?utf-8?B?SFU4ak1YN2dKTVVxNTAyamd1MnhXVlJSY1RQM2lZSGhmMFFobW1HVk16cEV2?= =?utf-8?B?WnVUN0tSajVMSUZRL25CNXlrbzI0RnZteDlTYnNodTVhWkp2d2hkNnRObUlC?= =?utf-8?B?ZWQ2aHMyWnUwMzJxSlArQmNiYjF4bTN3bGk1UWE3TzkxZ3N5WXdYek9nR2ZD?= =?utf-8?B?VkQxOTNrZzFqUTdUeGYzTW5GRXY3MUNvRTVvVGRTWmx4SzQvRjZHdz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0ab4bee-808a-49ae-fad1-08da13f5d8a0 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB2470.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2022 15:39:45.6189 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BsMCSLi2JnH1vFBAxEXWi1f8o0L934rOr3R+J32lyBz0/O+kxgtE4D3eifZtxcdo82Co8eU/wNV4/80yw0pNZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4755 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/1/2022 8:24 PM, Sean Christopherson wrote: > On Fri, Apr 01, 2022, Nikunj A. Dadhania wrote: >> >> On 4/1/2022 12:30 AM, Sean Christopherson wrote: >>> On Thu, Mar 31, 2022, Peter Gonda wrote: >>>> On Wed, Mar 30, 2022 at 10:48 PM Nikunj A. Dadhania wrote: >>>>> So with guest supporting KVM_FEATURE_HC_MAP_GPA_RANGE and host (KVM) supporting >>>>> KVM_HC_MAP_GPA_RANGE hypercall, SEV/SEV-ES guest should communicate private/shared >>>>> pages to the hypervisor, this information can be used to mark page shared/private. >>>> >>>> One concern here may be that the VMM doesn't know which guests have >>>> KVM_FEATURE_HC_MAP_GPA_RANGE support and which don't. Only once the >>>> guest boots does the guest tell KVM that it supports >>>> KVM_FEATURE_HC_MAP_GPA_RANGE. If the guest doesn't we need to pin all >>>> the memory before we run the guest to be safe to be safe. >>> >>> Yep, that's a big reason why I view purging the existing SEV memory management as >>> a long term goal. The other being that userspace obviously needs to be updated to >>> support UPM[*]. I suspect the only feasible way to enable this for SEV/SEV-ES >>> would be to restrict it to new VM types that have a disclaimer regarding additional >>> requirements. >> >> For SEV/SEV-ES could we base demand pinning on my first RFC[*]. > > No, because as David pointed out, elevating the refcount is not the same as actually > pinning the page. Things like NUMA balancing will still try to migrate the page, > and even go so far as to zap the PTE, before bailing due to the outstanding reference. > In other words, not actually pinning makes the mm subsystem less efficient. Would it > functionally work? Yes. Is it acceptable KVM behavior? No. > >> Those patches does not touch the core KVM flow. > > I don't mind touching core KVM code. If this goes forward, I actually strongly > prefer having the x86 MMU code handle the pinning as opposed to burying it in SEV > via kvm_x86_ops. The reason I don't think it's worth pursuing this approach is > because (a) we know that the current SEV/SEV-ES memory management scheme is flawed > and is a deadend, and (b) this is not so trivial as we (or at least I) originally > thought/hoped it would be. In other words, it's not that I think demand pinning > is a bad idea, nor do I think the issues are unsolvable, it's that I think the > cost of getting a workable solution, e.g. code churn, ongoing maintenance, reviewer > time, etc..., far outweighs the benefits. Point noted Sean, will focus on the UPM effort. Regards Nikunj