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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E10F3C433E1 for ; Thu, 4 Jun 2020 15:48:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE5F1206E6 for ; Thu, 4 Jun 2020 15:48:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE5F1206E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3675880007; Thu, 4 Jun 2020 11:48:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 317428E0006; Thu, 4 Jun 2020 11:48:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 205D780007; Thu, 4 Jun 2020 11:48:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 051E28E0006 for ; Thu, 4 Jun 2020 11:48:40 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B44CA81BA10E for ; Thu, 4 Jun 2020 15:48:40 +0000 (UTC) X-FDA: 76891962000.01.pest41_68a7d7e199900 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 75BF7185728BC for ; Thu, 4 Jun 2020 15:48:40 +0000 (UTC) X-HE-Tag: pest41_68a7d7e199900 X-Filterd-Recvd-Size: 5036 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 15:48:38 +0000 (UTC) IronPort-SDR: nh7p2AG1tzz3uCH1zMknCeEsXCLF0KMOF1w/cEKxMnhpLQIww5ffzhwIKkIMNUGqQGQFCfPxaK Xet1FhylLBWw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2020 08:48:36 -0700 IronPort-SDR: czgfksgqsVm/VnDrBXeRHwEEa5jbQTP7gldiJ1egYZulRkXR9PaUheprFn3q2xd5lhLpAlflog lDqkO3C6d/Jw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,472,1583222400"; d="scan'208";a="312930509" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jun 2020 08:48:34 -0700 Date: Thu, 4 Jun 2020 08:48:35 -0700 From: Sean Christopherson To: Marc Zyngier Cc: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Rientjes , Andrea Arcangeli , Kees Cook , Will Drewry , "Edgecombe, Rick P" , "Kleen, Andi" , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , kernel-team@android.com, will@kernel.org, Jun Nakajima Subject: Re: [RFC 00/16] KVM protected memory extension Message-ID: <20200604154835.GE30223@linux.intel.com> References: <20200522125214.31348-1-kirill.shutemov@linux.intel.com> <20200604161523.39962919@why> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200604161523.39962919@why> User-Agent: Mutt/1.5.24 (2015-08-30) X-Rspamd-Queue-Id: 75BF7185728BC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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: +Jun On Thu, Jun 04, 2020 at 04:15:23PM +0100, Marc Zyngier wrote: > Hi Kirill, >=20 > Thanks for this. >=20 > On Fri, 22 May 2020 15:51:58 +0300 > "Kirill A. Shutemov" wrote: >=20 > > =3D=3D Background / Problem =3D=3D > >=20 > > There are a number of hardware features (MKTME, SEV) which protect gu= est > > memory from some unauthorized host access. The patchset proposes a pu= rely > > software feature that mitigates some of the same host-side read-only > > attacks. > >=20 > >=20 > > =3D=3D What does this set mitigate? =3D=3D > >=20 > > - Host kernel =E2=80=9Daccidental=E2=80=9D access to guest data (thi= nk speculation) > >=20 > > - Host kernel induced access to guest data (write(fd, &guest_data_pt= r, len)) > >=20 > > - Host userspace access to guest data (compromised qemu) > >=20 > > =3D=3D What does this set NOT mitigate? =3D=3D > >=20 > > - Full host kernel compromise. Kernel will just map the pages again= . > >=20 > > - Hardware attacks >=20 > Just as a heads up, we (the Android kernel team) are currently > involved in something pretty similar for KVM/arm64 in order to bring > some level of confidentiality to guests. >=20 > The main idea is to de-privilege the host kernel by wrapping it in its > own nested set of page tables which allows us to remove memory > allocated to guests on a per-page basis. The core hypervisor runs more > or less independently at its own privilege level. It still is KVM > though, as we don't intend to reinvent the wheel. >=20 > Will has written a much more lingo-heavy description here: > https://lore.kernel.org/kvmarm/20200327165935.GA8048@willie-the-truck/ Pardon my arm64 ignorance... IIUC, in this mode, the host kernel runs at EL1? And to switch to a gues= t it has to bounce through EL2, which is KVM, or at least a chunk of KVM? I assume the EL1->EL2->EL1 switch is done by trapping an exception of som= e form? If all of the above are "yes", does KVM already have the necessary logic = to perform the EL1->EL2->EL1 switches, or is that being added as part of the de-privileging effort? =20 > This works for one of the virtualization modes that arm64 can use (what > we call non-VHE, or nVHE for short). The other mode (VHE), is much more > similar to what happens on other architectures, where the kernel and > the hypervisor are one single entity. In this case, we cannot use the > same trick with nested page tables, and have to rely on something that > would very much look like what you're proposing. >=20 > Note that the two modes of the architecture would benefit from this > work anyway, as I'd like the host to know that we've pulled memory > from under its feet. Since you have done most of the initial work, I > intend to give it a go on arm64 shortly and see what sticks.