Lines Matching refs:leaf
256 static int sev_cpuid_hv(struct cpuid_leaf *leaf) in sev_cpuid_hv() argument
268 if (cpuid_function_is_indexed(leaf->fn) && leaf->subfn) in sev_cpuid_hv()
271 ret = __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EAX, &leaf->eax); in sev_cpuid_hv()
272 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EBX, &leaf->ebx); in sev_cpuid_hv()
273 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_ECX, &leaf->ecx); in sev_cpuid_hv()
274 ret = ret ? : __sev_cpuid_hv(leaf->fn, GHCB_CPUID_REQ_EDX, &leaf->edx); in sev_cpuid_hv()
353 snp_cpuid_get_validated_func(struct cpuid_leaf *leaf) in snp_cpuid_get_validated_func() argument
361 if (e->eax_in != leaf->fn) in snp_cpuid_get_validated_func()
364 if (cpuid_function_is_indexed(leaf->fn) && e->ecx_in != leaf->subfn) in snp_cpuid_get_validated_func()
377 leaf->eax = e->eax; in snp_cpuid_get_validated_func()
378 leaf->ebx = e->ebx; in snp_cpuid_get_validated_func()
379 leaf->ecx = e->ecx; in snp_cpuid_get_validated_func()
380 leaf->edx = e->edx; in snp_cpuid_get_validated_func()
388 static void snp_cpuid_hv(struct cpuid_leaf *leaf) in snp_cpuid_hv() argument
390 if (sev_cpuid_hv(leaf)) in snp_cpuid_hv()
394 static int snp_cpuid_postprocess(struct cpuid_leaf *leaf) in snp_cpuid_postprocess() argument
396 struct cpuid_leaf leaf_hv = *leaf; in snp_cpuid_postprocess()
398 switch (leaf->fn) { in snp_cpuid_postprocess()
403 leaf->ebx = (leaf_hv.ebx & GENMASK(31, 24)) | (leaf->ebx & GENMASK(23, 0)); in snp_cpuid_postprocess()
405 leaf->edx = (leaf_hv.edx & BIT(9)) | (leaf->edx & ~BIT(9)); in snp_cpuid_postprocess()
409 leaf->ecx |= BIT(27); in snp_cpuid_postprocess()
413 leaf->ecx &= ~BIT(4); in snp_cpuid_postprocess()
415 leaf->ecx |= BIT(4); in snp_cpuid_postprocess()
422 leaf->edx = leaf_hv.edx; in snp_cpuid_postprocess()
429 if (leaf->subfn != 0 && leaf->subfn != 1) in snp_cpuid_postprocess()
434 if (leaf->subfn == 1) { in snp_cpuid_postprocess()
436 if (leaf->eax & BIT(3)) { in snp_cpuid_postprocess()
453 if (!(leaf->eax & (BIT(1) | BIT(3)))) in snp_cpuid_postprocess()
463 leaf->ebx = xsave_size; in snp_cpuid_postprocess()
470 leaf->eax = leaf_hv.eax; in snp_cpuid_postprocess()
472 leaf->ebx = (leaf->ebx & GENMASK(31, 8)) | (leaf_hv.ebx & GENMASK(7, 0)); in snp_cpuid_postprocess()
474 leaf->ecx = (leaf->ecx & GENMASK(31, 8)) | (leaf_hv.ecx & GENMASK(7, 0)); in snp_cpuid_postprocess()
488 static int snp_cpuid(struct cpuid_leaf *leaf) in snp_cpuid() argument
495 if (!snp_cpuid_get_validated_func(leaf)) { in snp_cpuid()
513 leaf->eax = leaf->ebx = leaf->ecx = leaf->edx = 0; in snp_cpuid()
516 if (!(leaf->fn <= cpuid_std_range_max || in snp_cpuid()
517 (leaf->fn >= 0x40000000 && leaf->fn <= cpuid_hyp_range_max) || in snp_cpuid()
518 (leaf->fn >= 0x80000000 && leaf->fn <= cpuid_ext_range_max))) in snp_cpuid()
522 return snp_cpuid_postprocess(leaf); in snp_cpuid()
534 struct cpuid_leaf leaf; in do_vc_no_ghcb() local
541 leaf.fn = fn; in do_vc_no_ghcb()
542 leaf.subfn = subfn; in do_vc_no_ghcb()
544 ret = snp_cpuid(&leaf); in do_vc_no_ghcb()
551 if (sev_cpuid_hv(&leaf)) in do_vc_no_ghcb()
555 regs->ax = leaf.eax; in do_vc_no_ghcb()
556 regs->bx = leaf.ebx; in do_vc_no_ghcb()
557 regs->cx = leaf.ecx; in do_vc_no_ghcb()
558 regs->dx = leaf.edx; in do_vc_no_ghcb()
850 struct cpuid_leaf leaf; in vc_handle_cpuid_snp() local
853 leaf.fn = regs->ax; in vc_handle_cpuid_snp()
854 leaf.subfn = regs->cx; in vc_handle_cpuid_snp()
855 ret = snp_cpuid(&leaf); in vc_handle_cpuid_snp()
857 regs->ax = leaf.eax; in vc_handle_cpuid_snp()
858 regs->bx = leaf.ebx; in vc_handle_cpuid_snp()
859 regs->cx = leaf.ecx; in vc_handle_cpuid_snp()
860 regs->dx = leaf.edx; in vc_handle_cpuid_snp()