<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/x86/kernel/cpu/sgx, branch linux-5.13.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-06-15T16:03:45Z</updated>
<entry>
<title>x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed</title>
<updated>2021-06-15T16:03:45Z</updated>
<author>
<name>Kai Huang</name>
</author>
<published>2021-06-15T10:16:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4692bc775d2180a937335ccba0edce557103d44a'/>
<id>urn:sha1:4692bc775d2180a937335ccba0edce557103d44a</id>
<content type='text'>
xa_destroy() needs to be called to destroy a virtual EPC's page array
before calling kfree() to free the virtual EPC. Currently it is not
called so add the missing xa_destroy().

Fixes: 540745ddbc70 ("x86/sgx: Introduce virtual EPC for use by KVM guests")
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Tested-by: Yang Zhong &lt;yang.zhong@intel.com&gt;
Link: https://lkml.kernel.org/r/20210615101639.291929-1-kai.huang@intel.com
</content>
</entry>
<entry>
<title>Merge tag 'x86_cleanups_for_v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip</title>
<updated>2021-04-26T16:25:47Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2021-04-26T16:25:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ea5bc7b977fc7cd2be4065ef41824adc976c807f'/>
<id>urn:sha1:ea5bc7b977fc7cd2be4065ef41824adc976c807f</id>
<content type='text'>
Pull misc x86 cleanups from Borislav Petkov:
 "Trivial cleanups and fixes all over the place"

* tag 'x86_cleanups_for_v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  MAINTAINERS: Remove me from IDE/ATAPI section
  x86/pat: Do not compile stubbed functions when X86_PAT is off
  x86/asm: Ensure asm/proto.h can be included stand-alone
  x86/platform/intel/quark: Fix incorrect kernel-doc comment syntax in files
  x86/msr: Make locally used functions static
  x86/cacheinfo: Remove unneeded dead-store initialization
  x86/process/64: Move cpu_current_top_of_stack out of TSS
  tools/turbostat: Unmark non-kernel-doc comment
  x86/syscalls: Fix -Wmissing-prototypes warnings from COND_SYSCALL()
  x86/fpu/math-emu: Fix function cast warning
  x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes
  x86: Fix various typos in comments, take #2
  x86: Remove unusual Unicode characters from comments
  x86/kaslr: Return boolean values from a function returning bool
  x86: Fix various typos in comments
  x86/setup: Remove unused RESERVE_BRK_ARRAY()
  stacktrace: Move documentation for arch_stack_walk_reliable() to header
  x86: Remove duplicate TSC DEADLINE MSR definitions
</content>
</entry>
<entry>
<title>x86/sgx: Mark sgx_vepc_vm_ops static</title>
<updated>2021-04-12T17:48:32Z</updated>
<author>
<name>Wei Yongjun</name>
</author>
<published>2021-04-12T16:00:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=523caed9efbb049339706b124185c9358c1b6477'/>
<id>urn:sha1:523caed9efbb049339706b124185c9358c1b6477</id>
<content type='text'>
Fix the following sparse warning:

  arch/x86/kernel/cpu/sgx/virt.c:95:35: warning:
    symbol 'sgx_vepc_vm_ops' was not declared. Should it be static?

This symbol is not used outside of virt.c so mark it static.

 [ bp: Massage commit message. ]

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Wei Yongjun &lt;weiyongjun1@huawei.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Link: https://lkml.kernel.org/r/20210412160023.193850-1-weiyongjun1@huawei.com
</content>
</entry>
<entry>
<title>x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()</title>
<updated>2021-04-08T15:24:42Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2021-04-08T09:29:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ae40aaf6bdbf0354a75b8284a0de453fcf5f4d32'/>
<id>urn:sha1:ae40aaf6bdbf0354a75b8284a0de453fcf5f4d32</id>
<content type='text'>
The commit in Fixes: changed the SGX EPC page sanitization to end up in
sgx_free_epc_page() which puts clean and sanitized pages on the free
list.

This was done for the reason that it is best to keep the logic to assign
available-for-use EPC pages to the correct NUMA lists in a single
location.

sgx_nr_free_pages is also incremented by sgx_free_epc_pages() but those
pages which are being added there per EPC section do not belong to the
free list yet because they haven't been sanitized yet - they land on the
dirty list first and the sanitization happens later when ksgxd starts
massaging them.

So remove that addition there and have sgx_free_epc_page() do that
solely.

 [ bp: Sanitize commit message too. ]

Fixes: 51ab30eb2ad4 ("x86/sgx: Replace section-&gt;init_laundry_list with sgx_dirty_page_list")
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Link: https://lkml.kernel.org/r/20210408092924.7032-1-jarkko@kernel.org
</content>
</entry>
<entry>
<title>x86/sgx: Move provisioning device creation out of SGX driver</title>
<updated>2021-04-06T17:18:46Z</updated>
<author>
<name>Sean Christopherson</name>
</author>
<published>2021-03-19T07:23:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b3754e5d3da320af2bebb7a690002685c7f5c15c'/>
<id>urn:sha1:b3754e5d3da320af2bebb7a690002685c7f5c15c</id>
<content type='text'>
And extract sgx_set_attribute() out of sgx_ioc_enclave_provision() and
export it as symbol for KVM to use.

The provisioning key is sensitive. The SGX driver only allows to create
an enclave which can access the provisioning key when the enclave
creator has permission to open /dev/sgx_provision. It should apply to
a VM as well, as the provisioning key is platform-specific, thus an
unrestricted VM can also potentially compromise the provisioning key.

