Skip to content

Commit 77892e1

Browse files
author
Peter Zijlstra
committed
KVM: x86: Convert em_salc() to C
Implement the SALC (Set AL if Carry) instruction in C. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Sean Christopherson <seanjc@google.com> Link: https://lkml.kernel.org/r/20250714103440.634145269@infradead.org
1 parent 2d82acd commit 77892e1

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

arch/x86/kvm/emulate.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,14 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
529529
ON64(FOP3E(op##q, rax, rdx, cl)) \
530530
FOP_END
531531

532-
FOP_START(salc)
533-
FOP_FUNC(salc)
534-
"pushf; sbb %al, %al; popf \n\t"
535-
FOP_RET(salc)
536-
FOP_END;
532+
static int em_salc(struct x86_emulate_ctxt *ctxt)
533+
{
534+
/*
535+
* Set AL 0xFF if CF is set, or 0x00 when clear.
536+
*/
537+
ctxt->dst.val = 0xFF * !!(ctxt->eflags & X86_EFLAGS_CF);
538+
return X86EMUL_CONTINUE;
539+
}
537540

538541
/*
539542
* XXX: inoutclob user must know where the argument is being expanded.
@@ -4423,7 +4426,7 @@ static const struct opcode opcode_table[256] = {
44234426
G(Src2CL | ByteOp, group2), G(Src2CL, group2),
44244427
I(DstAcc | SrcImmUByte | No64, em_aam),
44254428
I(DstAcc | SrcImmUByte | No64, em_aad),
4426-
F(DstAcc | ByteOp | No64, em_salc),
4429+
I(DstAcc | ByteOp | No64, em_salc),
44274430
I(DstAcc | SrcXLat | ByteOp, em_mov),
44284431
/* 0xD8 - 0xDF */
44294432
N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N,

0 commit comments

Comments
 (0)