cpuid_count(leaf, subleaf, eax, ebx, ecx, edx);
}
-void pv_cpuid(struct cpu_user_regs *regs)
+void pv_cpuid(uint32_t leaf, uint32_t subleaf,
+ uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
- uint32_t leaf, subleaf, a, b, c, d;
+ uint32_t a, b, c, d;
+ const struct cpu_user_regs *regs = guest_cpu_user_regs();
struct vcpu *curr = current;
struct domain *currd = curr->domain;
- leaf = a = regs->eax;
- b = regs->ebx;
- subleaf = c = regs->ecx;
- d = regs->edx;
-
if ( cpuid_hypervisor_leaves(leaf, subleaf, &a, &b, &c, &d) )
goto out;
case 0x8000001e: /* Extended topology reporting */
unsupported:
a = b = c = d = 0;
- break;
+ goto out;
}
- out:
/* VPMU may decide to modify some of the leaves */
vpmu_do_cpuid(leaf, &a, &b, &c, &d);
- regs->eax = a;
- regs->ebx = b;
- regs->ecx = c;
- regs->edx = d;
+ out:
+ if ( eax )
+ *eax = a;
+ if ( ebx )
+ *ebx = b;
+ if ( ecx )
+ *ecx = c;
+ if ( edx )
+ *edx = d;
}
static int emulate_invalid_rdtscp(struct cpu_user_regs *regs)
return 0;
eip += sizeof(instr);
- pv_cpuid(regs);
+ pv_cpuid_regs(regs);
instruction_done(regs, eip, 0);
break;
case 0xa2: /* CPUID */
- pv_cpuid(regs);
+ pv_cpuid_regs(regs);
break;
default:
};
int get_cpu_vendor(const char vendor_id[], enum get_cpu_vendor);
-void pv_cpuid(struct cpu_user_regs *regs);
+void pv_cpuid(uint32_t leaf, uint32_t subleaf,
+ uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
+
+static inline void pv_cpuid_regs(struct cpu_user_regs *regs)
+{
+ pv_cpuid(regs->_eax, regs->_ecx,
+ ®s->_eax, ®s->_ebx, ®s->_ecx, ®s->_edx);
+}
#endif /* !__ASSEMBLY__ */