tools/testing/selftests/kvm/x86/kvm_buslock_test.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/x86/kvm_buslock_test.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/kvm/x86/kvm_buslock_test.c
Extension
.c
Size
3376 bytes
Lines
136
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (run->exit_reason == KVM_EXIT_IO) {
			switch (get_ucall(vcpu, &uc)) {
			case UCALL_ABORT:
				REPORT_GUEST_ASSERT(uc);
				goto done;
			case UCALL_SYNC:
				continue;
			case UCALL_DONE:
				goto done;
			default:
				TEST_FAIL("Unknown ucall 0x%lx.", uc.cmd);
			}
		}

		TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_X86_BUS_LOCK);

		/*
		 * Verify the counter is actually getting incremented, e.g. that
		 * KVM isn't skipping the instruction.  On Intel, the exit is
		 * trap-like, i.e. the counter should already have been
		 * incremented.  On AMD, it's fault-like, i.e. the counter will
		 * be incremented when the guest re-executes the instruction.
		 */
		sync_global_from_guest(vm, *val);
		TEST_ASSERT_EQ(atomic_read(val), bus_locks + host_cpu_is_intel);

		bus_locks++;
	}
	TEST_FAIL("Didn't receive UCALL_DONE, took %u bus lock exits\n", bus_locks);
done:
	TEST_ASSERT_EQ(i, bus_locks);
	kvm_vm_free(vm);
	return 0;
}

Annotation

Implementation Notes