Lines Matching full:leaf

259 static int __sev_cpuid_hv_msr(struct cpuid_leaf *leaf)  in __sev_cpuid_hv_msr()  argument
271 if (cpuid_function_is_indexed(leaf->fn) && leaf->subfn) in __sev_cpuid_hv_msr()
274 ret = __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EAX, &leaf->eax); in __sev_cpuid_hv_msr()
275 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EBX, &leaf->ebx); in __sev_cpuid_hv_msr()
276 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_ECX, &leaf->ecx); in __sev_cpuid_hv_msr()
277 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EDX, &leaf->edx); in __sev_cpuid_hv_msr()
282 static int __sev_cpuid_hv_ghcb(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in __sev_cpuid_hv_ghcb() argument
287 ghcb_set_rax(ghcb, leaf->fn); in __sev_cpuid_hv_ghcb()
288 ghcb_set_rcx(ghcb, leaf->subfn); in __sev_cpuid_hv_ghcb()
307 leaf->eax = ghcb->save.rax; in __sev_cpuid_hv_ghcb()
308 leaf->ebx = ghcb->save.rbx; in __sev_cpuid_hv_ghcb()
309 leaf->ecx = ghcb->save.rcx; in __sev_cpuid_hv_ghcb()
310 leaf->edx = ghcb->save.rdx; in __sev_cpuid_hv_ghcb()
315 static int sev_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in sev_cpuid_hv() argument
317 return ghcb ? __sev_cpuid_hv_ghcb(ghcb, ctxt, leaf) in sev_cpuid_hv()
318 : __sev_cpuid_hv_msr(leaf); in sev_cpuid_hv()
395 snp_cpuid_get_validated_func(struct cpuid_leaf *leaf) in snp_cpuid_get_validated_func() argument
403 if (e->eax_in != leaf->fn) in snp_cpuid_get_validated_func()
406 if (cpuid_function_is_indexed(leaf->fn) && e->ecx_in != leaf->subfn) in snp_cpuid_get_validated_func()
419 leaf->eax = e->eax; in snp_cpuid_get_validated_func()
420 leaf->ebx = e->ebx; in snp_cpuid_get_validated_func()
421 leaf->ecx = e->ecx; in snp_cpuid_get_validated_func()
422 leaf->edx = e->edx; in snp_cpuid_get_validated_func()
430 static void snp_cpuid_hv(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid_hv() argument
432 if (sev_cpuid_hv(ghcb, ctxt, leaf)) in snp_cpuid_hv()
437 struct cpuid_leaf *leaf) in snp_cpuid_postprocess() argument
439 struct cpuid_leaf leaf_hv = *leaf; in snp_cpuid_postprocess()
441 switch (leaf->fn) { in snp_cpuid_postprocess()
446 leaf->ebx = (leaf_hv.ebx & GENMASK(31, 24)) | (leaf->ebx & GENMASK(23, 0)); in snp_cpuid_postprocess()
448 leaf->edx = (leaf_hv.edx & BIT(9)) | (leaf->edx & ~BIT(9)); in snp_cpuid_postprocess()
452 leaf->ecx |= BIT(27); in snp_cpuid_postprocess()
456 leaf->ecx &= ~BIT(4); in snp_cpuid_postprocess()
458 leaf->ecx |= BIT(4); in snp_cpuid_postprocess()
465 leaf->edx = leaf_hv.edx; in snp_cpuid_postprocess()
472 if (leaf->subfn != 0 && leaf->subfn != 1) in snp_cpuid_postprocess()
477 if (leaf->subfn == 1) { in snp_cpuid_postprocess()
479 if (leaf->eax & BIT(3)) { in snp_cpuid_postprocess()
496 if (!(leaf->eax & (BIT(1) | BIT(3)))) in snp_cpuid_postprocess()
506 leaf->ebx = xsave_size; in snp_cpuid_postprocess()
513 leaf->eax = leaf_hv.eax; in snp_cpuid_postprocess()
515 leaf->ebx = (leaf->ebx & GENMASK(31, 8)) | (leaf_hv.ebx & GENMASK(7, 0)); in snp_cpuid_postprocess()
517 leaf->ecx = (leaf->ecx & GENMASK(31, 8)) | (leaf_hv.ecx & GENMASK(7, 0)); in snp_cpuid_postprocess()
531 static int snp_cpuid(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf) in snp_cpuid() argument
538 if (!snp_cpuid_get_validated_func(leaf)) { in snp_cpuid()
556 leaf->eax = leaf->ebx = leaf->ecx = leaf->edx = 0; in snp_cpuid()
559 if (!(leaf->fn <= cpuid_std_range_max || in snp_cpuid()
560 (leaf->fn >= 0x40000000 && leaf->fn <= cpuid_hyp_range_max) || in snp_cpuid()
561 (leaf->fn >= 0x80000000 && leaf->fn <= cpuid_ext_range_max))) in snp_cpuid()
565 return snp_cpuid_postprocess(ghcb, ctxt, leaf); in snp_cpuid()
577 struct cpuid_leaf leaf; in do_vc_no_ghcb() local
584 leaf.fn = fn; in do_vc_no_ghcb()
585 leaf.subfn = subfn; in do_vc_no_ghcb()
587 ret = snp_cpuid(NULL, NULL, &leaf); in do_vc_no_ghcb()
594 if (__sev_cpuid_hv_msr(&leaf)) in do_vc_no_ghcb()
598 regs->ax = leaf.eax; in do_vc_no_ghcb()
599 regs->bx = leaf.ebx; in do_vc_no_ghcb()
600 regs->cx = leaf.ecx; in do_vc_no_ghcb()
601 regs->dx = leaf.edx; in do_vc_no_ghcb()
611 * - Availability of CPUID leaf 0x8000001f in do_vc_no_ghcb()
619 /* SEV leaf check */ in do_vc_no_ghcb()
929 struct cpuid_leaf leaf; in vc_handle_cpuid_snp() local
932 leaf.fn = regs->ax; in vc_handle_cpuid_snp()
933 leaf.subfn = regs->cx; in vc_handle_cpuid_snp()
934 ret = snp_cpuid(ghcb, ctxt, &leaf); in vc_handle_cpuid_snp()
936 regs->ax = leaf.eax; in vc_handle_cpuid_snp()
937 regs->bx = leaf.ebx; in vc_handle_cpuid_snp()
938 regs->cx = leaf.ecx; in vc_handle_cpuid_snp()
939 regs->dx = leaf.edx; in vc_handle_cpuid_snp()