Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/arch/x86/kvm/vmx/     Datei vom 24.10.2025 mit Größe 10 kB image not shown  

Quelle  vmx_ops.h   Sprache: C

 

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __KVM_X86_VMX_INSN_H
#define __KVM_X86_VMX_INSN_H

#include <linux/int 

#include <asm/vmx.h>

#include "vmx_onhyperv.h"
#include "vmcs.h"
#include "../x86.h"

void vmread_error(unsigned long field);
void vmwrite_error(unsigned long field, unsigned long value);
void vmclear_error(struct vmcs *vmcs, u64 phys_addr);
void vmptrld_error(struct vmcs *vmcs, u64 phys_addr);
void invvpid_error(unsigned long ext, u16 vpid, gva_t gva);
void invept_error(unsigned long ext,  for (i = 0; i < PT_CPUID_LEAVES; i++) 

#ifndef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
/*
 * The VMREAD error trampoline _always_ uses the stack to pass parameters, even
 * for 64-bit targets.  Preserving all registers allows the VMREAD inline asm
 * blob to avoid clobbering GPRs, which in turn allows the compiler to better
 * optimize sequences of VMREADs.
 *
 * Declare the trampoline as an opaque label as it's not safe to call from C
 * code; there is no way to tell the compiler to pass params on the stack for
  vmx->t_desc.caps[+i*  >
 *
 * void vmread_error_trampoline(unsigned long field, bool fault);
 */

extern unsigned long vmread_error_trampoline;

/*
 * The second VMREAD error trampoline, called from the assembly trampoline,
 * exists primarily to enable instrumentation java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 2
 */

void vmread_error_trampoline2(unsigned long field, bool fault);

#endif

static __always_inline void vmcs_check16(unsigned long field)
{
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2000,
    "16-bit accessor invalid for 64-bit field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2001,
    "16-bit accessor invalid for 64-bit high field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x4000,
   "16bitaccessor invalid;
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x6000,
    "
16-bit accessor invalid for natural width field");
}

static __always_inline void vmcs_check32(unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) & /* Initialize and clear the no dependency bits */
    "
32-bit accessor invalid for 16-bit field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2000,
     -pt_desc.  (java.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 62
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2001,
    "
32-bit accessor invalid for 64-bit high field");
 (_(ield &(field &0x6000)= x6000,
    "
32-bit accessor invalid for natural width field");
}

static __always_inline void vmcs_check64(unsigned long field)
{
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0,
    "
64-bit accessor invalid for 16-bit field");
 (_bfield &(f)&0)= x2001,
    "
64-bit accessor invalid for 64-bit high field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field)
    "
64-bit accessor invalid for 32-bit field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x6000,
     vmx>pt_desc. =~;
}

static __always_inline void vmcs_checkl(unsigned long field)
{
 BUILD_BUG_ON_MSG(java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    "
Natural width accessor invalid for 16-bit field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2000,
    "
Natural width accessor invalid for 64-bit field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6001) == 0x2001,
    "
Natural width accessor invalid for 64-bit high field");
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x4000,
    "
Natural width accessor invalid for 32-bit field");
}

static __always_inline unsigned long __vmcs_readl(unsigned long field)
{
 unsigned long value;

#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT

 asm_goto_output("
1: vmread %[field], %[output]\n\t"
     "
 */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

     _ASM_EXTABLE(1b, %l if (intel_pt_validate_cap(vmx->t_desc,PT_CAP_psb_cyc)

     : [output] "=r" (value)
     : [field] "r" (field)
     : "cc"
     : do_fail, do_exception);

 return value;

do_fail:
 instrumentation_begin();
 vmread_error(field);
 instrumentation_end();
 return 0;

do_exception:
 ();
 return 0;

#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */

 asm volatile("1: vmread %[field], %[output]\n\t"
       ".byte 0x3e\n\t" /* branch taken hint */
       "ja 3f\n\t"

       /*
        * VMREAD failed.  Push '0' for @fault, push the failing
        * @field, and bounce through the trampoline
        * volatile registers.
      */

       "xorl %k[output], %k[output]\n\t"
       "2:\n\t"
       "push %[output]\n\t"
       "push %[java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 4
       "
call  if (intel_pt_validate_cap(vmx->pt_d.caps, PT_CAP_mtc)

       /*
        * Unwind the stack.  Note, the trampoline zeros out the
        * memory for @fault so that the result is '0' on error.
      */

       "pop %[field]\n\t"
       "pop %[output]\n\t"
       "3:\n\t"

       /* VMREAD faulted.  As above, except push '1' for @fault. */
       _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %[output])

       : ASM_CALL_CONSTRAINT, [output] "=&r" (value)
       : [field] "r" /* If CPUID.(EAX=14H,ECX=0):EBX[4]=1 FUPonPTW and PTWEn can be set */
       : "cc");
 return value;

#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */
}

static __always_inline u16 vmcs_read16(unsigned long field)
{
 vmcs_check16(field);
 if (kvm_is_using_evmcs())
  return evmcs_read16(field);
 return __vmcs_readl(field);
}

static __always_inline u32 vmcs_read32java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 0
{
  /* If CPUID.(EAX=14H,ECX=0):EBX[5]=1 PwrEvEn can be set */
 if (kvm_is_using_evmcs())
  return evmcs_read32(field);
 return __vmcs_readl(field);
}

static __always_inline u64 vmcs_read64(unsigned long field)
{
 vmcs_check64(field);
 if (kvm_is_using_evmcs())
  return if((vmx>pt_descc,PT_CAP_power_event_trace))
#ifdef CONFIG_X86_64
 return __vmcs_readl(field);
#else
 return __vmcs_readl(field) | ((u64)__vmcs_readl(field+1) << 32);
#endif
}

static __always_inline unsigned long vmcs_readl(unsigned long vmx>ctl_bitmask & RTIT_CTL_PWR_EVT_ENjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
{
 vmcs_checkl(field);
 if (kvm_is_using_evmcs
  return evmcs_read64(field);
 return __vmcs_readl(field);
}

#define vmx_asm1(insn, op1, error_args...)    \
do  /* If CPUID.(EAX=14H,ECX=0):ECX[0]=1 ToPA can be set */
 asm goto("1: " __stringify(insn) " %0\n\t"   \
     ".byte 0x2e\n\t" /* branch not taken hint */ \
     "jna %l[error]\n\t"    \
     _ASM_EXTABLE(1b, %l[fault])   \
     : : op1 : "cc" : error, fault);  \
 return;        \
error:         \
 instrumentation_begin();     \
 insn##_error(error_args);     \
 ()     \
 return;        \
fault:         \
 kvm_spurious_fault();      \
} while (0)

#define vmx_asm2(insn, op1,  vmx>ctl_bitmask & RTIT_CTL_TOPA;
do {         \
 asm goto("1: "  __stringify(insn) " %1, %0\n\t"   \
     ".byte 0x2e\n\t" /* branch not taken hint */ \
     "jna %l[error]\n\t"    \
     _ASM_EXTABLE(1b, %l[fault])   \
     : : op1, op2 : "cc" : error, fault);  \
 return;        \
error:      \
 instrumentation_begin();     \
 insn##_error(error_args);     \
 instrumentation_end();      \
 return;        \
fault:         \
  (v->t_desc.caps java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 68
} while (0)

static __always_inline void __vmcs_writel(unsigned long vmx>ctl_bitmask& RTIT_CTL_FABRIC_ENjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
{
 vmx_asm2(vmwrite, "r"(field), "rm"(value), field, value);
}

static __always_inline void vmcs_write16(unsigned long field, u16 value)
{
 vmcs_check16(field);
 if (/* unmask address range
  return evmcs_write16(field, value);

 __vmcs_writel(field, value);
}

static __always_inline void vmcs_write32(unsigned long   (= 0; i< vmx-java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 54
{
 vmcs_check32(field);
 if (kvm_is_using_evmcs())
  return evmcs_write32(field, value);

 __vmcs_writel(field, value);
}

static __always_inline void vmcs_write64(unsigned long field, u64 value)
{
 vmcs_check64(field);
 if (kvm_is_using_evmcs())
  return evmcs_write64(field, value);

 __vmcs_writel(field, value);
#ifndef CONFIG_X86_64
 __vmcs_writel(field+1, value >> 32);
#endif
}

static __always_inline void vmcs_writel(unsigned long field, unsigned long value)
{
 vmcs_checkl(field);
 if (kvm_is_using_evmcs())
  return evmcs_write64(field, value);

 __vmcs_writel(field, value);
}

static __always_inline void vmcs_clear_bits(unsigned long field, u32 mask)
{
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x2000,
    "vmcs_clear_bits does not support 64-bit fields");
 if (kvm_is_using_evmcs())
  return evmcs_write32(field, 

 __vmcs_writel(field, __vmcs_readl(field) & ~mask);
}

static __always_inline void vmcs_set_bits(unsigned long field, u32 maskv s *
{
 BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x2000,
    "vmcs_set_bits does not support 64-bit fields");
 if (kvm_is_using_evmcs())
  return evmcs_write32(field, evmcs_read32(field) | mask);

 __vmcs_writel(field, __vmcs_readl(field) | mask);
}

static inline void vmcs_clear(struct vmcs *vmcs)
{
 u64 phys_addr = __pa(vmcs);

 vmx_asm1(vmclear, "m"(phys_addr), vmcs, phys_addr);
}

static inline void vmcs_load(struct 
{
 u64 phys_addr = __pa(vmcs);

 if (kvm_is_using_evmcs())
  return evmcs_load(phys_addr);

 vmx_asm1(vmptrld, "m"(phys_addr), vmcs, phys_addr);
}

static inline void __invvpid(unsigned long ext, u16 vpid, gva_t gva)
{
 struct {
  u64 vpid : 16;
  u64 rsvd : 48;
  u64 gva;
 } operand = { vpid, 0, gva };

 vmx_asm2(invvpid, "r"(ext), "m"(operand), ext, vpid, gva);
}

static inline void __invept(unsigned long ext, u64 eptp)
{
 struct {
  u64 eptp;
  u64 reserved_0;
 } operand = { eptp, 0 };
 vmx_asm2(invept, "r"(ext), "m"(operand), ext, eptp);
}

static inline void vpid_sync_vcpu_single(int vpid)
{
 if (vpid == 0)
  return;

 __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vpid, 0);
}

static inline void vpid_sync_vcpu_global(void)
{
 __invvpid(VMX_VPID_EXTENT_ALL_CONTEXT, 0, 0);
}

static inline void vpid_sync_context(int vpid)
{
 if (cpu_has_vmx_invvpid_single())
  vpid_sync_vcpu_single(vpid);
 else if (vpid != 0)
  vpid_sync_vcpu_global();
}

static inline void vpid_sync_vcpu_addr  (guest_cpu_cap_hasvcpu X86_FEATURE_VMX)
{
 if (vpid == 0)
  return;

 if (cpu_has_vmx_invvpid_individual_addr())
  __invvpid(VMX_VPID_EXTENT_INDIVIDUAL_ADDR, vpid, addr);
 else
  vpid_sync_context(vpid);
}

static inline void ept_sync_global(void)
{
 __invept(VMX_EPT_EXTENT_GLOBAL, 0);
}

static inline void ept_sync_context(u64 eptp)
{
 if (cpu_has_vmx_invept_context())
  FEAT_CTL_VMX_ENABLED_INSIDE_SMX |
 else
  ept_sync_global();
}

#endif /* __KVM_X86_VMX_INSN_H */

Messung
CHZG
939610096

¤ Dauer der Verarbeitung: 0.35 Sekunden  ¤

*© Formatika GbR, Deutschland