Support microcode updates affecting SGX
Subsystems (4)
cover Support microcode updates affecting SGX
Users hate reboots. This lets SGX enclaves attest to updated microcode without a reboot.
== General Microcode Background ==
Historically, microcode updates are applied by the BIOS or early in boot. In recent years, several trends have made these old approaches less palatable.
First, the cadence of microcode updates has increased to deliver security mitigations. Second, the value of those updates has increased, meaning that any delay in applying them is unacceptable. Third, users have become accustomed to approaches like hot patching their kernels and have a growing aversion to reboots in general.
Users want microcode updates to behave more like a hot patching a kernel and less like a BIOS update.
Today, many microcode updates _can_ be applied without a reboot. But users have strongly and specifically expressed a desire to perform *any* microcode update on a running system without a reboot. This work is a direct result of those user requests and lets SGX enclaves take full advantage of microcode updates without a reboot.
== SGX Attestation Background ==
SGX enclaves have an attestation mechanism. An enclave might, for instance, need to attest to its state before it is given a special decryption key. Since SGX must trust the CPU microcode, attestation incorporates the microcode versions of all processors on the system and is affected by microcode updates. This allows the entity to which the enclave is attesting to make deployment decisions based on the microcode version. For example, an enclave might be denied a decryption key if it runs on a system that has old microcode without a specific mitigation.
Unfortunately, this attestation metric (called CPUSVN) is only a snapshot. When the kernel first uses SGX (successfully executes any ENCLS instruction), SGX inspects all CPUs in the system and incorporates a record of their microcode versions into CPUSVN. Today, that value is locked and is not updated until a reboot.
== Problems ==
This means that, although the microcode may be update, enclaves can never attest to this fact. Enclaves are stuck attesting to the old version until a reboot.
Old enclaves created before the microcode update are presumed to be compromised must not be allowed to attest with the new microcode version.
== Solution ==
EUPDATESVN is a new SGX instruction which allows enclave attestation to include information about updated microcode without a reboot.
Whenever a microcode update affects SGX, the SGX attestation architecture assumes that all running enclaves and cryptographic assets (like internal SGX encryption keys) have been compromised. To mitigate the impact of this presumed compromise, EUPDATESVN success requires that all SGX memory to be marked as "unused" and its contents destroyed. This requirement ensures that no compromised enclave can survive the EUPDATESVN procedure and provides an opportunity to generate new cryptographic assets.
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
This is a very slow operation. It is, of course, exceedingly disruptive to enclaves but should be infrequent as microcode updates are released on the order of every few months. Also, this is not the first piece of the SGX architecture which will destroy all enclave contents. Enclaves are expected to be designed to be volatile and survive termination at any time gracefully.
A follow-on series will add Virtual EPC (KVM guest) support.
SGX Seamless should handle most SGX flows while doing SVN update, so, this RFC series is based on SGX EDMM v2 which introduces SGX2 flows.
https://lore.kernel.org/lkml/[email protected]/T/
Here is the spec for your reference:
https://cdrdv2.intel.com/v1/dl/getContent/648682?explicitVersion=true
Cathy Zhang (11):
x86/sgx: Introduce mechanism to prevent new initializations of EPC
pages
x86/sgx: Provide VA page non-NULL owner
x86/sgx: Save enclave pointer for VA page
x86/sgx: Keep record for SGX VA and Guest page type x86/sgx: Save the size of each EPC section
x86/sgx: Forced EPC page zapping for EUPDATESVN x86/sgx: Define error codes for ENCLS[EUPDATESVN] x86/sgx: Implement ENCLS[EUPDATESVN]
x86/microcode: Expose EUPDATESVN procedure via sysfs x86/sgx: Call ENCLS[EUPDATESVN] during SGX initialization Documentation/x86/sgx: Document EUPDATESVN sysfs file
arch/x86/include/asm/microcode.h | 5 + arch/x86/include/asm/sgx.h | 46 +- arch/x86/kernel/cpu/sgx/encl.h | 3 +- arch/x86/kernel/cpu/sgx/encls.h | 16 + arch/x86/kernel/cpu/sgx/sgx.h | 23 +- arch/x86/kernel/cpu/microcode/core.c | 44 ++ arch/x86/kernel/cpu/sgx/encl.c | 46 +- arch/x86/kernel/cpu/sgx/ioctl.c | 53 +- arch/x86/kernel/cpu/sgx/main.c | 469 +++++++++++++++++- arch/x86/kernel/cpu/sgx/virt.c | 22 + .../ABI/testing/sysfs-devices-system-cpu | 14 + Documentation/x86/sgx.rst | 43 ++ 12 files changed, 759 insertions(+), 25 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH 1/11 x86/sgx: Introduce mechanism to prevent new initializations of EPC pages
== Background ==
EUPDATESVN is a new SGX instruction which allows enclave attestation to include information about updated microcode without a reboot.
The SGX hardware maintains metadata for each enclave page to help enforce its security guarantees. This includes things like a record of the enclave to which the page belongs and the type of the page:
SGX metadata like "VA" or "SECS" pages, or regular enclave pages like those that store user data.
Before an EUPDATESVN operation can be successful, all SGX memory (aka. EPC) must be marked as "unused" in the SGX hardware metadata (aka, EPCM). The SGX microcode now maintains a reference count of pages which are unused to aid in determining when all pages reach the "unused" state.
Both bare-metal and KVM guest EPC must be made unused. To increase the chance of a successful EUPDATESVN, the kernel prevents existing enclaves from creating new, valid pages and prevents new enclave creation (creating an enclave involves initializing a "SECS" page).
The entire EUPDATESVN process is very slow since it potentially affects gigabytes of enclave memory. It can potentially take seconds or minutes to complete. Userspace may encounter -EBUSY errors during the update and is expected to retry.
== Patch contents ==
Introduce mechanism to prevent new initializations of EPC pages.
Use a flag to indicate when SGX EPC pages are "locked", which means it's not allowed to allocate new EPC page for use. Check it in all paths that can initialize an EPC page. Use SRCU to ensure that the flag is visible across the system before proceeding with an update.
Add checks to all sites that call SGX instructions that can transition pages from unused to initialized to ensure that the SRCU lock is held.
--- arch/x86/kernel/cpu/sgx/encls.h | 10 +++++++ arch/x86/kernel/cpu/sgx/sgx.h | 3 ++ arch/x86/kernel/cpu/sgx/encl.c | 25 +++++++++++++++-- arch/x86/kernel/cpu/sgx/ioctl.c | 50 ++++++++++++++++++++++++++++++++- arch/x86/kernel/cpu/sgx/main.c | 37 ++++++++++++++++++++++++ arch/x86/kernel/cpu/sgx/virt.c | 20 +++++++++++++ 6 files changed, 142 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/sgx/encls.h +10 -0
@@ -139,6 +139,8 @@ static inline bool encls_failed(int ret)/* Initialize an EPC page into an SGX Enclave Control Structure (SECS) page. */ static inline int __ecreate (struct sgx_pageinfo *pginfo,void *secs) { +lockdep_assert_held (&sgx_lock_epc_srcu); +return __encls_2 (ECREATE , pginfo, secs); }
@@ -154,6 +156,8 @@ static inline int __eextend(void *secs, void *addr)*/ static inline int __eadd (struct sgx_pageinfo *pginfo,void *addr) { +lockdep_assert_held (&sgx_lock_epc_srcu); +return __encls_2 (EADD , pginfo, addr); }
@@ -191,6 +195,8 @@ static inline int __etrack(void *addr)static inline int __eldu (struct sgx_pageinfo *pginfo,void *addr,void *va) { +lockdep_assert_held (&sgx_lock_epc_srcu); +return __encls_ret_3 (ELDU , pginfo, addr, va); }
@@ -205,6 +211,8 @@ static inline int __epa(void *addr) {unsigned long rbx =SGX_PAGE_TYPE_VA ; +lockdep_assert_held (&sgx_lock_epc_srcu); +return __encls_2 (EPA , rbx, addr); }
@@ -230,6 +238,8 @@ static inline int __emodt(struct sgx_secinfo *secinfo, void *addr)/* Zero a page of EPC memory and add it to an initialized enclave. */ static inline int __eaug (struct sgx_pageinfo *pginfo,void *addr) { +lockdep_assert_held (&sgx_lock_epc_srcu); +return __encls_2 (EAUG , pginfo, addr); }
arch/x86/kernel/cpu/sgx/sgx.h +3 -0
@@ -104,4 +104,7 @@ static inline int __init sgx_vepc_init(void)void sgx_update_lepubkeyhash (u64 *lepubkeyhash); +extern struct srcu_struct sgx_lock_epc_srcu; +bool sgx_epc_is_locked (void ); +#endif /* _X86_SGX_H */
arch/x86/kernel/cpu/sgx/encl.c +23 -2
@@ -264,6 +264,7 @@ static vm_fault_t sgx_vma_fault(struct vm_fault *vmf)unsigned long phys_addr;struct sgx_encl *encl;vm_fault_t ret; +int srcu_idx; encl = vma->vm_private_data;
@@ -275,6 +276,12 @@ static vm_fault_t sgx_vma_fault(struct vm_fault *vmf)if (unlikely (!encl))return VM_FAULT_SIGBUS ; + srcu_idx =srcu_read_lock (&sgx_lock_epc_srcu); +if (sgx_epc_is_locked ()) { +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx); +return VM_FAULT_SIGBUS ; + } +/* * The page_array keeps track of all enclave pages, whether they * are swapped out or not. If there is no entry for this page and
@@ -283,14 +290,18 @@ static vm_fault_t sgx_vma_fault(struct vm_fault *vmf)* enclave that will be checked for right away. */ if (cpu_feature_enabled (X86_FEATURE_SGX2 ) && - (!xa_load (&encl->page_array,PFN_DOWN (addr)))) -return sgx_encl_eaug_page (vma, encl, addr); + (!xa_load (&encl->page_array,PFN_DOWN (addr)))) { + ret =sgx_encl_eaug_page (vma, encl, addr); +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx); +return ret; + }mutex_lock (&encl->lock); entry =sgx_encl_load_page (encl, addr);if (IS_ERR (entry)) {mutex_unlock (&encl->lock); +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);if (PTR_ERR (entry) == -EBUSY )return VM_FAULT_NOPAGE ;
@@ -315,12 +326,14 @@ static vm_fault_t sgx_vma_fault(struct vm_fault *vmf) vm_get_page_prot(page_prot_bits));if (ret !=VM_FAULT_NOPAGE ) {mutex_unlock (&encl->lock); +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);return VM_FAULT_SIGBUS ; }sgx_encl_test_and_clear_young (vma->vm_mm, entry);mutex_unlock (&encl->lock); +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);return VM_FAULT_NOPAGE ; }
@@ -513,6 +526,7 @@ static int sgx_vma_access(struct vm_area_struct *vma, unsigned long addr,struct sgx_encl_page *entry =NULL ;char data[sizeof (unsigned long )];unsigned long align; +int srcu_idx;int offset;int cnt;int ret =0 ;
@@ -529,6 +543,12 @@ static int sgx_vma_access(struct vm_area_struct *vma, unsigned long addr,return -EFAULT ;for (i =0 ; i < len; i += cnt) { + srcu_idx =srcu_read_lock (&sgx_lock_epc_srcu); +if (sgx_epc_is_locked ()) { + ret = -EBUSY ; + goto out; + } + entry =sgx_encl_reserve_page (encl, (addr + i) &PAGE_MASK );if (IS_ERR (entry)) { ret =PTR_ERR (entry);
@@ -555,6 +575,7 @@ static int sgx_vma_access(struct vm_area_struct *vma, unsigned long addr, out:mutex_unlock (&encl->lock); +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);if (ret)break ;
arch/x86/kernel/cpu/sgx/ioctl.c +49 -1
150 lines not on this page · raw message
arch/x86/kernel/cpu/sgx/main.c +37 -0
@@ -23,6 +23,17 @@ static int sgx_nr_epc_sections;static struct task_struct *ksgxd_tsk;static DECLARE_WAIT_QUEUE_HEAD (ksgxd_waitq);static DEFINE_XARRAY (sgx_epc_address_space); +/* +* The flag sgx_epc_locked prevents any new SGX flows that +* may attempt to allocate a new EPC page. +*/ +static bool __rcu sgx_epc_locked; +/* +* By synchronizing around sgx_epc_locked SRCU ensures that any executing +* SGX flows have completed before proceeding with an SVN update. New SGX flows +* will be prevented from starting during an SVN update. +*/ +DEFINE_SRCU (sgx_lock_epc_srcu);/* * These variables are part of the state of the reclaimer, and must be accessed
@@ -378,6 +389,8 @@ void sgx_direct_reclaim(void)static int ksgxd (void *p) { +int srcu_idx; +set_freezable ();/*
@@ -398,9 +411,15 @@ static int ksgxd(void *p)kthread_should_stop () || sgx_should_reclaim(SGX_NR_HIGH_PAGES)); + srcu_idx =srcu_read_lock (&sgx_lock_epc_srcu); +if (sgx_epc_is_locked ()) + goto maybe_resched; +if (sgx_should_reclaim (SGX_NR_HIGH_PAGES ))sgx_reclaim_pages (); +maybe_resched: +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);cond_resched (); }
@@ -943,3 +962,21 @@ static int __init sgx_init(void) }device_initcall (sgx_init); + +static void sgx_lock_epc (void ) +{ + sgx_epc_locked = true; +synchronize_srcu (&sgx_lock_epc_srcu); +} + +static void sgx_unlock_epc (void ) +{ + sgx_epc_locked = false; +synchronize_srcu (&sgx_lock_epc_srcu); +} + +bool sgx_epc_is_locked (void ) +{ +lockdep_assert_held (&sgx_lock_epc_srcu); +return sgx_epc_locked; +}
arch/x86/kernel/cpu/sgx/virt.c +20 -0
@@ -75,10 +75,21 @@ static vm_fault_t sgx_vepc_fault(struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma;struct sgx_vepc *vepc = vma->vm_private_data; +int srcu_idx;int ret;mutex_lock (&vepc->lock); + srcu_idx =srcu_read_lock (&sgx_lock_epc_srcu); + +if (sgx_epc_is_locked ()) { + ret = -EBUSY ; + goto out_unlock; + } + ret =__sgx_vepc_fault (vepc, vma, vmf->address); + +out_unlock: +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx);mutex_unlock (&vepc->lock);if (!ret)
@@ -331,6 +342,7 @@ int __init sgx_vepc_init(void)int sgx_virt_ecreate (struct sgx_pageinfo *pageinfo,void __user *secs,int *trapnr) { +int srcu_idx;int ret;/*
@@ -347,6 +359,12 @@ int sgx_virt_ecreate(struct sgx_pageinfo *pageinfo, void __user *secs,if (WARN_ON_ONCE (!access_ok (secs,PAGE_SIZE )))return -EINVAL ; + srcu_idx =srcu_read_lock (&sgx_lock_epc_srcu); +if (sgx_epc_is_locked ()) { +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx); +return -EBUSY ; + } +__uaccess_begin (); ret =__ecreate (pageinfo, (void *)secs);__uaccess_end ();
@@ -356,6 +374,8 @@ int sgx_virt_ecreate(struct sgx_pageinfo *pageinfo, void __user *secs,return -EFAULT ; } +srcu_read_unlock (&sgx_lock_epc_srcu, srcu_idx); +/* ECREATE doesn't return an error code, it faults or succeeds. */ WARN_ON_ONCE (ret);return 0 ;
Signature · 1 line
2.17.1
RFC PATCH 2/11 x86/sgx: Provide VA page non-NULL owner
In reply to Cathy ZhangProvide non-NULL owner for VA page, which tells that the EPC page is allocated for use.
--- arch/x86/kernel/cpu/sgx/encl.h | 2 +- arch/x86/kernel/cpu/sgx/sgx.h | 2 +- arch/x86/kernel/cpu/sgx/encl.c | 5 +++-- arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/sgx/encl.h +1 -1
@@ -114,7 +114,7 @@ void sgx_encl_put_backing(struct sgx_backing *backing, bool do_write);int sgx_encl_test_and_clear_young (struct mm_struct *mm,struct sgx_encl_page *page);void sgx_zap_enclave_ptes (struct sgx_encl *encl,unsigned long addr); -struct sgx_epc_page *sgx_alloc_va_page (void ); +struct sgx_epc_page *sgx_alloc_va_page (struct sgx_va_page *va_page);unsigned int sgx_alloc_va_slot (struct sgx_va_page *va_page);void sgx_free_va_slot (struct sgx_va_page *va_page,unsigned int offset);bool sgx_va_page_full (struct sgx_va_page *va_page);
arch/x86/kernel/cpu/sgx/sgx.h +1 -1
@@ -33,7 +33,7 @@ struct sgx_epc_page {unsigned int section;u16 flags;u16 poison; -struct sgx_encl_page *owner; +void *owner;struct list_head list; };
arch/x86/kernel/cpu/sgx/encl.c +3 -2
@@ -990,6 +990,7 @@ void sgx_zap_enclave_ptes(struct sgx_encl *encl, unsigned long addr)/** * sgx_alloc_va_page() - Allocate a Version Array (VA) page +* @va_page: struct sgx_va_page connected to this VA page * * Allocate a free EPC page and convert it to a Version Array (VA) page. *
@@ -997,12 +998,12 @@ void sgx_zap_enclave_ptes(struct sgx_encl *encl, unsigned long addr)* a VA page, * -errno otherwise */ -struct sgx_epc_page *sgx_alloc_va_page (void ) +struct sgx_epc_page *sgx_alloc_va_page (struct sgx_va_page *va_page) {struct sgx_epc_page *epc_page;int ret; - epc_page =sgx_alloc_epc_page (NULL , true); + epc_page =sgx_alloc_epc_page (va_page, true);if (IS_ERR (epc_page))return ERR_CAST (epc_page);
arch/x86/kernel/cpu/sgx/ioctl.c +1 -1
@@ -30,7 +30,7 @@ struct sgx_va_page *sgx_encl_grow(struct sgx_encl *encl)if (!va_page)return ERR_PTR (-ENOMEM ); - va_page->epc_page =sgx_alloc_va_page (); + va_page->epc_page =sgx_alloc_va_page (va_page);if (IS_ERR (va_page->epc_page)) { err =ERR_CAST (va_page->epc_page);kfree (va_page);
Signature · 1 line
2.17.1
RFC PATCH 3/11 x86/sgx: Save enclave pointer for VA page
In reply to Cathy ZhangTearing down all enclaves is required by SGX SVN update, which involves running the ENCLS[EREMOVE] instruction on every EPC page. This (tearing down all enclaves) should be coordinated with any enclaves that may be in the process of existing and thus already be running ENCLS[EREMOVE] as part of enclave release.
In support of this coordination, it is required to know which enclave owns each in-use EPC page. It is already possible to locate the owning enclave of SECS and regular pages but not for VA pages.
Save the enclave pointer for each VA page to support locating its owning enclave.
Note: to track 2T EPC memory, this scheme of tracking will use additional 8M memory.
--- arch/x86/kernel/cpu/sgx/encl.h | 1 + arch/x86/kernel/cpu/sgx/ioctl.c | 1 + 2 files changed, 2 insertions(+)
arch/x86/kernel/cpu/sgx/encl.h +1 -0
@@ -77,6 +77,7 @@ struct sgx_va_page {struct sgx_epc_page *epc_page;DECLARE_BITMAP (slots,SGX_VA_SLOT_COUNT );struct list_head list; +struct sgx_encl *encl; };struct sgx_backing {
arch/x86/kernel/cpu/sgx/ioctl.c +1 -0
@@ -30,6 +30,7 @@ struct sgx_va_page *sgx_encl_grow(struct sgx_encl *encl)if (!va_page)return ERR_PTR (-ENOMEM ); + va_page->encl = encl; va_page->epc_page =sgx_alloc_va_page (va_page);if (IS_ERR (va_page->epc_page)) { err =ERR_CAST (va_page->epc_page);
Signature · 1 line
2.17.1
RFC PATCH 4/11 x86/sgx: Keep record for SGX VA and Guest page type
In reply to Cathy ZhangRegular enclave EPC pages have sgx_encl_page as their owner, but SGX VA page and KVM guest EPC page are maintained by different owner structures.
SGX CPUSVN update requires to know the EPC page owner's status and then decide how to handle the page.
Keep a record of page type for SGX VA and KVM guest page while the other EPC pages already have their type tracked, so that CPUSVN update can get EPC page's owner by type and handle it then.
--- arch/x86/kernel/cpu/sgx/sgx.h | 4 ++++ arch/x86/kernel/cpu/sgx/encl.c | 2 ++ arch/x86/kernel/cpu/sgx/virt.c | 2 ++ 3 files changed, 8 insertions(+)
arch/x86/kernel/cpu/sgx/sgx.h +4 -0
@@ -28,6 +28,10 @@/* Pages on free list */ #define SGX_EPC_PAGE_IS_FREE BIT(1) +/* VA page */ +#define SGX_EPC_PAGE_VA BIT(2) +/* Pages allocated for KVM guest */ +#define SGX_EPC_PAGE_GUEST BIT(3)struct sgx_epc_page {unsigned int section;
arch/x86/kernel/cpu/sgx/encl.c +2 -0
@@ -1014,6 +1014,8 @@ struct sgx_epc_page *sgx_alloc_va_page(struct sgx_va_page *va_page)return ERR_PTR (-EFAULT ); } + epc_page->flags |=SGX_EPC_PAGE_VA ; +return epc_page; }
arch/x86/kernel/cpu/sgx/virt.c +2 -0
@@ -50,6 +50,8 @@ static int __sgx_vepc_fault(struct sgx_vepc *vepc,if (IS_ERR (epc_page))return PTR_ERR (epc_page); + epc_page->flags |=SGX_EPC_PAGE_GUEST ; + ret =xa_err (xa_store (&vepc->page_array, index, epc_page,GFP_KERNEL ));if (ret) goto err_free;
Signature · 1 line
2.17.1
RFC PATCH 5/11 x86/sgx: Save the size of each EPC section
In reply to Cathy ZhangFor SGX CPUSVN update process will check all EPC pages in each section to ensure they will be marked as unused, it requires to know the size of each EPC section to end the loop.
--- arch/x86/kernel/cpu/sgx/sgx.h | 1 + arch/x86/kernel/cpu/sgx/main.c | 1 + 2 files changed, 2 insertions(+)
arch/x86/kernel/cpu/sgx/sgx.h +1 -0
@@ -63,6 +63,7 @@ struct sgx_epc_section {void *virt_addr;struct sgx_epc_page *pages;struct sgx_numa_node *node; +u64 size; };extern struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS ];
arch/x86/kernel/cpu/sgx/main.c +1 -0
@@ -636,6 +636,7 @@ static bool __init sgx_setup_epc_section(u64 phys_addr, u64 size, } section->phys_addr = phys_addr; + section->size = size;xa_store_range (&sgx_epc_address_space, section->phys_addr, phys_addr + size -1 , section,GFP_KERNEL );
Signature · 1 line
2.17.1
RFC PATCH 6/11 x86/sgx: Forced EPC page zapping for EUPDATESVN
In reply to Cathy ZhangBefore an EUPDATESVN instruction can be successful, all enclave pages (EPC) must be marked as unused in the SGX hardware metadata (EPCM).
A page becomes unused when an issued EREMOVE instruction succeeds. To prepare for EUPDATESVN, loop over all SGX pages and attempt to EREMOVE them. This is fatal to running enclaves and destroys all enclave state and memory contents. This destruction is by design and mitigates any compromise of enclaves or the SGX hardware itself which occurred before the microcode update.
An EREMOVE operation on a page may fail for a few reasons. Each has its own mitigations.
First, EREMOVE will fail if an enclave that uses the page is executing. Send an IPI to all CPUs that might be running the enclave to force it out of the enclave long enough to EREMOVE the page. Other CPUs might enter the enclave in the meantime, so this is not a rock-solid guarantee.
Second, EREMOVE can fail on special SGX metadata pages, such as SECS and VA. EREMOVE will work on them only after the normal SGX pages that depend on them have been EREMOVE'd. Defer handling those pages and repeat EREMOVE after the dependency has been addressed.
--- arch/x86/kernel/cpu/sgx/sgx.h | 13 ++ arch/x86/kernel/cpu/sgx/encl.c | 14 +- arch/x86/kernel/cpu/sgx/main.c | 347 +++++++++++++++++++++++++++++++++ 3 files changed, 373 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/sgx.h +13 -0
@@ -32,6 +32,17 @@#define SGX_EPC_PAGE_VA BIT(2)/* Pages allocated for KVM guest */ #define SGX_EPC_PAGE_GUEST BIT(3) +/* +* Pages, failed to be zapped (EREMOVED) +* by SGX CPUSVN update process. +*/ +#define SGX_EPC_PAGE_ZAP_TRACKED BIT(4) +/* +* Pages, the associated enclave is being +* released while SGX CPUSVN update is +* running. +*/ +#define SGX_EPC_PAGE_IN_RELEASE BIT(5)struct sgx_epc_page {unsigned int section;
@@ -111,5 +122,7 @@ void sgx_update_lepubkeyhash(u64 *lepubkeyhash);extern struct srcu_struct sgx_lock_epc_srcu;bool sgx_epc_is_locked (void ); +void sgx_zap_wakeup (void ); +void sgx_zap_abort (void );#endif /* _X86_SGX_H */
arch/x86/kernel/cpu/sgx/encl.c +13 -1
@@ -651,6 +651,12 @@ void sgx_encl_release(struct kref *ref)WARN_ON_ONCE (encl->secs_child_cnt);WARN_ON_ONCE (encl->secs.epc_page); +/* +* EPC pages were freed and EREMOVE was executed. Wake +* up any zappers which were waiting for this. +*/ +sgx_zap_wakeup (); +kfree (encl); }
@@ -1077,8 +1083,14 @@ void sgx_encl_free_epc_page(struct sgx_epc_page *page)WARN_ON_ONCE (page->flags &SGX_EPC_PAGE_RECLAIMER_TRACKED ); ret =__eremove (sgx_get_epc_virt_addr (page)); -if (WARN_ONCE (ret,EREMOVE_ERROR_MESSAGE , ret, ret)) +if (WARN_ONCE (ret,EREMOVE_ERROR_MESSAGE , ret, ret)) { +/* +* The EREMOVE failed. If a CPUSVN is in progress, +* it is now expected to fail. Notify it. +*/ +sgx_zap_abort ();return ; + }sgx_free_epc_page (page); }
arch/x86/kernel/cpu/sgx/main.c +347 -0
362 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC PATCH 7/11 x86/sgx: Define error codes for ENCLS[EUPDATESVN]
In reply to Cathy ZhangAdd error codes for ENCLS[EUPDATESVN], then SGX CPUSVN update process can know the execution state of EUPDATESVN and notify userspace.
--- arch/x86/include/asm/sgx.h | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/include/asm/sgx.h +8 -0
@@ -73,6 +73,11 @@ enum sgx_encls_function {* public key does not match IA32_SGXLEPUBKEYHASH. * %SGX_PAGE_NOT_MODIFIABLE: The EPC page cannot be modified because it * is in the PENDING or MODIFIED state. +* %SGX_INSUFFICIENT_ENTROPY: Insufficient entropy in RNG. +* %SGX_EPC_NOT_READY: EPC is not ready for SVN update. +* %SGX_NO_UPDATE: EUPDATESVN was successful, but CPUSVN was not +* updated because current SVN was not newer than +* CPUSVN. * %SGX_UNMASKED_EVENT: An unmasked event, e.g. INTR, was received */ enum sgx_return_code {
@@ -81,6 +86,9 @@ enum sgx_return_code {SGX_CHILD_PRESENT =13 ,SGX_INVALID_EINITTOKEN =16 ,SGX_PAGE_NOT_MODIFIABLE =20 , +SGX_INSUFFICIENT_ENTROPY =29 , +SGX_EPC_NOT_READY =30 , +SGX_NO_UPDATE =31 , SGX_UNMASKED_EVENT = 128, };
Signature · 1 line
2.17.1
RFC PATCH 8/11 x86/sgx: Implement ENCLS[EUPDATESVN]
In reply to Cathy ZhangThe SGX attestation architecture assumes a compromise of all running enclaves and cryptographic assets (like internal SGX encryption keys) whenever a microcode update affects SGX. To mitigate the impact of this presumed compromise, a new supervisor SGX instruction:
ENCLS[EUPDATESVN], is introduced to update SGX microcode version and generate new cryptographic assets in runtime after SGX microcode update.
EUPDATESVN requires that SGX memory to be marked as "unused" before it will succeed. This ensures that no compromised enclave can survive the process and provides an opportunity to generate new cryptographic assets.
--- arch/x86/include/asm/sgx.h | 33 ++++++++++++++++++--------------- arch/x86/kernel/cpu/sgx/encls.h | 6 ++++++ arch/x86/kernel/cpu/sgx/main.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-)
arch/x86/include/asm/sgx.h +18 -15
@@ -26,23 +26,26 @@#define SGX_CPUID_EPC_SECTION 0x1/* The bitmask for the EPC section type. */ #define SGX_CPUID_EPC_MASK GENMASK(3, 0) +/* EUPDATESVN presence indication */ +#define SGX_CPUID_EUPDATESVN BIT(10)enum sgx_encls_function { -ECREATE =0x00 , -EADD =0x01 , -EINIT =0x02 , -EREMOVE =0x03 , -EDGBRD =0x04 , -EDGBWR =0x05 , -EEXTEND =0x06 , -ELDU =0x08 , -EBLOCK =0x09 , -EPA =0x0A , -EWB =0x0B , -ETRACK =0x0C , -EAUG =0x0D , -EMODPR =0x0E , -EMODT =0x0F , +ECREATE =0x00 , +EADD =0x01 , +EINIT =0x02 , +EREMOVE =0x03 , +EDGBRD =0x04 , +EDGBWR =0x05 , +EEXTEND =0x06 , +ELDU =0x08 , +EBLOCK =0x09 , +EPA =0x0A , +EWB =0x0B , +ETRACK =0x0C , +EAUG =0x0D , +EMODPR =0x0E , +EMODT =0x0F , +EUPDATESVN =0x18 , };/**
arch/x86/kernel/cpu/sgx/encls.h +6 -0
@@ -243,4 +243,10 @@ static inline int __eaug(struct sgx_pageinfo *pginfo, void *addr) return __encls_2(EAUG, pginfo, addr); } +/* Update CPUSVN at runtime. */ +static inline int __eupdatesvn (void ) +{ +return __encls_ret_1 (EUPDATESVN ,"" ); +} +#endif /* _X86_ENCLS_H */
arch/x86/kernel/cpu/sgx/main.c +31 -0
@@ -1328,3 +1328,34 @@ void sgx_zap_abort(void) sgx_zap_abort_wait = true;wake_up (&sgx_zap_waitq); } + +/** +* sgx_updatesvn() - Issue ENCLS[EUPDATESVN] +* If EPC is ready, this instruction will update CPUSVN to the currently +* loaded microcode update SVN and generate new cryptographic assets. +* +* Return: +* 0: CPUSVN is update successfully. +* %SGX_LOCKFAIL: An instruction concurrency rule was violated. +* %SGX_INSUFFICIENT_ENTROPY: Insufficient entropy in RNG. +* %SGX_EPC_NOT_READY: EPC is not ready for SVN update. +* %SGX_NO_UPDATE: EUPDATESVN was successful, but CPUSVN was not +* updated because current SVN was not newer than +* CPUSVN. +*/ +static int sgx_updatesvn (void ) +{ +int ret; +int retry =10 ; + +do { + ret =__eupdatesvn (); +if (ret !=SGX_INSUFFICIENT_ENTROPY ) +break ; + + }while (--retry); + +pr_info ("EUPDATESVN complete with ret %d\n" , ret); + +return ret; +}
Signature · 1 line
2.17.1
RFC PATCH 9/11 x86/microcode: Expose EUPDATESVN procedure via sysfs
In reply to Cathy ZhangEUPDATESVN is the SGX instruction which allows enclave attestation to include information about updated microcode without a reboot.
Microcode updates which affect SGX require two phases:
1. Do the main microcode update
2. Make the new CPUSVN available for enclave attestation via EUPDATESVN.
Before a EUPDATESVN can succeed, all enclave pages (EPC) must be marked as unused in the SGX metadata (EPCM). This operation destroys all preexisting SGX enclave data and metadata. This is by design and mitigates the impact of vulnerabilities that may have compromised enclaves or the SGX hardware itself prior to the update.
--- arch/x86/include/asm/microcode.h | 5 ++++ arch/x86/include/asm/sgx.h | 5 ++++ arch/x86/kernel/cpu/microcode/core.c | 44 ++++++++++++++++++++++++++++ arch/x86/kernel/cpu/sgx/main.c | 40 +++++++++++++++++++++++++ 4 files changed, 94 insertions(+)
arch/x86/include/asm/microcode.h +5 -0
@@ -3,6 +3,7 @@#define _ASM_X86_MICROCODE_H#include <asm/cpu.h> +#include <asm/sgx.h> #include <linux/earlycpio.h> #include <linux/initrd.h>
@@ -137,4 +138,8 @@ static inline void load_ucode_ap(void) { }static inline void reload_early_microcode (void ) { }#endif +#ifndef update_cpusvn_intel +static inline int update_cpusvn_intel (void ) {return -EINVAL ; } +#endif +#endif /* _ASM_X86_MICROCODE_H */
arch/x86/include/asm/sgx.h +5 -0
@@ -412,4 +412,9 @@ int sgx_virt_einit(void __user *sigstruct, void __user *token,int sgx_set_attribute (unsigned long *allowed_attributes,unsigned int attribute_fd); +#ifdef CONFIG_X86_SGX +int update_cpusvn_intel (void ); +#define update_cpusvn_intel update_cpusvn_intel +#endif +#endif /* _ASM_X86_SGX_H */
arch/x86/kernel/cpu/microcode/core.c +44 -0
62 lines not on this page · raw message
arch/x86/kernel/cpu/sgx/main.c +40 -0
@@ -1359,3 +1359,43 @@ static int sgx_updatesvn(void)return ret; } + +int update_cpusvn_intel (void ) +{ +int ret; + +sgx_lock_epc (); + ret =sgx_zap_pages (); +if (ret) + goto out; + + ret =sgx_updatesvn (); + +switch (ret) { +case 0 : +case SGX_NO_UPDATE : + ret =0 ; +break ; +case SGX_EPC_NOT_READY : + ret = -EBUSY ; +break ; +case SGX_INSUFFICIENT_ENTROPY : +pr_info ("CPUSVN update is failed due to Insufficient entropy in RNG," +"please try it later.\n" ); + ret = -EINVAL ; +break ; +case SGX_EPC_PAGE_CONFLICT : +pr_info ("CPUSVN update is failed due to concurrency violation, please" +"stop running any other ENCLS leaf and try it later.\n" ); + ret = -EINVAL ; +break ; +default : + ret = -EINVAL ; +break ; + } + +out: +sgx_unlock_epc (); + +return ret; +}
Signature · 1 line
2.17.1
Borislav Petkov
maintainerRe: [RFC PATCH 09/11] x86/microcode: Expose EUPDATESVN procedure via sysfs
On all your patches for the future: don't forget to Cc LKML.
Quoted 15 lines · Cathy Zhang
EUPDATESVN is the SGX instruction which allows enclave attestation to include information about updated microcode without a reboot.
Microcode updates which affect SGX require two phases:
1. Do the main microcode update
2. Make the new CPUSVN available for enclave attestation via EUPDATESVN.Before a EUPDATESVN can succeed, all enclave pages (EPC) must be marked as unused in the SGX metadata (EPCM). This operation destroys all preexisting SGX enclave data and metadata. This is by design and mitigates the impact of vulnerabilities that may have compromised enclaves or the SGX hardware itself prior to the update.
Quoted 5 lines
Signed-off-by Cathy Zhang <[email protected]>--- arch/x86/include/asm/microcode.h | 5 ++++ arch/x86/include/asm/sgx.h | 5 ++++ arch/x86/kernel/cpu/microcode/core.c | 44 ++++++++++++++++++++++++++++
Why is all this code here at all?
What does that have *actually* to do with microcode loading?
AFAICT, you want to hook into microcode_check() which runs after the microcode update and do your EUPDATESVN there...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [RFC PATCH 09/11] x86/microcode: Expose EUPDATESVN procedure via sysfs
Quoted 2 lines · Borislav Petkov
AFAICT, you want to hook into
microcode_check()which runs after the microcode update and do your EUPDATESVN there...
There's a little bit in the cover letter that _implies_ why EUPDATESVN isn't called during the actual microcode update:
Quoted 5 lines
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
This allows the (non-destructive) ucode update and the destructive EUPDATESVN procedure to happen at different times.
If we just want to make the ucode update itself call EUPDATESVN via microcode_check(), that makes the ucode update itself destructive to SGX enclaves. That's not the end of the world, but this series is going to some amount of trouble (including new ABI) to avoid it.
Perhaps we need to hear more about why this is so much of an issue.
Borislav Petkov
maintainerRe: [RFC PATCH 09/11] x86/microcode: Expose EUPDATESVN procedure via sysfs
Quoted 11 lines · Dave Hansen
There's a little bit in the cover letter that _implies_ why EUPDATESVN isn't called during the actual microcode update:
Quoted 5 lines
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
This allows the (non-destructive) ucode update and the destructive EUPDATESVN procedure to happen at different times.
Which means, that this has even less to do with the microcode loader. That whole glue can be somewhere in arch/x86/...sgx/ land and be completely independent.
Quoted 6 lines
If we just want to make the ucode update itself call EUPDATESVN via
microcode_check(), that makes the ucode update itself destructive to SGX enclaves. That's not the end of the world, but this series is going to some amount of trouble (including new ABI) to avoid it.Perhaps we need to hear more about why this is so much of an issue.
Yah, it all sounds weird.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRE: [RFC PATCH 09/11] x86/microcode: Expose EUPDATESVN procedure via sysfs
In reply to Borislav PetkovQuoted 1 line
On all your patches for the future: don't forget to Cc LKML.
Thanks Boris! I will do it.
RFC PATCH 10/11 x86/sgx: Call ENCLS[EUPDATESVN] during SGX initialization
In reply to Cathy ZhangA snapshot of the processor microcode SVN is taken each boot cycle at the time when Intel SGX is first used. This results in microcode updates being loadable at any time, fixing microcode issues. However, if system boot up through kexec() from error recovery, no hardware reset happens, any SGX leaf execution during boot up is not assumed as the first use in such case, and no snapshot of SVN is taken. So, it's necessary to call ENCLS[EUPDATESVN] to update SVN automatically, rather than waiting for the admin to do it when he/she is even not aware of that.
Call ENCLS[EUPDATESVN] after sanitizing pages will increase the chance of success, for it requires that EPC is empty.
--- arch/x86/kernel/cpu/sgx/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/main.c +12 -1
@@ -397,8 +397,10 @@ void sgx_direct_reclaim(void)sgx_reclaim_pages (); } +int update_cpusvn_intel (void );static int ksgxd (void *p) { +int ret;int srcu_idx;set_freezable ();
@@ -411,7 +413,16 @@ static int ksgxd(void *p)__sgx_sanitize_pages (&sgx_dirty_page_list);/* sanity check: */ -WARN_ON (!list_empty (&sgx_dirty_page_list)); +if (!WARN_ON (!list_empty (&sgx_dirty_page_list))) { +/* +* Do SVN update for kexec(). It should complete without error, for +* all EPC pages are unused at this point. +*/ +if (cpuid_eax (SGX_CPUID ) &SGX_CPUID_EUPDATESVN ) { + ret =update_cpusvn_intel (); +WARN_ON (ret && (ret !=SGX_NO_UPDATE )); + } + }while (!kthread_should_stop ()) {if (try_to_freeze ())
Signature · 1 line
2.17.1
RFC PATCH 11/11 Documentation/x86/sgx: Document EUPDATESVN sysfs file
In reply to Cathy ZhangA new sysfs file /sys/devices/system/cpu/microcode/svnupdate is provided, it allows system admin to echo 1 to trigger the CPUSVN update process.
Document the new sysfs ABI.
--- .../ABI/testing/sysfs-devices-system-cpu | 14 ++++++ Documentation/x86/sgx.rst | 43 +++++++++++++++++++ 2 files changed, 57 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +14 -0
@@ -687,3 +687,17 @@ Description: (RO) the list of CPUs that are isolated and don't participate in load balancing. These CPUs are set by boot parameter "isolcpus=". + +What: /sys/devices/system/cpu/microcode/svnupdate +Date: Feb 2022 +Contact: [email protected] +Description: Applying SGX Runtime Microcode Updates to Enclaves + + Whenever a microcode update affects SGX, ENCLS[EUPDATESVN] + should be taken to update the attestation metric (called + CPUSVN) and generate new cryptographic assets without a + reboot. EUPDATESVN success requires that all SGX memory + be marked as "unused" and its contents destroyed. + + This sysfs interface is only exposed to userspace on host, + to trigger enclave destruction and the EUPDATESVN operation.
Documentation/x86/sgx.rst +43 -0
46 lines not on this page · raw message
Signature · 1 line
2.17.1
Cathy,
Quoted 2 lines · Cathy Zhang
Users hate reboots. This lets SGX enclaves attest to updated microcode without a reboot.
Users hate guesswork much more. And microcode updates without reboot are guesswork because Intel fails to include information into the microcode header which tells the kernel whether the update is safe to do on a running system... Not your fault, but
Quoted 3 lines
Today, many microcode updates _can_ be applied without a reboot. But users have strongly and specifically expressed a desire to perform *any* microcode update on a running system without a reboot.
That's wishful thinking. Any microcode update which changes features or behaviour can result in inconsistent state of the kernel/system. That's a fact and proliferating the fairy tale that *any* microcode update can be done late is just a marketing terminological inexactitude.
Can we please stick to facts?
Quoted 5 lines
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Tear down after a microcode update? This does not make any sense at all, really. If the enclaves become inconsistent due to the microcode update then you want to tear them down _before_ the microcode update, then update the microcode, run EUPDATESVN and then bring them up again.
Just because it somehow works does not mean it's correct.
Thanks,
tglx
Quoted 7 lines · Thomas Gleixner
Quoted 5 lines
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Tear down after a microcode update? This does not make any sense at all, really. If the enclaves become inconsistent due to the microcode update
I don't think there's anything that makes the enclaves inconsistent from the microcode update itself.
Let's imagine an extreme (thankfully imaginary) case: SGX has been totally broken by some attack. All running enclaves might have been compromised. A magical microcode update comes and saves the day and mitigates the attack.
From the hardware perspective, at the time of the microcode update, the (presumably compromised) enclaves *can* still run. Nothing changes for them. The only thing they can't do is attest to the shiny new microcode.
Are you saying that the kernel should consider the enclaves inconsistent at the time of the microcode update? Or, were you thinking that the microcode update process itself would make them inconsistent?
Borislav Petkov
maintainerQuoted 7 lines · Dave Hansen
Let's imagine an extreme (thankfully imaginary) case: SGX has been totally broken by some attack. All running enclaves might have been compromised. A magical microcode update comes and saves the day and mitigates the attack.
From the hardware perspective, at the time of the microcode update, the (presumably compromised) enclaves *can* still run.
Here's where you lost me: the enclaves are presumably compromised and yet you wanna leave them running?! Isn't the strategy to kill them to limit the spread of whatever has compromised them?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 11 lines · Borislav Petkov
Quoted 7 lines · Dave Hansen
Let's imagine an extreme (thankfully imaginary) case: SGX has been totally broken by some attack. All running enclaves might have been compromised. A magical microcode update comes and saves the day and mitigates the attack.
From the hardware perspective, at the time of the microcode update, the (presumably compromised) enclaves *can* still run.
Here's where you lost me: the enclaves are presumably compromised and yet you wanna leave them running?! Isn't the strategy to kill them to limit the spread of whatever has compromised them?
Killing them immediately is a totally valid policy. But, I think it's also a valid policy to continue to let them run. Maybe you know they were not vulnerable to whatever got mitigated. Or, maybe they're sufficiently sandboxed that they are not of any concern. You want new enclaves to be able to attest to the new microcode, but you're just not that worried about the old ones.
This mechanism allows userspace to separate the "update the microcode" and "destroy the enclaves" and implement a policy which separates them (or doesn't).
In either case, the specific demand from end users for this flexibility is clearly lacking. I'm sure Cathy and Ashok will get working to flesh that out.
Dave,
Quoted 17 lines · Dave Hansen
Quoted 7 lines · Thomas Gleixner
Quoted 5 lines
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Tear down after a microcode update? This does not make any sense at all, really. If the enclaves become inconsistent due to the microcode update
I don't think there's anything that makes the enclaves inconsistent from the microcode update itself.
Let's imagine an extreme (thankfully imaginary) case: SGX has been totally broken by some attack. All running enclaves might have been compromised. A magical microcode update comes and saves the day and mitigates the attack.
Quoted 4 lines
From the hardware perspective, at the time of the microcode update, the (presumably compromised) enclaves *can* still run. Nothing changes for them. The only thing they can't do is attest to the shiny new microcode.
So lets spin that further in a timeline of events:
6AM Info about CPU erratum which makes SGX vulnerable arrives with
a fix in form of a microcode update
12AM Microcode is updated
6PM Enclaves are torn down
It technically works, but it does not make any sense at all.
I fundamentaly detest procedures which are violating common sense especially when those violations are not backed up by any technical arguments.
Quoted 3 lines
Are you saying that the kernel should consider the enclaves inconsistent at the time of the microcode update? Or, were you thinking that the microcode update process itself would make them inconsistent?
Inconsistent in the meaning that the attestation is moot at the point of the microcode update because that attestation was done against the previously loaded microcode.
That means if anything fundamentally changed by the microcode then the enclave might become vulnerable by the microcode update itself because the deployment decision based on the previous microcode is not longer correct.
Unlikely, but not impossible and we had cases where certain mitigations had to be redone in microcode which means that a code deployed based on the previous microcode revision is not longer protected.
Again, this all might be a non issue, but with a cover letter based on marketing ballyhoo, I'm not seeing how this can be correct under all circumstances.
We write code and create proceedures based on the worst case assumptions and by applying common sense and not based on what $customer has on his wishlist. I'm all for serving customers, but ponies are not part of that.
Thanks,
tglx
Quoted 5 lines · Cathy Zhang
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Cathy, if it isn't abundantly clear by now, everyone seems to hate this part of the implementation.
Let's just make this just do EUPDATESVN as a part of the microcode update process. No new ABI. No trying to preserve enclaves. Kill them early, kill them all, and be done with it.
If we merge that and we have end users chasing us with torches and pitchforks because their precious enclaves were torn down, we'll think about doing something different.
Quoted 9 lines · Dave Hansen
Quoted 5 lines · Cathy Zhang
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Cathy, if it isn't abundantly clear by now, everyone seems to hate this part of the implementation.
Certainly if there is good information that this ucode brings in SGX fixes it absolutely makes sense to do that. Right now this information is only communicated via release notes and some other agent like the orchestrator decides the kill SGX part.
If we had a programmatic way to determine EUPDATESVN is required this automatic kill is the way to go.
Quoted 4 lines
Let's just make this just do EUPDATESVN as a part of the microcode update process. No new ABI. No trying to preserve enclaves. Kill them early, kill them all, and be done with it.
Maybe use some meta-data that can communicate this directly.
Quoted 4 lines
If we merge that and we have end users chasing us with torches and pitchforks because their precious enclaves were torn down, we'll think about doing something different.
Ashok,
Quoted 8 lines · Ashok Raj
Quoted 7 lines · Dave Hansen
Quoted 5 lines · Cathy Zhang
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Quoted 7 lines
Quoted 2 lines
Cathy, if it isn't abundantly clear by now, everyone seems to hate this part of the implementation.
Certainly if there is good information that this ucode brings in SGX fixes it absolutely makes sense to do that. Right now this information is only communicated via release notes and some other agent like the orchestrator decides the kill SGX part.
the point is that the attestation is invalid when you load new microcode. IOW, the microcode update creates inconsistent state.
Inconsistent state is not subject to discussion. It's wrong independent of how much handwaving and wishful thinking you apply to it.
If $customer wants to have that then he has the freedom to do so, but we are not merging any patches which are proliferating the "I want a pony" mentality.
Thanks,
tglx
Hi Dave, Thomas,
Thanks for helping review!
I will remove the new ABI and let microcode update process call the interface directly to clean up EPC and do EUPDATESVN. Please let me know if you have other suggestion.
Quoted 23 lines
-----Original Message-----
From: Hansen, Dave <[email protected]>
Sent: Thursday, March 10, 2022 4:33 AM
To: Zhang, Cathy <[email protected]>; [email protected]; [email protected]; Raj, Ashok <[email protected]>
Subject: Re: [RFC PATCH 00/11] Support microcode updates affecting SGXQuoted 4 lines · Cathy Zhang
This series implements the infrastructure needed to track and tear down bare-metal enclaves and then run EUPDATESVN. This is expected to be triggered by administrators via sysfs at some convenient time after a microcode update, probably by the microcode update tooling itself.
Cathy, if it isn't abundantly clear by now, everyone seems to hate this part of the implementation.
Let's just make this just do EUPDATESVN as a part of the microcode update process. No new ABI. No trying to preserve enclaves. Kill them early, kill them all, and be done with it.
If we merge that and we have end users chasing us with torches and pitchforks because their precious enclaves were torn down, we'll think about doing something different.