tools/testing/selftests/kvm/x86/xss_msr_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/xss_msr_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/x86/xss_msr_test.c- Extension
.c- Size
- 1398 bytes
- Lines
- 55
- 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
sys/ioctl.htest_util.hkvm_util.hvmx.h
Detected Declarations
function Copyright
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019, Google LLC.
*
* Tests for the IA32_XSS MSR.
*/
#include <sys/ioctl.h>
#include "test_util.h"
#include "kvm_util.h"
#include "vmx.h"
#define MSR_BITS 64
int main(int argc, char *argv[])
{
bool xss_in_msr_list;
struct kvm_vm *vm;
struct kvm_vcpu *vcpu;
u64 xss_val;
int i, r;
/* Create VM */
vm = vm_create_with_one_vcpu(&vcpu, NULL);
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVES));
xss_val = vcpu_get_msr(vcpu, MSR_IA32_XSS);
TEST_ASSERT(xss_val == 0,
"MSR_IA32_XSS should be initialized to zero");
vcpu_set_msr(vcpu, MSR_IA32_XSS, xss_val);
/*
* At present, KVM only supports a guest IA32_XSS value of 0. Verify
* that trying to set the guest IA32_XSS to an unsupported value fails.
* Also, in the future when a non-zero value succeeds check that
* IA32_XSS is in the list of MSRs to save/restore.
*/
xss_in_msr_list = kvm_msr_is_in_save_restore_list(MSR_IA32_XSS);
for (i = 0; i < MSR_BITS; ++i) {
r = _vcpu_set_msr(vcpu, MSR_IA32_XSS, 1ull << i);
/*
* Setting a list of MSRs returns the entry that "faulted", or
* the last entry +1 if all MSRs were successfully written.
*/
TEST_ASSERT(!r || r == 1, KVM_IOCTL_ERROR(KVM_SET_MSRS, r));
TEST_ASSERT(r != 1 || xss_in_msr_list,
"IA32_XSS was able to be set, but was not in save/restore list");
}
kvm_vm_free(vm);
}
Annotation
- Immediate include surface: `sys/ioctl.h`, `test_util.h`, `kvm_util.h`, `vmx.h`.
- Detected declarations: `function Copyright`.
- 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.