From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD39DC433DB for ; Thu, 4 Feb 2021 14:52:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 692A864F4D for ; Thu, 4 Feb 2021 14:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236737AbhBDOwU (ORCPT ); Thu, 4 Feb 2021 09:52:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:44838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236861AbhBDOwG (ORCPT ); Thu, 4 Feb 2021 09:52:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0196064E42; Thu, 4 Feb 2021 14:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612450285; bh=0qYGseK9qf12SS5lXXAuSTG3AzzmKTRorIWU/7nzoEw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dlNzm8dAKbkBKUruPZZi3TYb/UhRCldN/2NOVeBd5wxJ13B7iK7NFn77Fp511bMb3 K/QMAZKneSu0Fqdrg3//TubwABcutxn5J5LY3BUaUWFBDvR8oeiWlg65enEp5S5suC cwr7v04jk9ezr0OLsUC3pzoh8fPZ4McZFrxOBnIo5KJjv2gEIqZ9nB54Dj16W8vKbL 1tpszIvDYbdknpvo2Qg9vVrhgtrXueKBToFoZmnNRsvNfZvpuEYrOyDTSgYnM2Fi5b slDs8YFH810aoTP0JKrnPyBpFF/M9mnFzTuycD+q17utrVVkKUY/C3pOSygWkiGsqj GkfckfFmxSLpQ== Date: Thu, 4 Feb 2021 16:51:17 +0200 From: Jarkko Sakkinen To: Kai Huang Cc: Sean Christopherson , linux-sgx@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org, luto@kernel.org, dave.hansen@intel.com, haitao.huang@intel.com, pbonzini@redhat.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Subject: Re: [RFC PATCH v3 08/27] x86/sgx: Initialize virtual EPC driver even when SGX driver is disabled Message-ID: References: <20210203134906.78b5265502c65f13bacc5e68@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org On Thu, Feb 04, 2021 at 04:20:49PM +1300, Kai Huang wrote: > On Thu, 2021-02-04 at 05:09 +0200, Jarkko Sakkinen wrote: > > On Thu, Feb 04, 2021 at 05:05:56AM +0200, Jarkko Sakkinen wrote: > > > On Thu, Feb 04, 2021 at 03:59:20PM +1300, Kai Huang wrote: > > > > On Thu, 2021-02-04 at 03:39 +0200, Jarkko Sakkinen wrote: > > > > > On Wed, Feb 03, 2021 at 02:59:47PM -0800, Sean Christopherson wrote: > > > > > > On Thu, Feb 04, 2021, Jarkko Sakkinen wrote: > > > > > > > On Wed, Feb 03, 2021 at 01:49:06PM +1300, Kai Huang wrote: > > > > > > > > What working *incorrectly* thing is related to SGX virtualization? The things > > > > > > > > SGX virtualization requires (basically just raw EPC allocation) are all in > > > > > > > > sgx/main.c. > > > > > > > > > > > > > > States: > > > > > > > > > > > > > > A. SGX driver is unsupported. > > > > > > > B. SGX driver is supported and initialized correctly. > > > > > > > C. SGX driver is supported and failed to initialize. > > > > > > > > > > > > > > I just thought that KVM should support SGX when we are either in states A > > > > > > > or B. Even the short summary implies this. It is expected that SGX driver > > > > > > > initializes correctly if it is supported in the first place. If it doesn't, > > > > > > > something is probaly seriously wrong. That is something we don't expect in > > > > > > > a legit system behavior. > > > > > > > > > > > > It's legit behavior, and something we (you?) explicitly want to support. See > > > > > > patch 05, x86/cpu/intel: Allow SGX virtualization without Launch Control support. > > > > > > > > > > What I think would be a sane behavior, would be to allow KVM when > > > > > sgx_drv_init() returns -ENODEV (case A). This happens when LC is > > > > > not enabled: > > > > > > > > > > if (!cpu_feature_enabled(X86_FEATURE_SGX_LC)) > > > > > return -ENODEV; > > > > > > > > > > /Jarkko > > > > > > > > I really don't understand what's the difference between A and C. When "SGX driver is > > > > supported and failed to initialize" happens, it just means "SGX driver is > > > > unsupported". If it is not the case, can you explicitly point out what will be the > > > > problem? > > > > This is as explicit as I can ever possibly get: > > > > A: ret == -ENODEV > > B: ret == 0 > > C: ret != 0 && ret != -ENODEV > > Let me try again: > > Why A and C should be treated differently? What will behave incorrectly, in case of > C? So you don't know what different error codes mean? /Jarkko