tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c- Extension
.c- Size
- 2465 bytes
- Lines
- 119
- 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.
Dependency Surface
inttypes.hhtmintrin.hstring.hstdlib.hstdio.hpthread.hsys/mman.hunistd.htm.hutils.h
Detected Declarations
function tm_vmx_unavail_testfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2017, Michael Neuling, IBM Corp.
* Original: Breno Leitao <brenohl@br.ibm.com> &
* Gustavo Bueno Romero <gromero@br.ibm.com>
* Edited: Michael Neuling
*
* Force VMX unavailable during a transaction and see if it corrupts
* the checkpointed VMX register state after the abort.
*/
#include <inttypes.h>
#include <htmintrin.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/mman.h>
#include <unistd.h>
#include "tm.h"
#include "utils.h"
int passed;
void *worker(void *unused)
{
__int128 vmx0;
uint64_t texasr;
asm goto (
"li 3, 1;" /* Stick non-zero value in VMX0 */
"std 3, 0(%[vmx0_ptr]);"
"lvx 0, 0, %[vmx0_ptr];"
/* Wait here a bit so we get scheduled out 255 times */
"lis 3, 0x3fff;"
"1: ;"
"addi 3, 3, -1;"
"cmpdi 3, 0;"
"bne 1b;"
/* Kernel will hopefully turn VMX off now */
"tbegin. ;"
"beq failure;"
/* Cause VMX unavail. Any VMX instruction */
"vaddcuw 0,0,0;"
"tend. ;"
"b %l[success];"
/* Check VMX0 sanity after abort */
"failure: ;"
"lvx 1, 0, %[vmx0_ptr];"
"vcmpequb. 2, 0, 1;"
"bc 4, 24, %l[value_mismatch];"
"b %l[value_match];"
:
: [vmx0_ptr] "r"(&vmx0)
: "r3"
: success, value_match, value_mismatch
);
/* HTM aborted and VMX0 is corrupted */
value_mismatch:
texasr = __builtin_get_texasr();
printf("\n\n==============\n\n");
printf("Failure with error: %lx\n", _TEXASR_FAILURE_CODE(texasr));
printf("Summary error : %lx\n", _TEXASR_FAILURE_SUMMARY(texasr));
printf("TFIAR exact : %lx\n\n", _TEXASR_TFIAR_EXACT(texasr));
passed = 0;
return NULL;
/* HTM aborted but VMX0 is correct */
value_match:
// printf("!");
return NULL;
success:
// printf(".");
return NULL;
}
int tm_vmx_unavail_test()
{
int threads;
Annotation
- Immediate include surface: `inttypes.h`, `htmintrin.h`, `string.h`, `stdlib.h`, `stdio.h`, `pthread.h`, `sys/mman.h`, `unistd.h`.
- Detected declarations: `function tm_vmx_unavail_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.