Lines Matching refs:leaf

322 static int __sev_cpuid_hv_msr(struct cpuid_leaf *leaf)  in __sev_cpuid_hv_msr()  argument
334 if (cpuid_function_is_indexed(leaf->fn) && leaf->subfn) in __sev_cpuid_hv_msr()
337 ret = __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EAX, &leaf->eax); in __sev_cpuid_hv_msr()
338 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EBX, &leaf->ebx); in __sev_cpuid_hv_msr()
339 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_ECX, &leaf->ecx); in __sev_cpuid_hv_msr()
340 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EDX, &leaf->edx); in __sev_cpuid_hv_msr()
345 static int __sev_cpuid_hv_ghcb(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in __sev_cpuid_hv_ghcb() argument
350 ghcb_set_rax(ghcb, leaf->fn); in __sev_cpuid_hv_ghcb()
351 ghcb_set_rcx(ghcb, leaf->subfn); in __sev_cpuid_hv_ghcb()
370 leaf->eax = ghcb->save.rax; in __sev_cpuid_hv_ghcb()
371 leaf->ebx = ghcb->save.rbx; in __sev_cpuid_hv_ghcb()
372 leaf->ecx = ghcb->save.rcx; in __sev_cpuid_hv_ghcb()
373 leaf->edx = ghcb->save.rdx; in __sev_cpuid_hv_ghcb()
378 static int sev_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in sev_cpuid_hv() argument
380 return ghcb ? __sev_cpuid_hv_ghcb(ghcb, ctxt, leaf) in sev_cpuid_hv()
381 : __sev_cpuid_hv_msr(leaf); in sev_cpuid_hv()
452 snp_cpuid_get_validated_func(struct cpuid_leaf *leaf) in snp_cpuid_get_validated_func() argument
460 if (e->eax_in != leaf->fn) in snp_cpuid_get_validated_func()
463 if (cpuid_function_is_indexed(leaf->fn) && e->ecx_in != leaf->subfn) in snp_cpuid_get_validated_func()
476 leaf->eax = e->eax; in snp_cpuid_get_validated_func()
477 leaf->ebx = e->ebx; in snp_cpuid_get_validated_func()
478 leaf->ecx = e->ecx; in snp_cpuid_get_validated_func()
479 leaf->edx = e->edx; in snp_cpuid_get_validated_func()
487 static void snp_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid_hv() argument
489 if (sev_cpuid_hv(ghcb, ctxt, leaf)) in snp_cpuid_hv()
495 struct cpuid_leaf *leaf) in snp_cpuid_postprocess() argument
497 struct cpuid_leaf leaf_hv = *leaf; in snp_cpuid_postprocess()
499 switch (leaf->fn) { in snp_cpuid_postprocess()
504 leaf->ebx = (leaf_hv.ebx & GENMASK(31, 24)) | (leaf->ebx & GENMASK(23, 0)); in snp_cpuid_postprocess()
506 leaf->edx = (leaf_hv.edx & BIT(9)) | (leaf->edx & ~BIT(9)); in snp_cpuid_postprocess()
510 leaf->ecx |= BIT(27); in snp_cpuid_postprocess()
514 leaf->ecx &= ~BIT(4); in snp_cpuid_postprocess()
516 leaf->ecx |= BIT(4); in snp_cpuid_postprocess()
523 leaf->edx = leaf_hv.edx; in snp_cpuid_postprocess()
530 if (leaf->subfn != 0 && leaf->subfn != 1) in snp_cpuid_postprocess()
535 if (leaf->subfn == 1) { in snp_cpuid_postprocess()
537 if (leaf->eax & BIT(3)) { in snp_cpuid_postprocess()
554 if (!(leaf->eax & (BIT(1) | BIT(3)))) in snp_cpuid_postprocess()
564 leaf->ebx = xsave_size; in snp_cpuid_postprocess()
571 leaf->eax = leaf_hv.eax; in snp_cpuid_postprocess()
573 leaf->ebx = (leaf->ebx & GENMASK(31, 8)) | (leaf_hv.ebx & GENMASK(7, 0)); in snp_cpuid_postprocess()
575 leaf->ecx = (leaf->ecx & GENMASK(31, 8)) | (leaf_hv.ecx & GENMASK(7, 0)); in snp_cpuid_postprocess()
590 snp_cpuid(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid() argument
597 if (!snp_cpuid_get_validated_func(leaf)) { in snp_cpuid()
615 leaf->eax = leaf->ebx = leaf->ecx = leaf->edx = 0; in snp_cpuid()
618 if (!(leaf->fn <= cpuid_std_range_max || in snp_cpuid()
619 (leaf->fn >= 0x40000000 && leaf->fn <= cpuid_hyp_range_max) || in snp_cpuid()
620 (leaf->fn >= 0x80000000 && leaf->fn <= cpuid_ext_range_max))) in snp_cpuid()
624 return snp_cpuid_postprocess(ghcb, ctxt, leaf); in snp_cpuid()
637 struct cpuid_leaf leaf; in do_vc_no_ghcb() local
648 leaf.fn = fn; in do_vc_no_ghcb()
649 leaf.subfn = subfn; in do_vc_no_ghcb()
651 ret = snp_cpuid(NULL, NULL, &leaf); in do_vc_no_ghcb()
658 if (__sev_cpuid_hv_msr(&leaf)) in do_vc_no_ghcb()
662 regs->ax = leaf.eax; in do_vc_no_ghcb()
663 regs->bx = leaf.ebx; in do_vc_no_ghcb()
664 regs->cx = leaf.ecx; in do_vc_no_ghcb()
665 regs->dx = leaf.edx; in do_vc_no_ghcb()