Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp21561rwe; Tue, 30 Aug 2022 19:54:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR61EGy+e79ONUYcUG2EL6x6GyhBXO5gN+pJ7zNmJSOhnKIZtF+N5dyWeMXdQedG0EuG6qWO X-Received: by 2002:a17:903:189:b0:175:4643:f862 with SMTP id z9-20020a170903018900b001754643f862mr345129plg.5.1661914466345; Tue, 30 Aug 2022 19:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661914466; cv=none; d=google.com; s=arc-20160816; b=TjLHBRXQS3nJYPzCpcG9M4Cpks442IhBEBbbJaHAidVU1hvw86M0p2Di33lWNpu4NK 9Cexutpsu4RHBSw6hiVNceUeImPQs81qluJIy3MBilqKwxBS9MvB9n5VA6L/QW2dXk30 WRMvCkzTFK3V8ktL5fWQLv1dGlo39bnRklVXPHl2JFv/En9v6wGkrNzf0w6r0MdGhpfZ 4s1ecnXjBiH29xRMOeItXXtNmBxWJnzSKMqm0VNhsZOI9vaAgrZ9S8gvo5xAmMd7hXrM IB1g/meMIU9u4JjjxEez118AE9UvOgdGkXSyYLGmTKlY2/lRJzDIkNyUh8yScGVD0WXR f7DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9twwJluKsdF+MxWGalqadX4BhuagjdpZskv8RUnf9Qc=; b=WLVXC9cyju5Zc0jPKbIuV3qvPuswOyQjBxsyAQhIO94Jt+gPFXE1NrjHlKuFgqaykG dBQ1RJRZ7eBg23Fe3mZwMaZb3Rhtx/xe+Ooxj4ztaL5c4aI/Do6K0wPBaRutpKY5lFJq wdDHCvCQxJYevHf1ZhInnj4EzzPSg+tfu7+Y+8eSO5QFLNT/PDM3/vXIgHKucXQ1ltKF Ipz207qfImDUs/xzQCfxihy6sKvmk0T2MeTJZlu8qjnnsrREkG2tb40xdwNzwbeLbS5V j1tsvBfh79G8RuWR5UIJktIDZfxQnAOqDMNs6V9TYJnSUP9jyA1S1GE9Yf4nwRDdarLW 33CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=imqGM4z4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg10-20020a1709028e8a00b00170d34b95e0si3989817plb.85.2022.08.30.19.54.03; Tue, 30 Aug 2022 19:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=imqGM4z4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231975AbiHaCpH (ORCPT + 99 others); Tue, 30 Aug 2022 22:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbiHaCpB (ORCPT ); Tue, 30 Aug 2022 22:45:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1FF418356; Tue, 30 Aug 2022 19:44:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3FB026192E; Wed, 31 Aug 2022 02:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C52EC433C1; Wed, 31 Aug 2022 02:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661913897; bh=7akbOTuRrQCIYuRF795lZFUhzM12WJ++N4hz4TsdqRY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=imqGM4z4RM0CDiFVkP9CAajSeG7O3pvtiLwE4XSBPpDjhIYllmNoQuy8sFUFh/z6e 6hdhmRVf2HP3twPL5fM4yKcQ/D5YkH/FnB4XnvOiaZU4jAYrIq4CIF/lG1hEjUsD7d E08h8+p+/KZnsCciLi27IY3ioGruBuY519ccNFPq7krSDFzvPhEO7QTAFVF7HcihWv XazRWtMJ9Oa9aTnMnJW9jWsvCpsHwQCl4qOIKR+VhlpxA00z7G5WX0+sCMoQ8hnJ7U t4ZCORE7ow2YF9HCwcjiMiFS+mdojBxe4QA1RjwBGlsnfnMpixHDBOUSRtOLNHR5s9 2rcHplJiRBdpg== Date: Wed, 31 Aug 2022 05:44:53 +0300 From: "jarkko@kernel.org" To: "Huang, Kai" Cc: "pmenzel@molgen.mpg.de" , "linux-sgx@vger.kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "Dhanraj, Vijay" , "Chatre, Reinette" , "mingo@redhat.com" , "tglx@linutronix.de" , "bp@alien8.de" , "haitao.huang@linux.intel.com" , "hpa@zytor.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/6] x86/sgx: Do not consider unsanitized pages an error Message-ID: References: <20220830031206.13449-1-jarkko@kernel.org> <20220830031206.13449-2-jarkko@kernel.org> <1f43e7b9-c101-3872-bd1b-add66933b285@intel.com> <1b3308a364317d36ad41961ea9cfee24aa122f02.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 31, 2022 at 02:35:53AM +0000, Huang, Kai wrote: > On Wed, 2022-08-31 at 05:15 +0300, jarkko@kernel.org wrote: > > On Wed, Aug 31, 2022 at 01:27:58AM +0000, Huang, Kai wrote: > > > On Tue, 2022-08-30 at 15:54 -0700, Reinette Chatre wrote: > > > > Hi Jarkko, > > > > > > > > On 8/29/2022 8:12 PM, Jarkko Sakkinen wrote: > > > > > In sgx_init(), if misc_register() for the provision device fails, and > > > > > neither sgx_drv_init() nor sgx_vepc_init() succeeds, then ksgxd will be > > > > > prematurely stopped. > > > > > > > > I do not think misc_register() is required to fail for the scenario to > > > > be triggered (rather use "or" than "and"?). Perhaps just > > > > "In sgx_init(), if a failure is encountered after ksgxd is started > > > > (via sgx_page_reclaimer_init()) ...". > > > > > > IMHO "a failure" might be too vague. For instance, failure to sgx_drv_init() > > > won't immediately result in ksgxd to stop prematurally. As long as KVM SGX can > > > be initialized successfully, sgx_init() still returns 0. > > > > > > Btw I was thinking whether we should move sgx_page_reclaimer_init() to the end > > > of sgx_init(), after we make sure at least one of the driver and the KVM SGX is > > > initialized successfully. Then the code change in this patch won't be necessary > > > if I understand correctly. AFAICT there's no good reason to start the ksgxd at > > > early stage before we are sure either the driver or KVM SGX will work. > > > > I would focus fixing the existing flow rather than reinventing the flow. > > > > It can be made to work, and therefore it is IMHO correct action to take. > > From another perspective, the *existing flow* is the reason which causes this > bug. A real fix is to fix the flow itself. Any existing flow in part of the kernel can have a bug. That does not mean that switching flow would be proper way to fix a bug. BR, Jarkko