Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/arch/x86/cpu/centaur.c
Line
Count
Source (jump to first uncovered line)
1
#include <xen/lib.h>
2
#include <xen/init.h>
3
#include <xen/bitops.h>
4
#include <asm/processor.h>
5
#include <asm/msr.h>
6
#include <asm/e820.h>
7
#include "cpu.h"
8
9
0
#define ACE_PRESENT (1 << 6)
10
0
#define ACE_ENABLED (1 << 7)
11
0
#define ACE_FCR   (1 << 28)  /* MSR_VIA_FCR */
12
13
0
#define RNG_PRESENT (1 << 2)
14
0
#define RNG_ENABLED (1 << 3)
15
0
#define RNG_ENABLE  (1 << 6)  /* MSR_VIA_RNG */
16
17
static void init_c3(struct cpuinfo_x86 *c)
18
0
{
19
0
  uint64_t msr_content;
20
0
21
0
  /* Test for Centaur Extended Feature Flags presence */
22
0
  if (cpuid_eax(0xC0000000) >= 0xC0000001) {
23
0
    u32 tmp = cpuid_edx(0xC0000001);
24
0
25
0
    /* enable ACE unit, if present and disabled */
26
0
    if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) {
27
0
      rdmsrl(MSR_VIA_FCR, msr_content);
28
0
      /* enable ACE unit */
29
0
      wrmsrl(MSR_VIA_FCR, msr_content | ACE_FCR);
30
0
      printk(KERN_INFO "CPU: Enabled ACE h/w crypto\n");
31
0
    }
32
0
33
0
    /* enable RNG unit, if present and disabled */
34
0
    if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) {
35
0
      rdmsrl(MSR_VIA_RNG, msr_content);
36
0
      /* enable RNG unit */
37
0
      wrmsrl(MSR_VIA_RNG, msr_content | RNG_ENABLE);
38
0
      printk(KERN_INFO "CPU: Enabled h/w RNG\n");
39
0
    }
40
0
  }
41
0
42
0
  if (c->x86 == 0x6 && c->x86_model >= 0xf) {
43
0
    c->x86_cache_alignment = c->x86_clflush_size * 2;
44
0
    __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
45
0
  }
46
0
47
0
  get_model_name(c);
48
0
  display_cacheinfo(c);
49
0
}
50
51
static void init_centaur(struct cpuinfo_x86 *c)
52
0
{
53
0
  if (c->x86 == 6)
54
0
    init_c3(c);
55
0
}
56
57
static const struct cpu_dev centaur_cpu_dev = {
58
  .c_vendor = "Centaur",
59
  .c_ident  = { "CentaurHauls" },
60
  .c_init   = init_centaur,
61
};
62
63
int __init centaur_init_cpu(void)
64
1
{
65
1
  cpu_devs[X86_VENDOR_CENTAUR] = &centaur_cpu_dev;
66
1
  return 0;
67
1
}