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 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 BDA1DC56201 for ; Wed, 21 Oct 2020 18:21:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A45C72245B for ; Wed, 21 Oct 2020 18:21:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="Mlb6bwWn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A45C72245B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8EF286B005C; Wed, 21 Oct 2020 14:21:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C6726B005D; Wed, 21 Oct 2020 14:21:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78E626B0062; Wed, 21 Oct 2020 14:21:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 4CB346B005C for ; Wed, 21 Oct 2020 14:21:11 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D0C1C89CA39C for ; Wed, 21 Oct 2020 18:21:10 +0000 (UTC) X-FDA: 77396749500.16.cow97_4d179f62724a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 92565100C4146 for ; Wed, 21 Oct 2020 18:21:10 +0000 (UTC) X-HE-Tag: cow97_4d179f62724a X-Filterd-Recvd-Size: 5039 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 21 Oct 2020 18:21:10 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id a72so3109884wme.5 for ; Wed, 21 Oct 2020 11:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E8EasOxRhOP4tKSelXi8vOrt3irONBkQC3+dFEG5bU0=; b=Mlb6bwWn6Gm4wUGJrY2+hFY3C4CVXYM4RKDORq9plubHdK5JFCxrzlK8tWW2WyhiW0 +1bmCbOY9cvLDsUqrlEdlXXK3cUeQFSE2EgCpPiScdBXi94x32bHTPWDlwjFKvi+liNe uDD5PL5oUZnuOCPjueMfEmwtHQOXCpm/y3FNnczTQ2O/dLX042Z9F66jY6ZLVYA9houk ++xik8f53NSFyhCOYynA11/0mdWGqA4Plx/DTN+E02yOOAgZfIeaOZ9ESZJrTftpjLuM T6FL9e2iSUAV438PzGCWoPCZnNOqLjWrXaWF4wGsXW0Z97vvZ2YboI7Re2zsP6v+jttq J64A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E8EasOxRhOP4tKSelXi8vOrt3irONBkQC3+dFEG5bU0=; b=FnIHNt18+qB5M5HdQqtxbXaeCGCCAmlHwOTEQN3iqtQIZ3QyMICd7jJTB8NsEkPcxO ehPvzm9RUV/RcnGVgOoMQBrx3lzAq61l2RlNz41b5WJ/YX3nRnPQC8XPpj/gW/IlC+zX fWJ5qxx9POFXWD3px3rBVoXbJiidG1Ld2cTpNy+ELuYc3wVbiCOr1ytx1+krHTFWJQCZ 5RqDSVk3P+qehTWXhe+vV3J7UoWyTerlkZluyX//lnryrcxVeAqN7lLmJMcBFpznCdCU at/tTityxnDImFGf/yjKFzNfRRSKsDfJEOQeI1ocjW9RGMn2kDs4yV+rGQIqoBymK96M F39A== X-Gm-Message-State: AOAM532WY09eyYUl1Hj7D0vsn+sF7urzB3I3QXrMMw09mfrmzAfbxd4K wIvLq4+ACRWBH/hlpJpO4o9QFocQQd7allpDjcJaEg== X-Google-Smtp-Source: ABdhPJxeaHvFlSYfCn7icCcIaUnLYahs9NWAn8zCXcfEhTk7pgP/2yR1U+LNEDK6a6A9XIMuZAh6eXp/2YTAXoW/dOg= X-Received: by 2002:a05:600c:2241:: with SMTP id a1mr5097261wmm.49.1603304468859; Wed, 21 Oct 2020 11:21:08 -0700 (PDT) MIME-Version: 1.0 References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> In-Reply-To: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> From: Andy Lutomirski Date: Wed, 21 Oct 2020 11:20:56 -0700 Message-ID: Subject: Re: [RFCv2 00/16] KVM protected memory extension To: "Kirill A. Shutemov" 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" Content-Type: text/plain; charset="UTF-8" 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 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.