Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2076618ybv; Fri, 14 Feb 2020 11:01:23 -0800 (PST) X-Google-Smtp-Source: APXvYqz9v3DaLKMt+xfRsW3/eodURWY+ybw0XfhIaLCyKb2w7FMQ+1+wQlTp8yV0m00E4Naf7tmE X-Received: by 2002:a05:6808:8d0:: with SMTP id k16mr2866141oij.68.1581706883581; Fri, 14 Feb 2020 11:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581706883; cv=none; d=google.com; s=arc-20160816; b=RR1e44uqcTGKVoLWXYeGWAxwwDPU1fhCM6EJNC2ZEpNOjMX+A7hfq3anPH9b3RG+Zp Lsz5mPAwneAgpAZoFUfRAqO0MQHP4KPo4vAYIGCIvcDDxdJ6hm+jeem8e6tjUQGrAmHb tzNZWhoJkvI0VCz3e2aqk7iwdPK9kW3T0wtNszvVPEkovD1k756OiT6mfemprIT+hafv 27FPDZ/ZG8doPJTEvDNFLiz+jIUSWuieq5QcYPdoq0Z4Zn0EoXXFhTU8jbqExb34RhOl lCY2tXpq1cg7E9uRLN4QPBDeXC5nAKE4gb+y6hj/j9NsYjxkjCa+PSWu9oJg/4N1Quwu Gm8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=N88wgL7P5VZITKiWcTnZGP9kT87SHjGu1KBb5VAHdok=; b=WPQrtenKG8l1j5hhKOgEbc29/W/q8omiqABN3QkwhldD9VPOvVsZr+2RL6nSDoudtX eBO7vFNm4wFGvbhwVJpn4NG2yrqr/Za/XCnpUVX24ByQistZrKDOZFf0NPwpN2+sK7t5 y6qfpyHu5SBodPqKt3ZrUsCvJDx6I3Pw3rx7sRRYcWfwMwMCk2krbF2Y4KZ5vSPauBgA AFcBvBjYtiogrEL5VJGsiVvHFO8beBPMcX8Ak4ZdUSCLGm3svUHfWVwssk+reDzIiwM+ OyfJ+d+QMEjTFY3a2zhsTPxgrB0k/6gX2PS0KFhCBovuROH/3pFgXd9hyF5uzQvpy+a9 uroA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LFxgD4D+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b141si3087511oii.79.2020.02.14.11.01.11; Fri, 14 Feb 2020 11:01:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LFxgD4D+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbgBNS5I (ORCPT + 99 others); Fri, 14 Feb 2020 13:57:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:45774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgBNS5H (ORCPT ); Fri, 14 Feb 2020 13:57:07 -0500 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 901C622314 for ; Fri, 14 Feb 2020 18:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581706626; bh=YlbFqP4MOujySUgnVR9wtKNwv0GjLZbM5SbUJK0O0gQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LFxgD4D+vmep4eAzrKNlFmVFdKVoEdLCpcb8r6lf3Y7K8zRscdcjqr7NFiohrVA85 HzvaAZxHtIPji4PzbrjMDpMUOw9EiuIwJGLQ2/v7mzoIFjvifDnzJgHub58d+I9LIM 8U/QNff+0x9O+PPZqDCBUvpj8SGZ5n3iEL5Alnrw= Received: by mail-wm1-f48.google.com with SMTP id t23so11032596wmi.1 for ; Fri, 14 Feb 2020 10:57:06 -0800 (PST) X-Gm-Message-State: APjAAAXJio4xIhV1usPPg2dxHZaNo5x/BJoRnPrQQ9bu4vzo33tuxqdJ v6shP3htSy1SoI4hDPVPJvqLckaB3xSRMEGZy+hIWA== X-Received: by 2002:a7b:cbcf:: with SMTP id n15mr6008857wmi.21.1581706625011; Fri, 14 Feb 2020 10:57:05 -0800 (PST) MIME-Version: 1.0 References: <20200213222825.GA8784@ashkalra_ubuntu_server> In-Reply-To: <20200213222825.GA8784@ashkalra_ubuntu_server> From: Andy Lutomirski Date: Fri, 14 Feb 2020 10:56:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 10/12] mm: x86: Invoke hypercall when page encryption status is changed To: Ashish Kalra 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 13, 2020 at 2:28 PM Ashish Kalra wrote: > > 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. And have you ensured that, in the inevitable race when a guest gets migrated part way through an encryption state change, that no data corruption occurs?