Re: [PATCH v4 1/2] qemu/atomic: Update coding style to make checkpatch.pl happier
will be also nice to squash the following on top for a complete clean checkpatch version, as the original patch introduces at least 1 issue Carlo --- >8 --- Subject: fixup! [PATCH 1/2] qemu/atomic.h: rename atomic_ to qatomic_ fixes: ERROR: Macros with multiple statements should be enclosed in a do - while loop +#define qatomic_rcu_read__nocheck(ptr, valptr) \ +__atomic_load(ptr, valptr, __ATOMIC_RELAXED);\ smp_read_barrier_depends(); false positive: ERROR: memory barrier without comment +#define qatomic_xchg(ptr, i)(smp_mb(), __sync_lock_test_and_set(ptr, i)) Signed-off-by: Carlo Marcelo Arenas Belón --- include/qemu/atomic.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 87b85f9f6d..be47e083be 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -149,9 +149,10 @@ #define qatomic_rcu_read__nocheck(ptr, valptr) \ __atomic_load(ptr, valptr, __ATOMIC_CONSUME); #else -#define qatomic_rcu_read__nocheck(ptr, valptr) \ +#define qatomic_rcu_read__nocheck(ptr, valptr) do { \ __atomic_load(ptr, valptr, __ATOMIC_RELAXED);\ -smp_read_barrier_depends(); +smp_read_barrier_depends(); \ +} while (0) #endif #define qatomic_rcu_read(ptr) \ -- 2.28.0.681.g6f77f65b4e
[PATCH v2] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el]
MIPS provides 2 ILP32 ABIs, and therefore 4 possible qemu-mips binaries with 2 pairs using the same endianess and bitness. This could lead to an O32 image loading in the N32 binary or vice versa and in cryptic errors (if lucky that the CPU doesn't match the FPU used) like : qemu: Unexpected FPU mode (o32 ELF loaded to qemu-mipsn32[el]) ELF binary's NaN mode not supported by CPU(n32 -> qemu-mips[el]) Add an ABI check macro that could be used while checking the ELF header that relies in the ABI2 flag to identify n32 binaries and abort instead early with a more descriptive error : Invalid ELF image for this architecture Signed-off-by: Carlo Marcelo Arenas Belón --- Changes since v1: - Use the provided definition from include/elf.h (per Laurent) - Abort instead of warning (per Laurent, not using a custom error though) - Expand the check to all other combinations (per Aleksandar) linux-user/elfload.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index fe9dfe795d..69936dcd45 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -918,6 +918,12 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en #define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_NANOMIPS) +#ifdef TARGET_ABI_MIPSN32 +#define elf_check_abi(x) ((x) & EF_MIPS_ABI2) +#else +#define elf_check_abi(x) (!((x) & EF_MIPS_ABI2)) +#endif + static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { @@ -1487,6 +1493,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #define elf_check_arch(x) ((x) == ELF_ARCH) #endif +#ifndef elf_check_abi +#define elf_check_abi(x) (1) +#endif + #ifndef ELF_HWCAP #define ELF_HWCAP 0 #endif @@ -1644,6 +1654,7 @@ static bool elf_check_ident(struct elfhdr *ehdr) static bool elf_check_ehdr(struct elfhdr *ehdr) { return (elf_check_arch(ehdr->e_machine) +&& elf_check_abi(ehdr->e_flags) && ehdr->e_ehsize == sizeof(struct elfhdr) && ehdr->e_phentsize == sizeof(struct elf_phdr) && (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)); -- 2.28.0.424.gade71fd49b
[PATCH] linux-user: warn if trying to use qemu-mipsn32[el] with non n32 ELF
While technically compatible will (depending on the CPU) hopefully fail later with a cryptic error: qemu: Unexpected FPU mode Provide an earlier hint of what the problem might be by detecting if the binary might not be using the n32 ABI and print a warning. Signed-off-by: Carlo Marcelo Arenas Belón --- linux-user/elfload.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index fe9dfe795d..64c3921cd9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2390,6 +2390,13 @@ static void load_elf_image(const char *image_name, int image_fd, if (!elf_check_ehdr(ehdr)) { goto exit_errmsg; } +#ifdef TARGET_ABI_MIPSN32 +/* from arch/mips/include/asm/elf.h */ +#define EF_MIPS_ABI2 0x0020 +if (!(ehdr->e_flags & EF_MIPS_ABI2)) { +fprintf(stderr, "warning: ELF binary missing n32 flag\n"); +} +#endif i = ehdr->e_phnum * sizeof(struct elf_phdr); if (ehdr->e_phoff + i <= BPRM_BUF_SIZE) { -- 2.28.0.213.gdd9653da77
[Bug 1825002] Re: "qemu: Unexpected FPU mode" since 0c1bbedc10e86ea9366b6af8c5520fafa3266b2f
FWIW I am still seeing a similar failure with 5.1.0rc3 (using a "Hello World" like program in Ubuntu 20.04 x86_64 built statically): $ mipsisa32r6el-linux-gnu-gcc --static -o h h.c $ ./qemu-mipsn32el ./h qemu: Unexpected FPU mode big endian also seems to be affected -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1825002 Title: "qemu: Unexpected FPU mode" since 0c1bbedc10e86ea9366b6af8c5520fafa3266b2f Status in QEMU: Fix Released Bug description: This happens every time I attempt to chroot into a gentoo-mips image unless I load the executable via ld.so /home (root)# chroot gentoo-mips32r2el /bin/sh qemu: Unexpected FPU mode /home (root)# chroot gentoo-mips32r2el /lib/ld-2.19.so /bin/sh sh-4.2# exit /home (root)# I don't know the underlying cause, but keep in mind that we may lie and claim to have an FPU when our CPU doesn't because of kernel emulation that may not be present in the host kernel. Don't know if that's related. I get this with various gentoo-mips stage3 tarballs, but not with OpenWRT. (e.g., https://gentoo.osuosl.org/experimental/mips/stages/mips32r2el/2014) # emerge --info app-emulation/qemu Portage 2.3.51 (python 3.6.5-final-0, default/linux/amd64/17.0/desktop/plasma, gcc-8.2.0, glibc-2.27-r6, 4.14.96-gentoo x86_64) = System Settings = System uname: Linux-4.14.96-gentoo-x86_64-AMD_Ryzen_7_2700X_Eight-Core_Processor-with-gentoo-2.6 KiB Mem:32890732 total, 3480024 free KiB Swap: 16777212 total, 10575592 free Timestamp of repository gentoo: Thu, 11 Apr 2019 06:00:01 + Head commit of repository gentoo: 66eaaa28926103e690db0699466a274a17ab1979 sh bash 4.4_p23-r1 ld GNU ld (Gentoo 2.30 p5) 2.30.0 distcc 3.3.2 x86_64-pc-linux-gnu [disabled] ccache version 3.3.4 [disabled] app-shells/bash: 4.4_p23-r1::gentoo dev-java/java-config: 2.2.0-r4::gentoo dev-lang/perl:5.26.2::gentoo dev-lang/python: 2.7.15::gentoo, 3.6.5::gentoo dev-util/ccache: 3.3.4-r1::gentoo dev-util/cmake: 3.9.6::gentoo dev-util/pkgconfig: 0.29.2::gentoo sys-apps/baselayout: 2.6-r1::gentoo sys-apps/openrc: 0.38.3-r1::gentoo sys-apps/sandbox: 2.13::gentoo sys-devel/autoconf: 2.13-r1::gentoo, 2.64-r1::gentoo, 2.69-r4::gentoo sys-devel/automake: 1.11.6-r3::gentoo, 1.13.4-r2::gentoo, 1.15.1-r2::gentoo, 1.16.1-r1::gentoo sys-devel/binutils: 2.30-r4::gentoo sys-devel/gcc:4.9.4::gentoo, 5.4.0-r6::gentoo, 6.4.0-r5::gentoo, 7.3.0-r6::gentoo, 8.1.0-r3::gentoo, 8.2.0-r6::gentoo, 8.3.0::gentoo sys-devel/gcc-config: 2.0::gentoo sys-devel/libtool:2.4.6-r3::gentoo sys-devel/make: 4.2.1-r4::gentoo sys-kernel/linux-headers: 4.14-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.27-r6::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-jobs: 1 sync-rsync-extra-opts: sync-rsync-verify-metamanifest: yes sync-rsync-verify-max-age: 24 love-local location: /usr/local/portage masters: gentoo priority: 0 chaoslab location: /var/lib/layman/chaoslab masters: gentoo priority: 50 java location: /var/lib/layman/java masters: gentoo priority: 50 steam-overlay location: /var/lib/layman/steam-overlay masters: gentoo priority: 50 zugaina location: /var/lib/layman/zugaina masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -ggdb3 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-march=native -O2 -ggdb3 -pipe" DISTDIR="/mnt/large/distfiles" EMERGE_DEFAULT_OPTS="-j3 --load-average=17.5 --with-bdeps=y --autounmask=n" ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs buildpkg candy cgroup compress-build-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources ipc-sandbox merge-sync
[Bug 1821444] Re: qemu-ppc (user) incorrectly translates float32 arithmetics
fix committed with c0e6616b6685ffdb4c5e091bc152e46e14703dd1 and released with 4.2.0 ** Changed in: qemu Status: New => Fix Released -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1821444 Title: qemu-ppc (user) incorrectly translates float32 arithmetics Status in QEMU: Fix Released Bug description: I'm using qemu-3.1.0 (Gentoo). When I was running regression test suite via qemu-ppc for GHC I noticed a few uint32_t<->float32 failures I did not expect to encounter. Here is an example $ cat a.c #include #include int main() { volatile uint32_t i = 1; printf("0x1 = %e\n", *(volatile float*)); } $ powerpc-unknown-linux-gnu-gcc -O2 a.c -Wall -o a -fno-strict-aliasing -fno-stack-protector -static && ./a 0x1 = 2.802597e-45 $ scp a timberdoodle.ppc64.dev.gentoo.org:~/ a 100% 826KB 102.0KB/s 00:08 $ ssh timberdoodle.ppc64.dev.gentoo.org ./a 0x1 = 1.401298e-45 $ qemu-ppc ./a 0x1 = 2.802597e-45 Looks like off-by-one bit somewhere. I'm not sure if it's FPU instruction or some internals of printf() that are emulated incorrectly. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1821444/+subscriptions
[Bug 1821515] Re: qemu-ppc (user) incorrectly converts float(nan)->double(non-nan)
*** This bug is a duplicate of bug 1821444 *** https://bugs.launchpad.net/bugs/1821444 ** This bug has been marked a duplicate of bug 1821444 qemu-ppc (user) incorrectly translates float32 arithmetics -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1821515 Title: qemu-ppc (user) incorrectly converts float(nan)->double(non-nan) Status in QEMU: New Bug description: Noticed on qemu-3.1.0 on GHC test suite where float32 comparisons didn't work on NaNs. Here is the minimal reproducer: ```c // cat a.c #include #include #include int main() { volatile float f1 = NAN; volatile float f2 = NAN; printf ("f1 (%e, %#x) >= f2 (%e, %#x): %s\n", f1, *(volatile uint32_t*), f2, *(volatile uint32_t*), (f1 >= f2) ? "True" : "False"); volatile double d = f1; printf ("d (%e, %#llx)\n", d, *(volatile uint64_t*)); } ``` ``` # incorrect execution: $ powerpc-unknown-linux-gnu-gcc -O2 a.c -o a -static && qemu-ppc ./a f1 (5.104236e+38, 0x7fc0) >= f2 (5.104236e+38, 0x7fc0): True d (5.104236e+38, 0x47f8) # correct execution $ scp a timberdoodle.ppc64.dev.gentoo.org:~/; ssh timberdoodle.ppc64.dev.gentoo.org ./a f1 (nan, 0x7fc0) >= f2 (nan, 0x7fc0): False d (nan, 0x7ff8) ``` Note: qemu-ppc handled float32 extension as it was not a NaN (exp=111..) but a normalized number. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1821515/+subscriptions
[Qemu-devel] [PATCH] configure: fix sdl detection using sdl2-config
If SDL2 is requested but pkg-config doesn't have a module for it configure should fallback to use sdl*-config, but wasn't able to because and old variable (from SDL) was being used by mistake. Correct the variable name and complete other related changes so there are no more references to the old SDL. Fixes: 0015ca5cbabe ("ui: remove support for SDL1.2 in favour of SDL2") Signed-off-by: Carlo Marcelo Arenas Belón --- configure | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 4983c8b533..0f88ba98a6 100755 --- a/configure +++ b/configure @@ -3016,15 +3016,15 @@ fi ## # SDL probe -# Look for sdl configuration program (pkg-config or sdl-config). Try -# sdl-config even without cross prefix, and favour pkg-config over sdl-config. +# Look for sdl configuration program (pkg-config or sdl2-config). Try +# sdl2-config even without cross prefix, and favour pkg-config over sdl2-config. sdl_probe () { if $pkg_config sdl2 --exists; then sdlconfig="$pkg_config sdl2" sdlversion=$($sdlconfig --modversion 2>/dev/null) - elif has ${sdl_config}; then + elif has "$sdl2_config"; then sdlconfig="$sdl2_config" sdlversion=$($sdlconfig --version) else @@ -3035,7 +3035,7 @@ sdl_probe () # no need to do the rest return fi - if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then + if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2 fi @@ -8019,7 +8019,6 @@ preserve_env PKG_CONFIG preserve_env PKG_CONFIG_LIBDIR preserve_env PKG_CONFIG_PATH preserve_env PYTHON -preserve_env SDL_CONFIG preserve_env SDL2_CONFIG preserve_env SMBD preserve_env STRIP -- 2.22.0
[Qemu-devel] [PATCH] configure: remove obsoleted $sparc_cpu variable
9b9c37c364 ("tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode.", 2012-09-21) removed the need for this variable and most of the references to it, but this one. Remove defunct code, no effect or functionality change expected. Signed-off-by: Carlo Marcelo Arenas Belón --- configure | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure b/configure index 4983c8b533..7518f201ab 100755 --- a/configure +++ b/configure @@ -6378,9 +6378,6 @@ if test "$vnc" = "yes" ; then echo "VNC JPEG support $vnc_jpeg" echo "VNC PNG support $vnc_png" fi -if test -n "$sparc_cpu"; then -echo "Target Sparc Arch $sparc_cpu" -fi echo "xen support $xen" if test "$xen" = "yes" ; then echo "xen ctrl version $xen_ctrl_version" -- 2.22.0
[Qemu-devel] [PATCH] linux-user: add SO_LINGER to {g,s}etsockopt
Original implementation for setsockopt by Chen Gang[1]; all bugs mine, including removing assignment for optname which hopefully makes the logic easier to follow and moving some variables to make the code more selfcontained. [1] http://patchwork.ozlabs.org/patch/565659/ Signed-off-by: Carlo Marcelo Arenas Belón Co-Authored-By: Chen Gang --- linux-user/syscall.c | 52 ++- linux-user/syscall_defs.h | 5 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 02fba7606d..43f2839540 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3290,6 +3290,24 @@ set_timeout: unlock_user (dev_ifname, optval_addr, 0); return ret; } +case TARGET_SO_LINGER: +{ +struct linger lg; +struct target_linger *tlg; + +if (optlen != sizeof(struct target_linger)) { +return -TARGET_EINVAL; +} +if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) { +return -TARGET_EFAULT; +} +__get_user(lg.l_onoff, >l_onoff); +__get_user(lg.l_linger, >l_linger); +ret = get_errno(setsockopt(sockfd, SOL_SOCKET, SO_LINGER, +, sizeof(lg))); +unlock_user_struct(tlg, optval_addr, 0); +return ret; +} /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; @@ -3381,7 +3399,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, level = SOL_SOCKET; switch (optname) { /* These don't just return a single integer */ -case TARGET_SO_LINGER: case TARGET_SO_RCVTIMEO: case TARGET_SO_SNDTIMEO: case TARGET_SO_PEERNAME: @@ -3419,6 +3436,39 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, } break; } +case TARGET_SO_LINGER: +{ +struct linger lg; +socklen_t lglen; +struct target_linger *tlg; + +if (get_user_u32(len, optlen)) { +return -TARGET_EFAULT; +} +if (len < 0) { +return -TARGET_EINVAL; +} + +lglen = sizeof(lg); +ret = get_errno(getsockopt(sockfd, level, SO_LINGER, + , )); +if (ret < 0) { +return ret; +} +if (len > lglen) { +len = lglen; +} +if (!lock_user_struct(VERIFY_WRITE, tlg, optval_addr, 0)) { +return -TARGET_EFAULT; +} +__put_user(lg.l_onoff, >l_onoff); +__put_user(lg.l_linger, >l_linger); +unlock_user_struct(tlg, optval_addr, 1); +if (put_user_u32(len, optlen)) { +return -TARGET_EFAULT; +} +break; +} /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 40bb60ef4c..18d434d6dc 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -203,6 +203,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { +abi_int l_onoff;/* Linger active*/ +abi_int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec; -- 2.18.0
[Qemu-devel] [PATCH v2] gitignore: ignore check-qlit test
test introduced in 382176b4d78e070d119af8e0dcd00884c11bbec2 Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> Reviewed-by: Eric Blake <ebl...@redhat.com> --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.gitignore b/tests/.gitignore index cf6d99c91e..53cb2efaee 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,6 +6,7 @@ check-qdict check-qnum check-qjson check-qlist +check-qlit check-qnull check-qstring check-qom-interface -- 2.13.5 (Apple Git-94)
[Qemu-devel] [PATCH] gitignore: ignore check-qlit test
Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.gitignore b/tests/.gitignore index cf6d99c91e..53cb2efaee 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,6 +6,7 @@ check-qdict check-qnum check-qjson check-qlist +check-qlit check-qnull check-qstring check-qom-interface -- 2.13.5 (Apple Git-94)
[Qemu-devel] [PATCH] linux-user: remove duplicate break in syscall
likely introduced in 3532fa7402cda16f7b95261b0339c58630051f0b Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/syscall.c | 1 - 1 file changed, 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..3ef4d1c568 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3131,7 +3131,6 @@ set_timeout: case TARGET_SO_RCVLOWAT: optname = SO_RCVLOWAT; break; -break; default: goto unimplemented; } -- 2.14.1
[Qemu-devel] [PATCH v2 6/6] linux_user: consolidate sock_type
remove unnecessary sock_type enum and other unused surrounding code to allow for per arch sockbits to mirror better linux headers for maintenance Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/alpha/sockbits.h | 36 linux-user/hppa/sockbits.h | 30 --- linux-user/mips/sockbits.h | 35 --- linux-user/socket.h | 58 ++--- linux-user/sparc/sockbits.h | 35 --- 5 files changed, 29 insertions(+), 165 deletions(-) diff --git a/linux-user/alpha/sockbits.h b/linux-user/alpha/sockbits.h index 768579a1f7..defdb806ea 100644 --- a/linux-user/alpha/sockbits.h +++ b/linux-user/alpha/sockbits.h @@ -66,39 +66,3 @@ #define TARGET_SCM_TIMESTAMPING_PKTINFO 58 #define TARGET_SO_PEERGROUPS59 #define TARGET_SO_ZEROCOPY 60 - -/** sock_type - Socket types - * - * Please notice that for binary compat reasons ALPHA has to - * override the enum sock_type in include/linux/net.h, so - * we define ARCH_HAS_SOCKET_TYPES here. - * - * @SOCK_STREAM - stream (connection) socket - * @SOCK_DGRAM - datagram (conn.less) socket - * @SOCK_RAW - raw socket - * @SOCK_RDM - reliably-delivered message - * @SOCK_SEQPACKET - sequential packet socket - * @SOCK_DCCP - Datagram Congestion Control Protocol socket - * @SOCK_PACKET - linux specific way of getting packets at the dev level. - *For writing rarp and other similar things on the user - *level. - * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. - * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. - */ - -enum sock_type { -TARGET_SOCK_STREAM = 1, -TARGET_SOCK_DGRAM = 2, -TARGET_SOCK_RAW = 3, -TARGET_SOCK_RDM = 4, -TARGET_SOCK_SEQPACKET = 5, -TARGET_SOCK_DCCP= 6, -TARGET_SOCK_PACKET = 10, -TARGET_SOCK_CLOEXEC = 01000, -TARGET_SOCK_NONBLOCK= 0x4000, -}; - -#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX - 1. */ - -#define ARCH_HAS_SOCKET_TYPES 1 diff --git a/linux-user/hppa/sockbits.h b/linux-user/hppa/sockbits.h index 3dab31a76a..32f81357d6 100644 --- a/linux-user/hppa/sockbits.h +++ b/linux-user/hppa/sockbits.h @@ -71,33 +71,3 @@ #define TARGET_SO_PEERGROUPS0x4034 #define TARGET_SO_ZEROCOPY 0x4035 -/** sock_type - Socket types - default values - * - * @SOCK_STREAM - stream (connection) socket - * @SOCK_DGRAM - datagram (conn.less) socket - * @SOCK_RAW - raw socket - * @SOCK_RDM - reliably-delivered message - * @SOCK_SEQPACKET - sequential packet socket - * @SOCK_DCCP - Datagram Congestion Control Protocol socket - * @SOCK_PACKET - linux specific way of getting packets at the dev level. - *For writing rarp and other similar things on the user - *level. - * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. - * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. - */ -enum sock_type { -TARGET_SOCK_STREAM= 1, -TARGET_SOCK_DGRAM = 2, -TARGET_SOCK_RAW = 3, -TARGET_SOCK_RDM = 4, -TARGET_SOCK_SEQPACKET = 5, -TARGET_SOCK_DCCP = 6, -TARGET_SOCK_PACKET= 10, -TARGET_SOCK_CLOEXEC = 01000, -TARGET_SOCK_NONBLOCK = 0x4000, -}; - -#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX - 1. */ - -#define ARCH_HAS_SOCKET_TYPES 1 diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h index 6d8ea8aba2..fa8062391d 100644 --- a/linux-user/mips/sockbits.h +++ b/linux-user/mips/sockbits.h @@ -70,38 +70,3 @@ #define TARGET_SCM_TIMESTAMPING_PKTINFO 58 #define TARGET_SO_PEERGROUPS59 #define TARGET_SO_ZEROCOPY 60 - -/** sock_type - Socket types - * - * Please notice that for binary compat reasons MIPS has to - * override the enum sock_type in include/linux/net.h, so - * we define ARCH_HAS_SOCKET_TYPES here. - * - * @SOCK_DGRAM - datagram (conn.less) socket - * @SOCK_STREAM - stream (connection) socket - * @SOCK_RAW - raw socket - * @SOCK_RDM - reliably-delivered message - * @SOCK_SEQPACKET - sequential packet socket - * @SOCK_DCCP - Datagram Congestion Control Protocol socket - * @SOCK_PACKET - linux specific way of getting packets at the dev level. - *For writing rarp and other similar things on the user - *level. - * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. - * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. - */ -enum sock_type { -TARGET_SOCK_DGRAM = 1, -TARGET_SOCK_STREAM = 2, -TARGET_SOCK_RAW = 3, -TARGET_SOCK_RDM = 4, -TARGET_SOCK_SEQPACKET = 5, -TARGET_SOCK_DCCP
[Qemu-devel] [PATCH v2 4/6] linux-user: refactor socket.h for sparc
fixes SOL_SOCKET and SO_LINGER and all other values that didn't match the default (SO_PASSSEC being the exception as it only changed base) TARGET_SOCK_{NONBLOCK,CLOEXEC} updated to match the values for the header: arch/sparc/include/uapi/asm/fcntl.h Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> Reviewed-by: Laurent Vivier <laur...@vivier.eu> --- linux-user/socket.h | 46 ++-- linux-user/sparc/sockbits.h | 104 2 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 linux-user/sparc/sockbits.h diff --git a/linux-user/socket.h b/linux-user/socket.h index 036270a6e4..dfa692286b 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -4,50 +4,10 @@ #include "alpha/sockbits.h" #elif defined(TARGET_HPPA) #include "hppa/sockbits.h" +#elif defined(TARGET_SPARC) +#include "sparc/sockbits.h" #else -#if defined(TARGET_SPARC) -/** sock_type - Socket types - * - * Please notice that for binary compat reasons SPARC has to - * override the enum sock_type in include/linux/net.h, so - * we define ARCH_HAS_SOCKET_TYPES here. - * - * @SOCK_DGRAM - datagram (conn.less) socket - * @SOCK_STREAM - stream (connection) socket - * @SOCK_RAW - raw socket - * @SOCK_RDM - reliably-delivered message - * @SOCK_SEQPACKET - sequential packet socket - * @SOCK_DCCP - Datagram Congestion Control Protocol socket - * @SOCK_PACKET - linux specific way of getting packets at the dev level. - *For writing rarp and other similar things on the user - *level. - * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. - * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. - */ - -#define ARCH_HAS_SOCKET_TYPES 1 - -enum sock_type { - TARGET_SOCK_STREAM = 1, - TARGET_SOCK_DGRAM = 2, - TARGET_SOCK_RAW = 3, - TARGET_SOCK_RDM = 4, - TARGET_SOCK_SEQPACKET = 5, - TARGET_SOCK_DCCP= 6, - TARGET_SOCK_PACKET = 10, - TARGET_SOCK_CLOEXEC = 02000, - TARGET_SOCK_NONBLOCK= 04, -}; - -#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK0xf /* Covers up to TARGET_SOCK_MAX-1. */ - -#define TARGET_SO_PASSSEC31 -#else -#define TARGET_SO_PASSSEC34 -#endif - /* For setsockopt(2) */ #define TARGET_SOL_SOCKET 1 @@ -103,11 +63,11 @@ #define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PASSSEC 34 #endif #ifndef ARCH_HAS_SOCKET_TYPES /** sock_type - Socket types - default values - * * * @SOCK_STREAM - stream (connection) socket * @SOCK_DGRAM - datagram (conn.less) socket diff --git a/linux-user/sparc/sockbits.h b/linux-user/sparc/sockbits.h new file mode 100644 index 00..d51ae5f84f --- /dev/null +++ b/linux-user/sparc/sockbits.h @@ -0,0 +1,104 @@ +#define TARGET_SOL_SOCKET0x + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_PASSCRED 0x0002 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_PEERCRED 0x0040 +#define TARGET_SO_LINGER 0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_BSDCOMPAT 0x0400 +#define TARGET_SO_RCVLOWAT 0x0800 +#define TARGET_SO_SNDLOWAT 0x1000 +#define TARGET_SO_RCVTIMEO 0x2000 +#define TARGET_SO_SNDTIMEO 0x4000 +#define TARGET_SO_ACCEPTCONN 0x8000 +#define TARGET_SO_SNDBUF 0x1001 +#define TARGET_SO_RCVBUF 0x1002 +#define TARGET_SO_SNDBUFFORCE0x100a +#define TARGET_SO_RCVBUFFORCE0x100b +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN 0x1029 +#define TARGET_SO_NO_CHECK 0x000b +#define TARGET_SO_PRIORITY 0x000c +#define TARGET_SO_BINDTODEVICE 0x000d +#define TARGET_SO_ATTACH_FILTER 0x001a +#define TARGET_SO_DETACH_FILTER 0x001b +#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 0x001c +#define TARGET_SO_TIME
[Qemu-devel] [PATCH v2 5/6] linux-user: update default socket.h
enable SO_REUSEPORT as a sideeffect and add SO_GET_FILTER alias Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/socket.h | 59 +++-- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/linux-user/socket.h b/linux-user/socket.h index dfa692286b..6f49255b5f 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -27,7 +27,7 @@ #define TARGET_SO_PRIORITY 12 #define TARGET_SO_LINGER 13 #define TARGET_SO_BSDCOMPAT14 -/* To add :#define TARGET_SO_REUSEPORT 15 */ +#define TARGET_SO_REUSEPORT15 #if defined(TARGET_PPC) #define TARGET_SO_RCVLOWAT 16 #define TARGET_SO_SNDLOWAT 17 @@ -49,21 +49,58 @@ #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT23 #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24 -#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_BINDTODEVICE25 /* Socket filtering */ -#define TARGET_SO_ATTACH_FILTER26 -#define TARGET_SO_DETACH_FILTER27 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER -#define TARGET_SO_PEERNAME 28 -#define TARGET_SO_TIMESTAMP29 -#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP +#define TARGET_SO_PEERNAME28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP -#define TARGET_SO_ACCEPTCONN 30 +#define TARGET_SO_ACCEPTCONN 30 -#define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNSTARGET_SO_TIMESTAMPNS + +#define TARGET_SO_MARK36 + +#define TARGET_SO_TIMESTAMPING37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING + +#define TARGET_SO_PROTOCOL38 +#define TARGET_SO_DOMAIN 39 + +#define TARGET_SO_RXQ_OVFL40 + +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUSTARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF42 + +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS 48 +#define TARGET_SO_INCOMING_CPU49 +#define TARGET_SO_ATTACH_BPF 50 +#define TARGET_SO_DETACH_BPF TARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE 53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID56 +#define TARGET_SO_COOKIE 57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_SO_PEERGROUPS 59 +#define TARGET_SO_ZEROCOPY60 -#define TARGET_SO_PASSSEC 34 #endif #ifndef ARCH_HAS_SOCKET_TYPES @@ -94,6 +131,6 @@ }; #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK0xf /* Covers up to TARGET_SOCK_MAX-1. */ +#define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX - 1. */ #endif -- 2.14.1
[Qemu-devel] [PATCH v2 2/6] linux-user: refactor socket.h for alpha
based on fresh bits from linux 4.14 and therefore enabling SO_REUSEPORT as a side effect to easy on maintenance SO_NONBLOCK updated to match the value from linux headers (in hexadecimal) as seen in arch/alpha/include/asm/socket.h Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/alpha/sockbits.h | 104 linux-user/socket.h | 104 +--- 2 files changed, 105 insertions(+), 103 deletions(-) create mode 100644 linux-user/alpha/sockbits.h diff --git a/linux-user/alpha/sockbits.h b/linux-user/alpha/sockbits.h new file mode 100644 index 00..768579a1f7 --- /dev/null +++ b/linux-user/alpha/sockbits.h @@ -0,0 +1,104 @@ +#define TARGET_SOL_SOCKET 0x + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_SNDBUF0x1001 +#define TARGET_SO_RCVBUF0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_RCVLOWAT 0x1010 +#define TARGET_SO_SNDLOWAT 0x1011 +#define TARGET_SO_RCVTIMEO 0x1012 +#define TARGET_SO_SNDTIMEO 0x1013 +#define TARGET_SO_ACCEPTCONN0x1014 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN0x1029 +#define TARGET_SO_NO_CHECK 11 +#define TARGET_SO_PRIORITY 12 +#define TARGET_SO_BSDCOMPAT 14 +#define TARGET_SO_PASSCRED 17 +#define TARGET_SO_PEERCRED 18 +#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTERTARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_PEERSEC 30 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_SECURITY_AUTHENTICATION 19 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 20 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 21 +#define TARGET_SO_MARK 36 +#define TARGET_SO_TIMESTAMPING 37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING +#define TARGET_SO_RXQ_OVFL 40 +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 42 +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE 45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS48 +#define TARGET_SO_INCOMING_CPU 49 +#define TARGET_SO_ATTACH_BPF50 +#define TARGET_SO_DETACH_BPFTARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID 56 +#define TARGET_SO_COOKIE57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_SO_PEERGROUPS59 +#define TARGET_SO_ZEROCOPY 60 + +/** sock_type - Socket types + * + * Please notice that for binary compat reasons ALPHA has to + * override the enum sock_type in include/linux/net.h, so + * we define ARCH_HAS_SOCKET_TYPES here. + * + * @SOCK_STREAM - stream (connection) socket + * @SOCK_DGRAM - datagram (conn.less) socket + * @SOCK_RAW - raw socket + * @SOCK_RDM - reliably-delivered message + * @SOCK_SEQPACKET - sequential packet socket + * @SOCK_DCCP - Datagram Congestion Control Protocol socket + * @SOCK_PACKET - linux specific way of getting packets at the dev
[Qemu-devel] [PATCH v2 3/6] linux-user: refactor socket.h for mips
fresh bits from linux 4.14, redefine SO_STYLE and {SO,SCM}_TIMESTAMP to the right target values and enables SO_REUSEPORT to easy on maintenance SOCK_NONBLOCK has been updated to use the same value (in hexadecimal) as defined for O_NONBLOCK from the linux header arch/mips/linux/uapi/asm/fcntl.h Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> Reviewed-by: Laurent Vivier <laur...@vivier.eu> --- linux-user/mips/sockbits.h | 107 + linux-user/socket.h| 103 +-- 2 files changed, 108 insertions(+), 102 deletions(-) create mode 100644 linux-user/mips/sockbits.h diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h new file mode 100644 index 00..6d8ea8aba2 --- /dev/null +++ b/linux-user/mips/sockbits.h @@ -0,0 +1,107 @@ +#define TARGET_SOL_SOCKET 0x + +#define TARGET_SO_DEBUG 0x0001 /* Record debugging information. */ +#define TARGET_SO_REUSEADDR 0x0004 /* Allow reuse of local addresses. */ +#define TARGET_SO_KEEPALIVE 0x0008 /* Keep connections alive and send +SIGPIPE when they die. */ +#define TARGET_SO_DONTROUTE 0x0010 /* Don't do local routing. */ +#define TARGET_SO_BROADCAST 0x0020 /* Allow transmission of +broadcast messages. */ +#define TARGET_SO_LINGER 0x0080 /* Block on close of a reliable +socket to transmit pending data. */ +#define TARGET_SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band. */ +#define TARGET_SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ +#define TARGET_SO_TYPE0x1008 /* Compatible name for TARGET_SO_STYLE. */ +#define TARGET_SO_STYLE TARGET_SO_TYPE /* Synonym */ +#define TARGET_SO_ERROR 0x1007 /* get error status and clear */ +#define TARGET_SO_SNDBUF 0x1001 /* Send buffer size. */ +#define TARGET_SO_RCVBUF 0x1002 /* Receive buffer. */ +#define TARGET_SO_SNDLOWAT0x1003 /* send low-water mark */ +#define TARGET_SO_RCVLOWAT0x1004 /* receive low-water mark */ +#define TARGET_SO_SNDTIMEO0x1005 /* send timeout */ +#define TARGET_SO_RCVTIMEO0x1006 /* receive timeout */ +#define TARGET_SO_ACCEPTCONN 0x1009 +#define TARGET_SO_PROTOCOL0x1028 /* protocol type */ +#define TARGET_SO_DOMAIN 0x1029 /* domain/socket family */ +#define TARGET_SO_NO_CHECK 11 +#define TARGET_SO_PRIORITY 12 +#define TARGET_SO_BSDCOMPAT 14 +#define TARGET_SO_PASSCRED 17 +#define TARGET_SO_PEERCRED 18 +#define TARGET_SO_SECURITY_AUTHENTICATION 22 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24 +#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTERTARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_PEERSEC 30 +#define TARGET_SO_SNDBUFFORCE 31 +#define TARGET_SO_RCVBUFFORCE 33 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_MARK 36 +#define TARGET_SO_TIMESTAMPING 37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING +#define TARGET_SO_RXQ_OVFL 40 +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 42 +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE 45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS48 +#define TARGET_SO_INCOMING_CPU 49 +#define TARGET_SO_ATTACH_BPF50 +#define TARGET_SO_DETACH_BPFTARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID 56 +#define TARGET_SO_COOKIE57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_S
[Qemu-devel] [PATCH v2 1/6] linux-user: update hppa sockbits
updated to match arch/parisc/include/uapi/asm/socket.h from linux 4.14 include in socket.h changed to prefer a local path like all other qemu headers and for consistency and clarity when adding all other arch Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/hppa/sockbits.h | 148 +++-- linux-user/socket.h| 2 +- 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/linux-user/hppa/sockbits.h b/linux-user/hppa/sockbits.h index 5044619e16..3dab31a76a 100644 --- a/linux-user/hppa/sockbits.h +++ b/linux-user/hppa/sockbits.h @@ -1,71 +1,77 @@ -#define TARGET_SOL_SOCKET 0x +#define TARGET_SOL_SOCKET 0x -#define TARGET_SO_DEBUG0x0001 -#define TARGET_SO_REUSEADDR0x0004 -#define TARGET_SO_KEEPALIVE0x0008 -#define TARGET_SO_DONTROUTE0x0010 -#define TARGET_SO_BROADCAST0x0020 -#define TARGET_SO_LINGER 0x0080 -#define TARGET_SO_OOBINLINE0x0100 -#define TARGET_SO_REUSEPORT0x0200 -#define TARGET_SO_SNDBUF 0x1001 -#define TARGET_SO_RCVBUF 0x1002 -#define TARGET_SO_SNDBUFFORCE 0x100a -#define TARGET_SO_RCVBUFFORCE 0x100b -#define TARGET_SO_SNDLOWAT 0x1003 -#define TARGET_SO_RCVLOWAT 0x1004 -#define TARGET_SO_SNDTIMEO 0x1005 -#define TARGET_SO_RCVTIMEO 0x1006 -#define TARGET_SO_ERROR0x1007 -#define TARGET_SO_TYPE 0x1008 -#define TARGET_SO_PROTOCOL 0x1028 -#define TARGET_SO_DOMAIN 0x1029 -#define TARGET_SO_PEERNAME 0x2000 -#define TARGET_SO_NO_CHECK 0x400b -#define TARGET_SO_PRIORITY 0x400c -#define TARGET_SO_BSDCOMPAT0x400e -#define TARGET_SO_PASSCRED 0x4010 -#define TARGET_SO_PEERCRED 0x4011 -#define TARGET_SO_TIMESTAMP0x4012 -#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP -#define TARGET_SO_TIMESTAMPNS 0x4013 -#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_SNDBUF0x1001 +#define TARGET_SO_RCVBUF0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_SNDLOWAT 0x1003 +#define TARGET_SO_RCVLOWAT 0x1004 +#define TARGET_SO_SNDTIMEO 0x1005 +#define TARGET_SO_RCVTIMEO 0x1006 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN0x1029 +#define TARGET_SO_PEERNAME 0x2000 +#define TARGET_SO_NO_CHECK 0x400b +#define TARGET_SO_PRIORITY 0x400c +#define TARGET_SO_BSDCOMPAT 0x400e +#define TARGET_SO_PASSCRED 0x4010 +#define TARGET_SO_PEERCRED 0x4011 +#define TARGET_SO_TIMESTAMP 0x4012 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_TIMESTAMPNS 0x4013 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS -#define TARGET_SO_SECURITY_AUTHENTICATION 0x4016 -#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT0x4017 -#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 0x4018 +#define TARGET_SO_SECURITY_AUTHENTICATION 0x4016 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 0x4017 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 0x4018 -#define TARGET_SO_BINDTODEVICE 0x4019 -#define TARGET_SO_ATTACH_FILTER0x401a -#define TARGET_SO_DETACH_FILTER0x401b -#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER -#define TARGET_SO_ACCEPTCONN 0x401c -#define TARGET_SO_PEERSEC 0x401d -#define TARGET_SO_PASSSEC 0x401e -#define TARGET_SO_MARK 0x401f -#define TARGET_SO_TIMESTAMPING 0x4020 -#define TARGET_SCM_TIMESTAMPINGTARGET_SO_TIMESTAMPING -#define TARGET_SO_RXQ_OVFL 0x4021 -#define TARGET_SO_WIFI_STATUS 0x4022 -#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS -#define TARGET_SO_PEEK_OFF 0x4023 -#define TARGET_SO_NOFCS0x4024 -#define TARGET_SO_LOCK_FILTER 0x4025 -#define TARGET_SO_SELECT_ERR_QUEUE 0x4026 -#define TARGET_SO_BUSY_POLL0x4027 -#define TARGET_SO_MAX_PACING_RATE 0x4028 -#define TARGET_SO_BPF_EXTENSIONS 0x4029 -#
[Qemu-devel] linux-user: refactor socket.h into architecture specific sockbits
the definitions in socket.h are meant to reflect the ones in linux for each respective target, but are sometimes difficult to maintain. hppa (AKA parisc) was initially merged with an independent file that mirrors more closely the corresponding one in linux but hasn't been updated since. this series updates hppa with the latest bits from linux 4.14 and makes sure all relevant architectures had a sockbits file that would be easy to maintain going forward. most of the changes are pretty mechanical and I had made (thanks to Laurent's tough review) every effort to ensure no value gets changed accidentaly and all changes (even the ones where the value remains but is now in a different base to better match what was used in the linux headers) are documented, so it should be fairly safe and will fix bugs (mostly for sparc).
[Qemu-devel] [RFC 6/6] linux-user: update default socket.h
* enable SO_REUSEPORT as a sideeffect and add SO_GET_FILTER alias * make sure 64bit version for ppc is also supported Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/socket.h | 61 ++--- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/linux-user/socket.h b/linux-user/socket.h index 6fd486c6b1..c37c10822a 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -27,8 +27,8 @@ #define TARGET_SO_PRIORITY 12 #define TARGET_SO_LINGER 13 #define TARGET_SO_BSDCOMPAT14 -/* To add :#define TARGET_SO_REUSEPORT 15 */ -#if defined(TARGET_PPC) +#define TARGET_SO_REUSEPORT15 +#if defined(TARGET_PPC) || defined(TARGET_PPC64) #define TARGET_SO_RCVLOWAT 16 #define TARGET_SO_SNDLOWAT 17 #define TARGET_SO_RCVTIMEO 18 @@ -49,21 +49,58 @@ #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT23 #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24 -#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_BINDTODEVICE25 /* Socket filtering */ -#define TARGET_SO_ATTACH_FILTER26 -#define TARGET_SO_DETACH_FILTER27 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER -#define TARGET_SO_PEERNAME 28 -#define TARGET_SO_TIMESTAMP29 -#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP +#define TARGET_SO_PEERNAME28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP -#define TARGET_SO_ACCEPTCONN 30 +#define TARGET_SO_ACCEPTCONN 30 -#define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNSTARGET_SO_TIMESTAMPNS + +#define TARGET_SO_MARK36 + +#define TARGET_SO_TIMESTAMPING37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING + +#define TARGET_SO_PROTOCOL38 +#define TARGET_SO_DOMAIN 39 + +#define TARGET_SO_RXQ_OVFL40 + +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUSTARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF42 + +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS 48 +#define TARGET_SO_INCOMING_CPU49 +#define TARGET_SO_ATTACH_BPF 50 +#define TARGET_SO_DETACH_BPF TARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE 53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID56 +#define TARGET_SO_COOKIE 57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_SO_PEERGROUPS 59 +#define TARGET_SO_ZEROCOPY60 -#define TARGET_SO_PASSSEC 34 #endif #ifndef ARCH_HAS_SOCKET_TYPES @@ -94,6 +131,6 @@ }; #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK0xf /* Covers up to TARGET_SOCK_MAX-1. */ +#define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX - 1. */ #endif -- 2.14.1
[Qemu-devel] [RFC 4/6] linux-user: refactor socket.h for sparc
fixes SOL_SOCKET and SO_LINGER at least Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/socket.h | 46 ++-- linux-user/sparc/sockbits.h | 104 2 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 linux-user/sparc/sockbits.h diff --git a/linux-user/socket.h b/linux-user/socket.h index 036270a6e4..dfa692286b 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -4,50 +4,10 @@ #include "alpha/sockbits.h" #elif defined(TARGET_HPPA) #include "hppa/sockbits.h" +#elif defined(TARGET_SPARC) +#include "sparc/sockbits.h" #else -#if defined(TARGET_SPARC) -/** sock_type - Socket types - * - * Please notice that for binary compat reasons SPARC has to - * override the enum sock_type in include/linux/net.h, so - * we define ARCH_HAS_SOCKET_TYPES here. - * - * @SOCK_DGRAM - datagram (conn.less) socket - * @SOCK_STREAM - stream (connection) socket - * @SOCK_RAW - raw socket - * @SOCK_RDM - reliably-delivered message - * @SOCK_SEQPACKET - sequential packet socket - * @SOCK_DCCP - Datagram Congestion Control Protocol socket - * @SOCK_PACKET - linux specific way of getting packets at the dev level. - *For writing rarp and other similar things on the user - *level. - * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. - * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. - */ - -#define ARCH_HAS_SOCKET_TYPES 1 - -enum sock_type { - TARGET_SOCK_STREAM = 1, - TARGET_SOCK_DGRAM = 2, - TARGET_SOCK_RAW = 3, - TARGET_SOCK_RDM = 4, - TARGET_SOCK_SEQPACKET = 5, - TARGET_SOCK_DCCP= 6, - TARGET_SOCK_PACKET = 10, - TARGET_SOCK_CLOEXEC = 02000, - TARGET_SOCK_NONBLOCK= 04, -}; - -#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) -#define TARGET_SOCK_TYPE_MASK0xf /* Covers up to TARGET_SOCK_MAX-1. */ - -#define TARGET_SO_PASSSEC31 -#else -#define TARGET_SO_PASSSEC34 -#endif - /* For setsockopt(2) */ #define TARGET_SOL_SOCKET 1 @@ -103,11 +63,11 @@ #define TARGET_SO_PEERSEC 31 +#define TARGET_SO_PASSSEC 34 #endif #ifndef ARCH_HAS_SOCKET_TYPES /** sock_type - Socket types - default values - * * * @SOCK_STREAM - stream (connection) socket * @SOCK_DGRAM - datagram (conn.less) socket diff --git a/linux-user/sparc/sockbits.h b/linux-user/sparc/sockbits.h new file mode 100644 index 00..d51ae5f84f --- /dev/null +++ b/linux-user/sparc/sockbits.h @@ -0,0 +1,104 @@ +#define TARGET_SOL_SOCKET0x + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_PASSCRED 0x0002 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_PEERCRED 0x0040 +#define TARGET_SO_LINGER 0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_BSDCOMPAT 0x0400 +#define TARGET_SO_RCVLOWAT 0x0800 +#define TARGET_SO_SNDLOWAT 0x1000 +#define TARGET_SO_RCVTIMEO 0x2000 +#define TARGET_SO_SNDTIMEO 0x4000 +#define TARGET_SO_ACCEPTCONN 0x8000 +#define TARGET_SO_SNDBUF 0x1001 +#define TARGET_SO_RCVBUF 0x1002 +#define TARGET_SO_SNDBUFFORCE0x100a +#define TARGET_SO_RCVBUFFORCE0x100b +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN 0x1029 +#define TARGET_SO_NO_CHECK 0x000b +#define TARGET_SO_PRIORITY 0x000c +#define TARGET_SO_BINDTODEVICE 0x000d +#define TARGET_SO_ATTACH_FILTER 0x001a +#define TARGET_SO_DETACH_FILTER 0x001b +#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 0x001c +#define TARGET_SO_TIMESTAMP 0x001d +#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP +#define TARGET_SO_PEERSEC0x001e +#define TARGET_SO_PASSSEC0x001f +#define TARGET_SO_TIMESTAMPNS0x
[Qemu-devel] [RFC 5/6] linux-user: fix 64bit versions of sparc and mips
Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/mips64/sockbits.h | 1 + linux-user/socket.h | 4 ++-- linux-user/sparc64/sockbits.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 linux-user/mips64/sockbits.h create mode 100644 linux-user/sparc64/sockbits.h diff --git a/linux-user/mips64/sockbits.h b/linux-user/mips64/sockbits.h new file mode 100644 index 00..e6b6d31ac9 --- /dev/null +++ b/linux-user/mips64/sockbits.h @@ -0,0 +1 @@ +#include "../mips/sockbits.h" diff --git a/linux-user/socket.h b/linux-user/socket.h index dfa692286b..6fd486c6b1 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -1,10 +1,10 @@ -#if defined(TARGET_MIPS) +#if defined(TARGET_MIPS) || defined(TARGET_MIPS64) #include "mips/sockbits.h" #elif defined(TARGET_ALPHA) #include "alpha/sockbits.h" #elif defined(TARGET_HPPA) #include "hppa/sockbits.h" -#elif defined(TARGET_SPARC) +#elif defined(TARGET_SPARC) || defined(TARGET_SPARC64) #include "sparc/sockbits.h" #else diff --git a/linux-user/sparc64/sockbits.h b/linux-user/sparc64/sockbits.h new file mode 100644 index 00..658899e4d3 --- /dev/null +++ b/linux-user/sparc64/sockbits.h @@ -0,0 +1 @@ +#include "../sparc/sockbits.h" -- 2.14.1
[Qemu-devel] [RFC 3/6] linux-user: refactor socket.h for mips
fresh bits from linux 4.14, redefine SO_STYLE and {SO,SCM}_TIMESTAMP to the target values and enables SO_REUSEPORT Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/mips/sockbits.h | 107 + linux-user/socket.h| 103 +-- 2 files changed, 108 insertions(+), 102 deletions(-) create mode 100644 linux-user/mips/sockbits.h diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h new file mode 100644 index 00..6d8ea8aba2 --- /dev/null +++ b/linux-user/mips/sockbits.h @@ -0,0 +1,107 @@ +#define TARGET_SOL_SOCKET 0x + +#define TARGET_SO_DEBUG 0x0001 /* Record debugging information. */ +#define TARGET_SO_REUSEADDR 0x0004 /* Allow reuse of local addresses. */ +#define TARGET_SO_KEEPALIVE 0x0008 /* Keep connections alive and send +SIGPIPE when they die. */ +#define TARGET_SO_DONTROUTE 0x0010 /* Don't do local routing. */ +#define TARGET_SO_BROADCAST 0x0020 /* Allow transmission of +broadcast messages. */ +#define TARGET_SO_LINGER 0x0080 /* Block on close of a reliable +socket to transmit pending data. */ +#define TARGET_SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band. */ +#define TARGET_SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ +#define TARGET_SO_TYPE0x1008 /* Compatible name for TARGET_SO_STYLE. */ +#define TARGET_SO_STYLE TARGET_SO_TYPE /* Synonym */ +#define TARGET_SO_ERROR 0x1007 /* get error status and clear */ +#define TARGET_SO_SNDBUF 0x1001 /* Send buffer size. */ +#define TARGET_SO_RCVBUF 0x1002 /* Receive buffer. */ +#define TARGET_SO_SNDLOWAT0x1003 /* send low-water mark */ +#define TARGET_SO_RCVLOWAT0x1004 /* receive low-water mark */ +#define TARGET_SO_SNDTIMEO0x1005 /* send timeout */ +#define TARGET_SO_RCVTIMEO0x1006 /* receive timeout */ +#define TARGET_SO_ACCEPTCONN 0x1009 +#define TARGET_SO_PROTOCOL0x1028 /* protocol type */ +#define TARGET_SO_DOMAIN 0x1029 /* domain/socket family */ +#define TARGET_SO_NO_CHECK 11 +#define TARGET_SO_PRIORITY 12 +#define TARGET_SO_BSDCOMPAT 14 +#define TARGET_SO_PASSCRED 17 +#define TARGET_SO_PEERCRED 18 +#define TARGET_SO_SECURITY_AUTHENTICATION 22 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24 +#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTERTARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_PEERSEC 30 +#define TARGET_SO_SNDBUFFORCE 31 +#define TARGET_SO_RCVBUFFORCE 33 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_MARK 36 +#define TARGET_SO_TIMESTAMPING 37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING +#define TARGET_SO_RXQ_OVFL 40 +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 42 +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE 45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS48 +#define TARGET_SO_INCOMING_CPU 49 +#define TARGET_SO_ATTACH_BPF50 +#define TARGET_SO_DETACH_BPFTARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID 56 +#define TARGET_SO_COOKIE57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_SO_PEERGROUPS59 +#define TARGET_SO_ZEROCOPY 60 + +/** sock_type - Socket types + * + * Please notice that for binary compat reasons MIPS has to + * override the enum sock_type in include/linux/net.h, so
[Qemu-devel] [RFC 1/6] linux-user: update hppa sockbits
updated to match arch/parisc/include/uapi/asm/socket.h from linux 4.14 Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/hppa/sockbits.h | 148 +++-- linux-user/socket.h| 2 +- 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/linux-user/hppa/sockbits.h b/linux-user/hppa/sockbits.h index 5044619e16..3dab31a76a 100644 --- a/linux-user/hppa/sockbits.h +++ b/linux-user/hppa/sockbits.h @@ -1,71 +1,77 @@ -#define TARGET_SOL_SOCKET 0x +#define TARGET_SOL_SOCKET 0x -#define TARGET_SO_DEBUG0x0001 -#define TARGET_SO_REUSEADDR0x0004 -#define TARGET_SO_KEEPALIVE0x0008 -#define TARGET_SO_DONTROUTE0x0010 -#define TARGET_SO_BROADCAST0x0020 -#define TARGET_SO_LINGER 0x0080 -#define TARGET_SO_OOBINLINE0x0100 -#define TARGET_SO_REUSEPORT0x0200 -#define TARGET_SO_SNDBUF 0x1001 -#define TARGET_SO_RCVBUF 0x1002 -#define TARGET_SO_SNDBUFFORCE 0x100a -#define TARGET_SO_RCVBUFFORCE 0x100b -#define TARGET_SO_SNDLOWAT 0x1003 -#define TARGET_SO_RCVLOWAT 0x1004 -#define TARGET_SO_SNDTIMEO 0x1005 -#define TARGET_SO_RCVTIMEO 0x1006 -#define TARGET_SO_ERROR0x1007 -#define TARGET_SO_TYPE 0x1008 -#define TARGET_SO_PROTOCOL 0x1028 -#define TARGET_SO_DOMAIN 0x1029 -#define TARGET_SO_PEERNAME 0x2000 -#define TARGET_SO_NO_CHECK 0x400b -#define TARGET_SO_PRIORITY 0x400c -#define TARGET_SO_BSDCOMPAT0x400e -#define TARGET_SO_PASSCRED 0x4010 -#define TARGET_SO_PEERCRED 0x4011 -#define TARGET_SO_TIMESTAMP0x4012 -#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP -#define TARGET_SO_TIMESTAMPNS 0x4013 -#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_SNDBUF0x1001 +#define TARGET_SO_RCVBUF0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_SNDLOWAT 0x1003 +#define TARGET_SO_RCVLOWAT 0x1004 +#define TARGET_SO_SNDTIMEO 0x1005 +#define TARGET_SO_RCVTIMEO 0x1006 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN0x1029 +#define TARGET_SO_PEERNAME 0x2000 +#define TARGET_SO_NO_CHECK 0x400b +#define TARGET_SO_PRIORITY 0x400c +#define TARGET_SO_BSDCOMPAT 0x400e +#define TARGET_SO_PASSCRED 0x4010 +#define TARGET_SO_PEERCRED 0x4011 +#define TARGET_SO_TIMESTAMP 0x4012 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_TIMESTAMPNS 0x4013 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS -#define TARGET_SO_SECURITY_AUTHENTICATION 0x4016 -#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT0x4017 -#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 0x4018 +#define TARGET_SO_SECURITY_AUTHENTICATION 0x4016 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 0x4017 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 0x4018 -#define TARGET_SO_BINDTODEVICE 0x4019 -#define TARGET_SO_ATTACH_FILTER0x401a -#define TARGET_SO_DETACH_FILTER0x401b -#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER -#define TARGET_SO_ACCEPTCONN 0x401c -#define TARGET_SO_PEERSEC 0x401d -#define TARGET_SO_PASSSEC 0x401e -#define TARGET_SO_MARK 0x401f -#define TARGET_SO_TIMESTAMPING 0x4020 -#define TARGET_SCM_TIMESTAMPINGTARGET_SO_TIMESTAMPING -#define TARGET_SO_RXQ_OVFL 0x4021 -#define TARGET_SO_WIFI_STATUS 0x4022 -#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS -#define TARGET_SO_PEEK_OFF 0x4023 -#define TARGET_SO_NOFCS0x4024 -#define TARGET_SO_LOCK_FILTER 0x4025 -#define TARGET_SO_SELECT_ERR_QUEUE 0x4026 -#define TARGET_SO_BUSY_POLL0x4027 -#define TARGET_SO_MAX_PACING_RATE 0x4028 -#define TARGET_SO_BPF_EXTENSIONS 0x4029 -#define TARGET_SO_INCOMING_CPU 0x402A -#define TARGET_SO_ATTACH_BPF 0x402B -#define TARGET_SO_DETA
[Qemu-devel] [RFC 2/6] linux-user: refactor socket.h for alpha
based on fresh bits from linux 4.14 and therefore enabling SO_REUSEPORT as a side effect Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/alpha/sockbits.h | 104 linux-user/socket.h | 104 +--- 2 files changed, 105 insertions(+), 103 deletions(-) create mode 100644 linux-user/alpha/sockbits.h diff --git a/linux-user/alpha/sockbits.h b/linux-user/alpha/sockbits.h new file mode 100644 index 00..768579a1f7 --- /dev/null +++ b/linux-user/alpha/sockbits.h @@ -0,0 +1,104 @@ +#define TARGET_SOL_SOCKET 0x + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_SNDBUF0x1001 +#define TARGET_SO_RCVBUF0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_RCVLOWAT 0x1010 +#define TARGET_SO_SNDLOWAT 0x1011 +#define TARGET_SO_RCVTIMEO 0x1012 +#define TARGET_SO_SNDTIMEO 0x1013 +#define TARGET_SO_ACCEPTCONN0x1014 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN0x1029 +#define TARGET_SO_NO_CHECK 11 +#define TARGET_SO_PRIORITY 12 +#define TARGET_SO_BSDCOMPAT 14 +#define TARGET_SO_PASSCRED 17 +#define TARGET_SO_PEERCRED 18 +#define TARGET_SO_BINDTODEVICE 25 +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 +#define TARGET_SO_GET_FILTERTARGET_SO_ATTACH_FILTER +#define TARGET_SO_PEERNAME 28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMPTARGET_SO_TIMESTAMP +#define TARGET_SO_PEERSEC 30 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS +#define TARGET_SO_SECURITY_AUTHENTICATION 19 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 20 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 21 +#define TARGET_SO_MARK 36 +#define TARGET_SO_TIMESTAMPING 37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING +#define TARGET_SO_RXQ_OVFL 40 +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 42 +#define TARGET_SO_NOFCS 43 +#define TARGET_SO_LOCK_FILTER 44 +#define TARGET_SO_SELECT_ERR_QUEUE 45 +#define TARGET_SO_BUSY_POLL 46 +#define TARGET_SO_MAX_PACING_RATE 47 +#define TARGET_SO_BPF_EXTENSIONS48 +#define TARGET_SO_INCOMING_CPU 49 +#define TARGET_SO_ATTACH_BPF50 +#define TARGET_SO_DETACH_BPFTARGET_SO_DETACH_FILTER +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 51 +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 52 +#define TARGET_SO_CNX_ADVICE53 +#define TARGET_SCM_TIMESTAMPING_OPT_STATS 54 +#define TARGET_SO_MEMINFO 55 +#define TARGET_SO_INCOMING_NAPI_ID 56 +#define TARGET_SO_COOKIE57 +#define TARGET_SCM_TIMESTAMPING_PKTINFO 58 +#define TARGET_SO_PEERGROUPS59 +#define TARGET_SO_ZEROCOPY 60 + +/** sock_type - Socket types + * + * Please notice that for binary compat reasons ALPHA has to + * override the enum sock_type in include/linux/net.h, so + * we define ARCH_HAS_SOCKET_TYPES here. + * + * @SOCK_STREAM - stream (connection) socket + * @SOCK_DGRAM - datagram (conn.less) socket + * @SOCK_RAW - raw socket + * @SOCK_RDM - reliably-delivered message + * @SOCK_SEQPACKET - sequential packet socket + * @SOCK_DCCP - Datagram Congestion Control Protocol socket + * @SOCK_PACKET - linux specific way of getting packets at the dev level. + *For writing rarp and other similar things on the user + *level. + * @SOCK_CLOEXEC - sets the close-on-exec (FD_C
[Qemu-devel] [RFC 0/6] linux-user: refactor socket.h into architecture specific sockbits
the definitions in socket.h are meant to reflect the ones in linux for each respective target, but are sometimes difficult to maintain. hppa (AKA parisc) was initially merged with an independent file that mirrors more closely the corresponding one in linux but hasn't been updated since. while testing what should had been a simple change (adding to setsockopt support for another SO flag) it became obvious that doing this refactor would help making the code easier to understand and avoid hard to see bugs (like definitions set to the wrong target as shown for sparc at least) the changes are somehow mechanical, and I had made an effort to try to identify what has changed (and hopefully fix a bug), but there is a high probability something as silly as a typo might have introduced a bug, therefore, testing for each target is encouraged but not something I could do on my own (being new to qemu-user and not having access to the corresponding sysroots) the fact that it is most likely that most socket functions where not working for sparc, sparc64, mips64 and ppc64 is most likely an indication that more testing (and regressions) is likely needed around this, so suggestions and help on that is also needed.
[Qemu-devel] [PATCH] linux_user: fix TARGET_SOL_SOCKET for sparc
Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/socket.h | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/linux-user/socket.h b/linux-user/socket.h index 129f9b4713..1db1a184b9 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -229,7 +229,9 @@ * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. */ -#define ARCH_HAS_SOCKET_TYPES 1 +#define ARCH_HAS_SOCKET_TYPES1 + +#define TARGET_SOL_SOCKET0x enum sock_type { TARGET_SOCK_STREAM = 1, @@ -250,14 +252,13 @@ #define TARGET_SO_PASSSEC31 #else +#define TARGET_SOL_SOCKET1 + #define TARGET_SO_LINGER 13 #define TARGET_SO_PASSSEC34 #endif -/* For setsockopt(2) */ -#define TARGET_SOL_SOCKET 1 - #define TARGET_SO_DEBUG1 #define TARGET_SO_REUSEADDR2 #define TARGET_SO_TYPE 3 -- 2.14.1
[Qemu-devel] [PATCH 3/3] linux-user: add SO_LINGER to getsockopt
Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/syscall.c | 34 +- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ad689dad50..91bd27c63a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3178,7 +3178,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, level = SOL_SOCKET; switch (optname) { /* These don't just return a single integer */ -case TARGET_SO_LINGER: case TARGET_SO_RCVTIMEO: case TARGET_SO_SNDTIMEO: case TARGET_SO_PEERNAME: @@ -3216,6 +3215,39 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, } break; } +case TARGET_SO_LINGER: +{ +struct linger lg; +socklen_t lglen; +struct target_linger *tlg; + +if (get_user_u32(len, optlen)) { +return -TARGET_EFAULT; +} +if (len < 0) { +return -TARGET_EINVAL; +} + +lglen = sizeof(lg); +ret = get_errno(getsockopt(sockfd, level, SO_LINGER, + , )); +if (ret < 0) { +return ret; +} +if (len > lglen) { +len = lglen; +} +if (!lock_user_struct(VERIFY_WRITE, tlg, optval_addr, 0)) { +return -TARGET_EFAULT; +} +__put_user(lg.l_onoff, >l_onoff); +__put_user(lg.l_linger, >l_linger); +unlock_user_struct(tlg, optval_addr, 1); +if (put_user_u32(len, optlen)) { +return -TARGET_EFAULT; +} +break; +} /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; -- 2.14.1
[Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt
Original implementation by Chen Gang; all bugs mine Signed-off-by: Chen Gang <gang.chen.5...@gmail.com> Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/syscall.c | 15 +++ linux-user/syscall_defs.h | 5 + 2 files changed, 20 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..ad689dad50 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3071,6 +3071,21 @@ set_timeout: unlock_user (dev_ifname, optval_addr, 0); return ret; } +case TARGET_SO_LINGER: +{ +struct linger lg; +struct target_linger *tlg; + +if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) { +return -TARGET_EFAULT; +} +__get_user(lg.l_onoff, >l_onoff); +__get_user(lg.l_linger, >l_linger); +ret = get_errno(setsockopt(sockfd, SOL_SOCKET, SO_LINGER, +, optlen)); +unlock_user_struct(tlg, optval_addr, 0); +return ret; +} /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 40c5027e93..a60d6bb163 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -202,6 +202,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { +abi_int l_onoff;/* Linger active*/ +abi_int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec; -- 2.14.1
[Qemu-devel] [PATCH 1/3] linux-user: fix TARGET_SO_LINGER for sparc
Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/socket.h | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/socket.h b/linux-user/socket.h index 7051cd2cf4..129f9b4713 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -246,8 +246,12 @@ #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) #define TARGET_SOCK_TYPE_MASK0xf /* Covers up to TARGET_SOCK_MAX-1. */ +#define TARGET_SO_LINGER 0x0080 + #define TARGET_SO_PASSSEC31 #else +#define TARGET_SO_LINGER 13 + #define TARGET_SO_PASSSEC34 #endif @@ -268,7 +272,7 @@ #define TARGET_SO_OOBINLINE10 #define TARGET_SO_NO_CHECK 11 #define TARGET_SO_PRIORITY 12 -#define TARGET_SO_LINGER 13 + #define TARGET_SO_BSDCOMPAT14 /* To add :#define TARGET_SO_REUSEPORT 15 */ #if defined(TARGET_PPC) -- 2.14.1
[Qemu-devel] [PATCH v3] linux-user: syscall: Add SO_LINGER for setsockopt
Original implementation from Chen Gang; code moved around as per v2 Signed-off-by: Chen Gang <gang.chen.5...@gmail.com> Signed-off-by: Carlo Marcelo Arenas Belón <care...@gmail.com> --- linux-user/syscall.c | 16 linux-user/syscall_defs.h | 5 + 2 files changed, 21 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..d3c500ca78 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2829,6 +2829,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, int val; struct ip_mreqn *ip_mreq; struct ip_mreq_source *ip_mreq_source; +struct linger lg; +struct target_linger *tlg; switch(level) { case SOL_TCP: @@ -3071,6 +3073,20 @@ set_timeout: unlock_user (dev_ifname, optval_addr, 0); return ret; } +case TARGET_SO_LINGER: +optname = SO_LINGER; +if (optlen != sizeof(struct target_linger)) { +return -TARGET_EINVAL; +} +if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) { +return -TARGET_EFAULT; +} +__get_user(lg.l_onoff, >l_onoff); +__get_user(lg.l_linger, >l_linger); +ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, +, sizeof(lg))); +unlock_user_struct(tlg, optval_addr, 0); +return ret; /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 40c5027e93..a60d6bb163 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -202,6 +202,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { +abi_int l_onoff;/* Linger active*/ +abi_int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec; -- 2.11.0 (Apple Git-81)