Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2510050ybe; Tue, 3 Sep 2019 14:07:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7yCdDurFhWChtq2IoZA5qVqsT/ekhgMi9mayRXMBPs1nhXJhnIRYrelyWS3H7Gt+wqafX X-Received: by 2002:aa7:85cd:: with SMTP id z13mr43334533pfn.214.1567544830793; Tue, 03 Sep 2019 14:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567544830; cv=none; d=google.com; s=arc-20160816; b=QvHRq/993OL1HrxE2z5NI47C4x9DhmGurLUSAmOHqQJgktAuJKAyNAzBCwBH4Q5rOa WFM5CJyIKaPCo82XQmW2e3ksUtkRHZECeshPhtbLari/sd7GzIUsSbJyKVqDIgrYmIaP ccMfi2VgpeX1wwyamFrX1hDdfhbIj9FwkfZMSR/8JLq+kbKYF6qCLw7kNIOXdj/op1mY zUj5bkhPytoJtqO4c3s+OICoacL6/7s/TYCrhNZbIYD8QRSgJo54uDiPf8jSJI91+n+Q CTuTyrODcHVPSUNHEKSAT6Wf3R7Sb/fLH2XbETFPgREJHBmWMCVf+YcxW7iTFrfMguTC 8Utw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=EhAgceRXpCbg5J+X7ycTxi1Y6v5TrsxsYI0tCejUJJ8=; b=eakImjXBJTo3GEwi6gpbhO/NATevEBg4r78ho2m3xYsdWuuDFsiLkH0BkvXoIZcSUV o/pcbCIUjROFXJaHZOmNl/96LogOqgy9+MvCW2NwTdIK6+qbJgwmk0W5aZYhUUwqdG4K vVU//C4cElJ1taE6v5Az40Uj/AYg87I3rd68fthFatJNk+zZMiUCUWycUlk8PeWt8AlZ sGk0AC8jwihuE0e0YcNsuNiwCXcv+TZwqVN5uS1vqusoVn6akswg360zT5RPDgwxP+TI aEOO9/V4vjQuV4U1XxWQIXitYGX6lyHb5CVnbhEjeZtn8x2z/Q2wveLSBgjxuCM7A4qP L2xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=NpihaS58; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si2644209pff.107.2019.09.03.14.06.54; Tue, 03 Sep 2019 14:07:10 -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; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=NpihaS58; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbfICVFd (ORCPT + 99 others); Tue, 3 Sep 2019 17:05:33 -0400 Received: from ste-pvt-msa1.bahnhof.se ([213.80.101.70]:57979 "EHLO ste-pvt-msa1.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfICVFd (ORCPT ); Tue, 3 Sep 2019 17:05:33 -0400 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 30F0C3F3EF; Tue, 3 Sep 2019 23:05:31 +0200 (CEST) Authentication-Results: ste-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=NpihaS58; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XIBw9yZbCl08; Tue, 3 Sep 2019 23:05:30 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 350063F333; Tue, 3 Sep 2019 23:05:26 +0200 (CEST) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 6380C360160; Tue, 3 Sep 2019 23:05:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1567544726; bh=/li7YegAhw6RYebLGGt/o3WJvHeG1ytUqRCNCZ9yHwo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=NpihaS584vAezzYGEJFzcCqhRmOPFt5+xrYeQK5B9B2tNMdEtQQufvDy2twLS8/Lr +V1hvYJ9E3E+XhWlmlOQ8pnECLnM3I0Js1Zpog+5Cv/TNXfjxsNpvQLHiloHigHe8c RCbL+v7L5SnK7SFv5+0MrTxSTs78rki5TArr4mNM= Subject: Re: [PATCH v2 3/4] drm/ttm, drm/vmwgfx: Correctly support support AMD memory encryption To: Dave Hansen , Daniel Vetter Cc: dri-devel , pv-drivers@vmware.com, VMware Graphics , Linux Kernel Mailing List , Tom Lendacky , Thomas Hellstrom , Peter Zijlstra , Dave Hansen , Heiko Carstens , Christian Borntraeger , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Thomas Gleixner , =?UTF-8?Q?Christian_K=c3=b6nig?= References: <20190903131504.18935-1-thomas_os@shipmail.org> <20190903131504.18935-4-thomas_os@shipmail.org> <6d0fafcc-b596-481b-7b22-1f26f0c02c5c@intel.com> <7fa3b178-b9b4-2df9-1eee-54e24d48342e@intel.com> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= Organization: VMware Inc. Message-ID: Date: Tue, 3 Sep 2019 23:05:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <7fa3b178-b9b4-2df9-1eee-54e24d48342e@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/3/19 10:51 PM, Dave Hansen wrote: > On 9/3/19 1:36 PM, Thomas Hellström (VMware) wrote: >> So the question here should really be, can we determine already at mmap >> time whether backing memory will be unencrypted and adjust the *real* >> vma->vm_page_prot under the mmap_sem? >> >> Possibly, but that requires populating the buffer with memory at mmap >> time rather than at first fault time. > I'm not connecting the dots. > > vma->vm_page_prot is used to create a VMA's PTEs regardless of if they > are created at mmap() or fault time. If we establish a good > vma->vm_page_prot, can't we just use it forever for demand faults? With SEV I think that we could possibly establish the encryption flags at vma creation time. But thinking of it, it would actually break with SME where buffer content can be moved between encrypted system memory and unencrypted graphics card PCI memory behind user-space's back. That would imply killing all user-space encrypted PTEs and at fault time set up new ones pointing to unencrypted PCI memory.. > > Or, are you concerned that if an attempt is made to demand-fault page > that's incompatible with vma->vm_page_prot that we have to SEGV? > >> And it still requires knowledge whether the device DMA is always >> unencrypted (or if SEV is active). > I may be getting mixed up on MKTME (the Intel memory encryption) and > SEV. Is SEV supported on all memory types? Page cache, hugetlbfs, > anonymous? Or just anonymous? SEV AFAIK encrypts *all* memory except DMA memory. To do that it uses a SWIOTLB backed by unencrypted memory, and it also flips coherent DMA memory to unencrypted (which is a very slow operation and patch 4 deals with caching such memory). /Thomas