Re: [intel-sgx-kernel-dev] [PATCH v5 06/11] intel_sgx: driver for Intel Software Guard Extensions

2017-11-15 Thread Sean Christopherson
On Tue, 2017-11-14 at 22:28 +0200, Jarkko Sakkinen wrote: > On Tue, Nov 14, 2017 at 09:55:06AM -0800, Sean Christopherson wrote: > > > > What do you mean by bottlenecks?  Assuming you're referring to performance > > bottlenecks, this statement is flat out false.  Movi

Re: [PATCH v5 11/11] intel_sgx: driver documentation

2017-11-27 Thread Sean Christopherson
On Tue, 2017-11-21 at 01:08 +0200, Jarkko Sakkinen wrote: > On Sat, Nov 18, 2017 at 12:34:33AM +0100, Thomas Gleixner wrote: > > > > This is architecural. From the cursory read of that series it seems there > > are two parts to it: > > > >   1) The actual core handling, which should be in

Re: [PATCH v5 11/11] intel_sgx: driver documentation

2017-11-27 Thread Sean Christopherson
+ Cc: KVM, Paolo and Radim On Mon, 2017-11-27 at 09:03 -0800, Sean Christopherson wrote: > On Tue, 2017-11-21 at 01:08 +0200, Jarkko Sakkinen wrote: > > > > On Sat, Nov 18, 2017 at 12:34:33AM +0100, Thomas Gleixner wrote: > > > > > > > > > T

Re: [PATCH v6 03/11] x86: define IA32_FEATURE_CONTROL.SGX_ENABLE

2017-11-28 Thread Sean Christopherson
On Sat, 2017-11-25 at 21:29 +0200, Jarkko Sakkinen wrote: > From: Sean Christopherson <sean.j.christopher...@intel.com> > > When IA32_FEATURE_CONTROL.SGX_ENABLE and IA32_FEATURE_CONTROL.LOCK are > set by the pre-boot firmware, SGX is usable by the OS. This implies that only pre

Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-28 Thread Sean Christopherson
On Tue, 2017-11-28 at 09:16 -0800, Sean Christopherson wrote: > On Sat, 2017-11-25 at 21:29 +0200, Jarkko Sakkinen wrote: > > > > When IA32_FEATURE_CONTROL.SGX_LC identifies that the root key for > > enclave signatures can be configured either by the OS or

Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-28 Thread Sean Christopherson
On Sat, 2017-11-25 at 21:29 +0200, Jarkko Sakkinen wrote: > When IA32_FEATURE_CONTROL.SGX_LC identifies that the root key for > enclave signatures can be configured either by the OS or pre-boot > firmware. > > If this the case, IA32_SGXLEPUBKEYHASHn MSRs (0 < n < 4) can be used > to > set the

Re: [PATCH v6 05/11] x86: add SGX MSRs to msr-index.h

2017-11-28 Thread Sean Christopherson
On Sat, 2017-11-25 at 21:29 +0200, Jarkko Sakkinen wrote: > From: Haim Cohen > > These MSRs hold the SHA256 checksum of the currently configured root > key for enclave signatures. The commit message doesn't talk about the launch control bit in the feature control MSR. >

Re: [PATCH v6 06/11] intel_sgx: driver for Intel Software Guard Extensions

2017-11-28 Thread Sean Christopherson
> diff --git a/arch/x86/include/asm/sgx_arch.h b/arch/x86/include/asm/sgx_arch.h > new file mode 100644 > index ..515676031006 > --- /dev/null > +++ b/arch/x86/include/asm/sgx_arch.h > @@ -0,0 +1,268 @@ [...] > + > +#ifndef _ASM_X86_SGX_ARCH_H > +#define _ASM_X86_SGX_ARCH_H Still

Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-28 Thread Sean Christopherson
On Tue, 2017-11-28 at 23:24 +0200, Jarkko Sakkinen wrote: > On Tue, Nov 28, 2017 at 10:53:24PM +0200, Jarkko Sakkinen wrote: > > > > > > > > So, maybe something like this? > > > > > >     After SGX is activated[1] the IA32_SGXLEPUBKEYHASHn MSRs are writable > > >     if and only if SGX_LC is

Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-28 Thread Sean Christopherson
On Tue, 2017-11-28 at 23:55 +0200, Jarkko Sakkinen wrote: > On Tue, Nov 28, 2017 at 01:33:14PM -0800, Sean Christopherson wrote: > > > > On Tue, 2017-11-28 at 23:24 +0200, Jarkko Sakkinen wrote: > > > > > > On Tue, Nov 28, 2017 at 10:53:

Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-28 Thread Sean Christopherson
On Tue, 2017-11-28 at 23:40 +0200, Jarkko Sakkinen wrote: > On Tue, Nov 28, 2017 at 11:24:07PM +0200, Jarkko Sakkinen wrote: > > > > On Tue, Nov 28, 2017 at 10:53:24PM +0200, Jarkko Sakkinen wrote: > > > > > > > > > > > So, maybe something like this? > > > > > > > >     After SGX is

Re: [PATCH v6 06/11] intel_sgx: driver for Intel Software Guard Extensions

