New vs old-style hypercalls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In xen_internal.c we've got code which claims to sniff out whether we are using new-style hypercall ioctls or old-style hypercall ioctls.

    hc.op = __HYPERVISOR_xen_version;
    hc.arg[0] = (unsigned long) XENVER_version;
    hc.arg[1] = 0;

    cmd = IOCTL_PRIVCMD_HYPERCALL;
    ret = ioctl(fd, cmd, (unsigned long) &hc);

    if ((ret != -1) && (ret != 0)) {
#ifdef DEBUG
        fprintf(stderr, "Using new hypervisor call: %X\n", ret);
#endif
        hv_version = ret;
        xen_ioctl_hypercall_cmd = cmd;
        goto detect_v2;
    }

    /*
     * check if the old hypercall are actually working
     */
    v0_hc.op = __HYPERVISOR_xen_version;
    v0_hc.arg[0] = (unsigned long) XENVER_version;
    v0_hc.arg[1] = 0;
    cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t));
    ret = ioctl(fd, cmd, (unsigned long) &v0_hc);

But on 64 bit platforms (not 32 bit) cmd will be identical, so we'll just be trying the same ioctl twice.

From <xen/linux/privcmd.h>:

    typedef struct privcmd_hypercall
    {
        __u64 op;
        __u64 arg[5];
    } privcmd_hypercall_t;

    #define IOCTL_PRIVCMD_HYPERCALL                                 \
        _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))

From src/xen_internal.c:

    typedef struct v0_hypercall_struct {
        unsigned long op;
        unsigned long arg[5];
    } v0_hypercall_t;

    cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t));

On 64 bit platforms, both structures will be the same size.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]