GNU/Hurd support
v3 cover GNU/Hurd support
Hi all,
This patchset was buried in the mailing list, I have rebased and addressed all comments in the separated threads relating to this series.
Thanks for reviewing previously, and I hope the original author does not mind I have picked up this work.
TESTED: It compiles and runs qemu-system-i386 and qemu-system-x86_64 on GNU/Hurd x86_64.
Cheers,
Damien
PATCH v3 1/4 Include new arbitrary limits if not already defined
From: Manolo de Medici <[email protected]>
Although GNU/Hurd supports unlimited path lengths
only bounded by available memory, for now we can use an arbitrary limit on PATH_MAX that matches what POSIX requires. We don't have the bandwith to fix this properly right now.
Author: Manolo de Medici <[email protected]>
--- include/qemu/osdep.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
include/qemu/osdep.h +11 -4
@@ -385,6 +385,17 @@ void QEMU_ERROR("code path is reachable")#define TIME_MAX TYPE_MAXIMUM(time_t)#endif +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/* +* Use the same value as Linux for now. +*/ +#ifndef IOV_MAX +#define IOV_MAX 1024 +#endif +/* Mac OSX has a <stdint.h> bug that incorrectly defines SIZE_MAX with * the wrong type. Our replacement isn't usable in preprocessor * expressions, but it is sufficient for our needs. */
@@ -661,10 +672,6 @@ struct iovec {void *iov_base;size_t iov_len; }; -/* -* Use the same value as Linux for now. -*/ -#define IOV_MAX 1024ssize_t readv (int fd,const struct iovec *iov,int iov_cnt);ssize_t writev (int fd,const struct iovec *iov,int iov_cnt);
Signature · 1 line
2.51.0
PATCH v3 2/4 Add GNU/Hurd host_os=gnu
In reply to Damien ZammitUse same value for host_os as meson for GNU/Hurd.
--- configure | 2 ++ 1 file changed, 2 insertions(+)
configure +2 -0
@@ -372,6 +372,8 @@ elif check_define __APPLE__; then elif check_define EMSCRIPTEN ; then host_os=emscripten cross_compile="yes" +elif check_define __GNU__; then + host_os=gnu else # This is a fatal error, but don't report it yet, because we # might be going to just print the --help text, or it might
Signature · 1 line
2.51.0
PATCH v3 3/4 Exclude TPM ioctls definitions for the GNU/Hurd
In reply to Damien ZammitFrom: Manolo de Medici <[email protected]>
The Hurd currently doesn't have any TPM driver, compilation fails for missing symbols unless these are left undefined.
--- backends/tpm/tpm_ioctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
backends/tpm/tpm_ioctl.h +1 -1
@@ -285,7 +285,7 @@ typedef struct ptm_lockstorage ptm_lockstorage;#define PTM_CAP_SEND_COMMAND_HEADER (1 << 15)#define PTM_CAP_LOCK_STORAGE (1 << 16) -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__GNU__)enum {PTM_GET_CAPABILITY =_IOR ('P' ,0 , ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init),
Signature · 1 line
2.51.0
Re: [PATCH v3 3/4 qemu] Exclude TPM ioctls definitions for the GNU/Hurd
Quoted 4 lines · Damien Zammit
From: Manolo de Medici <[email protected]>
The Hurd currently doesn't have any TPM driver, compilation fails for missing symbols unless these are left undefined.
This is due to the missing _IO* symbols, not the TPM driver.
Fortunately, these are unused and the whole enum can be removed. Please check if it's also possible to remove
#ifndef _WIN32
#include <sys/uio.h>
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
at the top of the file.
Paolo
Quoted 19 lines
Signed-off-by Manolo de Medici <[email protected]>Reviewed-by Stefan Berger <[email protected]>--- backends/tpm/tpm_ioctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)backends/tpm/tpm_ioctl.h +1
-1@@ -285,7 +285,7 @@ typedef struct ptm_lockstorage ptm_lockstorage;#define PTM_CAP_SEND_COMMAND_HEADER (1 << 15)#define PTM_CAP_LOCK_STORAGE (1 << 16) -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__GNU__)enum {PTM_GET_CAPABILITY =_IOR ('P' ,0 , ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init),
Re: [PATCH v3 3/4 qemu] Exclude TPM ioctls definitions for the GNU/Hurd
Quoted 10 lines · Paolo Bonzini
Quoted 4 lines · Damien Zammit
From: Manolo de Medici <[email protected]>
The Hurd currently doesn't have any TPM driver, compilation fails for missing symbols unless these are left undefined.
This is due to the missing _IO* symbols, not the TPM driver.
Fortunately, these are unused and the whole enum can be removed. Please check if it's also possible to remove
Quoted 8 lines
#ifndef
_WIN32
#include <sys/uio.h>
#include <sys/ioctl.h>
#endif#ifdef
HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
So this file comes originally from swtpm here: https://github.com/stefanberger/swtpm/blob/master/include/swtpm/tpm_ioctl.h
To keep them in sync as much as possible -- would this here work?
#ifndef _WIN32
#include <sys/uio.h>
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
#ifdef __gnu_hurd__
#include <mach/x86_64/ioccom.h>
#endif
and then keep this as-is?
#if !defined(_WIN32)
enum {
PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap),
PTM_INIT = _IOWR('P', 1, ptm_init),
PTM_SHUTDOWN = _IOR('P', 2, ptm_res),Quoted 25 lines
at the top of the file.
Paolo
Quoted 18 lines
Signed-off-by Manolo de Medici <[email protected]>Reviewed-by Stefan Berger <[email protected]>---
backends/tpm/tpm_ioctl.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)backends/tpm/tpm_ioctl.h +1
-1@@ -285,7 +285,7 @@ typedef struct ptm_lockstorage ptm_lockstorage; #define PTM_CAP_SEND_COMMAND_HEADER (1 << 15) #define PTM_CAP_LOCK_STORAGE (1 << 16) -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__GNU__) enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init),
Re: [PATCH v3 3/4 qemu] Exclude TPM ioctls definitions for the GNU/Hurd
Hi Stefan,
Quoted 18 lines · Stefan Berger
So this file comes originally from swtpm here:
https://github.com/stefanberger/swtpm/blob/master/include/swtpm/tpm_ioctl.hTo keep them in sync as much as possible -- would this here work?
#ifndef
_WIN32
#include <sys/uio.h>
#include <sys/ioctl.h>
#endif#ifdef
HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif#ifdef
__gnu_hurd__
#include <mach/x86_64/ioccom.h>
#endif
Quoted 7 lines
and then keep this as-is?
#if !defined(_WIN32)
enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init), PTM_SHUTDOWN = _IOR('P', 2, ptm_res),
No, this wont work because the _IOT__IOTBASE_* symbols are missing for the tpm structs on GNU platform:
In file included from /usr/include/x86_64-gnu/sys/ioctl.h:26,
from ../backends/tpm/tpm_ioctl.h:17,
from ../backends/tpm/tpm_emulator.c:39:../backends/tpm/tpm_ioctl.h:290:30: error: ‘_IOT__IOTBASE_ptm_cap’ undeclared here (not in a function)
290 | PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), | ^~~~../backends/tpm/tpm_ioctl.h:291:30: error: ‘_IOT__IOTBASE_ptm_init’ undeclared here (not in a function)
291 | PTM_INIT = _IOWR('P', 1, ptm_init), | ^~~~~../backends/tpm/tpm_ioctl.h:292:30: error: ‘_IOT__IOTBASE_ptm_res’ undeclared here (not in a function)
292 | PTM_SHUTDOWN = _IOR('P', 2, ptm_res), | ^~~~../backends/tpm/tpm_ioctl.h:293:30: error: ‘_IOT__IOTBASE_ptm_est’ undeclared here (not in a function)
293 | PTM_GET_TPMESTABLISHED = _IOR('P', 3, ptm_est), | ^~~~../backends/tpm/tpm_ioctl.h:294:30: error: ‘_IOT__IOTBASE_ptm_loc’ undeclared here (not in a function)
294 | PTM_SET_LOCALITY = _IOWR('P', 4, ptm_loc), | ^~~~~../backends/tpm/tpm_ioctl.h:296:30: error: ‘_IOT__IOTBASE_ptm_hdata’ undeclared here (not in a function)
296 | PTM_HASH_DATA = _IOWR('P', 6, ptm_hdata), | ^~~~~../backends/tpm/tpm_ioctl.h:300:32: error: ‘_IOT__IOTBASE_ptm_reset_est’ undeclared here (not in a function)
300 | PTM_RESET_TPMESTABLISHED = _IOWR('P', 10, ptm_reset_est), | ^~~~~../backends/tpm/tpm_ioctl.h:301:30: error: ‘_IOT__IOTBASE_ptm_getstate’ undeclared here (not in a function)
301 | PTM_GET_STATEBLOB = _IOWR('P', 11, ptm_getstate), | ^~~~~../backends/tpm/tpm_ioctl.h:302:30: error: ‘_IOT__IOTBASE_ptm_setstate’ undeclared here (not in a function)
302 | PTM_SET_STATEBLOB = _IOWR('P', 12, ptm_setstate), | ^~~~~../backends/tpm/tpm_ioctl.h:304:30: error: ‘_IOT__IOTBASE_ptm_getconfig’ undeclared here (not in a function)
304 | PTM_GET_CONFIG = _IOR('P', 14, ptm_getconfig), | ^~~~../backends/tpm/tpm_ioctl.h:306:30: error:
‘_IOT__IOTBASE_ptm_setbuffersize’ undeclared here (not in a function)
306 | PTM_SET_BUFFERSIZE = _IOWR('P', 16, ptm_setbuffersize), | ^~~~~../backends/tpm/tpm_ioctl.h:307:30: error: ‘_IOT__IOTBASE_ptm_getinfo’ undeclared here (not in a function)
307 | PTM_GET_INFO = _IOWR('P', 17, ptm_getinfo), | ^~~~~../backends/tpm/tpm_ioctl.h:308:30: error:
‘_IOT__IOTBASE_ptm_lockstorage’ undeclared here (not in a function)
308 | PTM_LOCK_STORAGE = _IOWR('P', 18, ptm_lockstorage),
If you want to preserve the enum, I am happy to put an ifdef instead of removing it.
That would be exactly what we had in v3 3/4.
Damien
Re: [PATCH v3 3/4 qemu] Exclude TPM ioctls definitions for the GNU/Hurd
Quoted 33 lines · Damien Zammit
Hi Stefan,
Quoted 18 lines · Stefan Berger
So this file comes originally from swtpm here:
https://github.com/stefanberger/swtpm/blob/master/include/swtpm/tpm_ioctl.hTo keep them in sync as much as possible -- would this here work?
#ifndef
_WIN32
#include <sys/uio.h>
#include <sys/ioctl.h>
#endif#ifdef
HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif#ifdef
__gnu_hurd__
#include <mach/x86_64/ioccom.h>
#endifQuoted 7 lines
and then keep this as-is?
#if !defined(_WIN32)
enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init), PTM_SHUTDOWN = _IOR('P', 2, ptm_res),No, this wont work because the _IOT__IOTBASE_* symbols are missing for the tpm structs on GNU platform:
Quoted 7 lines
In file included from
/usr/include/x86_64-gnu/sys/ioctl.h:26,
from../backends/tpm/tpm_ioctl.h:17, from../backends/tpm/tpm_emulator.c:39:../backends/tpm/tpm_ioctl.h:290:30: error: ‘_IOT__IOTBASE_ptm_cap’ undeclared here (not in a function)
290 | PTM_GET_CAPABILITY =_IOR('P', 0, ptm_cap), | ^~~~
I have it compile because I added this here (above):
#ifdef __gnu_hurd__
#include <mach/x86_64/ioccom.h>
#endif
Without this header I do see these errors as well. Either way, am fine with your suggestion in v5.
Stefan
Re: [PATCH v3 3/4 qemu] Exclude TPM ioctls definitions for the GNU/Hurd
Hello,
Stefan Berger, le mar. 10 févr. 2026 12:58:24 -0500, a ecrit:
Quoted 19 lines · Damien Zammit
Quoted 10 lines · Stefan Berger
Quoted 4 lines
enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init), PTM_SHUTDOWN = _IOR('P', 2, ptm_res),No, this wont work because the _IOT__IOTBASE_* symbols are missing for the tpm structs on GNU platform:
Quoted 7 lines
In file included from
/usr/include/x86_64-gnu/sys/ioctl.h:26,
from../backends/tpm/tpm_ioctl.h:17, from../backends/tpm/tpm_emulator.c:39:../backends/tpm/tpm_ioctl.h:290:30: error: ‘_IOT__IOTBASE_ptm_cap’ undeclared here (not in a function)
290 | PTM_GET_CAPABILITY =_IOR('P', 0, ptm_cap), | ^~~~
Quoted 5 lines
I have it compile because I added this here (above):
#ifdef
__gnu_hurd__
#include <mach/x86_64/ioccom.h>
#endif
This mach-ish ioccom.h is not the way ioctls are defined in the Hurd. I have actually even dropped it from gnumach, since we don't actually use this way of defining ioctls any more. _IOT macros for ptm_capt/init/res really need to be defined for _IOR/WR to be usable.
Samuel
PATCH v3 4/4 Avoid static definition of copy_file_range on GNU/Hurd
In reply to Damien Zammitglibc already has this as non-static on __GNU__ systems. Also, add the missing sys/ioctl.h header for the same platform.
--- block/file-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
block/file-posix.c +5 -1
@@ -116,6 +116,10 @@#include <sys/ioctl.h> #endif +#ifdef __GNU__ +#include <sys/ioctl.h> +#endif +/* OS X does not have O_DSYNC */ #ifndef O_DSYNC #ifdef O_SYNC
@@ -2113,7 +2117,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) }#ifndef HAVE_COPY_FILE_RANGE -#ifndef EMSCRIPTEN +#if !defined(EMSCRIPTEN ) && !defined(__GNU__) static#endif ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
Signature · 1 line
2.51.0
Re: [PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd
Quoted 2 lines · Damien Zammit
glibc already has this as non-static on
__GNU__systems. Also, add the missingsys/ioctl.hheader for the same platform.
Please just move the inclusion of sys/ioctl.h outside all #ifdefs, i.e.
...
#include <sys/ioctl.h>
#if defined(__APPLE__) && (__MACH__)
#if defined(HAVE_HOST_BLOCK_DEVICE)
#include <paths.h>
#include <sys/param.h>
...
and remove all the #includes for it after the first.
Thanks,
Paolo
Quoted 29 lines
Signed-off-by Damien Zammit <[email protected]>--- block/file-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)block/file-posix.c +5
-1@@ -116,6 +116,10 @@#include <sys/ioctl.h> #endif +#ifdef __GNU__ +#include <sys/ioctl.h> +#endif +/* OS X does not have O_DSYNC */ #ifndef O_DSYNC #ifdef O_SYNC @@ -2113,7 +2117,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) }#ifndef HAVE_COPY_FILE_RANGE -#ifndef EMSCRIPTEN +#if !defined(EMSCRIPTEN ) && !defined(__GNU__) static#endif ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
Re: [PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd
In reply to Damien Zammitblock/file-posix.c static int handle_aiocb_write_zeroes_unmap(void *opaque) · line 2123
Quoted 8 lines · Damien Zammit
glibc already has this as non-static on
__GNU__systems.#ifndef
HAVE_COPY_FILE_RANGEblock/file-posix.c +1
-1-#ifndef EMSCRIPTEN +#if !defined(EMSCRIPTEN ) && !defined(__GNU__) static#endif ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
Do I understand it correctly that it has the prototype but not the function?
Thanks,
Paolo