lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 18 Mar 2021 13:04:35 +1300
From:   Kai Huang <kai.huang@...el.com>
To:     Jarkko Sakkinen <jarkko@...nel.org>
Cc:     Sean Christopherson <seanjc@...gle.com>, kvm@...r.kernel.org,
        linux-sgx@...r.kernel.org, x86@...nel.org,
        linux-kernel@...r.kernel.org, luto@...nel.org,
        dave.hansen@...el.com, rick.p.edgecombe@...el.com,
        haitao.huang@...el.com, pbonzini@...hat.com, bp@...en8.de,
        tglx@...utronix.de, mingo@...hat.com, hpa@...or.com
Subject: Re: [PATCH v2 07/25] x86/sgx: Initialize virtual EPC driver even
 when SGX driver is disabled

On Tue, 16 Mar 2021 14:46:05 +0200 Jarkko Sakkinen wrote:
> On Mon, Mar 15, 2021 at 06:13:53PM -0700, Sean Christopherson wrote:
> > On Tue, Mar 16, 2021, Jarkko Sakkinen wrote:
> > > On Tue, Mar 16, 2021 at 01:05:05AM +0200, Jarkko Sakkinen wrote:
> > > > The way I've understood it is that given that KVM can support SGX
> > > > without FLC, vEPC should be available even if driver cannot be
> > > > enabled.
> > > > 
> > > > This is also exactly what the short summary states.
> > > > 
> > > > "Initialize virtual EPC driver even when SGX driver is disabled"
> > > > 
> > > > It *does not* state:
> > > > 
> > > > "Initialize SGX driver even when vEPC driver is disabled"
> > > > 
> > > > Also, this is how I interpret the inline comment.
> > > > 
> > > > All this considered, the other direction is undocumented functionality.
> > > 
> > > Also:
> > > 
> > > 1. There is *zero* good practical reasons to support the "2nd direction".
> > 
> > Uh, yes there is.  CONFIG_KVM_INTEL=n and X86_FEATURE_VMX=n, either of which
> > will cause vEPC initialization to fail.  The former is obvious, the latter is
> > possible via BIOS configuration.
> 
> Hmm... So you make the checks as if ret != -ENODEV? That's the sane way to
> deal with that situation IMHO.
> 
> /Jarkko

OK. I actually wrote the code to show your idea:

-       ret = sgx_drv_init();
-       if (ret)
+       /*
+        * Only continue to initialize SGX driver when SGX virtualization
+        * initialization is successful, or is not supported (-ENODEV), since
+        * any other initialization failure means SGX driver is unlikely to be
+        * initialized successfully.
+        */
+       ret = sgx_vepc_init();
+       if (ret && ret != -ENODEV)
                goto err_kthread;
 
+       if (sgx_drv_init()) {
+               /*
+                * Cleanup when *both* SGX virtualization and SGX driver are
+                * not enabled, due to either not supported (-ENODEV), or
+                * somehow fail to initialize.
+                */
+               if (ret && ret != -ENODEV)
+                       goto err_kthread;
+       }
+
        return 0;
 
 err_kthread:


Is this the code you want?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