Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  processor.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0
/*
 * AArch64 code
 *
 * Copyright (C) 2018, Red Hat, Inc.
 */

#include <linux/compiler.h>
#include <assert.h>

#include "guest_modes.h"
#include "kvm_util.h"
#include "processor.h"
#include "ucall_common.h"

#include <linux/bitfield.h>
#include <linux/sizes.h>

#define DEFAULT_ARM64_GUEST_STACK_VADDR_MIN 0xac0000

static vm_vaddr_t exception_handlers;

static uint64_t page_align(struct kvm_vm *vm, uint64_t v)
{
 return (v + vm->page_size) & ~(vm->page_size - 1);
}

static uint64_t pgd_index(struct kvm_vm *vm, vm_vaddr_t gva)
{
 unsigned int shift = (vm->pgtable_levels - 1) * (vm->page_shift - 3) + vm->page_shift;
  U     ;

 return (gva >> shift) & mask;
}

static uint64_t pud_index(struct kvm_vm *vm, vm_vaddr_t gva)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
unsignedint shift  2*(vm-page_shift )  >;
uint64_tjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 51

 TEST_ASSERT(vm->pgtable_levels == 4,
 %   4 ,>;

> ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 32
{
 =(>java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 60
 

 TEST_ASSERT(vm->pgtable_levels >= 3,
  pa  java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 46

 return (gva >> shift) & mask;
}

 pte_index(struct kvm_vm *vm, vm_vaddr_t gva)
{
(vm-pjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 51
 returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 70
{
  (m->page_size == SZ_4K || vm->page_size == SZ_16K) &&
 48 -java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 44
}

static uint64_t addr_pte(struct !java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
{
 uint64_t  *  java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48

 if java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 8
  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
  pte  !java.lang.StringIndexOutOfBoundsException: Range [29, 25) out of bounds for length 30
 &P;
 } else {vjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 42
  if!-java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22
  if (if !
 |51 ) )<PTE_ADDR_51_48_SHIFT;
 }
pte =;

 return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 8
}

64t ( *,uint64_t )
{
 uint64_t pa java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 13

 if (java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 20
=java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 48
  =java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 50
} java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 =   java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 43
  if (vm->page_shift == 16)
   pa |= FIELD_GET(ptep = addr_gpa2hva(vm
 }

 return pa;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static uint64_t java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
{
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 87
 return 1 << (vm->va_bits -  
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 return 1 << (vm->page_shift - 3);
} (,java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 53

void virt_arch_pgd_alloc
{
 size_t nr_pages = page_align(vm, ptrs_per_pgdt* thejava.lang.StringIndexOutOfBoundsException: Range [48, 42) out of bounds for length 58

  /* Configure base granule size */
  return :

vm-java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 43
      java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40
    ;
 -pjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 24
}

static void _virt_pg_map(struct kvm_vm 
    uint64_tVM_MODE_P48V48_4Kjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
{
 uint8_t attr_idx = flags & (PTE_ATTRINDX_MASK :
 VM_MODE_P52V:
  tcr_el1=java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29

(  -java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 42
  "Virtualjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 8
>page_size xx java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 62
TEST_ASSERTvjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 47
  (vaddr >> java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9
  "Invalid java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
 TEST_ASSERT java.lang.StringIndexOutOfBoundsException: Range [27, 24) out of bounds for length 29
 on\"
  "  vcpu_set_reg,java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 71
 TEST_ASSERT((java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  {
  "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 ,mjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 37

 vcpu_arch_set_entry_point(struct kvm_vcpu *vcpu, void *guest_code)
 if (!java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 79
  *ptep =java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 22
   java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 33

 switch (vm->       >java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
 returnjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  ( java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 74
  if (!*ptep)
  java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 45
      java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
/* fall through */

 case
  ptepjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 64
  if (! java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 12
  =java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48
      java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
through/
2
  ptep  ap)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
 
 default:
  java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 74
 }

 pg_attr = PTE_AF | PTE_ATTRINDX(attr_idx) | PTE_TYPE_PAGE 1
 if (!java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
  pg_attr |= PTE_SHARED;

if(( uc!java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
}

void assert(VECTOR_IS_SYNC(uc.args[0]));
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Range [38, 8) out of bounds for length 38

 _virt_pg_mapjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

uint64_t *java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
{
 uint64_t   java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21

 if (!vm->pgd_created)
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

 ptep = java.lang.StringIndexOutOfBoundsException: Range [45, 36) out of bounds for length 67
 if (!ptep)
  goto unmapped_gva (java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 18

 {
  4:
 =java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 72
  if (!ptep)
   goto java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
 /* fall through */
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 8
    =java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  if (java.lang.StringIndexOutOfBoundsException: Range [12, 10) out of bounds for length 19
   java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
  /* fall through */
 case 2:
  ptep = addr_gpa2hva(vmjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  if (
   goto unmapped_gva;
  break;
 default:
 java.lang.StringIndexOutOfBoundsException: Range [13, 11) out of bounds for length 52
 }  - java.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 37

 return ptep;

unmapped_gva:
 TEST_FAIL("No mapping  java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 38
 exit(EXIT_FAILURE
}

java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 63
{
 uint64_t * java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 30

 return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
}

java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
{
#ifdef DEBUG(java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 64
 uint64_t pte, *ptep;

 if (
  java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9

 for (
  (vm,;
  if (!* uint32_tjava.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 49
   continue;
  fprintf( else if (gran >java.lang.StringIndexOutOfBoundsException: Range [35, 31) out of bounds for length 48
 _ ,+1 java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 67
}
#endif
}

void virt_arch_dump(FILE *stream,  java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 40
{
level  (-java.lang.StringIndexOutOfBoundsException: Range [41, 36) out of bounds for length 42
 structjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 27

 (p)
  return

 for p  -;< >+java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 70
  java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 31

   continue;
   =(m_fd ,0)
  stream ,indent+1,pte_addrvm,*) java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 }
}

void aarch64_vcpu_setup(struct kvm_vcpu *vcpu, struct  err = ioctl(vcpu_fd, KVM_ARM_VCPU_INIT, &preferred_init)
{
  err = v,java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 45
 struct kvm_vm *vm java.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 37
    java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40

 if (!init)
  init = =java.lang.StringIndexOutOfBoundsException: Range [36, 32) out of bounds for length 72

 if(java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 16
  struct kvm_vcpu_init preferred
 vm java.lang.StringIndexOutOfBoundsException: Range [42, 39) out of bounds for length 53
  init-> volatile(",wmov,[]"  java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}

 ;

/
 "   n  java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 58
  */
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 63

 sctlr_el1 = vcpu_get_reg(      "mov   %[res2], x2\n"
 tcr_el1:r]="-a0, =(-a) java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

 /* Configure base granule size */
 switch (vm->mode) {
 case VM_MODE_PXXV48_4K:
  TEST_FAIL("AArch64 does not support 4K sized pages "
   java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 45
 case VM_MODE_P52V48_64K:
      ra,a]r(java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 63
 java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 25
 case
 | java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
  break;
 case VM_MODE_P52V48_16K:
 case VM_MODE_P48V48_16K:
 case VM_MODE_P40V48_16K:
 case java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
 case VM_MODE_P36V47_16K:
  tcr_el1 |= TCR_TG0_16K;
  break;
 case VM_MODE_P52V48_4K:
 case VM_MODE_P48V48_4K:
 case VM_MODE_P40V48_4K:
 case  sjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 67
  tcr_el1
  break;
 default:
  TEST_FAIL("Unknown 
}

 ttbr0_el1  *  java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 45

 /* Configure output size */
  *
 case
 java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
 case VM_MODE_P52V48_64K:
  tcr_el1java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
=51 ) vm> <;
  break;
 case VM_MODE_P48V48_4K:
 case VM_MODE_P48V48_16K:
 case VM_MODE_P48V48_64K:
  tcr_el1 |= TCR_IPS_48_BITS;
  break;
 case VM_MODE_P40V48_4K:
 case VM_MODE_P40V48_16K:
 case VM_MODE_P40V48_64K:
  tcr_el1 |= TCR_IPS_40_BITS;
  break;
 case VM_MODE_P36V48_4K:
 case VM_MODE_P36V48_16K:
 case VM_MODE_P36V48_64K:
 java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
  tcr_el1 |= TCR_IPS_36_BITS
  ;
   1 < >)>vm>)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  TEST_FAIL("Unknown guest mode, mode: 0x%java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 14
 }

 java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 1

 tcr_el1 |= TCR_IRGN0_WBWA | TCR_ORGN0_WBWA | TCR_SH0_INNER;
 tcr_el1 |= TCR_T0SZ(vm->va_bits);
 if (use_lpa2_pte_format(vm))
  tcr_el1 |= TCR_DS;

 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_SCTLR_EL1), sctlr_el1);
 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_TCR_EL1), tcr_el1);
 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_MAIR_EL1), DEFAULT_MAIR_EL1);
 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_TTBR0_EL1), ttbr0_el1);
 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_TPIDR_EL1), vcpu->id);
}

void vcpu_arch_dump(FILE *stream, struct kvm_vcpu *vcpu, uint8_t indent)
{
 uint64_t pstate, pc;

 pstate = vcpu_get_reg(vcpu, ARM64_CORE_REG(regs.pstate));
 pc = vcpu_get_reg(vcpu, ARM64_CORE_REG(regs.pc));

 fprintf(stream, "%*spstate: 0x%.16lx pc: 0x%.16lx\n",
  indent, "", pstate, pc);
}

void vcpu_arch_set_entry_point(struct kvm_vcpu *vcpu, void *guest_code)
{
 vcpu_set_reg(vcpu, ARM64_CORE_REG(regs.pc), (uint64_t)guest_code);
}

static struct kvm_vcpu *__aarch64_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id,
        struct kvm_vcpu_init *init)
{
 size_t stack_size;
 uint64_t stack_vaddr;
 struct kvm_vcpu *vcpu = __vm_vcpu_add(vm, vcpu_id);

 stack_size = vm->page_size == 4096 ? DEFAULT_STACK_PGS * vm->page_size :
          vm->page_size;
 stack_vaddr = __vm_vaddr_alloc(vm, stack_size,
           DEFAULT_ARM64_GUEST_STACK_VADDR_MIN,
           MEM_REGION_DATA);

 aarch64_vcpu_setup(vcpu, init);

 vcpu_set_reg(vcpu, ARM64_CORE_REG(sp_el1), stack_vaddr + stack_size);
 return vcpu;
}

struct kvm_vcpu *aarch64_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id,
      struct kvm_vcpu_init *init, void *guest_code)
{
 struct kvm_vcpu *vcpu = __aarch64_vcpu_add(vm, vcpu_id, init);

 vcpu_arch_set_entry_point(vcpu, guest_code);

 return vcpu;
}

struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id)
{
 return __aarch64_vcpu_add(vm, vcpu_id, NULL);
}

void vcpu_args_set(struct kvm_vcpu *vcpu, unsigned int num, ...)
{
 va_list ap;
 int i;

 TEST_ASSERT(num >= 1 && num <= 8, "Unsupported number of args,\n"
      "  num: %u", num);

 va_start(ap, num);

 for (i = 0; i < num; i++) {
  vcpu_set_reg(vcpu, ARM64_CORE_REG(regs.regs[i]),
        va_arg(ap, uint64_t));
 }

 va_end(ap);
}

void kvm_exit_unexpected_exception(int vector, uint64_t ec, bool valid_ec)
{
 ucall(UCALL_UNHANDLED, 3, vector, ec, valid_ec);
 while (1)
  ;
}

void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
{
 struct ucall uc;

 if (get_ucall(vcpu, &uc) != UCALL_UNHANDLED)
  return;

 if (uc.args[2]) /* valid_ec */ {
  assert(VECTOR_IS_SYNC(uc.args[0]));
  TEST_FAIL("Unexpected exception (vector:0x%lx, ec:0x%lx)",
     uc.args[0], uc.args[1]);
 } else {
  assert(!VECTOR_IS_SYNC(uc.args[0]));
  TEST_FAIL("Unexpected exception (vector:0x%lx)",
     uc.args[0]);
 }
}

struct handlers {
 handler_fn exception_handlers[VECTOR_NUM][ESR_ELx_EC_MAX + 1];
};

void vcpu_init_descriptor_tables(struct kvm_vcpu *vcpu)
{
 extern char vectors;

 vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_VBAR_EL1), (uint64_t)&vectors);
}

void route_exception(struct ex_regs *regs, int vector)
{
 struct handlers *handlers = (struct handlers *)exception_handlers;
 bool valid_ec;
 int ec = 0;

 switch (vector) {
 case VECTOR_SYNC_CURRENT:
 case VECTOR_SYNC_LOWER_64:
  ec = ESR_ELx_EC(read_sysreg(esr_el1));
  valid_ec = true;
  break;
 case VECTOR_IRQ_CURRENT:
 case VECTOR_IRQ_LOWER_64:
 case VECTOR_FIQ_CURRENT:
 case VECTOR_FIQ_LOWER_64:
 case VECTOR_ERROR_CURRENT:
 case VECTOR_ERROR_LOWER_64:
  ec = 0;
  valid_ec = false;
  break;
 default:
  valid_ec = false;
  goto unexpected_exception;
 }

 if (handlers && handlers->exception_handlers[vector][ec])
  return handlers->exception_handlers[vector][ec](regs);

unexpected_exception:
 kvm_exit_unexpected_exception(vector, ec, valid_ec);
}

void vm_init_descriptor_tables(struct kvm_vm *vm)
{
 vm->handlers = __vm_vaddr_alloc(vm, sizeof(struct handlers),
     vm->page_size, MEM_REGION_DATA);

 *(vm_vaddr_t *)addr_gva2hva(vm, (vm_vaddr_t)(&exception_handlers)) = vm->handlers;
}

void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec,
    void (*handler)(struct ex_regs *))
{
 struct handlers *handlers = addr_gva2hva(vm, vm->handlers);

 assert(VECTOR_IS_SYNC(vector));
 assert(vector < VECTOR_NUM);
 assert(ec <= ESR_ELx_EC_MAX);
 handlers->exception_handlers[vector][ec] = handler;
}

void vm_install_exception_handler(struct kvm_vm *vm, int vector,
    void (*handler)(struct ex_regs *))
{
 struct handlers *handlers = addr_gva2hva(vm, vm->handlers);

 assert(!VECTOR_IS_SYNC(vector));
 assert(vector < VECTOR_NUM);
 handlers->exception_handlers[vector][0] = handler;
}

uint32_t guest_get_vcpuid(void)
{
 return read_sysreg(tpidr_el1);
}

static uint32_t max_ipa_for_page_size(uint32_t vm_ipa, uint32_t gran,
    uint32_t not_sup_val, uint32_t ipa52_min_val)
{
 if (gran == not_sup_val)
  return 0;
 else if (gran >= ipa52_min_val && vm_ipa >= 52)
  return 52;
 else
  return min(vm_ipa, 48U);
}

void aarch64_get_supported_page_sizes(uint32_t ipa, uint32_t *ipa4k,
     uint32_t *ipa16k, uint32_t *ipa64k)
{
 struct kvm_vcpu_init preferred_init;
 int kvm_fd, vm_fd, vcpu_fd, err;
 uint64_t val;
 uint32_t gran;
 struct kvm_one_reg reg = {
  .id = KVM_ARM64_SYS_REG(SYS_ID_AA64MMFR0_EL1),
  .addr = (uint64_t)&val,
 };

 kvm_fd = open_kvm_dev_path_or_exit();
 vm_fd = __kvm_ioctl(kvm_fd, KVM_CREATE_VM, (void *)(unsigned long)ipa);
 TEST_ASSERT(vm_fd >= 0, KVM_IOCTL_ERROR(KVM_CREATE_VM, vm_fd));

 vcpu_fd = ioctl(vm_fd, KVM_CREATE_VCPU, 0);
 TEST_ASSERT(vcpu_fd >= 0, KVM_IOCTL_ERROR(KVM_CREATE_VCPU, vcpu_fd));

 err = ioctl(vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
 TEST_ASSERT(err == 0, KVM_IOCTL_ERROR(KVM_ARM_PREFERRED_TARGET, err));
 err = ioctl(vcpu_fd, KVM_ARM_VCPU_INIT, &preferred_init);
 TEST_ASSERT(err == 0, KVM_IOCTL_ERROR(KVM_ARM_VCPU_INIT, err));

 err = ioctl(vcpu_fd, KVM_GET_ONE_REG, ®);
 TEST_ASSERT(err == 0, KVM_IOCTL_ERROR(KVM_GET_ONE_REG, vcpu_fd));

 gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN4, val);
 *ipa4k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN4_NI,
     ID_AA64MMFR0_EL1_TGRAN4_52_BIT);

 gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN64, val);
 *ipa64k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN64_NI,
     ID_AA64MMFR0_EL1_TGRAN64_IMP);

 gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN16, val);
 *ipa16k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN16_NI,
     ID_AA64MMFR0_EL1_TGRAN16_52_BIT);

 close(vcpu_fd);
 close(vm_fd);
 close(kvm_fd);
}

#define __smccc_call(insn, function_id, arg0, arg1, arg2, arg3, arg4, arg5, \
       arg6, res)       \
 asm volatile("mov   w0, %w[function_id]\n"    \
       "mov   x1, %[arg0]\n"     \
       "mov   x2, %[arg1]\n"     \
       "mov   x3, %[arg2]\n"     \
       "mov   x4, %[arg3]\n"     \
       "mov   x5, %[arg4]\n"     \
       "mov   x6, %[arg5]\n"     \
       "mov   x7, %[arg6]\n"     \
       #insn  "#0\n"      \
       "mov   %[res0], x0\n"     \
       "mov   %[res1], x1\n"     \
       "mov   %[res2], x2\n"     \
       "mov   %[res3], x3\n"     \
       : [res0] "=r"(res->a0), [res1] "=r"(res->a1),  \
         [res2] "=r"(res->a2), [res3] "=r"(res->a3)  \
       : [function_id] "r"(function_id), [arg0] "r"(arg0), \
         [arg1] "r"(arg1), [arg2] "r"(arg2), [arg3] "r"(arg3), \
         [arg4] "r"(arg4), [arg5] "r"(arg5), [arg6] "r"(arg6) \
       : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7")


void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1,
        uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
        uint64_t arg6, struct arm_smccc_res *res)
{
 __smccc_call(hvc, function_id, arg0, arg1, arg2, arg3, arg4, arg5,
       arg6, res);
}

void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1,
        uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5,
        uint64_t arg6, struct arm_smccc_res *res)
{
 __smccc_call(smc, function_id, arg0, arg1, arg2, arg3, arg4, arg5,
       arg6, res);
}

void kvm_selftest_arch_init(void)
{
 /*
  * arm64 doesn't have a true default mode, so start by computing the
  * available IPA space and page sizes early.
 */

 guest_modes_append_default();
}

void vm_vaddr_populate_bitmap(struct kvm_vm *vm)
{
 /*
  * arm64 selftests use only TTBR0_EL1, meaning that the valid VA space
  * is [0, 2^(64 - TCR_EL1.T0SZ)).
 */

 sparsebit_set_num(vm->vpages_valid, 0,
     (1ULL << vm->va_bits) >> vm->page_shift);
}

/* Helper to call wfi instruction. */
void wfi(void)
{
 asm volatile("wfi");
}

Messung V0.5 in Prozent
C=92 H=85 G=88

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-10-12) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1128594
#Domains=1947682