Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2992152ybt; Mon, 29 Jun 2020 12:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPN+oi66tpIvUsrOFZ7Vyp7v/rfNIbfyjjq6+LT11uTS2HTy5mG6VpB6jGbT1NBdp7ErjE X-Received: by 2002:a17:906:1187:: with SMTP id n7mr10513266eja.161.1593458315513; Mon, 29 Jun 2020 12:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593458315; cv=none; d=google.com; s=arc-20160816; b=h4VXAnT59navPkmCWSKe1HSn4/MM2wYDNtvM2h3jdg2ioxe1CudmznSPbHibiUJSOW +PM0y5hWY2Uaij3Hlp2Rdw9zyMJsMgTH1fGeeKt/2FmRnVve0ZAJMqhCmGohMavpEkv9 WnN3UhkPtqsVOyS5rQKNAagy2hY2wq4L7Q2etkZbuZEGino/JUYGXoZ+IoPEjMGJoGli /+LVPk7uVMDvUqSd8aR2IV7oLHLo653xDOQIB7itGS/UUHIkokG+H7whT33kosmVg/KO kzRuKytbDRQnbqK0wqu1Fs8iP75+T/wJLKpLPWP2Y0VPZVrz+TpeZ/9Pmb+bICyASyYQ Im3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=E2Vy1BjgpL7djeeIafMFG4u5IsZeMp6SGkzpkdddWqk=; b=0rOBqopERCjYF66A9+KP32/CTQp4ZAsRp4vZoOesnBs2lwCL9PuUFYyFHS9kHRVUHC Xaft0v/eA1FwjD8B+kzGHYhC/rQStQRe6tp+GqxV5fsGcac2rycqO9NI6h9CurKMty/h DJyr0OIdddXbqqm0Xm2vQeMLVEVrlKb7yER4jrqW4KkpKD2xzp/yTkLQR/0dNL2jLJ/T JVhpY/LO9wLmsH9uKZy46G6PwQKGozurqpRg3nDbm89qj+4Fz3ocxeY9RVT0QsS8LyNr MPMV9kU7cgghaYnW9/yERedD1O74PAJk3tjKTKwVPyg/0aXh7b6m0iuT+j4dbbTbkB5T mE1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=CBoXxLFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt16si443287ejc.525.2020.06.29.12.18.12; Mon, 29 Jun 2020 12:18:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=CBoXxLFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731950AbgF2TSK (ORCPT + 99 others); Mon, 29 Jun 2020 15:18:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730984AbgF2TRn (ORCPT ); Mon, 29 Jun 2020 15:17:43 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FD63C03079B; Mon, 29 Jun 2020 08:37:43 -0700 (PDT) Received: from zn.tnic (p200300ec2f09280085fdc63970f65a73.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:2800:85fd:c639:70f6:5a73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 8A1B31EC0281; Mon, 29 Jun 2020 17:37:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1593445058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=E2Vy1BjgpL7djeeIafMFG4u5IsZeMp6SGkzpkdddWqk=; b=CBoXxLFoMIY5VXcvAjrKeGHkctJgQQ+mpYy95c4ccd0Z87tioA+Bk1XaGXpZgf608oRnP4 WbzG9rrLcBktAzNOsrOwzcQC8CIKp04tXZlgE2YypfyeekjI8h9hWQpyLus8riMgcX90WB iXQ8njrtu3RsCR8dpQkSF0SD2QKnOWs= Date: Mon, 29 Jun 2020 17:37:37 +0200 From: Borislav Petkov To: Sean Christopherson Cc: Jarkko Sakkinen , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Jethro Beekman , Haitao Huang , Chunyang Hui , Jordan Hand , Nathaniel McCallum , Seth Moore , Suresh Siddha , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v33 11/21] x86/sgx: Linux Enclave Driver Message-ID: <20200629153737.GA32176@zn.tnic> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-12-jarkko.sakkinen@linux.intel.com> <20200627174335.GC15585@zn.tnic> <20200629152718.GA12312@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200629152718.GA12312@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 08:27:19AM -0700, Sean Christopherson wrote: > Hmm, I was going to say that SGX_ENCL_INITIALIZED can't be checked until > encl->lock is held, but that's not true for this path as mutual exclusion > is provided by the SGX_ENCL_IOCTL flag. So yeah, this can be checked at > the same time as SGX_ENCL_CREATED in sgx_ioc_enclave_init(). Right, so my point is to have state checks for flags which make sense in all ioctl entry points, in order to catch a misuse early. But we're on the same page. > ENCLS[EINIT] is interruptible because it has such a high latency, e.g. 50k+ > cycles on success. If an IRQ/NMI/SMI becomes pending, EINIT may fail with > SGX_UNMASKED_EVENT so that the event can be serviced. > > The idea behind the double loop is to try EINIT in a tight loop, then back > off and sleep for a while before retrying that tight inner loop. That gist of that kinda wants to be in a comment over that double-loop for future on-lookers. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette