KVM_SET_FPU isn't implemented on ppc, bah
authorLauri Kasanen <cand@gmx.com>
Thu, 27 May 2021 15:25:11 +0000 (18:25 +0300)
committerLauri Kasanen <cand@gmx.com>
Thu, 27 May 2021 15:25:11 +0000 (18:25 +0300)
main.c

diff --git a/main.c b/main.c
index 0ace48812d8afaffba0ce87acba3cee77e01a06f..cf98fe3dbfbedc20e4861db2449a227605cec57f 100644 (file)
--- 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, &regs) == -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