Lines Matching full:leaf
408 static int __sev_cpuid_hv_msr(struct cpuid_leaf *leaf) in __sev_cpuid_hv_msr() argument
420 if (cpuid_function_is_indexed(leaf->fn) && leaf->subfn) in __sev_cpuid_hv_msr()
423 ret = __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EAX, &leaf->eax); in __sev_cpuid_hv_msr()
424 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EBX, &leaf->ebx); in __sev_cpuid_hv_msr()
425 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_ECX, &leaf->ecx); in __sev_cpuid_hv_msr()
426 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EDX, &leaf->edx); in __sev_cpuid_hv_msr()
431 static int __sev_cpuid_hv_ghcb(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in __sev_cpuid_hv_ghcb() argument
436 ghcb_set_rax(ghcb, leaf->fn); in __sev_cpuid_hv_ghcb()
437 ghcb_set_rcx(ghcb, leaf->subfn); in __sev_cpuid_hv_ghcb()
456 leaf->eax = ghcb->save.rax; in __sev_cpuid_hv_ghcb()
457 leaf->ebx = ghcb->save.rbx; in __sev_cpuid_hv_ghcb()
458 leaf->ecx = ghcb->save.rcx; in __sev_cpuid_hv_ghcb()
459 leaf->edx = ghcb->save.rdx; in __sev_cpuid_hv_ghcb()
464 static int sev_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in sev_cpuid_hv() argument
466 return ghcb ? __sev_cpuid_hv_ghcb(ghcb, ctxt, leaf) in sev_cpuid_hv()
467 : __sev_cpuid_hv_msr(leaf); in sev_cpuid_hv()
538 snp_cpuid_get_validated_func(struct cpuid_leaf *leaf) in snp_cpuid_get_validated_func() argument
546 if (e->eax_in != leaf->fn) in snp_cpuid_get_validated_func()
549 if (cpuid_function_is_indexed(leaf->fn) && e->ecx_in != leaf->subfn) in snp_cpuid_get_validated_func()
562 leaf->eax = e->eax; in snp_cpuid_get_validated_func()
563 leaf->ebx = e->ebx; in snp_cpuid_get_validated_func()
564 leaf->ecx = e->ecx; in snp_cpuid_get_validated_func()
565 leaf->edx = e->edx; in snp_cpuid_get_validated_func()
573 static void snp_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid_hv() argument
575 if (sev_cpuid_hv(ghcb, ctxt, leaf)) in snp_cpuid_hv()
580 struct cpuid_leaf *leaf) in snp_cpuid_postprocess() argument
582 struct cpuid_leaf leaf_hv = *leaf; in snp_cpuid_postprocess()
584 switch (leaf->fn) { in snp_cpuid_postprocess()
589 leaf->ebx = (leaf_hv.ebx & GENMASK(31, 24)) | (leaf->ebx & GENMASK(23, 0)); in snp_cpuid_postprocess()
591 leaf->edx = (leaf_hv.edx & BIT(9)) | (leaf->edx & ~BIT(9)); in snp_cpuid_postprocess()
595 leaf->ecx |= BIT(27); in snp_cpuid_postprocess()
599 leaf->ecx &= ~BIT(4); in snp_cpuid_postprocess()
601 leaf->ecx |= BIT(4); in snp_cpuid_postprocess()
608 leaf->edx = leaf_hv.edx; in snp_cpuid_postprocess()
615 if (leaf->subfn != 0 && leaf->subfn != 1) in snp_cpuid_postprocess()
620 if (leaf->subfn == 1) { in snp_cpuid_postprocess()
622 if (leaf->eax & BIT(3)) { in snp_cpuid_postprocess()
639 if (!(leaf->eax & (BIT(1) | BIT(3)))) in snp_cpuid_postprocess()
649 leaf->ebx = xsave_size; in snp_cpuid_postprocess()
656 leaf->eax = leaf_hv.eax; in snp_cpuid_postprocess()
658 leaf->ebx = (leaf->ebx & GENMASK(31, 8)) | (leaf_hv.ebx & GENMASK(7, 0)); in snp_cpuid_postprocess()
660 leaf->ecx = (leaf->ecx & GENMASK(31, 8)) | (leaf_hv.ecx & GENMASK(7, 0)); in snp_cpuid_postprocess()
675 snp_cpuid(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid() argument
682 if (!snp_cpuid_get_validated_func(leaf)) { in snp_cpuid()
700 leaf->eax = leaf->ebx = leaf->ecx = leaf->edx = 0; in snp_cpuid()
703 if (!(leaf->fn <= RIP_REL_REF(cpuid_std_range_max) || in snp_cpuid()
704 (leaf->fn >= 0x40000000 && leaf->fn <= RIP_REL_REF(cpuid_hyp_range_max)) || in snp_cpuid()
705 (leaf->fn >= 0x80000000 && leaf->fn <= RIP_REL_REF(cpuid_ext_range_max)))) in snp_cpuid()
709 return snp_cpuid_postprocess(ghcb, ctxt, leaf); in snp_cpuid()
722 struct cpuid_leaf leaf; in do_vc_no_ghcb() local
733 leaf.fn = fn; in do_vc_no_ghcb()
734 leaf.subfn = subfn; in do_vc_no_ghcb()
736 ret = snp_cpuid(NULL, NULL, &leaf); in do_vc_no_ghcb()
743 if (__sev_cpuid_hv_msr(&leaf)) in do_vc_no_ghcb()
747 regs->ax = leaf.eax; in do_vc_no_ghcb()
748 regs->bx = leaf.ebx; in do_vc_no_ghcb()
749 regs->cx = leaf.ecx; in do_vc_no_ghcb()
750 regs->dx = leaf.edx; in do_vc_no_ghcb()
760 * - Availability of CPUID leaf 0x8000001f in do_vc_no_ghcb()
768 /* SEV leaf check */ in do_vc_no_ghcb()
1078 struct cpuid_leaf leaf; in vc_handle_cpuid_snp() local
1081 leaf.fn = regs->ax; in vc_handle_cpuid_snp()
1082 leaf.subfn = regs->cx; in vc_handle_cpuid_snp()
1083 ret = snp_cpuid(ghcb, ctxt, &leaf); in vc_handle_cpuid_snp()
1085 regs->ax = leaf.eax; in vc_handle_cpuid_snp()
1086 regs->bx = leaf.ebx; in vc_handle_cpuid_snp()
1087 regs->cx = leaf.ecx; in vc_handle_cpuid_snp()
1088 regs->dx = leaf.edx; in vc_handle_cpuid_snp()