{
DECLARE_DOMCTL;
int ret = -1;
+ uint8_t local[sizeof (cpumap)];
domctl.cmd = XEN_DOMCTL_setvcpuaffinity;
domctl.domain = (domid_t)domid;
domctl.u.vcpuaffinity.vcpu = vcpu;
- set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap,
- (uint8_t *)&cpumap);
+ bitmap_64_to_byte(local, &cpumap, sizeof (cpumap));
+
+ set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local);
+
domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(cpumap) * 8;
- if ( lock_pages(&cpumap, sizeof(cpumap)) != 0 )
+ if ( lock_pages(local, sizeof(local)) != 0 )
{
PERROR("Could not lock memory for Xen hypercall");
goto out;
ret = do_domctl(xc_handle, &domctl);
- unlock_pages(&cpumap, sizeof(cpumap));
+ unlock_pages(local, sizeof(local));
out:
return ret;
{
DECLARE_DOMCTL;
int ret = -1;
+ uint8_t local[sizeof (cpumap)];
domctl.cmd = XEN_DOMCTL_getvcpuaffinity;
domctl.domain = (domid_t)domid;
domctl.u.vcpuaffinity.vcpu = vcpu;
- set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap,
- (uint8_t *)cpumap);
- domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(*cpumap) * 8;
+ set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local);
+ domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(cpumap) * 8;
- if ( lock_pages(cpumap, sizeof(*cpumap)) != 0 )
+ if ( lock_pages(local, sizeof(local)) != 0 )
{
PERROR("Could not lock memory for Xen hypercall");
goto out;
ret = do_domctl(xc_handle, &domctl);
- unlock_pages(cpumap, sizeof(*cpumap));
-
+ unlock_pages(local, sizeof (local));
+ bitmap_byte_to_64(cpumap, local, sizeof (local));
out:
return ret;
}
return errbuf;
}
+void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits)
+{
+ uint64_t l;
+ int i, j, b;
+
+ for (i = 0, b = 0; nbits > 0; i++, b += sizeof(l)) {
+ l = lp[i];
+ for (j = 0; (j < sizeof(l)) && (nbits > 0); j++) {
+ bp[b+j] = l;
+ l >>= 8;
+ nbits -= 8;
+ }
+ }
+}
+
+void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits)
+{
+ uint64_t l;
+ int i, j, b;
+
+ for (i = 0, b = 0; nbits > 0; i++, b += sizeof(l)) {
+ l = 0;
+ for (j = 0; (j < sizeof(l)) && (nbits > 0); j++) {
+ l <<= 8;
+ l |= bp[b+j];
+ nbits -= 8;
+ }
+ lp[i] = l;
+ }
+}
+
/*
* Local variables:
* mode: C
int xc_waitdomain_core(int xc_handle, int domain, int *status,
int options, vcpu_guest_context_t *ctxt);
+void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits);
+void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
+
#endif /* __XC_PRIVATE_H__ */