tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c- Extension
.c- Size
- 7125 bytes
- Lines
- 271
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdint.hfcntl.herrno.hsys/ioctl.hsys/mman.hasm/uvdevice.hkselftest_harness.h
Detected Declarations
struct test_attest_bufferfunction Authorfunction att_inval_sizes_testfunction att_inval_addr_testfunction main
Annotated Snippet
struct test_attest_buffer {
uint8_t arcb[0x180];
uint8_t meas[64];
uint8_t add[32];
};
FIXTURE(attest_fixture) {
int uv_fd;
struct uvio_ioctl_cb uvio_ioctl;
struct uvio_attest uvio_attest;
struct test_attest_buffer attest_buffer;
__u64 fault_page;
};
FIXTURE_SETUP(attest_fixture)
{
self->uv_fd = open(UV_PATH, O_ACCMODE);
self->uvio_ioctl.argument_addr = (__u64)&self->uvio_attest;
self->uvio_ioctl.argument_len = sizeof(self->uvio_attest);
self->uvio_attest.arcb_addr = (__u64)&self->attest_buffer.arcb;
self->uvio_attest.arcb_len = sizeof(self->attest_buffer.arcb);
self->uvio_attest.meas_addr = (__u64)&self->attest_buffer.meas;
self->uvio_attest.meas_len = sizeof(self->attest_buffer.meas);
self->uvio_attest.add_data_addr = (__u64)&self->attest_buffer.add;
self->uvio_attest.add_data_len = sizeof(self->attest_buffer.add);
self->fault_page =
(__u64)mmap(NULL, (size_t)getpagesize(), PROT_NONE, MAP_ANONYMOUS, -1, 0);
}
FIXTURE_TEARDOWN(attest_fixture)
{
if (self->uv_fd)
close(self->uv_fd);
munmap((void *)self->fault_page, (size_t)getpagesize());
}
static void att_inval_sizes_test(uint32_t *size, uint32_t max_size, bool test_zero,
struct __test_metadata *_metadata,
FIXTURE_DATA(attest_fixture) *self)
{
int rc, errno_cache;
uint32_t tmp = *size;
if (test_zero) {
*size = 0;
rc = ioctl(self->uv_fd, UVIO_IOCTL_ATT, &self->uvio_ioctl);
errno_cache = errno;
ASSERT_EQ(rc, -1);
ASSERT_EQ(errno_cache, EINVAL);
}
*size = max_size + 1;
rc = ioctl(self->uv_fd, UVIO_IOCTL_ATT, &self->uvio_ioctl);
errno_cache = errno;
ASSERT_EQ(rc, -1);
ASSERT_EQ(errno_cache, EINVAL);
*size = tmp;
}
/*
* Test to verify that attestation IOCTLs with invalid values in the UVIO
* attestation control block are rejected.
*/
TEST_F(attest_fixture, att_inval_request)
{
int rc, errno_cache;
att_inval_sizes_test(&self->uvio_attest.add_data_len, UVIO_ATT_ADDITIONAL_MAX_LEN,
false, _metadata, self);
att_inval_sizes_test(&self->uvio_attest.meas_len, UVIO_ATT_MEASUREMENT_MAX_LEN,
true, _metadata, self);
att_inval_sizes_test(&self->uvio_attest.arcb_len, UVIO_ATT_ARCB_MAX_LEN,
true, _metadata, self);
self->uvio_attest.reserved136 = (uint16_t)-1;
rc = ioctl(self->uv_fd, UVIO_IOCTL_ATT, &self->uvio_ioctl);
errno_cache = errno;
ASSERT_EQ(rc, -1);
ASSERT_EQ(errno_cache, EINVAL);
memset(&self->uvio_attest, 0x11, sizeof(self->uvio_attest));
rc = ioctl(self->uv_fd, UVIO_IOCTL_ATT, &self->uvio_ioctl);
ASSERT_EQ(rc, -1);
}
static void att_inval_addr_test(__u64 *addr, struct __test_metadata *_metadata,
FIXTURE_DATA(attest_fixture) *self)
Annotation
- Immediate include surface: `stdint.h`, `fcntl.h`, `errno.h`, `sys/ioctl.h`, `sys/mman.h`, `asm/uvdevice.h`, `kselftest_harness.h`.
- Detected declarations: `struct test_attest_buffer`, `function Author`, `function att_inval_sizes_test`, `function att_inval_addr_test`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.