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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 A705AC4363A for ; Mon, 26 Oct 2020 15:29:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A1BA22400 for ; Mon, 26 Oct 2020 15:29:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="EPBJN71/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A1BA22400 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61FC76B006E; Mon, 26 Oct 2020 11:29:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A7B76B0070; Mon, 26 Oct 2020 11:29:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46F016B0071; Mon, 26 Oct 2020 11:29:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 16F5C6B006E for ; Mon, 26 Oct 2020 11:29:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A7BD33624 for ; Mon, 26 Oct 2020 15:29:13 +0000 (UTC) X-FDA: 77414460186.29.dock53_3d130cf27274 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 7D5FB1801BD8B for ; Mon, 26 Oct 2020 15:29:13 +0000 (UTC) X-HE-Tag: dock53_3d130cf27274 X-Filterd-Recvd-Size: 6030 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Mon, 26 Oct 2020 15:29:12 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id y16so10654200ljk.1 for ; Mon, 26 Oct 2020 08:29:12 -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=l372PbWXT5osBey6O1UaGRL7232zTKY/+FiOdJz0KMmxiiwNYmfVRk8kMAAU1gVG3M g2jkcWj2BdEOERn0iU6isr1v0ooe0fEHkQu6MjkKazoFDLiLN9Ls1zJPP+dMWMHFco+1 0CDN0kLJsJTGByjlkUoelkYvgvCLhdAClKvyxdylgfz3OQJaukTm+qCLBaQfg7edl/wd BqrDqHIFTwsDYa7vEGp3jz8haxafu6corKEir5CavXo5WBUOoh7qNQCrvsFnD7BAMwDA bkBA6fyAhghPDBgrKdfC09Gev12CanxTud3WCodcCU1GR1W/N0wS8L6edVjhnqTmO52I Kagg== X-Gm-Message-State: AOAM531abmjddIJY9iiSdYa4iddQKojpjaOBoMMRUc6NFrExqNDTWQ87 wtHvN9bs11ucQjp9FSoPuYtoUg== X-Google-Smtp-Source: ABdhPJwgJmr5qqnTpZrUz2JUkooPo2pPwM+xTp1Z3a13ceXJJ/6BSAtswICdSIuB01sAfeHKJH2E+Q== 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: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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