Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4876398pxj; Wed, 12 May 2021 15:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVrx3VzRq/GKmKbKm0sBcjnMehoxY+GzSbUH6PpjP2lnwWvZNstIXcrWFsxyHD435sCGgP X-Received: by 2002:a50:f41a:: with SMTP id r26mr46000387edm.339.1620858271278; Wed, 12 May 2021 15:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620858271; cv=none; d=google.com; s=arc-20160816; b=zqxiRFPaF1PRcsveLabJqngM0aEv5PFM0vBpDI+xtEaBVCttH5uCKHz7HQ0QkMLd7T IEv8V49JVtD6qIrdxabRKoK2oDvRogUAU2CvuxlFVZ60Q6pMlj30gvKyzlYiqMKagqNy U5S1OPGDfkKwjW9aqDR7uFH3b1mIe34qZnZ4DgUNGaI5cN4BO0p9lHBYE5cKHzncrGgo WcqVeWbe2MsXl25963/5TLAWCt1fQanHMYJFQZ1gJ0tUny/OnrQFVPWAkewZvoR5erVt t55TteFyEwp0LidNMUHrUErJxcM3aGWESWstM+VLZh5WmVVAXJL5XMrK5RNssRycVG4Q 2Wyw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=bNYtR8vR57NR8qBTFrCH6GVvu/m3IzC46S8vgpTD30k=; b=t1LoPJfwB4YsvaMv+q/YmT8uhNxTweEsdcF2mErWGC7kbxZVoLDf1lJ4h9MDxB0Sju lIAqgOpm3tj1u4xzMb9gBqpARuvAR90ggkKCq4hJ4w7jm+tzHZDmrw8nwnBg65YWaJmX teo3AnVmYx0cOQw/aedQfAyv96c5yKGq0mB0Yy9Ra5k7wse4p/IVlpnwPPZS9jkGes98 Nh3P2CzWLnD4XvFMscFg2B2YrHwXS1Q9psz4nwzcuqIS+RHYOpd8U413b88GGAUGFQAB bnrSEVuVPQhTuVVz2nRrtdbg6MKFA8ON0bbmr78CB92pvddlrZbaAuU7oePg0RQrg2c2 fa0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VULSSm+3; 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 ka15si1200920ejc.148.2021.05.12.15.24.06; Wed, 12 May 2021 15:24:31 -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=VULSSm+3; 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 S1443511AbhELWUG (ORCPT + 99 others); Wed, 12 May 2021 18:20:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347652AbhELVyv (ORCPT ); Wed, 12 May 2021 17:54:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7CBB6121E; Wed, 12 May 2021 21:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620856416; bh=EPv1u0azdmPO9qKoh7wx6ebVCAg50T2BxrxpYsroTDs=; h=From:To:Cc:Subject:Date:From; b=VULSSm+3YNij6JWlBdDJ0sT9vh3GVtnwdEQ6iQF1s3ibZK4ROyx2uROkbY5BhorlF nD8aW7ZxwvUj6L3Om5gDJi8lFah8otfagmVYhPqfqgmv6COEziUnWWC+yJdmFKqnir kX8X5QDe5RJpVSIjOUZKwQg4xlevyI6xx/o1231hyxcDG3drmM360WEHLkFixdjRbz DRrUfj6uxMZBgHgLtZDRgKVxHNUXqNwjc09wDnaH6lHFQKlIzG66smnmMfwyHStQ6j gfUSgcRl2Y4gRMM2h3NRx/ONhXJkWs3WdUViB3XqnxsJOgope2ZD9AIr/jV60hBy7G 8GdEyp70x+5wg== From: Jarkko Sakkinen To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-sgx@vger.kernel.org, Reinette Chatre , Jarkko Sakkinen , Dave Hansen , linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] selftests/sgx: Rename 'eenter' and 'sgx_call_vdso' Date: Thu, 13 May 2021 00:53:22 +0300 Message-Id: <20210512215323.420639-1-jarkko@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename symbols for better clarity: * 'eenter' might be confused for directly calling ENCLU[EENTER]. It does not. It calls into the VDSO, which actually has the EENTER instruction. * 'sgx_call_vdso' is *only* used for entering the enclave. It's not some generic SGX call into the VDSO. Signed-off-by: Jarkko Sakkinen --- v3: Refine the commit message according to Dave's suggestions. v2: Refined the renames just a bit. tools/testing/selftests/sgx/call.S | 6 +++--- tools/testing/selftests/sgx/main.c | 25 +++++++++++++------------ tools/testing/selftests/sgx/main.h | 4 ++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/sgx/call.S b/tools/testing/selftests/sgx/call.S index 4ecadc7490f4..b09a25890f3b 100644 --- a/tools/testing/selftests/sgx/call.S +++ b/tools/testing/selftests/sgx/call.S @@ -5,8 +5,8 @@ .text - .global sgx_call_vdso -sgx_call_vdso: + .global sgx_enter_enclave +sgx_enter_enclave: .cfi_startproc push %r15 .cfi_adjust_cfa_offset 8 @@ -27,7 +27,7 @@ sgx_call_vdso: .cfi_adjust_cfa_offset 8 push 0x38(%rsp) .cfi_adjust_cfa_offset 8 - call *eenter(%rip) + call *vdso_sgx_enter_enclave(%rip) add $0x10, %rsp .cfi_adjust_cfa_offset -0x10 pop %rbx diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c index d304a4044eb9..43da68388e25 100644 --- a/tools/testing/selftests/sgx/main.c +++ b/tools/testing/selftests/sgx/main.c @@ -21,7 +21,7 @@ #include "../kselftest.h" static const uint64_t MAGIC = 0x1122334455667788ULL; -vdso_sgx_enter_enclave_t eenter; +vdso_sgx_enter_enclave_t vdso_sgx_enter_enclave; struct vdso_symtab { Elf64_Sym *elf_symtab; @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { struct sgx_enclave_run run; struct vdso_symtab symtab; - Elf64_Sym *eenter_sym; + Elf64_Sym *sgx_enter_enclave_sym; uint64_t result = 0; struct encl encl; unsigned int i; @@ -194,29 +194,30 @@ int main(int argc, char *argv[]) if (!vdso_get_symtab(addr, &symtab)) goto err; - eenter_sym = vdso_symtab_get(&symtab, "__vdso_sgx_enter_enclave"); - if (!eenter_sym) + sgx_enter_enclave_sym = vdso_symtab_get(&symtab, "__vdso_sgx_enter_enclave"); + if (!sgx_enter_enclave_sym) goto err; - eenter = addr + eenter_sym->st_value; + vdso_sgx_enter_enclave = addr + sgx_enter_enclave_sym->st_value; - ret = sgx_call_vdso((void *)&MAGIC, &result, 0, EENTER, NULL, NULL, &run); - if (!report_results(&run, ret, result, "sgx_call_vdso")) + ret = sgx_enter_enclave((void *)&MAGIC, &result, 0, EENTER, + NULL, NULL, &run); + if (!report_results(&run, ret, result, "sgx_enter_enclave_unclobbered")) goto err; /* Invoke the vDSO directly. */ result = 0; - ret = eenter((unsigned long)&MAGIC, (unsigned long)&result, 0, EENTER, - 0, 0, &run); - if (!report_results(&run, ret, result, "eenter")) + ret = vdso_sgx_enter_enclave((unsigned long)&MAGIC, (unsigned long)&result, + 0, EENTER, 0, 0, &run); + if (!report_results(&run, ret, result, "sgx_enter_enclave")) goto err; /* And with an exit handler. */ run.user_handler = (__u64)user_handler; run.user_data = 0xdeadbeef; - ret = eenter((unsigned long)&MAGIC, (unsigned long)&result, 0, EENTER, - 0, 0, &run); + ret = vdso_sgx_enter_enclave((unsigned long)&MAGIC, (unsigned long)&result, + 0, EENTER, 0, 0, &run); if (!report_results(&run, ret, result, "user_handler")) goto err; diff --git a/tools/testing/selftests/sgx/main.h b/tools/testing/selftests/sgx/main.h index 67211a708f04..68672fd86cf9 100644 --- a/tools/testing/selftests/sgx/main.h +++ b/tools/testing/selftests/sgx/main.h @@ -35,7 +35,7 @@ bool encl_load(const char *path, struct encl *encl); bool encl_measure(struct encl *encl); bool encl_build(struct encl *encl); -int sgx_call_vdso(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9, - struct sgx_enclave_run *run); +int sgx_enter_enclave(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9, + struct sgx_enclave_run *run); #endif /* MAIN_H */ -- 2.31.1