Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp646642ybe; Thu, 5 Sep 2019 03:47:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaSlO+ahnJkNLLBat1sWpypOxBPHnv37q1mjrBBUMvA+ENw1PJXiGg51pGJLnnl+e0E8TB X-Received: by 2002:a17:90a:a414:: with SMTP id y20mr3137927pjp.64.1567680441292; Thu, 05 Sep 2019 03:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567680441; cv=none; d=google.com; s=arc-20160816; b=Civ1ybNQSNGWfaOXGkisvPeyXYn1+AWfwq7BMukk1vOQLNB4rco0ZWRaEFF5ihbC6E u0p3NiXP6xEvIosKpOP9bCGL9XpBbMb2mOQ31poZgcvc/RkNrLO2Ks65mgS9ycn7ezOj nB6HNYiv60AqfWgRCPgrsYTEZUtnziRm/idTCxgiH77XbBZKMIeS7sWR7eKT5gWhMzRF 6NXtBfs/vqvqDy0gNAt0bHkrcGEFYkcTFSM4hctWtXIJCDCEosBGnKOZ+XPVQeuh+RZE +PSjU2RC4erF9j73c73FRfZ2vZlSX49eJUdy9fT5aKIt8ENycJ9haJQREcyP3IVd6ThO bUag== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=du9nGe7OBhLtXGE2CLeRd0A2Kmy5zfstPoMQ5e80EaU=; b=dqZa5y3E5iBN62tIr6tD5eMXoG//vPGLKkujHjo/9XpcmP/oiIrXeZzD45GHwn4miJ 2bHLkmzmIJd3gA6LQQN8JDhVqIJcr2r4/EPfvWYCiG6jO0M2sC7x0qzU5Bgw+PjXduot TQxS1rNNk3V1yCGEBT8LPSwWzKHu3FCdkHtgtlPb9PYfFQtKJIIRP8oZ7mI16g2wDVyd F2MT6ZXEq8GjcF4HILWeiLk/GJV1C5POEqrU4bazIG4D073UwK6BBosV0WrCYLAtIBml OfqvuSK6BMi1OoWx1p2sb2MStvv5CtpdGTtNfNnAwxLL3ec+TQdmIpOtdUXrXnBwgzKT nK+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=NZANDzDi; 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 m22si1454994pgh.190.2019.09.05.03.47.04; Thu, 05 Sep 2019 03:47:21 -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=NZANDzDi; 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 S2387682AbfIEKgF (ORCPT + 99 others); Thu, 5 Sep 2019 06:36:05 -0400 Received: from pio-pvt-msa3.bahnhof.se ([79.136.2.42]:44484 "EHLO pio-pvt-msa3.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfIEKgF (ORCPT ); Thu, 5 Sep 2019 06:36:05 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id A46E63FCA7; Thu, 5 Sep 2019 12:35:58 +0200 (CEST) Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=NZANDzDi; 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 pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wxlKR9w0komC; Thu, 5 Sep 2019 12:35:52 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id B7E7B3FC5B; Thu, 5 Sep 2019 12:35:50 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 63BC1360100; Thu, 5 Sep 2019 12:35:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1567679750; bh=du9nGe7OBhLtXGE2CLeRd0A2Kmy5zfstPoMQ5e80EaU=; h=From:To:Cc:Subject:Date:From; b=NZANDzDi7RHcjm+kvO4s6ALwfMiXRKnWZZtIJexZg3T04kSGMkNe2bKcFnqFf2Y6w k9z7BavRhHrkZ4M2lcDFsuhS0orseOZds/VaBLFU3mL5LS939m6tRG3RFFCe3nX8xy /P8/0iZHXfJwQFIJVoy3vEcxH4cewvqMaEMpxitA= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: linux-kernel@vger.kernel.org, x86@kernel.org, pv-drivers@vmware.com Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Christoph Hellwig , =?UTF-8?q?Christian=20K=C3=B6nig?= , Marek Szyprowski , Tom Lendacky Subject: [RFC PATCH 0/2] Fix SEV user-space mapping of unencrypted coherent memory Date: Thu, 5 Sep 2019 12:35:39 +0200 Message-Id: <20190905103541.4161-1-thomas_os@shipmail.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With SEV and sometimes with SME encryption, The dma api coherent memory is typically unencrypted, meaning the linear kernel map has the encryption bit cleared. However, default page protection returned from vm_get_page_prot() has the encryption bit set. So to compute the correct page protection we need to clear the encryption bit. Also, in order for the encryption bit setting to survive across do_mmap() and mprotect_fixup(), We need to make pgprot_modify() aware of it and not touch it. (Note that the encryption status is not logically encoded in the pfn but in the page protection even if an address line in the physical address is used). The patchset has seen some sanity testing by exporting dma_pgprot() and using it in the vmwgfx mmap handler with SEV enabled. Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Christoph Hellwig Cc: Christian König Cc: Marek Szyprowski Cc: Tom Lendacky