Message ID | 20220816051656.3622-1-haitao.huang@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | selftests/sgx: retry the ioctls returned with EAGAIN | expand |
On Mon, Aug 15, 2022 at 10:16:56PM -0700, Haitao Huang wrote: > For EMODT and EREMOVE ioctls with a large range, kernel > may not finish in one shot and return EAGAIN error code > and count of bytes of EPC pages on that operations are > finished successfully. > > Change the unclobbered_vdso_oversubscribed_remove test > to rerun the ioctls in a loop, updating offset and length > using the byte count returned in each iteration. > > Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com> > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Also, Tested-by: Jarkko Sakkinen <jarkko@kernel.org> Dave, in addition to [*], these should be picked x86 tree for v6.0 https://lore.kernel.org/linux-sgx/20220815233900.11225-1-jarkko@kernel.org/T/#t BR, Jarkko
On 8/16/22 07:24, Jarkko Sakkinen wrote: > Dave, in addition to [*], these should be picked x86 tree for v6.0 > > https://lore.kernel.org/linux-sgx/20220815233900.11225-1-jarkko@kernel.org/T/#t Was there an ack somewhere in that thread that I missed?
On Mon, Aug 22, 2022 at 04:24:50PM -0700, Dave Hansen wrote: > On 8/16/22 07:24, Jarkko Sakkinen wrote: > > Dave, in addition to [*], these should be picked x86 tree for v6.0 > > > > https://lore.kernel.org/linux-sgx/20220815233900.11225-1-jarkko@kernel.org/T/#t > > Was there an ack somewhere in that thread that I missed? Yes, both had mine. I sent both unmodified bundled into a single patch set, except cosmetic changes to the commit message. The discussion that followed up came up a day later I've send that response. The next version will be lacking ack's, given that I'm modifying the patches, i.e. will be disqualified to review them. BR, Jarkko
On Thu, Aug 25, 2022 at 07:42:18AM +0300, Jarkko Sakkinen wrote: > On Mon, Aug 22, 2022 at 04:24:50PM -0700, Dave Hansen wrote: > > On 8/16/22 07:24, Jarkko Sakkinen wrote: > > > Dave, in addition to [*], these should be picked x86 tree for v6.0 > > > > > > https://lore.kernel.org/linux-sgx/20220815233900.11225-1-jarkko@kernel.org/T/#t > > > > Was there an ack somewhere in that thread that I missed? > > Yes, both had mine. > > I sent both unmodified bundled into a single patch set, except cosmetic > changes to the commit message. The discussion that followed up came up a > day later I've send that response. > > The next version will be lacking ack's, given that I'm modifying the > patches, i.e. will be disqualified to review them. Also, the next version will include additional patch for a bpftrace script derived from what I tossed with Haitao in order to root cause the error. Probably useful to have available, as it did the trick. BR, Jarkko
diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c index 9820b3809c69..9c8b5868b0f3 100644 --- a/tools/testing/selftests/sgx/main.c +++ b/tools/testing/selftests/sgx/main.c @@ -391,7 +391,7 @@ TEST_F_TIMEOUT(enclave, unclobbered_vdso_oversubscribed_remove, 900) unsigned long total_mem; int ret, errno_save; unsigned long addr; - unsigned long i; + unsigned long i, count; /* * Create enclave with additional heap that is as big as all @@ -453,16 +453,27 @@ TEST_F_TIMEOUT(enclave, unclobbered_vdso_oversubscribed_remove, 900) modt_ioc.offset = heap->offset; modt_ioc.length = heap->size; modt_ioc.page_type = SGX_PAGE_TYPE_TRIM; - + count = 0; TH_LOG("Changing type of %zd bytes to trimmed may take a while ...", heap->size); - ret = ioctl(self->encl.fd, SGX_IOC_ENCLAVE_MODIFY_TYPES, &modt_ioc); - errno_save = ret == -1 ? errno : 0; + do { + ret = ioctl(self->encl.fd, SGX_IOC_ENCLAVE_MODIFY_TYPES, &modt_ioc); + errno_save = ret == -1 ? errno : 0; + if (errno_save == EAGAIN) { + count += modt_ioc.count; + modt_ioc.offset += modt_ioc.count; + modt_ioc.length -= modt_ioc.count; + modt_ioc.result = 0; + modt_ioc.count = 0; + } else + break; + } while (modt_ioc.length != 0); EXPECT_EQ(ret, 0); EXPECT_EQ(errno_save, 0); EXPECT_EQ(modt_ioc.result, 0); - EXPECT_EQ(modt_ioc.count, heap->size); + count += modt_ioc.count; + EXPECT_EQ(count, heap->size); /* EACCEPT all removed pages. */ addr = self->encl.encl_base + heap->offset; @@ -490,15 +501,25 @@ TEST_F_TIMEOUT(enclave, unclobbered_vdso_oversubscribed_remove, 900) remove_ioc.offset = heap->offset; remove_ioc.length = heap->size; - + count = 0; TH_LOG("Removing %zd bytes from enclave may take a while ...", heap->size); - ret = ioctl(self->encl.fd, SGX_IOC_ENCLAVE_REMOVE_PAGES, &remove_ioc); - errno_save = ret == -1 ? errno : 0; + do { + ret = ioctl(self->encl.fd, SGX_IOC_ENCLAVE_REMOVE_PAGES, &remove_ioc); + errno_save = ret == -1 ? errno : 0; + if (errno_save == EAGAIN) { + count += remove_ioc.count; + remove_ioc.offset += remove_ioc.count; + remove_ioc.length -= remove_ioc.count; + remove_ioc.count = 0; + } else + break; + } while (remove_ioc.length != 0); EXPECT_EQ(ret, 0); EXPECT_EQ(errno_save, 0); - EXPECT_EQ(remove_ioc.count, heap->size); + count += remove_ioc.count; + EXPECT_EQ(count, heap->size); } TEST_F(enclave, clobbered_vdso)