Revision 45024f09

b/hw/ppc.h
47 47
#define FW_CFG_PPC_HEIGHT	(FW_CFG_ARCH_LOCAL + 0x01)
48 48
#define FW_CFG_PPC_DEPTH	(FW_CFG_ARCH_LOCAL + 0x02)
49 49
#define FW_CFG_PPC_TBFREQ	(FW_CFG_ARCH_LOCAL + 0x03)
50
#define FW_CFG_PPC_IS_KVM       (FW_CFG_ARCH_LOCAL + 0x05)
51
#define FW_CFG_PPC_KVM_HC       (FW_CFG_ARCH_LOCAL + 0x06)
52
#define FW_CFG_PPC_KVM_PID      (FW_CFG_ARCH_LOCAL + 0x07)
50 53

  
51 54
#define PPC_SERIAL_MM_BAUDBASE 399193
b/hw/ppc_newworld.c
427 427
    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
428 428
    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
429 429

  
430
    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
430 431
    if (kvm_enabled()) {
431 432
#ifdef CONFIG_KVM
433
        uint8_t *hypercall;
434

  
432 435
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
436
        hypercall = qemu_malloc(16);
437
        kvmppc_get_hypercall(env, hypercall, 16);
438
        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
439
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
433 440
#endif
434 441
    } else {
435 442
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
b/hw/ppc_oldworld.c
399 399
    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
400 400
    fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
401 401

  
402
    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
402 403
    if (kvm_enabled()) {
403 404
#ifdef CONFIG_KVM
405
        uint8_t *hypercall;
406

  
404 407
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
408
        hypercall = qemu_malloc(16);
409
        kvmppc_get_hypercall(env, hypercall, 16);
410
        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
411
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
405 412
#endif
406 413
    } else {
407 414
        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
b/target-ppc/kvm.c
327 327
    return retval;
328 328
}
329 329

  
330
int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len)
331
{
332
    uint32_t *hc = (uint32_t*)buf;
333

  
334
#ifdef KVM_CAP_PPC_GET_PVINFO
335
    struct kvm_ppc_pvinfo pvinfo;
336

  
337
    if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) &&
338
        !kvm_vm_ioctl(env->kvm_state, KVM_PPC_GET_PVINFO, &pvinfo)) {
339
        memcpy(buf, pvinfo.hcall, buf_len);
340

  
341
        return 0;
342
    }
343
#endif
344

  
345
    /*
346
     * Fallback to always fail hypercalls:
347
     *
348
     *     li r3, -1
349
     *     nop
350
     *     nop
351
     *     nop
352
     */
353

  
354
    hc[0] = 0x3860ffff;
355
    hc[1] = 0x60000000;
356
    hc[2] = 0x60000000;
357
    hc[3] = 0x60000000;
358

  
359
    return 0;
360
}
361

  
330 362
bool kvm_arch_stop_on_emulation_error(CPUState *env)
331 363
{
332 364
    return true;
b/target-ppc/kvm_ppc.h
15 15
                                     void *val, size_t len);
16 16

  
17 17
uint32_t kvmppc_get_tbfreq(void);
18
int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len);
18 19

  
19 20
#endif /* __KVM_PPC_H__ */

Also available in: Unified diff