/* L1 has now set up a shadow VMCS for us. */
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffee);
GUEST_SYNC(10);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0ffee);
GUEST_ASSERT(!vmwrite(GUEST_RIP, 0xc0fffee));
GUEST_SYNC(11);
GUEST_ASSERT(vmreadz(GUEST_RIP) == 0xc0fffee);
GUEST_ASSERT(!vmwrite(GUEST_RIP, 0xc0ffffee));
GUEST_SYNC(12);
/* Done, exit to L1 and never come back. */
vmcall();
}
if (this_cpu_has(X86_FEATURE_XSAVE)) {
uint64_t supported_xcr0 = this_cpu_supported_xcr0();
uint8_t buffer[4096];
memset(buffer, 0xcc, sizeof(buffer));
/* * Modify state for all supported xfeatures to take them out of * their "init" state, i.e. to make them show up in XSTATE_BV. * * Note off-by-default features, e.g. AMX, are out of scope for * this particular testcase as they have a different ABI.
*/
GUEST_ASSERT(supported_xcr0 & XFEATURE_MASK_FP); asmvolatile ("fincstp");
/* * Don't bother trying to get BNDCSR into the INUSE * state. MSR_IA32_BNDCFGS doesn't count as it isn't * managed via XSAVE/XRSTOR, and BNDCFGU can only be * modified by XRSTOR. Stuffing XSTATE_BV in the host * is simpler than doing XRSTOR here in the guest. * * However, temporarily enable MPX in BNDCFGS so that * BNDMOV actually loads BND1. If MPX isn't *fully* * enabled, all MPX instructions are treated as NOPs. * * Hand encode "bndmov (%rax),%bnd1" as support for MPX * mnemonics/registers has been removed from gcc and * clang (and was never fully supported by clang).
*/
wrmsr(MSR_IA32_BNDCFGS, BIT_ULL(0)); asmvolatile (".byte 0x66,0x0f,0x1a,0x08" :: "a" (bounds)); /* * Hand encode "bndmov %bnd1, (%rax)" to sanity check * that BND1 actually got loaded.
*/ asmvolatile (".byte 0x66,0x0f,0x1b,0x08" :: "a" (output));
wrmsr(MSR_IA32_BNDCFGS, 0);
state = vcpu_save_state(vcpu);
memset(®s1, 0, sizeof(regs1));
vcpu_regs_get(vcpu, ®s1);
kvm_vm_release(vm);
/* Restore state in a new VM. */
vcpu = vm_recreate_with_one_vcpu(vm);
vcpu_load_state(vcpu, state);
/* * Restore XSAVE state in a dummy vCPU, first without doing * KVM_SET_CPUID2, and then with an empty guest CPUID. Except * for off-by-default xfeatures, e.g. AMX, KVM is supposed to * allow KVM_SET_XSAVE regardless of guest CPUID. Manually * load only XSAVE state, MSRs in particular have a much more * convoluted ABI. * * Load two versions of XSAVE state: one with the actual guest * XSAVE state, and one with all supported features forced "on" * in xstate_bv, e.g. to ensure that KVM allows loading all * supported features, even if something goes awry in saving * the original snapshot.
*/
xstate_bv = (void *)&((uint8_t *)state->xsave->region)[512];
saved_xstate_bv = *xstate_bv;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.