Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2653738pxu; Sun, 18 Oct 2020 10:13:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOI4lnoX/JBZUD54b+ZO88zlt5p26QMgdpWH32iSJhJvQbUeQrjd9X5zYAYM+FVcxCXbxa X-Received: by 2002:a17:906:401b:: with SMTP id v27mr13355196ejj.475.1603041212343; Sun, 18 Oct 2020 10:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603041212; cv=none; d=google.com; s=arc-20160816; b=F3FMjVQiwsBam+7PfONT9hAchhPNcTdSZRn2KkHWDT+0Hfkxxbj41korRiHM4XQsCO 2NU3xpXBMQ2DGSgBqZ+KE0kI/7JM47XTjo6kb9PlH5Lo5tQQzZGha8z+smSkvlqx8YGO hvK34zX2Wq9zZWW2wnZC2wHKWTGwA6KAsJRLuJ0iTzDkvaoJOFIlKIqxX8qgrRcYTau1 G5CtE2K7KLOyjsTvVyBDSNk/gbvBwfebd9xm59P2O1fJBmWfXv2PeT5yQixf+XXDcUbC wnvmJtxBroVQwx2oWoritGjZGEXdNLhpfecjdZ8Frm7SACHfo8bey1mHtoMTMSOcl1VT ppHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=G1NfFqRvQCLurPJ/4oycBIXRpf/JK9ZrKM1/uUoh0IA=; b=WZc5os7nLokKJr+qvJk/MS4E0IHjKoahKlkio25BgBs+TDoyobU+Oo1r1RmqX8oks9 NkpqNh/FtGXuKvJrCJOnASllE//SuJSxRIVh6weyODMy4x4O9v3yEinPhclgZKDJkzlJ cuntfdPzJNxlggzdd/jzmUkBc8KLC7CYjwFpRi/QzwtDQTx3hK7Qza3w86IUETEdAfqg ZJeROpn/KBoRzn+E3c7rbQmYQZ/3vZkXqAGe8crcBj3+qwAnBoCsxeLFuyjPqAP3Hbys UEdfxV4cbUiFZumErGk8JUB5DbGTPw9Pld0FA7QluhHntS3hQvNqVScR1fw7dQmUKPwo yEMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pyf4yAXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si6347105edr.288.2020.10.18.10.13.09; Sun, 18 Oct 2020 10:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pyf4yAXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbgJRP7v (ORCPT + 99 others); Sun, 18 Oct 2020 11:59:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26099 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgJRP7t (ORCPT ); Sun, 18 Oct 2020 11:59:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603036787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=G1NfFqRvQCLurPJ/4oycBIXRpf/JK9ZrKM1/uUoh0IA=; b=Pyf4yAXzQVn2Aj82XmoXSyLYN97mk9UayHMBtuxkEhO2tsJrAtLI8o/4ftXbS1JseST0dR MUozCkLLJkcBN2mmXQUtGjfeBWpeek3vqoyUp3WZnuUg1d5frZLAVidmNiV+JJKe9Yvu9f dSZolVLhGG7ZO7zxXGEhltq8Rr3yQbw= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-bBNfxWFrNm6RfPZ0aQydnA-1; Sun, 18 Oct 2020 11:59:45 -0400 X-MC-Unique: bBNfxWFrNm6RfPZ0aQydnA-1 Received: by mail-wr1-f72.google.com with SMTP id 91so4235131wrk.20 for ; Sun, 18 Oct 2020 08:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=G1NfFqRvQCLurPJ/4oycBIXRpf/JK9ZrKM1/uUoh0IA=; b=TWVXMPXXY6c7cOEPnwejz2n536xGvrRn1BxtdmmzT06QBeMdMRMpd2i8bNrrTS2EeY 8DRbfjvOSj8xiLRfua2bz++zVgWqg04tHa/6sYscq6/9R8jTCCqtHxT9dJoXVCJMAJwa FgwpBuV5376Q52uhM3sVAV2QHZv1SFpeSMcOlrvlrKEgG38+lot1XWORQ7i+6VXW/fPK 7XU921mEYvkfz2qDJXKIo41LAbsf5rlB4ozPR8JwehzCvtTqjWamqSE/+QcVmQQjGXTk acGvssBoHfgb2nIoG3xM0NsYvnB3df4lfD1W2F+1fhAetpoLNheVY/S+wrytU++78iWF ZuLw== X-Gm-Message-State: AOAM5316QSuSF4uupTqO0qKmV6KHyvwM85gAHcF9tt3/MHKZdy+pB9Ox 7aw2YCbDJTgZ20JSowoQLtxw3ccpc6GiszMPFCrKjHCfQNlSPPQb3UJHwBFBlU1FyY+FF9VNsFW cTAaZReQ3PP9ZXUvqJJRmjXIB X-Received: by 2002:a1c:f719:: with SMTP id v25mr13416586wmh.186.1603036784680; Sun, 18 Oct 2020 08:59:44 -0700 (PDT) X-Received: by 2002:a1c:f719:: with SMTP id v25mr13416551wmh.186.1603036784415; Sun, 18 Oct 2020 08:59:44 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id a82sm12794262wmc.44.2020.10.18.08.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 08:59:43 -0700 (PDT) Date: Sun, 18 Oct 2020 11:59:39 -0400 From: "Michael S. Tsirkin" To: Andy Lutomirski Cc: "Jason A. Donenfeld" , Jann Horn , Willy Tarreau , Colm MacCarthaigh , "Catangiu, Adrian Costin" , "Theodore Y. Ts'o" , Eric Biggers , "open list:DOCUMENTATION" , kernel list , "open list:VIRTIO GPU DRIVER" , "Graf (AWS), Alexander" , "Woodhouse, David" , bonzini@gnu.org, "Singh, Balbir" , "Weiss, Radu" , oridgar@gmail.com, ghammer@redhat.com, Jonathan Corbet , Greg Kroah-Hartman , Qemu Developers , KVM list , Michal Hocko , "Rafael J. Wysocki" , Pavel Machek , Linux API Subject: Re: [PATCH] drivers/virt: vmgenid: add vm generation id driver Message-ID: <20201018115524-mutt-send-email-mst@kernel.org> References: <6CC3DB03-27BA-4F5E-8ADA-BE605D83A85C@amazon.com> <20201017053712.GA14105@1wt.eu> <20201017064442.GA14117@1wt.eu> <20201018114625-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 18, 2020 at 08:54:36AM -0700, Andy Lutomirski wrote: > On Sun, Oct 18, 2020 at 8:52 AM Michael S. Tsirkin wrote: > > > > On Sat, Oct 17, 2020 at 03:24:08PM +0200, Jason A. Donenfeld wrote: > > > 4c. The guest kernel maintains an array of physical addresses that are > > > MADV_WIPEONFORK. The hypervisor knows about this array and its > > > location through whatever protocol, and before resuming a > > > moved/snapshotted/duplicated VM, it takes the responsibility for > > > memzeroing this memory. The huge pro here would be that this > > > eliminates all races, and reduces complexity quite a bit, because the > > > hypervisor can perfectly synchronize its bringup (and SMP bringup) > > > with this, and it can even optimize things like on-disk memory > > > snapshots to simply not write out those pages to disk. > > > > > > A 4c-like approach seems like it'd be a lot of bang for the buck -- we > > > reuse the existing mechanism (MADV_WIPEONFORK), so there's no new > > > userspace API to deal with, and it'd be race free, and eliminate a lot > > > of kernel complexity. > > > > Clearly this has a chance to break applications, right? > > If there's an app that uses this as a non-system-calls way > > to find out whether there was a fork, it will break > > when wipe triggers without a fork ... > > For example, imagine: > > > > MADV_WIPEONFORK > > copy secret data to MADV_DONTFORK > > fork > > > > > > used to work, with this change it gets 0s instead of the secret data. > > > > > > I am also not sure it's wise to expose each guest process > > to the hypervisor like this. E.g. each process needs a > > guest physical address of its own then. This is a finite resource. > > > > > > The mmap interface proposed here is somewhat baroque, but it is > > certainly simple to implement ... > > Wipe of fork/vmgenid/whatever could end up being much more problematic > than it naively appears -- it could be wiped in the middle of a read. > Either the API needs to handle this cleanly, or we need something more > aggressive like signal-on-fork. > > --Andy Right, it's not on fork, it's actually when process is snapshotted. If we assume it's CRIU we care about, then I wonder what's wrong with something like MADV_CHANGEONPTRACE_SEIZE and basically say it's X bytes which change the value... -- MST