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 X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4464AC352A3 for ; Thu, 13 Feb 2020 22:28:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E99D224696 for ; Thu, 13 Feb 2020 22:28:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="TIDVisVY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgBMW2f (ORCPT ); Thu, 13 Feb 2020 17:28:35 -0500 Received: from mail-mw2nam12on2054.outbound.protection.outlook.com ([40.107.244.54]:6194 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726780AbgBMW2e (ORCPT ); Thu, 13 Feb 2020 17:28:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n2KVNgEVtN2uKuS/Lg6kdN9Bxd+qBkNVkYwjDBSd6Yy79IPPiD7eIOs2t9i0RqafUMQS4aGNXYIRAAGaKgehdtawdM1fGEOUJ7u1O07jX3ssHLz+nGhex7T7AVoib63rrjN3zCAscf0wtJ/gclGH+iIv69BZlVPsUkp0aWfAAZvfppAA4GUqG6jkMsb8IUtcqydyLO/+MB5hE9dA2uqjhMwgfGLkJjR/gOHZdrmF9CWPotso1B54LA2Bafw3u+HP2zeUWwOftty5jGWgX4Llxxdz8+aecZWr6G5rRCzP8yomEVysuZMV3Q7BtcTWGOi9xBG62LKYnz/u2EX/i22K3w== 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-SenderADCheck; bh=y+NKkAFnf1wCFqWpZ4FwDbTT+ee+Tq7RQ+oCptIR2Z8=; b=gxhUeEyPl82niyADyxEGLRiu7+5QucyTeUSVPROScaKj8nqHQqfomK4OHHr5CeuKx1RapW0x2MXubWSw0YpIn9Q5ifFT8IQkJtYj0ALBm6giLWy3+JIOgrMAuCdSA+LjRC6px2kKBeHuC0rzng0KmnDu9HbBCyApKh25D/BjdfxX5UchhClJJ8IDTbIlIRCEw0dxVGjswaSdlV0C2GOxK5FHRwTBtT8C1Qh3r7bcGXRIJjHMebO/Gi9jJNaGR5w1Zdi4z4XOKhnz2NS0UaZM1Q/yg5u/T9X3dqkc3NtsRtSlAvcqkLXpJr01M+Xsz0WwPmdcTauJS10yOGPc9xSktw== 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y+NKkAFnf1wCFqWpZ4FwDbTT+ee+Tq7RQ+oCptIR2Z8=; b=TIDVisVY01nPuaUrjQkUGLGe5cX0487G3+ds9d9MGuFqIAtH6b1LeUF6q6LdQIkC7lnUfdr3qfNip4LcYpZIEXuxF5lBYJYCHaheeNnrkzR65ref8i6OIWdiMPx5Qp4dY1T/pTg1Pe/jxWUCGnk5eoJ9WcEGiZhJ7wjGRJJf7hU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ashish.Kalra@amd.com; Received: from SN1PR12MB2528.namprd12.prod.outlook.com (52.132.196.33) by SN1PR12MB2589.namprd12.prod.outlook.com (52.132.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.22; Thu, 13 Feb 2020 22:28:32 +0000 Received: from SN1PR12MB2528.namprd12.prod.outlook.com ([fe80::fd48:9921:dd63:c6e1]) by SN1PR12MB2528.namprd12.prod.outlook.com ([fe80::fd48:9921:dd63:c6e1%7]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 22:28:32 +0000 Date: Thu, 13 Feb 2020 22:28:25 +0000 From: Ashish Kalra To: Andy Lutomirski Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Radim Krcmar , Joerg Roedel , Borislav Petkov , Tom Lendacky , David Rientjes , X86 ML , kvm list , LKML Subject: Re: [PATCH 10/12] mm: x86: Invoke hypercall when page encryption status is changed Message-ID: <20200213222825.GA8784@ashkalra_ubuntu_server> References: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: DM3PR11CA0017.namprd11.prod.outlook.com (2603:10b6:0:54::27) To SN1PR12MB2528.namprd12.prod.outlook.com (2603:10b6:802:28::33) MIME-Version: 1.0 Received: from ashkalra_ubuntu_server (165.204.77.1) by DM3PR11CA0017.namprd11.prod.outlook.com (2603:10b6:0:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.24 via Frontend Transport; Thu, 13 Feb 2020 22:28:31 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 382e77ec-4c28-4e2a-4aba-08d7b0d40eba X-MS-TrafficTypeDiagnostic: SN1PR12MB2589:|SN1PR12MB2589: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(346002)(366004)(136003)(396003)(39860400002)(189003)(199004)(316002)(6916009)(33656002)(2906002)(33716001)(956004)(86362001)(8676002)(5660300002)(7416002)(54906003)(81156014)(81166006)(44832011)(8936002)(52116002)(53546011)(6496006)(478600001)(26005)(186003)(16526019)(66556008)(66476007)(66946007)(6666004)(4326008)(9686003)(1076003)(55016002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB2589;H:SN1PR12MB2528.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fLY35JEOJ/oj2l1SKvQ6TdzZ2eSnCpZMwWXyfxCX6ZTHcjFnFw9o1zlOLlBxJDmyfMs3ps5KZgHfwmdItsJz+ObBcpGBmF/0MQBn83NPMe2HxoxMtvHz/hgi+oSbPIZYA5ssZtcmV4/5dk4PBVGUY8XX0Hz6YB5H9JCzz79zLf7nX8BMwgB4v5us0uKS77/4MApvF9Z1qaw38b/N6Qk5I8iQzVDtw3n61gluz1CcyzOjWLJYAHXt8xWvlkzQRnLdxB1xV1K60sp1FcbO6gIO7HToXRyepmiMGRXcZYfHtK5mix0lZwkXxpjc5ZfSVMWAQZMFa5QKjw2pCamJTB/iKeRctgmpi+PlrxE4BwtMTROL8gDW+Bi5Hz7QsRwFNu3rGg1/jNFgEh/BbOcYuEi/3t1rfTb9jS4N9FpYVo08oBkJziGkzIdloTmfBFsNZQib X-MS-Exchange-AntiSpam-MessageData: ZxbWk4lLAsy/LsEvo8BG75VYuONXJMPK6tM+xfPsK8spqOOWKxlLIV/9G0QxSFb079I9+OJ2XP6lhDvtGQ17IoaT9gTITOZG0zqJiNax1ZBSbJln/Uo5Y8S7rRa/JiyfYjjAp+3B8LiN5tw/vf8CVw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 382e77ec-4c28-4e2a-4aba-08d7b0d40eba X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 22:28:32.6657 (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: +4ImK4TBmDmKPo0G+SmhxvqNiHU43b/1wxSJYL5HXz3MvZzMP++4HfaurVZA0pa/Dj3FWBswdAF27VAdCihjLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2589 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 09:42:02PM -0800, Andy Lutomirski wrote: >> On Wed, Feb 12, 2020 at 5:18 PM Ashish Kalra wrote: >> > >> > From: Brijesh Singh > > > > Invoke a hypercall when a memory region is changed from encrypted -> > > decrypted and vice versa. Hypervisor need to know the page encryption > > status during the guest migration. >> >> What happens if the guest memory status doesn't match what the >> hypervisor thinks it is? What happens if the guest gets migrated >> between the hypercall and the associated flushes? This is basically same as the dirty page tracking and logging being done during Live Migration. As with dirty page tracking and logging we maintain a page encryption bitmap in the kernel which keeps tracks of guest's page encrypted/decrypted state changes and this bitmap is sync'ed regularly from kernel to qemu and also during the live migration process, therefore any dirty pages whose encryption status will change during migration, should also have their page status updated when the page encryption bitmap is sync'ed. Also i think that when the amount of dirty pages reach a low threshold, QEMU stops the source VM and then transfers all the remaining dirty pages, so at that point, there will also be a final sync of the page encryption bitmap, there won't be any hypercalls after this as the source VM has been stopped and the remaining VM state gets transferred. Thanks, Ashish