Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3214459ybi; Mon, 17 Jun 2019 19:24:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzA0f9q23QWgMWh+/0ziehsmqqs7tk91cAy8DCR0EdN33oS2I52jKMY5mtAEN9WXJXmPPet X-Received: by 2002:a17:90a:360b:: with SMTP id s11mr2413148pjb.51.1560824644221; Mon, 17 Jun 2019 19:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560824644; cv=none; d=google.com; s=arc-20160816; b=CqkAWORbAZuXZV7b0AB06nCAr1CowcNxE+KLgEGluYPQUPr91aUKkM9UWeBgxTZ9Ym keApAJfIK35aVQ4GW9l1S321xjLtnSJgLl5DO/zfnjlXlq/JZgNXKbscYKvWvtPByxU9 4KW/sODkNZB/FH+ESobUaM9pmtZnr6RnJUgGa0Vb6SMCjYejOx/sQ++LkfoA+Q+fV1ch g80hGoPrZMQRyRh8rsfl6S/yM64I7wRkQCYWQkkl9zDLBXYxCvKjz5ndDwBnIxyALRXC H3KePn7sStd2zqmsbYmJ6jNs+6eOGo+65+whBFk8fNNLVpCd0nrcnXrW3KsQhTQupDt3 6j4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=txRIaWhSfzqBxD1NzIX0yspEqQ9516er1fu65kGUCoM=; b=Gx1fM248nBSLRxLGc/PMemzFcyNH9VVMnjhfe5xlabINqO2ekoCbXX7D4zlDYA12u+ B9kGxFwy5PsFwPPBaY+WgiexyYF3icWG9VWSr0hZvM5VeV6lvNCcRPQMTMjsEc3dBm1s Ge/8BwC3/zJSwKXFPmeV2VS+dHopyKuqhyyuB+SCatgKQ1vNIrgDMuPvuhS16ozyTrVn gTUqAHXy0y8m065fFcrmK4mVWJwPjDkaydRsSp0A0B8Pk6PI6l93dZpq0UArd5AOZad2 IEE9CZYnIChTFsPcBOrTFVV/fPVUyO4gzEXL4bVNM8YjVayBUIuCm3v8sFBro7itIwBR jXfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si11833094pgs.312.2019.06.17.19.23.48; Mon, 17 Jun 2019 19:24:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbfFRCXj (ORCPT + 99 others); Mon, 17 Jun 2019 22:23:39 -0400 Received: from mga05.intel.com ([192.55.52.43]:57213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfFRCXj (ORCPT ); Mon, 17 Jun 2019 22:23:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2019 19:23:37 -0700 X-ExtLoop1: 1 Received: from khuang2-desk.gar.corp.intel.com ([10.255.91.82]) by orsmga007.jf.intel.com with ESMTP; 17 Jun 2019 19:23:33 -0700 Message-ID: <1560824611.5187.100.camel@linux.intel.com> Subject: Re: [PATCH, RFC 45/62] mm: Add the encrypt_mprotect() system call for MKTME From: Kai Huang To: Andy Lutomirski Cc: Dave Hansen , "Kirill A. Shutemov" , Andrew Morton , X86 ML , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Peter Zijlstra , David Howells , Kees Cook , Jacob Pan , Alison Schofield , Linux-MM , kvm list , keyrings@vger.kernel.org, LKML , Tom Lendacky Date: Tue, 18 Jun 2019 14:23:31 +1200 In-Reply-To: References: <20190508144422.13171-1-kirill.shutemov@linux.intel.com> <20190508144422.13171-46-kirill.shutemov@linux.intel.com> <3c658cce-7b7e-7d45-59a0-e17dae986713@intel.com> <5cbfa2da-ba2e-ed91-d0e8-add67753fc12@intel.com> <1560816342.5187.63.camel@linux.intel.com> <1560821746.5187.82.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.6 (3.24.6-1.fc26) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-06-17 at 18:43 -0700, Andy Lutomirski wrote: > On Mon, Jun 17, 2019 at 6:35 PM Kai Huang wrote: > > > > > > > > > > > > > > I'm having a hard time imagining that ever working -- wouldn't it blow > > > > > up if someone did: > > > > > > > > > > fd = open("/dev/anything987"); > > > > > ptr1 = mmap(fd); > > > > > ptr2 = mmap(fd); > > > > > sys_encrypt(ptr1); > > > > > > > > > > So I think it really has to be: > > > > > fd = open("/dev/anything987"); > > > > > ioctl(fd, ENCRYPT_ME); > > > > > mmap(fd); > > > > > > > > This requires "/dev/anything987" to support ENCRYPT_ME ioctl, right? > > > > > > > > So to support NVDIMM (DAX), we need to add ENCRYPT_ME ioctl to DAX? > > > > > > Yes and yes, or we do it with layers -- see below. > > > > > > I don't see how we can credibly avoid this. If we try to do MKTME > > > behind the DAX driver's back, aren't we going to end up with cache > > > coherence problems? > > > > I am not sure whether I understand correctly but how is cache coherence problem related to > > putting > > MKTME concept to different layers? To make MKTME work with DAX/NVDIMM, I think no matter which > > layer > > MKTME concept resides, eventually we need to put keyID into PTE which maps to NVDIMM, and kernel > > needs to manage cache coherence for NVDIMM just like for normal memory showed in this series? > > > > I mean is that, to avoid cache coherence problems, something has to > prevent user code from mapping the same page with two different key > ids. If the entire MKTME mechanism purely layers on top of DAX, > something needs to prevent the underlying DAX device from being mapped > at the same time as the MKTME-decrypted view. This is obviously > doable, but it's not automatic. Assuming I am understanding the context correctly, yes from this perspective it seems having sys_encrypt is annoying, and having ENCRYPT_ME should be better. But Dave said "nobody is going to do what you suggest in the ptr1/ptr2 example"? Thanks, -Kai