Move the provisioning device creation out of sgx_drv_init() to
sgx_init() as a preparation for adding SGX virtualization support,
so that even if the SGX driver is not enabled due to flexible launch
control not being available, SGX virtualization can still be enabled,
and use it to restrict a VM's capability of being able to access the
provisioning key.

 [ bp: Massage commit message. ]

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Link: https://lkml.kernel.org/r/0f4d044d621561f26d5f4ef73e8dc6cd18cc7e79.1616136308.git.kai.huang@intel.com
</content>
</entry>
<entry>
<title>x86/sgx: Add helpers to expose ECREATE and EINIT to KVM</title>
<updated>2021-04-06T17:18:27Z</updated>
<author>
<name>Sean Christopherson</name>
</author>
<published>2021-03-19T07:23:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d155030b1e7c0e448aab22a803f7a71ea2e117d7'/>
<id>urn:sha1:d155030b1e7c0e448aab22a803f7a71ea2e117d7</id>
<content type='text'>
The host kernel must intercept ECREATE to impose policies on guests, and
intercept EINIT to be able to write guest's virtual SGX_LEPUBKEYHASH MSR
values to hardware before running guest's EINIT so it can run correctly
according to hardware behavior.

Provide wrappers around __ecreate() and __einit() to hide the ugliness
of overloading the ENCLS return value to encode multiple error formats
in a single int.  KVM will trap-and-execute ECREATE and EINIT as part
of SGX virtualization, and reflect ENCLS execution result to guest by
setting up guest's GPRs, or on an exception, injecting the correct fault
based on return value of __ecreate() and __einit().

Use host userspace addresses (provided by KVM based on guest physical
address of ENCLS parameters) to execute ENCLS/EINIT when possible.
Accesses to both EPC and memory originating from ENCLS are subject to
segmentation and paging mechanisms.  It's also possible to generate
kernel mappings for ENCLS parameters by resolving PFN but using
__uaccess_xx() is simpler.

 [ bp: Return early if the __user memory accesses fail, use
   cpu_feature_enabled(). ]

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Link: https://lkml.kernel.org/r/20e09daf559aa5e9e680a0b4b5fba940f1bad86e.1616136308.git.kai.huang@intel.com
</content>
</entry>
<entry>
<title>x86/sgx: Add helper to update SGX_LEPUBKEYHASHn MSRs</title>
<updated>2021-04-06T07:43:42Z</updated>
<author>
<name>Kai Huang</name>
</author>
<published>2021-03-19T07:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=73916b6a0c714258f9c2619408a66c6696a761a7'/>
<id>urn:sha1:73916b6a0c714258f9c2619408a66c6696a761a7</id>
<content type='text'>
Add a helper to update SGX_LEPUBKEYHASHn MSRs.  SGX virtualization also
needs to update those MSRs based on guest's "virtual" SGX_LEPUBKEYHASHn
before EINIT from guest.

Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Acked-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Link: https://lkml.kernel.org/r/dfb7cd39d4dd62ea27703b64afdd8bccb579f623.1616136308.git.kai.huang@intel.com
</content>
</entry>
<entry>
<title>x86/sgx: Add encls_faulted() helper</title>
<updated>2021-04-06T07:43:42Z</updated>
<author>
<name>Sean Christopherson</name>
</author>
<published>2021-03-19T07:23:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a67136b458e5e63822b19c35794451122fe2bf3e'/>
<id>urn:sha1:a67136b458e5e63822b19c35794451122fe2bf3e</id>
<content type='text'>
Add a helper to extract the fault indicator from an encoded ENCLS return
value.  SGX virtualization will also need to detect ENCLS faults.

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Link: https://lkml.kernel.org/r/c1f955898110de2f669da536fc6cf62e003dff88.1616136308.git.kai.huang@intel.com
</content>
</entry>
<entry>
<title>x86/sgx: Move ENCLS leaf definitions to sgx.h</title>
<updated>2021-04-06T07:43:41Z</updated>
<author>
<name>Sean Christopherson</name>
</author>
<published>2021-03-19T07:23:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c55c78a73ce6e62a1d46ba6e4f242c23c29b812'/>
<id>urn:sha1:9c55c78a73ce6e62a1d46ba6e4f242c23c29b812</id>
<content type='text'>
Move the ENCLS leaf definitions to sgx.h so that they can be used by
KVM.

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Link: https://lkml.kernel.org/r/2e6cd7c5c1ced620cfcd292c3c6c382827fde6b2.1616136308.git.kai.huang@intel.com
</content>
</entry>
<entry>
<title>x86/sgx: Expose SGX architectural definitions to the kernel</title>
<updated>2021-04-06T07:43:41Z</updated>
<author>
<name>Sean Christopherson</name>
</author>
<published>2021-03-19T07:23:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8ca52cc38dc8fdcbdbd0c23eafb19db5e5f5c8d0'/>
<id>urn:sha1:8ca52cc38dc8fdcbdbd0c23eafb19db5e5f5c8d0</id>
<content type='text'>
Expose SGX architectural structures, as KVM will use many of the
architectural constants and structs to virtualize SGX.

Name the new header file as asm/sgx.h, rather than asm/sgx_arch.h, to
have single header to provide SGX facilities to share with other kernel
componments. Also update MAINTAINERS to include asm/sgx.h.

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Co-developed-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Kai Huang &lt;kai.huang@intel.com&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Acked-by: Dave Hansen &lt;dave.hansen@intel.com&gt;
Link: https://lkml.kernel.org/r/6bf47acd91ab4d709e66ad1692c7803e4c9063a0.1616136308.git.kai.huang@intel.com
</content>
</entry>
</feed>
