Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5924966pxv; Wed, 7 Jul 2021 15:13:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9e9VQDicgugcTx58FXz5TUbB6XGiFh8Ky6vaJt82DDUi97CFNQRsW3AYPvaLwr5rJTYo7 X-Received: by 2002:a50:fc0b:: with SMTP id i11mr32960643edr.383.1625696025853; Wed, 07 Jul 2021 15:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625696025; cv=none; d=google.com; s=arc-20160816; b=bdSZ2PQ5jNJ03U821RkXEx2sYx+NY8CtuKpBWY3hZhSwLs96RQ3+sbnrkviwmmHl3o QrLhKhKn3FkfcHLn9D7+qw1INtv8l3t9yXbVyoPSxICONv8jwuMVrV7cWU/WQsaln9fP g+h9xnl9uA0olx0Kn4AH2mkajSwuWRfvuk6ziDPAHFWlFaWfaMZ0rHQXs8t5SlrbOyAL Oa/RSNIgp67APJ6lHK5flMcfqIP3eAj7z3Z9bWLkHdCFkhOShABDN6sUX5jik1rS7P2u Y8gblCWbdELrxhNRxGSNk6QTq8G4pnkhgupbP3ADJVphkkda5a3X3nB40gmDUnBT/Kbu aumQ== 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=Ezpb8DKcaKaKFDD6KoUbAFwPIgxKb9mV8Oh5LYOAk1c=; b=MltRH/6G1WH7eQiasaZ9s33jyPUIOBss8oGae94foRfHbtpuswOYhDjYg0usMlQ+Hs SNc91Yi9qmj7jBX85CYoYvOEQfdI7ogTgW0lPbzKDbLnm+3A6OqnNnLpmSpS3O6iKQvf AJ9OkQPWufi+pgj+L/2Atxjl/gAyDhBekDIjO2CJnCWtdzm75f8EwPFmUENSaeg5A9C3 3nWB/tYcowU8lkadG4o0/6iNchq6lQrWG7ziuM0xQfIUABmtpmA3RDbv+rAfLtolHiGA lJ58KK1UOISpDR8xGR3l0i0ZZT/K3k3JVoKgOKG9hT/+1UIdiK/cK+Eohcrj1KsXkRq5 q6eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i3mCVC2z; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si289635eje.13.2021.07.07.15.13.22; Wed, 07 Jul 2021 15:13:45 -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=@kernel.org header.s=k20201202 header.b=i3mCVC2z; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230492AbhGGUxD (ORCPT + 99 others); Wed, 7 Jul 2021 16:53:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbhGGUxD (ORCPT ); Wed, 7 Jul 2021 16:53:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D259B61CB0; Wed, 7 Jul 2021 20:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625691022; bh=9zDDWkBWSm0T5z6aXmZqdehpL2Wuu1uLQ4ONnfG8f/g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i3mCVC2zi7QCTtx99z0UQWcvt4aCEkN1puxnjBGJdQs0UMM0755abE3ReSXyDIQcl Yg2z0C8BrDrelfrId+E2cCfC13p5KUtC8tgbVpEDUYxbpQDki5kqS7ICgcajQumIhY vjRGWXC1KvskFm2sfwduOuoDx0gQVT4vicEhCVTbGXB6CuNH+WwVsL9VApc7s+qZ4E b+1gjmtlVFtxizvI5Z8vwq3NjsfAPTHXGnSpMRjeZx6G33qsebGNy9hf7iMlUYG0yb LxA4WbeZX+eE+4MAowwBvyTz9k+CbmYLqcfd1r5dd+KPB6Sob3HeJWVDoRvmLsFysl rlfdUeYIArguQ== Date: Wed, 7 Jul 2021 23:50:19 +0300 From: Jarkko Sakkinen To: Reinette Chatre Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-sgx@vger.kernel.org, Borislav Petkov , Dave Hansen , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] selftests/sgx: Trigger the reclaimer and #PF handler Message-ID: <20210707205019.6jy64s4uqcw65q4h@kernel.org> References: <20210705143652.116125-1-jarkko@kernel.org> <20210705143652.116125-5-jarkko@kernel.org> <715ed555-5044-6fee-1d09-1c4cfa827af3@intel.com> <20210706235016.uucukyrr3ckk57pi@kernel.org> <16505466-e001-c4b0-ec41-5384ddcf194b@intel.com> <20210707091736.6wzemgmtzuegk3uf@kernel.org> <10664754-7e53-d9d1-f00c-f9dbd4a2d877@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10664754-7e53-d9d1-f00c-f9dbd4a2d877@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 07, 2021 at 08:02:42AM -0700, Reinette Chatre wrote: > Hi Jarkko, > > On 7/7/2021 2:17 AM, Jarkko Sakkinen wrote: > > On Tue, Jul 06, 2021 at 05:10:38PM -0700, Reinette Chatre wrote: > > > Hi Jarkko, > > > > > > On 7/6/2021 4:50 PM, Jarkko Sakkinen wrote: > > > > On Tue, Jul 06, 2021 at 11:34:54AM -0700, Reinette Chatre wrote: > > > > > Hi Jarkko, > > > > > > > > > > On 7/5/2021 7:36 AM, Jarkko Sakkinen wrote: > > > > > > Create a heap for the test enclave, which has the same size as all > > > > > > available Enclave Page Cache (EPC) pages in the system. This will guarantee > > > > > > that all test_encl.elf pages *and* SGX Enclave Control Structure (SECS) > > > > > > have been swapped out by the page reclaimer during the load time. Actually, > > > > > > this adds a bit more stress than that since part of the EPC gets reserved > > > > > > for the Version Array (VA) pages. > > > > > > > > > > > > For each test, the page fault handler gets triggered in two occasions: > > > > > > > > > > > > - When SGX_IOC_ENCLAVE_INIT is performed, SECS gets swapped in by the > > > > > > page fault handler. > > > > > > - During the execution, each page that is referenced gets swapped in > > > > > > by the page fault handler. > > > > > > > > > > > > > > > > If I understand this correctly, all EPC pages are now being consumed during > > > > > fixture setup and thus every SGX test, no matter how big or small, now > > > > > becomes a stress test of the reclaimer instead of there being a unique > > > > > reclaimer test. Since an enclave is set up and torn down for every test this > > > > > seems like a significant addition. It also seems like this would impact > > > > > future tests of dynamic page addition where not all scenarios could be > > > > > tested with all EPC pages already consumed. > > > > > > > > > > Reinette > > > > > > > > Re-initializing the test enclave is mandatory thing to do for all tests > > > > because it has an internals state. > > > > > > > > > > Right, but not all tests require the same enclave. In kselftest terminology > > > I think you are attempting to force all tests to depend on the same test > > > fixture. Is it not possible to have a separate "reclaimer" test fixture that > > > would build an enclave with a large heap and then have reclaimer tests that > > > exercise it by being tests that are specific to this "reclaimer fixture"? > > > > > > Reinette > > > > Why add that complexity? > > > > With this change every test is turned into a pseudo reclaimer test without > there being any explicit testing (with pass/fail criteria) of reclaimer > behavior. This is an expensive addition and reduces the scenarios that the > tests can exercise. > > Reinette There is consistent known behaviour how reclaimer and also the page fault are exercised for each test. I think that is what matters most right now that the basic behaviour of both the page reclaimer and page fault handler gets exercised. I don't understand the real-world gain of doing something factors more complex than necessary at a particular point of time, when you don't really need to hang yourself into it forever. This patch does increase the coverage in a deterministic manner to the code paths that were not previously exercised, i.e. we know the code paths, and could even calculate the exact number of times that they are triggered. And without doing anything obscure. That's what matters to me. /Jarkko /Jarkko