Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp799506pxb; Wed, 15 Sep 2021 13:33:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0vq/XfwKjPWrxnoq67CkrIELZM679E3VV3RqloARgq3S+dIX92pBhDdB2zFZP4bGv1Bfy X-Received: by 2002:a17:906:38ce:: with SMTP id r14mr2080914ejd.268.1631738008374; Wed, 15 Sep 2021 13:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631738008; cv=none; d=google.com; s=arc-20160816; b=hxDGRkCiOEM0R9ihmfP96nfNBFj8Q6Dgojt6Hbkf9Fr+3oPz5K7q+DMW5VRQSoATgO ygdUErvvCBEwKWzLjUkkDTczp2luRELGSWQcho93KAQZdryi+F/XfRj4eHZhGYQucoAo KnVCDdlgNQxvMnp0Uu/483EBbdOuj0AzHSd5AQm56zf+SRPLUbnzMc4TDVZphVLXR6Y5 hclKeurNguazPopfzCdKIrDQPHJ45ALz2n6nH6p4y/DL/dH2TY4ZHZshRtld5N1CZy2y 0dIUYA3Mwheb1UvuNKOOlIXVucpfzZJ5QJLyy1BVlGe6tQ34VyfFGt3dqTgLo1tezCGB rAeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WKiDyceV6wT0gxwl7sTXC7+iTUzsU9RqZKKci4o4Q8M=; b=L9oITIOAXcuaUYSQQzIdgUAo3c1VXAKvUyYHApLVQhdWmWELSrChhKYToAcYfz574K asUsiOjnLFmt6ncxMrvveUpQo7K6JISGDXFuMFqTotHhEwKd1xNZDbUhbM2OuhgDN8tH p/5UAlfq+fLZkpG7mKPLOX58HZobU4+urwjB1pg9F30B4G1K+Uu/jRhMTiJ/f+Ey6EBA UgMEOJeJOClnZmgfAi+AWNO3RMtEkiiPmkx3xKG01Z6SwnojxUXe5vPolVH3Ivd9juYD ApfklqD088boG2NGd03skAZGMGPVmjepDJkOYsnEk+5VfRAYcu6mU93T+YcoXk6DIULN dIvw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si1113219ejt.393.2021.09.15.13.33.02; Wed, 15 Sep 2021 13:33:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232005AbhIOUc4 (ORCPT + 99 others); Wed, 15 Sep 2021 16:32:56 -0400 Received: from mga07.intel.com ([134.134.136.100]:13811 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbhIOUce (ORCPT ); Wed, 15 Sep 2021 16:32:34 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="286109365" X-IronPort-AV: E=Sophos;i="5.85,296,1624345200"; d="scan'208";a="286109365" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 13:31:14 -0700 X-IronPort-AV: E=Sophos;i="5.85,296,1624345200"; d="scan'208";a="545092778" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 13:31:14 -0700 From: Reinette Chatre To: linux-sgx@vger.kernel.org, jarkko@kernel.org, shuah@kernel.org Cc: seanjc@google.com, bp@alien8.de, dave.hansen@linux.intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] selftests/sgx: Dump segments and /proc/self/maps only on failure Date: Wed, 15 Sep 2021 13:30:56 -0700 Message-Id: <968ee11bd65ef200716ec070ec098eb95f0578b6.1631731214.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jarkko Sakkinen Logging is always a compromise between clarity and detail. The main use case for dumping VMA's is when FIXTURE_SETUP() fails, and is less important for enclaves that do initialize correctly. Therefore, print the segments and /proc/self/maps only in the error case. Finally, if a single test ever creates multiple enclaves, the amount of log lines would become enormous. Signed-off-by: Jarkko Sakkinen Signed-off-by: Reinette Chatre --- tools/testing/selftests/sgx/main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c index 6858a35fed20..deab02f2f3ce 100644 --- a/tools/testing/selftests/sgx/main.c +++ b/tools/testing/selftests/sgx/main.c @@ -127,12 +127,6 @@ FIXTURE_SETUP(enclave) ksft_exit_skip("cannot load enclaves\n"); } - for (i = 0; i < self->encl.nr_segments; i++) { - seg = &self->encl.segment_tbl[i]; - - TH_LOG("0x%016lx 0x%016lx 0x%02x", seg->offset, seg->size, seg->prot); - } - if (!encl_measure(&self->encl)) goto err; @@ -169,6 +163,17 @@ FIXTURE_SETUP(enclave) memset(&self->run, 0, sizeof(self->run)); self->run.tcs = self->encl.encl_base; + return; + +err: + encl_delete(&self->encl); + + for (i = 0; i < self->encl.nr_segments; i++) { + seg = &self->encl.segment_tbl[i]; + + TH_LOG("0x%016lx 0x%016lx 0x%02x", seg->offset, seg->size, seg->prot); + } + maps_file = fopen("/proc/self/maps", "r"); if (maps_file != NULL) { while (fgets(maps_line, sizeof(maps_line), maps_file) != NULL) { @@ -181,11 +186,7 @@ FIXTURE_SETUP(enclave) fclose(maps_file); } -err: - if (!sgx_enter_enclave_sym) - encl_delete(&self->encl); - - ASSERT_NE(sgx_enter_enclave_sym, NULL); + ASSERT_TRUE(false); } FIXTURE_TEARDOWN(enclave) -- 2.25.1