From: Lauri Kasanen Date: Thu, 27 May 2021 15:25:11 +0000 (+0300) Subject: KVM_SET_FPU isn't implemented on ppc, bah X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81e453e2d0c1852055654de9582aa350d451528f;p=kvm-minippc.git KVM_SET_FPU isn't implemented on ppc, bah --- diff --git a/main.c b/main.c index 0ace488..cf98fe3 100644 --- a/main.c +++ b/main.c @@ -196,6 +196,34 @@ static void load(const char arg[], uint8_t *ram) { fclose(f); } +static void setfpregs(const int vcpu, struct kvm_fpu *fpregs) { + // KVM_[SG]ET_FPU isn't supported on PPC, we have to move individual regs... + unsigned i; + for (i = 0; i < 32; i++) { + struct kvm_one_reg r = { + .id = KVM_REG_PPC_FPR(i), + .addr = (uint64_t) &fpregs->fpr[i] + }; + + if (ioctl(vcpu, KVM_SET_ONE_REG, &r) != 0) + abort(); + } +} + +static void getfpregs(const int vcpu, struct kvm_fpu *fpregs) { + // KVM_[SG]ET_FPU isn't supported on PPC, we have to move individual regs... + unsigned i; + for (i = 0; i < 32; i++) { + struct kvm_one_reg r = { + .id = KVM_REG_PPC_FPR(i), + .addr = (uint64_t) &fpregs->fpr[i] + }; + + if (ioctl(vcpu, KVM_GET_ONE_REG, &r) != 0) + abort(); + } +} + int main(int argc, char **argv) { const struct option longopts[] = { @@ -358,8 +386,7 @@ int main(int argc, char **argv) { if (ioctl(vcpu, KVM_SET_REGS, ®s) == -1) abort(); - if (ioctl(vcpu, KVM_SET_FPU, &fpregs) == -1) - abort(); + setfpregs(vcpu, &fpregs); const struct kvm_guest_debug dbg = { .control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP