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

Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support



Hi,

On 19/02/2020 15:49, Jan Beulich wrote:
On 19.02.2020 09:11, Juergen Gross wrote:
+int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
+        return -EDOM;
+
+    if ( copy_from_guest(u.buf, uaddr, ulen) )
+        return -EFAULT;
+
+    switch ( leaf->e.size )
+    {
+    case 1:
+        *(uint8_t *)leaf->write_ptr = !!u.u8;
+        break;
+    case 2:
+        *(uint16_t *)leaf->write_ptr = !!u.u16;
+        break;
+    case 4:
+        *(uint32_t *)leaf->write_ptr = !!u.u32;
+        break;
+    case 8:
+        *(uint64_t *)leaf->write_ptr = !!u.u64;
+        break;
+    }

Looking at this again, is there really a need for uint64_t support
here? I.e. can't you cap at unsigned long (or even unsigned int),
and perhaps additionally avoid use of fixed width types here
altogether (some trickery may be needed for 32-bit's
sizeof(long) == sizeof(int))?

On Arm, we want to have the interface exactly the same for 64-bit and 32-bit. If you plan to not support 8-byte here, this would effectively mean that 8-byte could not be used on Arm.

However, I can't find any use of hypfs_write_bool, so I am not entirely sure why we would want to cater size other than 1. Juerge, do you mind expanding your thoughts?

Cheers,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.