2017-11-30 Thread Sean Christopherson
On Sat, Nov 25, 2017 at 09:29:24PM +0200, Jarkko Sakkinen wrote: > +static void *sgx_try_alloc_page(void) > +{ > + struct sgx_epc_bank *bank; > + void *page = NULL; > + int i; > + > + for (i = 0; i < sgx_nr_epc_banks; i++) { > + bank = _epc_banks[i]; > + > +

Re: [intel-sgx-kernel-dev] [PATCH v7 4/8] intel_sgx: driver for Intel Software Guard Extensions

2017-12-12 Thread Sean Christopherson
On Thu, 2017-12-07 at 18:05 +0200, Jarkko Sakkinen wrote: > On Thu, Dec 07, 2017 at 02:46:39PM +, Christopherson, Sean J wrote: > > > > > > > > + for (i = 0; i < 2; i++) { > > > + va_page = list_first_entry(>va_pages, > > > +    struct sgx_va_page,

Re: [intel-sgx-kernel-dev] [PATCH v7 4/8] intel_sgx: driver for Intel Software Guard Extensions

2017-12-12 Thread Sean Christopherson
On Fri, 2017-12-08 at 07:31 -0800, Christopherson, Sean J wrote: > Jarkko Sakkinen wrote: > > On Thu, Dec 07, 2017 at 02:46:39PM +, Christopherson, Sean J wrote: > > > > + for (i = 0; i < 2; i++) { > > > > + va_page = list_first_entry(>va_pages, > > >

Re: [intel-sgx-kernel-dev] [PATCH v5 08/11] intel_sgx: in-kernel launch enclave

2017-11-14 Thread Sean Christopherson
On Mon, 2017-11-13 at 21:45 +0200, Jarkko Sakkinen wrote: > This commits implements the in-kernel launch enclave. It is wrapped into > a user space program that reads SIGSTRUCT instances from stdin and > outputs launch tokens to stdout. > > The commit also adds enclave signing tool that is used

Re: [intel-sgx-kernel-dev] [PATCH v5 06/11] intel_sgx: driver for Intel Software Guard Extensions

2017-11-14 Thread Sean Christopherson
On Mon, 2017-11-13 at 21:45 +0200, Jarkko Sakkinen wrote: > Intel SGX is a set of CPU instructions that can be used by applications > to set aside private regions of code and data.  The code outside the > enclave is disallowed to access the memory inside the enclave by the CPU > access control. >

Re: [intel-sgx-kernel-dev] [PATCH v5 10/11] intel_sgx: glue code for in-kernel LE

2017-11-14 Thread Sean Christopherson
On Mon, 2017-11-13 at 21:45 +0200, Jarkko Sakkinen wrote: > --- a/drivers/platform/x86/intel_sgx/sgx_main.c > +++ b/drivers/platform/x86/intel_sgx/sgx_main.c > @@ -88,6 +88,37 @@ u64 sgx_encl_size_max_64; >  u64 sgx_xfrm_mask = 0x3; >  u32 sgx_misc_reserved; >  u32 sgx_xsave_size_tbl[64]; > +bool

Re: [PATCH v11 11/13] intel_sgx: ptrace() support

2018-06-11 Thread Sean Christopherson
On Fri, 2018-06-08 at 11:34 -0700, Dave Hansen wrote: > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > > + ret = sgx_edbgrd(encl, entry, align, data); > > + if (ret) > > + break; > > + if (write) { > > + memcpy(data + offset,

Re: [intel-sgx-kernel-dev] [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-11 Thread Sean Christopherson
On Sat, 2018-06-09 at 22:32 -0700, Andy Lutomirski wrote: > On Fri, Jun 8, 2018 at 10:22 AM Jarkko Sakkinen > wrote: > > > > > > SGX has a set of data structures to maintain information about the enclaves > > and their security properties. BIOS reserves a fixed size region of > > physical

Re: [PATCH v11 06/13] crypto: aesni: add minimal build option for SGX LE

2018-06-11 Thread Sean Christopherson
On Fri, 2018-06-08 at 10:27 -0700, Dave Hansen wrote: > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > > --- a/arch/x86/crypto/aesni-intel_asm.S > > +++ b/arch/x86/crypto/aesni-intel_asm.S > > @@ -45,6 +45,8 @@ > >  #define MOVADQ movaps > >  #define MOVUDQ movups > >   > > +#ifndef

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Sean Christopherson
On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > +static __init bool sgx_is_enabled(bool *lc_enabled) > > > { > > > unsigned long fc; > > > > > > @@ -41,12

Re: [intel-sgx-kernel-dev] [PATCH v11 13/13] intel_sgx: in-kernel launch enclave

2018-06-25 Thread Sean Christopherson
On Mon, Jun 25, 2018 at 05:00:05PM -0400, Nathaniel McCallum wrote: > On Thu, Jun 21, 2018 at 5:21 PM Sean Christopherson > wrote: > > > > On Thu, Jun 21, 2018 at 03:11:18PM -0400, Nathaniel McCallum wrote: > > > If this is acceptable for everyone, my hope is the foll

Re: [intel-sgx-kernel-dev] [PATCH v11 13/13] intel_sgx: in-kernel launch enclave

2018-06-20 Thread Sean Christopherson
On Wed, Jun 20, 2018 at 11:39:00AM -0700, Jethro Beekman wrote: > On 2018-06-20 11:16, Jethro Beekman wrote: > > > This last bit is also repeated in different words in Table 35-2 and > > > Section 42.2.2. The MSRs are *not writable* before the write-lock bit > > > itself is locked. Meaning the

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [PATCH v11 08/13] x86, sgx: added ENCLS wrappers

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > This commit adds wrappers for Intel(R) SGX ENCLS opcode functionality. > > Signed-off-by: Jarkko Sakkinen > --- >  arch/x86/include/asm/sgx.h | 198 + >  1 file changed, 198 insertions(+) > > diff

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [intel-sgx-kernel-dev] [PATCH v11 13/13] intel_sgx: in-kernel launch enclave

2018-06-21 Thread Sean Christopherson
lly maximize both security and freedom. > > [0]: details here - > https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/README#n19 > On Thu, Jun 21, 2018 at 11:29 AM Neil Horman wrote: > > > > On Thu, Jun 21, 2018 at 08:32:25AM -0400,

[PATCH] x86/pkeys: Explicitly treat PK #PF on kernel address as a bad area

2018-08-07 Thread Sean Christopherson
of the kernel's TLB flushing behavior. [1] http://lists-archives.com/linux-kernel/28407455-x86-pkeys-new-page-fault-error-code-bit-pf_pk.html Signed-off-by: Sean Christopherson Cc: Dave Hansen --- There's no indication that this condition has ever been encountered. I came across the code

[PATCH] x86/speculation/l1tf: Exempt zeroed PTEs from XOR conversion

2018-08-16 Thread Sean Christopherson
() is trying to adjust a high MMIO address. Fixes: 6b28baca9b1f ("x86/speculation/l1tf: Protect PROT_NONE PTEs against speculation") Signed-off-by: Sean Christopherson Cc: Andi Kleen Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: Michal Hocko Cc: Vlastimil Babka Cc: Dave Hansen Cc: Greg Kro

[PATCH 1/2] KVM: vmx: Add defines for SGX ENCLS exiting

2018-08-14 Thread Sean Christopherson
asons"). Signed-off-by: Sean Christopherson --- arch/x86/include/asm/vmx.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 6aa8499e1f62..2665c10ece4c 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.

Re: [PATCH] x86/speculation/l1tf: Exempt zeroed PTEs from XOR conversion

2018-08-17 Thread Sean Christopherson
On Fri, Aug 17, 2018 at 09:13:51AM -0700, Linus Torvalds wrote: > On Thu, Aug 16, 2018 at 1:47 PM Sean Christopherson > wrote: > > > > Fixes: 6b28baca9b1f ("x86/speculation/l1tf: Protect PROT_NONE PTEs against > > speculation") > > This seems wrong. &

Re: SEV guest regression in 4.18

2018-08-23 Thread Sean Christopherson
On Thu, Aug 23, 2018 at 01:26:55PM +0200, Paolo Bonzini wrote: > On 22/08/2018 22:11, Brijesh Singh wrote: > > > > Yes, this is one of approach I have in mind. It will avoid splitting > > the larger pages; I am thinking that early in boot code we can lookup > > for this special section and

Re: SEV guest regression in 4.18

2018-08-24 Thread Sean Christopherson
On Fri, Aug 24, 2018 at 10:41:27AM -0500, Brijesh Singh wrote: > > > On 08/23/2018 11:16 AM, Paolo Bonzini wrote: > >On 23/08/2018 17:29, Sean Christopherson wrote: > >>On Thu, Aug 23, 2018 at 01:26:55PM +0200, Paolo Bonzini wrote: > >>>On 22/08/2018 22:11, B

Re: [PATCH v13 09/13] x86/sgx: Enclave Page Cache (EPC) memory manager

2018-08-28 Thread Sean Christopherson
On Tue, Aug 28, 2018 at 02:26:36PM -0700, Dave Hansen wrote: > On 08/28/2018 02:22 PM, Sean Christopherson wrote: > > On Tue, Aug 28, 2018 at 07:07:33AM -0700, Dave Hansen wrote: > >> On 08/28/2018 01:35 AM, Jarkko Sakkinen wrote: > >>> On Mon, Aug 27, 2018 at 02:15

Re: [PATCH v13 07/13] x86/sgx: Add data structures for tracking the EPC pages

2018-08-28 Thread Sean Christopherson
On Tue, Aug 28, 2018 at 09:53:11AM -0700, Dave Hansen wrote: > >>> + sgx_nr_epc_banks++; > >>> + } > >>> + > >>> + if (!sgx_nr_epc_banks) { > >>> + pr_err("There are zero EPC banks.\n"); > >>> + return -ENODEV; > >>> + } > >>> + > >>> + return 0; > >>> +} > >> > >> Does

Re: [PATCH v13 09/13] x86/sgx: Enclave Page Cache (EPC) memory manager

2018-08-28 Thread Sean Christopherson
On Tue, Aug 28, 2018 at 07:07:33AM -0700, Dave Hansen wrote: > On 08/28/2018 01:35 AM, Jarkko Sakkinen wrote: > > On Mon, Aug 27, 2018 at 02:15:34PM -0700, Dave Hansen wrote: > >> On 08/27/2018 11:53 AM, Jarkko Sakkinen wrote: > >>> +struct sgx_epc_page_ops { > >>> + bool (*get)(struct

Re: SEV guest regression in 4.18

2018-08-22 Thread Sean Christopherson
On Wed, Aug 22, 2018 at 10:14:17AM +0200, Borislav Petkov wrote: > Dropping Pavel as it bounces. > > On Tue, Aug 21, 2018 at 11:07:38AM -0500, Brijesh Singh wrote: > > The tsc_early_init() is called before setup_arch() -> init_mem_mapping. > > Ok, I see it, thanks for explaining. > > So back to

Re: [PATCH v2 2/3] x86/mm: add .data..decrypted section to hold shared variables

2018-08-29 Thread Sean Christopherson
On Tue, Aug 28, 2018 at 05:12:56PM -0500, Brijesh Singh wrote: > kvmclock defines few static variables which are shared with hypervisor > during the kvmclock initialization. > > When SEV is active, memory is encrypted with a guest-specific key, and > if guest OS wants to share the memory region

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-31 Thread Sean Christopherson
On Fri, Aug 31, 2018 at 03:17:03PM +0300, Jarkko Sakkinen wrote: > On Wed, Aug 29, 2018 at 07:33:54AM +, Huang, Kai wrote: > > [snip..] > > > > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > > >

Re: [RFC][PATCH 5/5] [PATCH 5/5] kvm-ept-idle: enable module

2018-09-04 Thread Sean Christopherson
On Sat, Sep 01, 2018 at 07:28:23PM +0800, Fengguang Wu wrote: > Signed-off-by: Fengguang Wu > --- > arch/x86/kvm/Kconfig | 11 +++ > arch/x86/kvm/Makefile | 4 > 2 files changed, 15 insertions(+) > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Sean Christopherson
On Tue, Sep 04, 2018 at 06:30:21PM +0300, Jarkko Sakkinen wrote: > On Tue, Sep 04, 2018 at 07:54:51AM -0700, Sean Christopherson wrote: > > I don't see any value in trying to rule out specific causes of > > INVALID_TOKEN, but we should only retry EINIT if ret==INVALID_TOKEN >

Re: [PATCH v13 07/13] x86/sgx: Add data structures for tracking the EPC pages

2018-09-04 Thread Sean Christopherson
On Mon, Sep 03, 2018 at 05:41:53PM +0300, Andy Shevchenko wrote: > On Mon, Aug 27, 2018 at 9:58 PM Jarkko Sakkinen > wrote: > > > + va = ioremap_cache(addr, size); > > + if (!va) > > + return -ENOMEM; > > I'm not sure this is a right API. Do we operate with memory?

Re: [PATCH v13 07/13] x86/sgx: Add data structures for tracking the EPC pages

2018-09-04 Thread Sean Christopherson
On Tue, Sep 04, 2018 at 09:01:15PM +0300, Andy Shevchenko wrote: > On Tue, Sep 4, 2018 a> +/** > > > > > + va = ioremap_cache(addr, size); > > > > + if (!va) > > > > + return -ENOMEM; > > > > > > I'm not sure this is a right API. Do we operate with memory? Does it > > >

Re: [RFC][PATCH 2/5] [PATCH 2/5] proc: introduce /proc/PID/idle_bitmap

2018-09-04 Thread Sean Christopherson
On Sat, Sep 01, 2018 at 07:28:20PM +0800, Fengguang Wu wrote: > diff --git a/fs/proc/internal.h b/fs/proc/internal.h > index da3dbfa09e79..732a502acc27 100644 > --- a/fs/proc/internal.h > +++ b/fs/proc/internal.h > @@ -305,6 +305,7 @@ extern const struct file_operations >

Re: [PATCH] x86/pkeys: Explicitly treat PK #PF on kernel address as a bad area

2018-09-04 Thread Sean Christopherson
Cc-ing Jann and Andy. On Tue, Aug 07, 2018 at 10:29:20AM -0700, Sean Christopherson wrote: > Kernel addresses are always mapped with _PAGE_USER=0, i.e. PKRU > isn't enforced, and so we should never see X86_PF_PK set on a > kernel address fault. WARN once to capture the issue in case we

Re: [PATCH v4 4/4] x86/kvm: use __decrypted attribute in shared variables

2018-09-04 Thread Sean Christopherson
ingh > Reviewed-by: Tom Lendacky > Fixes: 368a540e0232 ("x86/kvmclock: Remove memblock dependency") > Cc: Tom Lendacky > Cc: k...@vger.kernel.org > Cc: Thomas Gleixner > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: linux-kernel@vger.kernel.org &

Re: [PATCH v13 11/13] platform/x86: Intel SGX driver

2018-09-07 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 05:50:01PM -0700, Joe Perches wrote: > On Thu, 2018-09-06 at 19:35 +0200, Miguel Ojeda wrote: > > > Which one is right and why the kernel tree is polluted with C99-headers > > > when they do not pass checkpatch.pl? > > checkpatch ignores c99 headers since 2016. Jarkko was

Re: [PATCH v13 09/13] x86/sgx: Enclave Page Cache (EPC) memory manager

2018-09-04 Thread Sean Christopherson
On Tue, Sep 04, 2018 at 06:38:03PM +0300, Jarkko Sakkinen wrote: > On Mon, Sep 03, 2018 at 10:02:16PM +0300, Andy Shevchenko wrote: > > On Mon, Aug 27, 2018 at 9:58 PM Jarkko Sakkinen > > wrote: > > > > > > + WARN(ret < 0, "sgx: cannot free page, reclaim in-progress"); > > > +

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Sean Christopherson
t; mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > > > Subject: Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing > > enclaves > > > > On Fri, Aug 31, 2018 at 11:15:09AM -0700, Sean Christopherson wrote: > > > On Fri, Aug 31, 2018 at 03:17:03

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
pted_mem(). > > Signed-off-by: Brijesh Singh > Suggested-by: Sean Christopherson > Cc: Tom Lendacky > Cc: k...@vger.kernel.org > Cc: Thomas Gleixner > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: linux-kernel@vger.kernel.org > Cc: Paolo Bonzini > Cc:

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
ped with C=0 during the boot. > > > > In non-SEV case, this static page will unused and free'd by the > > free_decrypted_mem(). > > > > Signed-off-by: Brijesh Singh > > Suggested-by: Sean Christopherson > > Cc: Tom Lendacky > > Cc: k...@vger.kernel.org

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 06:50:41AM -0700, Sean Christopherson wrote: > On Thu, Sep 06, 2018 at 02:24:23PM +0200, Borislav Petkov wrote: > > On Thu, Sep 06, 2018 at 06:43:02AM -0500, Brijesh Singh wrote: > > > Currently, the per-cpu pvclock data is allocated dynamica

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 04:43:42PM +0200, Borislav Petkov wrote: > On Thu, Sep 06, 2018 at 06:50:41AM -0700, Sean Christopherson wrote: > > That would prevent adding __decrypted to existing declarations, e.g. > > hv_clock_boot, which would be ugly in its own right. A more gener

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 05:19:38PM +0200, Borislav Petkov wrote: > On Thu, Sep 06, 2018 at 07:56:40AM -0700, Sean Christopherson wrote: > > Wouldn't that result in @hv_clock_boot being incorrectly freed in the > > !SEV case? > > Ok, maybe I'm missing something but why do we

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 03:20:46PM -0500, Brijesh Singh wrote: > > > On 09/06/2018 02:47 PM, Sean Christopherson wrote: > ... > > >> > >>Yes, the auxiliary array will dumped into the regular .bss when > >>CONFIG_AMD_MEM_ENCRYPT=n. Typically it wil

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 02:24:32PM -0500, Brijesh Singh wrote: > > > On 09/06/2018 01:47 PM, Sean Christopherson wrote: > >On Thu, Sep 06, 2018 at 01:37:50PM -0500, Brijesh Singh wrote: > >> > >> > >>On 09/06/2018 09:18 AM, Sean Christopherson wrote: &g

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 01:37:50PM -0500, Brijesh Singh wrote: > > > On 09/06/2018 09:18 AM, Sean Christopherson wrote: > > > >>> > >>>So are we going to be defining a decrypted section for every piece of > >>>machinery now? > >>&

Re: [PATCH v5 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-06 Thread Sean Christopherson
On Thu, Sep 06, 2018 at 08:33:34PM +0200, Borislav Petkov wrote: > On Thu, Sep 06, 2018 at 08:54:52AM -0700, Sean Christopherson wrote: > > My thought was that we could simply define a second array for the SEV > > case to statically allocate for NR_CPUS since __decrypted has

Re: [PATCH v6 4/5] x86/kvm: use __decrypted attribute in shared variables

2018-09-10 Thread Sean Christopherson
On Mon, 2018-09-10 at 14:04 +0200, Borislav Petkov wrote: > On Fri, Sep 07, 2018 at 12:57:29PM -0500, Brijesh Singh wrote: > > > > Commit: 368a540e0232 (x86/kvmclock: Remove memblock dependency) > > caused SEV guest regression. > When mentioning a commit in the commit message, put it on a

Re: [PATCH v6 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-10 Thread Sean Christopherson
On Mon, 2018-09-10 at 08:15 -0500, Brijesh Singh wrote: > > On 9/10/18 7:27 AM, Borislav Petkov wrote: > > > > On Fri, Sep 07, 2018 at 12:57:30PM -0500, Brijesh Singh wrote: > > > > > > diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > > > index 376fd3a..6086b56 100644 > >

Re: [PATCH v6 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-10 Thread Sean Christopherson
On Mon, 2018-09-10 at 17:53 +0200, Borislav Petkov wrote: > On Mon, Sep 10, 2018 at 08:15:38AM -0500, Brijesh Singh wrote: > > > > > > > > Now, the real question from all this SNAFU is, why can't all those point > > > to a single struct pvclock_vsyscall_time_info and all CPUs read a single > > >

Re: [PATCH 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-10 Thread Sean Christopherson
On Mon, 2018-09-10 at 08:38 +, Tianyu Lan wrote: > Add flush range call back in the kvm_x86_ops and platform can use it > to register its associated function. The parameter "kvm_tlb_range" > accepts a single range and flush list which contains a list of ranges. > > Signed-off-by: Lan Tianyu

Re: [PATCH v6 5/5] x86/kvm: Avoid dynamic allocation of pvclock data when SEV is active

2018-09-10 Thread Sean Christopherson
On Mon, 2018-09-10 at 10:10 -0500, Brijesh Singh wrote: > > On 09/10/2018 08:29 AM, Sean Christopherson wrote: > ... > > > > > > + */ > > > > > +static struct pvclock_vsyscall_time_info > > > > > + hv_clock_aux[NR_CPUS]

Re: [RFC][PATCH 5/8] x86/mm: fix exception table comments

2018-09-10 Thread Sean Christopherson
On Fri, 2018-09-07 at 14:51 -0700, Dave Hansen wrote: > > > > > > > > +  * Only do the expensive exception table search when we might be at > > > +  * risk of a deadlock: > > > +  * 1. We failed to acquire mmap_sem, and > > > +  * 2. The access was an explicit kernel-mode access > > > +  *

Re: [RFC PATCH 1/6] x86/alternative: assert text_mutex is taken

2018-08-29 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 07:36:22PM +, Nadav Amit wrote: > at 10:11 AM, Nadav Amit wrote: > > > at 1:59 AM, Masami Hiramatsu wrote: > > > >> On Wed, 29 Aug 2018 01:11:42 -0700 > >> Nadav Amit wrote: > >> > >>> Use lockdep to ensure that text_mutex is taken when text_poke() is > >>>

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 12:33:54AM -0700, Huang, Kai wrote: > [snip..] > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > > static struct task_struct *ksgxswapd_tsk; static > > > >

Re: [RFC PATCH 1/6] x86/alternative: assert text_mutex is taken

2018-08-29 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 08:44:47PM +, Nadav Amit wrote: > at 1:13 PM, Sean Christopherson wrote: > > > On Wed, Aug 29, 2018 at 07:36:22PM +, Nadav Amit wrote: > >> at 10:11 AM, Nadav Amit wrote: > >> > >>> at 1:59 AM, Masami Hiramatsu wrote:

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 01:58:09PM -0700, Huang, Kai wrote: > > -Original Message- > > From: Christopherson, Sean J > > Sent: Thursday, August 30, 2018 8:34 AM > > To: Huang, Kai > > Cc: Jarkko Sakkinen ; platform-driver- > > x...@vger.kernel.org; x...@kernel.org; nhor...@redhat.com;

Re: [PATCH v3 4/4] x86/kvm: use __decrypted attribute in shared variables

2018-08-29 Thread Sean Christopherson
ency") > Cc: Tom Lendacky > Cc: k...@vger.kernel.org > Cc: Thomas Gleixner > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: linux-kernel@vger.kernel.org > Cc: Paolo Bonzini > Cc: Sean Christopherson > Cc: k...@vger.kernel.org > Cc: "Radim Krč

Re: [RFC][PATCH 5/8] x86/mm: fix exception table comments

2018-09-07 Thread Sean Christopherson
mments, and make them more precise. > > Also add a comment explaining why we are doing the > bad_area_nosemaphore() path here. > > Signed-off-by: Dave Hansen > Cc: Sean Christopherson > Cc: "Peter Zijlstra (Intel)" > Cc: Thomas Gleixner > Cc: x...@kernel.or

Re: [RFC][PATCH 2/8] x86/mm: break out kernel address space handling

2018-09-07 Thread Sean Christopherson
On Fri, 2018-09-07 at 12:48 -0700, Dave Hansen wrote: > From: Dave Hansen > > The page fault handler (__do_page_fault())  basically has two sections: > one for handling faults in the kernel porttion of the address space > and another for faults in the user porttion of the address space.

Re: [PATCH] x86/kvm/vmx: don't read current->thread.{fs,gs}base of legacy tasks

2018-07-13 Thread Sean Christopherson
On Wed, Jul 11, 2018 at 07:37:18PM +0200, Vitaly Kuznetsov wrote: > When we switched from doing rdmsr() to reading FS/GS base values from > current->thread we completely forgot about legacy 32-bit userspaces which > we still support in KVM (why?). task->thread.{fsbase,gsbase} are only > synced for

Re: [PATCH v13 09/13] x86/sgx: Enclave Page Cache (EPC) memory manager

2018-09-11 Thread Sean Christopherson
executing these operations usually (if not > always) requires to do some subsystem-internal locking operations. > > Signed-off-by: Jarkko Sakkinen > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > --- >  arch/x86/include/asm/sgx.h  |  56

Re: [PATCH] X86/KVM: Do not allow DISABLE_EXITS_MWAIT when LAPIC ARAT is not available

2018-04-11 Thread Sean Christopherson
On Wed, 2018-04-11 at 11:16 +0200, KarimAllah Ahmed wrote: > If the processor does not have an "Always Running APIC Timer" (aka ARAT), > we should not give guests direct access to MWAIT. The LAPIC timer would > stop ticking in deep C-states, so any host deadlines would not wakeup the > host

Re: [PATCH 06/10] KVM/nVMX: Use kvm_vcpu_map when mapping the virtual APIC page

2018-04-12 Thread Sean Christopherson
On Thu, Apr 12, 2018 at 04:38:39PM +0200, Paolo Bonzini wrote: > On 21/02/2018 18:47, KarimAllah Ahmed wrote: > > + > > + if (kvm_vcpu_map(vcpu, > > gpa_to_gfn(vmcs12->virtual_apic_page_addr), map)) > > + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, > > gfn_to_gpa(map->pfn));

Re: [PATCH v3 4/9] x86/kvm/mmu: introduce guest_mmu

2018-10-05 Thread Sean Christopherson
;L1->L2 vmexit > goes from 42k to 26k cycles. > > Signed-off-by: Vitaly Kuznetsov One nit below, otherwise: Reviewed-by: Sean Christopherson > --- > Changes since v2: > - move kvm_mmu_free_roots() call to nested_release_vmcs12(). > [Sean Christopherson] > - in kvm

Re: [PATCH v3 7/9] x86/kvm/nVMX: introduce source data cache for kvm_init_shadow_ept_mmu()

2018-10-05 Thread Sean Christopherson
> > Signed-off-by: Vitaly Kuznetsov Nit below, otherwise: Reviewed-by: Sean Christopherson > --- > Changes since v2: > - Preserve mmu_role.base in kvm_calc_shadow_ept_root_page_role() > [Sean Christopherson] > - Rename kvm_calc_mmu_role_common() -> kvm_calc_mmu_role_ext() t

Re: [PATCH v3 8/9] x86/kvm/mmu: check if tdp/shadow MMU reconfiguration is needed

2018-10-05 Thread Sean Christopherson
mmon code in > kvm_calc_mmu_role_common(). > > Signed-off-by: Vitaly Kuznetsov Same comments about kvm_read_cr4_bits(), otherwise: Reviewed-by: Sean Christopherson > --- > Changes since v2: > - Rename 'mmu_init' parameter to 'base_only' [Sean Christopherson] > --- > arch/x86/incl

Re: [PATCH] KVM/nVMX: Do not validate that posted_intr_desc_addr is page aligned

2018-10-24 Thread Sean Christopherson
return -EINVAL; Can you update the comment for this code block? It has a stale blurb about "the descriptor address has been already checked in nested_get_vmcs12_pages" and it'd be nice to state why bits[5:0] must be zero (your changelog is much more helpful than the current comment). With that: Reviewed-by: Sean Christopherson > > /* tpr shadow is needed by all apicv features. */ > -- > 2.7.4 >

Re: [PATCH 2/4] kvm, vmx: move register clearing out of assembly path

2018-10-26 Thread Sean Christopherson
On Wed, Oct 24, 2018 at 10:28:57AM +0200, Julian Stecklina wrote: > Split the security related register clearing out of the large inline > assembly VM entry path. This results in two slightly less complicated > inline assembly statements, where it is clearer what each one does. > > Signed-off-by:

Re: [PATCH v14 09/19] x86/mm: x86/sgx: Signal SEGV_SGXERR for #PFs w/ PF_SGX

2018-10-31 Thread Sean Christopherson
On Mon, Oct 01, 2018 at 03:03:30PM -0700, Dave Hansen wrote: > On 10/01/2018 02:42 PM, Jethro Beekman wrote: > > > > 1) Even though the vDSO function exists, userspace may still call > > `ENCLU[EENTER]` manually, so the fault handling as described in the > > current patch should also be

Re: [PATCH 4/4] kvm, vmx: remove manually coded vmx instructions

2018-10-26 Thread Sean Christopherson
On Fri, Oct 26, 2018 at 10:46:27AM +, Stecklina, Julian wrote: > On Wed, 2018-10-24 at 10:44 -0700, Eric Northup wrote: > > This loses the exception handling from __ex* -> > > kvm_handle_fault_on_reboot. > > > > If deliberate, this should be called out in changelog.  Has the race > >

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Fri, Nov 02, 2018 at 08:02:23PM +0100, Jann Horn wrote: > On Fri, Nov 2, 2018 at 7:27 PM Sean Christopherson > wrote: > > On Fri, Nov 02, 2018 at 10:48:38AM -0700, Andy Lutomirski wrote: > > > This whole mechanism seems very complicated, and it's not clear > > > e

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Fri, Nov 02, 2018 at 10:13:23AM -0700, Dave Hansen wrote: > On 11/2/18 10:06 AM, Sean Christopherson wrote: > > On Fri, Nov 02, 2018 at 09:56:44AM -0700, Dave Hansen wrote: > >> On 11/2/18 9:30 AM, Sean Christopherson wrote: > >>> What if rather than having

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Fri, Nov 02, 2018 at 09:56:44AM -0700, Dave Hansen wrote: > On 11/2/18 9:30 AM, Sean Christopherson wrote: > > What if rather than having userspace register an address for fixup, the > > kernel instead unconditionally does fixup on the ENCLU opcode? > > The problem

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Thu, Nov 01, 2018 at 04:22:55PM -0700, Andy Lutomirski wrote: > On Thu, Nov 1, 2018 at 2:24 PM Linus Torvalds > wrote: > > > > On Thu, Nov 1, 2018 at 12:31 PM Rich Felker wrote: > > > > > > See my other emails in this thread. You would register the *address* > > > (in TLS) of a function

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Fri, Nov 02, 2018 at 04:37:10PM +, Jethro Beekman wrote: > On 2018-11-02 09:30, Sean Christopherson wrote: > >... The intended convention for EENTER is to have an ENCLU at the AEX target > >... > > > >... to further enforce that the AEX target needs to be ENCLU.

Re: RFC: userspace exception fixups

2018-11-02 Thread Sean Christopherson
On Fri, Nov 02, 2018 at 04:56:36PM +, Jethro Beekman wrote: > On 2018-11-02 09:52, Sean Christopherson wrote: > >On Fri, Nov 02, 2018 at 04:37:10PM +, Jethro Beekman wrote: > >>On 2018-11-02 09:30, Sean Christopherson wrote: > >>>... The intended convention

Re: [PATCH v2 2/3] kvm, vmx: move register clearing out of assembly path

2018-10-29 Thread Sean Christopherson
On Mon, Oct 29, 2018 at 04:40:43PM +0100, Julian Stecklina wrote: > Split the security related register clearing out of the large inline > assembly VM entry path. This results in two slightly less complicated > inline assembly statements, where it is clearer what each one does. > > Signed-off-by:

Re: [PATCH v2 1/3] kvm, vmx: move CR2 context switch out of assembly path

2018-10-29 Thread Sean Christopherson
KVM isn't deliberately avoiding the paravirt ops. The above info makes it trivially easy to review this patch from a correctness standpoint. With that: Reviewed-by: Sean Christopherson [1] Commit 6aa8b732ca01 ("[PATCH] kvm: userspace interface") [2] Commit d3561b7fa0fb ("

[PATCH] mm/mmu_notifier: rename mmu_notifier_synchronize() to <...>_barrier()

2018-11-05 Thread Sean Christopherson
a variation of mmu_notifier_unregister() that synchronizes SRCU without invoking ->release. A Documentation-allergic and hasty developer could be further confused by the fact that rcu_barrier() is indeed a pass-through to synchronize_rcu()... in tiny SRCU. Signed-off-by: Sean Christopherson ---

[PATCH] x86/cpufeatures: Remove get_scattered_cpuid_leaf()

2018-11-05 Thread Sean Christopherson
ve in some scenarios, e.g. when KVM needs to do more than simply expose the leaf. [1] 47bdf3378d62 ("x86/cpuid: Provide get_scattered_cpuid_leaf()") [2] b7b27aa011a1 ("KVM/x86: Update the reverse_cpuid list to include CPUID_7_EDX") Signed-off-by: Sean Christopherson Cc: Paolo Bonzin

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, 2018-11-06 at 08:57 -0800, Andy Lutomirski wrote: > > So I guess the non-enclave code basically can’t trust its stack pointer > because of these shenanigans. And the AEP code has to live with the fact > that its RSP is basically arbitrary and probably can’t even be unwound > by a debugger?

Re: [PATCH v16 18/22] platform/x86: Intel SGX driver

2018-11-06 Thread Sean Christopherson
On Tue, 2018-11-06 at 15:45 +0200, Jarkko Sakkinen wrote: > Intel Software Guard eXtensions (SGX) is a set of CPU instructions that > can be used by applications to set aside private regions of code and > data. The code outside the enclave is disallowed to access the memory > inside the enclave by

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 07:34:52AM -0800, Sean Christopherson wrote: > On Tue, Nov 06, 2018 at 05:17:14PM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson > > wrote: > > > > > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy

Re: [PATCH v16 18/22] platform/x86: Intel SGX driver

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 06:37:57PM +0200, Jarkko Sakkinen wrote: > On Tue, Nov 06, 2018 at 08:40:00AM -0800, Sean Christopherson wrote: > > On Tue, 2018-11-06 at 15:45 +0200, Jarkko Sakkinen wrote: > > > Intel Software Guard eXtensions (SGX) is a set of CPU instructions that

Re: [PATCH] mm/mmu_notifier: rename mmu_notifier_synchronize() to <...>_barrier()

2018-11-05 Thread Sean Christopherson
On Mon, Nov 05, 2018 at 12:18:33PM -0800, Andrew Morton wrote: > On Mon, 5 Nov 2018 11:29:55 -0800 Sean Christopherson > wrote: > > > ...and update its comment to explicitly reference its association with > > mmu_notifier_call_srcu(). > > > > Contrary to i

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > wrote: > > > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > > > > >> On Nov 6, 201

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 04:27:58PM -0500, Rich Felker wrote: > On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > >

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: > On 11/8/18 12:05 PM, Andy Lutomirski wrote: > > Hmm. The idea being that the SDK preserves RBP but not RSP. That's > > not the most terrible thing in the world. But could the SDK live with > > something more like my suggestion where

  1   2   >