Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp411953pxx; Mon, 26 Oct 2020 11:17:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTHEWVajsVphvLu8o4SmItOFoE5L8+nM20Z0H/YVbtAY7xR3XnWOFWJW4hv5omOylZuVD3 X-Received: by 2002:a17:906:7844:: with SMTP id p4mr16645612ejm.26.1603736266137; Mon, 26 Oct 2020 11:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603736266; cv=none; d=google.com; s=arc-20160816; b=TCF9c52sygfs5Zy7KCrnDjJA+QoForXJ8euq9HjZdhEAdQWfG189afDU2A/PcrK5T0 p0Eeyz35Ek7sxGoJt5NMfI3lY20+8ITjM0ni96vHOLIsIoQ/XpYZ6wTywOi3MN8QeC14 QEeln4leE/EVCkwAdfw3baDJ7eSg3Djb4g6mi9cPi+QjnrgLpLhGCQIr5r+YRnlAyUqp TJQa1xQjCgmK1YXtlxCbWduq7GTpPTNGCE4YmQMQF7gAXUVxCb+gq/g9u1ILiXQi37se DJMFOfEi/Ug6oUIbnbm4KUgEFOhLKeVE/K0g0s76i2n0HURBlKQh4KwR1wpva/ZiVqX2 c+MQ== 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=2ASN/DBUumncOIXrVy0+uLgrT6nDM6lupwXazfbf6yY=; b=qfFlgWuXKGekuWBZULBhVrzOKxp8zJ0C/sq/xlUgYy7kB7w1hHYM5h+H+PQhgk8Jan quiY2OGsBQB7OFa7oZzTr0GSVJxW/wXlRnvNcMgpWEhW54MFDsEzkeYpu3jApGwxkZ2k 3As9lM+lzCd8Q3yvII3fK2Le8ZThi3jlncIgSsISqKer/SgyzCbt4SYlN2lCa81FlKnF QIwotnFo65fMCQe/EYVDULTK+XkwkczoqMM0RwAH8EGmRWj9AFL5eDPugSrlO5SkzbDW 020zhWiF2LGL56bru5HQfLnbdiJ0GcVnB3RPXaXGJdCErt+F+AvJhjh5yLM57LYmn1IH 8/dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="EPBJN71/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si7232008ejl.239.2020.10.26.11.17.23; Mon, 26 Oct 2020 11:17:46 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="EPBJN71/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1783851AbgJZP3R (ORCPT + 99 others); Mon, 26 Oct 2020 11:29:17 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42144 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1783845AbgJZP3P (ORCPT ); Mon, 26 Oct 2020 11:29:15 -0400 Received: by mail-lj1-f194.google.com with SMTP id h20so10644080lji.9 for ; Mon, 26 Oct 2020 08:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2ASN/DBUumncOIXrVy0+uLgrT6nDM6lupwXazfbf6yY=; b=EPBJN71/a4yW2KNB4CZyN2SstX8ZPfZe1Yd139rZU2H/AwTqQzrPycVY6F8BH3y5le M17ZN9EGRHCQoaOFgHizwD/0aSwS0IR8u9gI6qpG9095ryTwpm2quspWyd4aUNAEMJfS dnuyNKQ3oEopLbKSb8KK1C5I5pTFhSC/KBYQRCMD1sojSqVQvF2PwE4ekq739Ek1IVMi Osw4L0hbOLYHvCtZvPh+pb+sNDXAn2nQnXvmOVadPjo4KZF/eGYtRHF2abtExs28HhiO vNOXFSDMNEs+i17/qL42Z/227K0y061wpPZyhXrmN3EsjeZorN4ietGRKYwjB8zr9wRx Olbw== 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=2ASN/DBUumncOIXrVy0+uLgrT6nDM6lupwXazfbf6yY=; b=S/R/ksa8meezQnUjBEY5HxiszyxoS0H6e1rzXaRbqyHMA2/nToNabMpZvNfc0NxyA7 MOGzoiGaLWN6ArHeEnA5b2sykPmHLnCR4C9KXlSj/X8G+aarIYSNvzaiqwl3yl7MfPmf t5Ij/HQDGZ1edIpYBl87dUOV3zIz8PSBytXW4gU+tLWUOEhtdp2SLeaZ2CYVOD9k4ukx mvf+xyzGPWgcMZ56c79NlOZJboLYBLip8r32jW/l/9TQkANEELfx2LwocgF7V0SHw8Ya AXmWvHHQ9Sf//G2VuPg0N/NhbBUIpTaJNsI/t+SKfS6Bsjmg9ClY/DhUK9EvLNzheA2H ULBQ== X-Gm-Message-State: AOAM533EHwgLK7qw+JeqGgId3rTcqeapnxkWIR6U45QNu0zBKjmIlS4B cMY1LvBJ3xWknPQImdJ58VC2tg== X-Received: by 2002:a2e:9255:: with SMTP id v21mr6267205ljg.228.1603726150222; Mon, 26 Oct 2020 08:29:10 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id z11sm1222830ljk.7.2020.10.26.08.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 08:29:09 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id CAA6010366B; Mon, 26 Oct 2020 18:29:10 +0300 (+03) Date: Mon, 26 Oct 2020 18:29:10 +0300 From: "Kirill A. Shutemov" To: Andy Lutomirski Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Rientjes , Andrea Arcangeli , Kees Cook , Will Drewry , "Edgecombe, Rick P" , "Kleen, Andi" , Liran Alon , Mike Rapoport , X86 ML , kvm list , Linux-MM , LKML , "Kirill A. Shutemov" Subject: Re: [RFCv2 00/16] KVM protected memory extension Message-ID: <20201026152910.happu7wic4qjxmp7@box> References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> 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 Wed, Oct 21, 2020 at 11:20:56AM -0700, Andy Lutomirski wrote: > > On Oct 19, 2020, at 11:19 PM, Kirill A. Shutemov wrote: > > > For removing the userspace mapping, use a trick similar to what NUMA > > balancing does: convert memory that belongs to KVM memory slots to > > PROT_NONE: all existing entries converted to PROT_NONE with mprotect() and > > the newly faulted in pages get PROT_NONE from the updated vm_page_prot. > > The new VMA flag -- VM_KVM_PROTECTED -- indicates that the pages in the > > VMA must be treated in a special way in the GUP and fault paths. The flag > > allows GUP to return the page even though it is mapped with PROT_NONE, but > > only if the new GUP flag -- FOLL_KVM -- is specified. Any userspace access > > to the memory would result in SIGBUS. Any GUP access without FOLL_KVM > > would result in -EFAULT. > > > > I definitely like the direction this patchset is going in, and I think > that allowing KVM guests to have memory that is inaccessible to QEMU > is a great idea. > > I do wonder, though: do we really want to do this with these PROT_NONE > tricks, or should we actually come up with a way to have KVM guest map > memory that isn't mapped into QEMU's mm_struct at all? As an example > of the latter, I mean something a bit like this: > > https://lkml.kernel.org/r/CALCETrUSUp_7svg8EHNTk3nQ0x9sdzMCU=h8G-Sy6=SODq5GHg@mail.gmail.com > > I don't mean to say that this is a requirement of any kind of > protected memory like this, but I do think we should understand the > tradeoffs, in terms of what a full implementation looks like, the > effort and time frames involved, and the maintenance burden of > supporting whatever gets merged going forward. I considered the PROT_NONE trick neat. Complete removing of the mapping from QEMU would require more changes into KVM and I'm not really familiar with it. About tradeoffs: the trick interferes with AutoNUMA. I didn't put much thought into how we can get it work together. Need to look into it. Do you see other tradeoffs? -- Kirill A. Shutemov