From: Ingo Molnar <mingo@kernel.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Ingo Molnar <mingo@redhat.com>,
x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@intel.com>,
Kai Huang <kai.huang@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCHv3 0/5] x86: Enumerate TME and PCONFIG, add MKTME_KEY_PROG helper
Date: Tue, 13 Feb 2018 09:53:08 +0100 [thread overview]
Message-ID: <20180213085308.vaq6d2cqu7qhxy33@gmail.com> (raw)
In-Reply-To: <20180212074809.7hk6m7y2yzf5r252@node.shutemov.name>
* Kirill A. Shutemov <kirill@shutemov.name> wrote:
> On Sun, Feb 11, 2018 at 08:02:41PM +0100, Ingo Molnar wrote:
> >
> > * Kirill A. Shutemov <kirill.shutemov@linux.intel.com> wrote:
> >
> > > Multikey Total Memory Encryption (MKTME)[1] is a technology that allows
> > > transparent memory encryption in upcoming Intel platforms.
> > >
> > > MKTME is built on top of TME. TME allows encryption of the entirety of
> > > system memory using a single key. MKTME allows to have multiple encryption
> > > domains, each having own key -- different memory pages can be encrypted
> > > with different keys.
> > >
> > > The patchset does some ground work for MKTME enabling:
> > > - Adds two new cpufeatures: TME and PCONFIG;
> > > - Detects if BIOS enabled TME and MKTME;
> > > - Enumerates what PCONFIG targets are supported;
> > > - Provides helper to program encryption keys into CPU;
> > >
> > > As part of TME enumeration we check out how many bits from physical address
> > > are claimed for encryption key ID. This may be critical as we or guest VM
> > > must not use these bits for physical address.
> >
> > So how will the 'full' patchset look like, roughly - is there a tree or diffstat
> > we could take a look at perhaps?
>
> I don't have anything to show beyond this yet. I'll post as soon I have it
> ready.
>
> This patchset includes only things that are close to hardware and unlikely
> to change substantially by the next steps.
Ok.
> > I'm also wondering how 'TME' compares to AMD's SME (Secure Memory Encryption) and
> > SEV features. SME required a number of low level boot code changes - I'm wondering
> > how much commonality there can be achieved with Intel's TME so that we don't end
> > up with two sets of interfaces.
>
> Unlike AMD SME, Intel TME doesn't really requires enabling on kernel side.
>
> It's job of BIOS to get it enabled and by time kernel has control all
> memory it has access too is encrypted with the single TME key. BIOS
> exclude some of its memory for encryption to work properly.
>
> What requires enabling is MKTME. As with TME, it gets enabled by BIOS: it
> reserves a number of upper bits from physical address to indicate KeyID.
>
> This means we don't need to change anything during early boot. MKTME is
> targeted to userspace memory: typically to protect one VM from another.
>
> Of course we can choose to use MKTME for kernel hardening and it may
> require changes during early boot, that's not part of my initial enabling
> plan.
>
> Key design points of Intel MKTME:
>
> - Initial HW implementation would support upto 63 keys (plus one default
> TME key). But the number of keys may be as low as 3, depending to SKU
> and BIOS settings
>
> - To access encrypted memory you need to use mapping with proper KeyID
> int the page table entry. KeyID is encoded in upper bits of PFN in page
> table entry.
>
> This means we cannot use direct map to access encrypted memory from
> kernel side. My idea is to re-use kmap() interface to get proper
> temporary mapping on kernel side.
>
> - CPU does not enforce coherency between mappings of the same physical
> page with different KeyIDs or encryption keys. We wound need to take
> care about flushing cache on allocation of encrypted page and on
> returning it back to free pool.
>
> - For managing keys, there's MKTME_KEY_PROGRAM leaf of the new PCONFIG
> (platform configuration) instruction. It allows load and clear keys
> associated with a KeyID. You can also ask CPU to generate a key for
> you or disable memory encryption when a KeyID is used.
>
> If you have any questions I would be glad to answer.
Ok, this sounds pretty flexible at first glance - thanks for the summary!
Ingo
prev parent reply other threads:[~2018-02-13 8:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-09 14:07 Kirill A. Shutemov
2018-02-09 14:07 ` [PATCHv3 1/5] x86/cpufeatures: Add Intel Total Memory Encryption cpufeature Kirill A. Shutemov
2018-02-09 14:07 ` [PATCHv3 2/5] x86/tme: Detect if TME and MKTME is activated by BIOS Kirill A. Shutemov
2018-02-09 14:07 ` [PATCHv3 3/5] x86/cpufeatures: Add Intel PCONFIG cpufeature Kirill A. Shutemov
2018-02-09 14:07 ` [PATCHv3 4/5] x86/pconfig: Detect PCONFIG targets Kirill A. Shutemov
2018-02-09 14:07 ` [PATCHv3 5/5] x86/pconfig: Provide defines and helper to run MKTME_KEY_PROG leaf Kirill A. Shutemov
2018-02-11 19:02 ` [PATCHv3 0/5] x86: Enumerate TME and PCONFIG, add MKTME_KEY_PROG helper Ingo Molnar
2018-02-12 7:48 ` Kirill A. Shutemov
2018-02-13 8:53 ` Ingo Molnar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180213085308.vaq6d2cqu7qhxy33@gmail.com \
--to=mingo@kernel.org \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®