Переглянути джерело

[Pal/Linux-SGX] pal-sgx-sign: add enable_avx option and drop disable_avx option

For consistency, add enable_avx option in addition to enable_avx512 and
drop disable_avx option. Because this is incompatible change, update
affected manifest.template file.

Attribute tracking logic is changed to use set because list may cause
ValueError.
Isaku Yamahata 5 роки тому
батько
коміт
8e894b10d0

+ 2 - 1
Pal/regression/AvxDisable.manifest.template

@@ -1,2 +1,3 @@
-sgx.disable_avx = 1
+sgx.enable_avx = 0
+sgx.enable_avx512 = 0
 sgx.allowed_files.res = file:avxRes

+ 6 - 9
Pal/src/host/Linux-SGX/signer/pal-sgx-sign

@@ -148,17 +148,18 @@ def get_enclave_attributes(manifest):
         'MISC_EXINFO'         : struct.pack("<L", SGX_MISCSELECT_EXINFO),
     }
 
-    default_attributes = [
+    default_attributes = {
         'FLAG_DEBUG',
         'XFRM_LEGACY',
         'XFRM_AVX',
-    ]
+    }
 
     if ARCHITECTURE == 'amd64':
-        default_attributes.append('FLAG_MODE64BIT')
+        default_attributes.add('FLAG_MODE64BIT')
 
     manifest_options = {
         'debug'          : 'FLAG_DEBUG',
+        'enable_avx'     : 'XFRM_AVX',
         'enable_avx512'  : 'XFRM_AVX512',
         'enable_mpx'     : 'XFRM_MPX',
         'support_exinfo' : 'MISC_EXINFO',
@@ -170,13 +171,9 @@ def get_enclave_attributes(manifest):
         key = 'sgx.' + opt
         if key in manifest:
             if manifest[key] == '1':
-                attributes.append(manifest_options[opt])
+                attributes.add(manifest_options[opt])
             else:
-                if manifest_options[opt] in attributes:
-                    attributes.pop(manifest_options[opt])
-
-    if manifest.get('sgx.disable_avx') == '1':
-      attributes.remove('XFRM_AVX')
+                attributes.discard(manifest_options[opt])
 
     flags_raw = struct.pack("<Q", 0)
     xfrms_raw = struct.pack("<Q", 0)