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=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A9BD7C433E7 for ; Sun, 18 Oct 2020 15:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 631B421655 for ; Sun, 18 Oct 2020 15:52:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eXW2s2cw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgJRPwT (ORCPT ); Sun, 18 Oct 2020 11:52:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31525 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbgJRPwQ (ORCPT ); Sun, 18 Oct 2020 11:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603036335; 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=98NF5I6kW3PEIcXhLOKqmMDjTo2gmlFaETZTllsyzbc=; b=eXW2s2cwTi3F4VGWSjbxrULm7vx2pqBo7Whj+hIXq++u8mHniFXW5Q1gYjpYGtP3FQMdBS P7X5fIKFbLSTuF3/Um9jfD3L8qBl7W/kAuX7rdPfgcvBIZW6krwibdxjOr/6VqVti4hIw3 7/e7ngcdJ1zz64Krp6RkYXZM/Gx+tbo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-cDxzA_1dOAm895riBxTsng-1; Sun, 18 Oct 2020 11:52:13 -0400 X-MC-Unique: cDxzA_1dOAm895riBxTsng-1 Received: by mail-wr1-f70.google.com with SMTP id i6so6243063wrx.11 for ; Sun, 18 Oct 2020 08:52:13 -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=98NF5I6kW3PEIcXhLOKqmMDjTo2gmlFaETZTllsyzbc=; b=jZgOj5AG9wux3KJDK96uD3kDzjLtbjGQKsETIyOMwjdJUyosPDkuHZyJbfqBZjhHT5 O0oJLLpGigKrASPSQ477lhwe1LRwbYet5f1LTbOZvbKn7nW1B9kObS7stp/W46hoNG4Z 21gZymazj8USo93vvy1EIKDfCXBOnM6h0gVEOzDcpADijEV+HSb5kfkz9vfdayHqhO9T cmjltJqNj+w9LxFlIgVgblo/m+xySTb0uXMcClN7UvOjJsn1LPh56TCsEvBp32shVnQp fyMayGBVFXffJY99PmCVYdE4f1JkWBErlm77TQHiGR++31bqzD0h/7xp8dDXVaIrJTmW Cl6Q== X-Gm-Message-State: AOAM531qKGOpf1uRppYGWgKN81Fi1/k7MFWocUaW8RLAd7h6DJVM5zOV TounighawV49UnaHIi7YeQdkmzLp2SOI7bdRqfYei9VLQzx50yiazUSXq3GXvpJxOPtifpSV7Em LZDZN+/0EDjTwMJKiOIk/NJp3 X-Received: by 2002:a05:6000:1084:: with SMTP id y4mr14633136wrw.138.1603036332032; Sun, 18 Oct 2020 08:52:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDk0m1PaAgQbG5uGn8JDuTOpRDE6IZs81q1mD08uCdggM28IdBmZmD2H7MRJNdhDzXVGo/nQ== X-Received: by 2002:a05:6000:1084:: with SMTP id y4mr14633124wrw.138.1603036331866; Sun, 18 Oct 2020 08:52:11 -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 i8sm12624962wmd.14.2020.10.18.08.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 08:52:11 -0700 (PDT) Date: Sun, 18 Oct 2020 11:52:06 -0400 From: "Michael S. Tsirkin" To: "Jason A. Donenfeld" Cc: Jann Horn , Willy Tarreau , Colm MacCarthaigh , "Catangiu, Adrian Costin" , Andy Lutomirski , "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: <20201018114625-mutt-send-email-mst@kernel.org> References: <20201017033606.GA14014@1wt.eu> <6CC3DB03-27BA-4F5E-8ADA-BE605D83A85C@amazon.com> <20201017053712.GA14105@1wt.eu> <20201017064442.GA14117@1wt.eu> 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 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 ... -- MST