tools/testing/selftests/kvm/s390/memop.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/s390/memop.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/s390/memop.c- Extension
.c- Size
- 32263 bytes
- Lines
- 1188
- 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
stdio.hstdlib.hstring.hsys/ioctl.hpthread.hlinux/bits.htest_util.hkvm_util.hkselftest.hucall_common.hprocessor.h
Detected Declarations
struct mop_descstruct test_infostruct test_defaultstruct testdefenum mop_targetenum mop_access_modeenum stagefunction ksmo_from_descfunction print_memopfunction err_memop_ioctlfunction memop_ioctlfunction test_default_initfunction prepare_mem12function default_write_readfunction default_readfunction default_cmpxchgfunction guest_copyfunction test_copyfunction test_copy_access_registerfunction set_storage_key_rangefunction guest_copy_keyfunction test_copy_keyfunction test_cmpxchg_keyfunction cut_to_sizefunction popcount_eqfunction rotatefunction choose_blockfunction permutate_bitsfunction _cmpxchgfunction guest_cmpxchg_keyfunction test_cmpxchg_key_concurrentfunction guest_copy_key_fetch_protfunction test_copy_key_storage_prot_overridefunction test_copy_key_fetch_protfunction guest_error_keyfunction test_errors_keyfunction test_errors_cmpxchg_keyfunction test_terminationfunction test_errors_key_storage_prot_overridefunction guest_copy_key_fetch_prot_overridefunction test_copy_key_fetch_prot_overridefunction test_errors_key_fetch_prot_override_not_enabledfunction test_errors_key_fetch_prot_override_enabledfunction guest_idlefunction _test_errors_commonfunction test_errorsfunction test_errors_cmpxchgfunction main
Annotated Snippet
struct mop_desc {
uintptr_t gaddr;
uintptr_t gaddr_v;
u64 set_flags;
unsigned int f_check : 1;
unsigned int f_inject : 1;
unsigned int f_key : 1;
unsigned int _gaddr_v : 1;
unsigned int _set_flags : 1;
unsigned int _sida_offset : 1;
unsigned int _ar : 1;
u32 size;
enum mop_target target;
enum mop_access_mode mode;
void *buf;
u32 sida_offset;
void *old;
u8 old_value[16];
bool *cmpxchg_success;
u8 ar;
u8 key;
};
const u8 NO_KEY = 0xff;
static struct kvm_s390_mem_op ksmo_from_desc(struct mop_desc *desc)
{
struct kvm_s390_mem_op ksmo = {
.gaddr = (uintptr_t)desc->gaddr,
.size = desc->size,
.buf = ((uintptr_t)desc->buf),
.reserved = "ignored_ignored_ignored_ignored"
};
switch (desc->target) {
case LOGICAL:
if (desc->mode == READ)
ksmo.op = KVM_S390_MEMOP_LOGICAL_READ;
if (desc->mode == WRITE)
ksmo.op = KVM_S390_MEMOP_LOGICAL_WRITE;
break;
case SIDA:
if (desc->mode == READ)
ksmo.op = KVM_S390_MEMOP_SIDA_READ;
if (desc->mode == WRITE)
ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
break;
case ABSOLUTE:
if (desc->mode == READ)
ksmo.op = KVM_S390_MEMOP_ABSOLUTE_READ;
if (desc->mode == WRITE)
ksmo.op = KVM_S390_MEMOP_ABSOLUTE_WRITE;
if (desc->mode == CMPXCHG) {
ksmo.op = KVM_S390_MEMOP_ABSOLUTE_CMPXCHG;
ksmo.old_addr = (u64)desc->old;
memcpy(desc->old_value, desc->old, desc->size);
}
break;
case INVALID:
ksmo.op = -1;
}
if (desc->f_check)
ksmo.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
if (desc->f_inject)
ksmo.flags |= KVM_S390_MEMOP_F_INJECT_EXCEPTION;
if (desc->_set_flags)
ksmo.flags = desc->set_flags;
if (desc->f_key && desc->key != NO_KEY) {
ksmo.flags |= KVM_S390_MEMOP_F_SKEY_PROTECTION;
ksmo.key = desc->key;
}
if (desc->_ar)
ksmo.ar = desc->ar;
else
ksmo.ar = 0;
if (desc->_sida_offset)
ksmo.sida_offset = desc->sida_offset;
return ksmo;
}
struct test_info {
struct kvm_vm *vm;
struct kvm_vcpu *vcpu;
};
#define PRINT_MEMOP false
static void print_memop(struct kvm_vcpu *vcpu, const struct kvm_s390_mem_op *ksmo)
{
if (!PRINT_MEMOP)
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `pthread.h`, `linux/bits.h`, `test_util.h`, `kvm_util.h`.
- Detected declarations: `struct mop_desc`, `struct test_info`, `struct test_default`, `struct testdef`, `enum mop_target`, `enum mop_access_mode`, `enum stage`, `function ksmo_from_desc`, `function print_memop`, `function err_memop_ioctl`.
- 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.