[PATCH v1 1/6] tests/docker: Fix _get_so_libs() for docker-binfmt-image

2021-01-19 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

Fix a variable rename mistake from commit 5e33f7fead5:

  Traceback (most recent call last):
File "./tests/docker/docker.py", line 710, in 
  sys.exit(main())
File "./tests/docker/docker.py", line 706, in main
  return args.cmdobj.run(args, argv)
File "./tests/docker/docker.py", line 489, in run
  _copy_binary_with_libs(args.include_executable,
File "./tests/docker/docker.py", line 149, in _copy_binary_with_libs
  libs = _get_so_libs(src)
File "./tests/docker/docker.py", line 123, in _get_so_libs
  libs.append(s.group(1))
  NameError: name 's' is not defined

Fixes: 5e33f7fead5 ("tests/docker: better handle symlinked libs")
Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Alex Bennée 
Message-Id: <20210119050149.516910-1-f4...@amsat.org>
---
 tests/docker/docker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 884dfeb29c..0b4f6167b3 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -120,7 +120,7 @@ def _get_so_libs(executable):
 search = ldd_re.search(line)
 if search:
 try:
-libs.append(s.group(1))
+libs.append(search.group(1))
 except IndexError:
 pass
 except subprocess.CalledProcessError:
-- 
2.20.1




[PATCH v1 5/6] tests/docker: alias docker-help target for consistency

2021-01-19 Thread Alex Bennée
We have a bunch of -help targets so this will save some cognitive
dissonance. Keep the original for those with muscle memory.

Signed-off-by: Alex Bennée 
---
 tests/docker/Makefile.include | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index bdc53ddfcf..a5c1e4a615 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -1,6 +1,6 @@
 # Makefile for Docker tests
 
-.PHONY: docker docker-test docker-clean docker-image docker-qemu-src
+.PHONY: docker docker-help docker-test docker-clean docker-image 
docker-qemu-src
 
 NULL :=
 SPACE := $(NULL) #
@@ -218,6 +218,8 @@ endif
@echo ' Specify which container engine to run.'
@echo 'REGISTRY=url Cache builds from registry 
(default:$(DOCKER_REGISTRY))'
 
+docker-help: docker
+
 # This rule if for directly running against an arbitrary docker target.
 # It is called by the expanded docker targets (e.g. make
 # docker-test-foo@bar) which will do additional verification.
-- 
2.20.1




[PATCH v1 6/6] tests/docker: add a docker-exec-copy-test

2021-01-19 Thread Alex Bennée
This provides test machinery for checking the QEMU copying logic works
properly. It takes considerably less time to run than starting a
debootstrap only for it to fail later. I considered adding a remove
command to docker.py but figured that might be gold plating given the
relative size of the containers compared to the ones with actual stuff
in them.

Signed-off-by: Alex Bennée 
---
 tests/docker/Makefile.include | 20 +++-
 tests/docker/docker.py|  7 ++-
 tests/docker/dockerfiles/empty.docker |  8 
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 tests/docker/dockerfiles/empty.docker

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index a5c1e4a615..93b29ad823 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -11,7 +11,7 @@ HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
 DOCKER_SUFFIX := .docker
 DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
 # we don't run tests on intermediate images (used as base by another image)
-DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap
+DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap empty
 DOCKER_IMAGES := $(sort $(notdir $(basename $(wildcard 
$(DOCKER_FILES_DIR)/*.docker
 DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES))
 # Use a global constant ccache directory to speed up repetitive builds
@@ -92,6 +92,24 @@ docker-binfmt-image-debian-%: 
$(DOCKER_FILES_DIR)/debian-bootstrap.docker
{ echo "You will need to build $(EXECUTABLE)"; exit 
1;},\
"CHECK", "debian-$* exists"))
 
+# These are test targets
+USER_TCG_TARGETS=$(patsubst %-linux-user,qemu-%,$(filter 
%-linux-user,$(TARGET_DIRS)))
+EXEC_COPY_TESTS=$(patsubst %,docker-exec-copy-test-%, $(USER_TCG_TARGETS))
+
+$(EXEC_COPY_TESTS): docker-exec-copy-test-%: $(DOCKER_FILES_DIR)/empty.docker
+   $(call quiet-command,   
\
+   $(DOCKER_SCRIPT) build -t qemu/exec-copy-test-$* -f $<  
\
+   $(if $V,,--quiet) --no-cache
\
+   --include-executable=$* 
\
+   --skip-binfmt,  
\
+   "TEST","copy $* to container")
+   $(call quiet-command,   
\
+   $(DOCKER_SCRIPT) run qemu/exec-copy-test-$* 
\
+   /$* -version > tests/docker-exec-copy-test-$*.out,  
\
+   "TEST","check $* works in container")
+
+docker-exec-copy-test: $(EXEC_COPY_TESTS)
+
 endif
 
 # Enforce dependencies for composite images
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 39da3fefcf..d28df4c140 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -438,6 +438,9 @@ class BuildCommand(SubCommand):
 help="""Specify a binary that will be copied to the
 container together with all its dependent
 libraries""")
+parser.add_argument("--skip-binfmt",
+action="store_true",
+help="""Skip binfmt entry check (used for 
testing)""")
 parser.add_argument("--extra-files", nargs='*',
 help="""Specify files that will be copied in the
 Docker image, fulfilling the ADD directive from the
@@ -466,7 +469,9 @@ class BuildCommand(SubCommand):
 docker_dir = tempfile.mkdtemp(prefix="docker_build")
 
 # Validate binfmt_misc will work
-if args.include_executable:
+if args.skip_binfmt:
+qpath = args.include_executable
+elif args.include_executable:
 qpath, enabled = _check_binfmt_misc(args.include_executable)
 if not enabled:
 return 1
diff --git a/tests/docker/dockerfiles/empty.docker 
b/tests/docker/dockerfiles/empty.docker
new file mode 100644
index 00..9ba980f1a8
--- /dev/null
+++ b/tests/docker/dockerfiles/empty.docker
@@ -0,0 +1,8 @@
+#
+# Empty Dockerfile
+#
+
+FROM scratch
+
+# Add everything from the context into the container
+ADD . /
-- 
2.20.1




[PATCH v1 4/6] tests/docker: preserve original name when copying libs

2021-01-19 Thread Alex Bennée
While it is important we chase down the symlinks to copy the correct
data we can confuse the kernel by renaming the interpreter to what is
in the binary. Extend _copy_with_mkdir to preserve the original name
of the file when asked.

Fixes: 5e33f7fead ("tests/docker: better handle symlinked libs")
Signed-off-by: Alex Bennée 
---
 tests/docker/docker.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index fb3de41c0b..39da3fefcf 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -93,7 +93,7 @@ def _guess_engine_command():
 commands_txt)
 
 
-def _copy_with_mkdir(src, root_dir, sub_path='.'):
+def _copy_with_mkdir(src, root_dir, sub_path='.', name=None):
 """Copy src into root_dir, creating sub_path as needed."""
 dest_dir = os.path.normpath("%s/%s" % (root_dir, sub_path))
 try:
@@ -102,7 +102,7 @@ def _copy_with_mkdir(src, root_dir, sub_path='.'):
 # we can safely ignore already created directories
 pass
 
-dest_file = "%s/%s" % (dest_dir, os.path.basename(src))
+dest_file = "%s/%s" % (dest_dir, name if name else os.path.basename(src))
 
 try:
 copy(src, dest_file)
@@ -155,8 +155,9 @@ def _copy_binary_with_libs(src, bin_dest, dest_dir):
 if libs:
 for l in libs:
 so_path = os.path.dirname(l)
+name = os.path.basename(l)
 real_l = os.path.realpath(l)
-_copy_with_mkdir(real_l, dest_dir, so_path)
+_copy_with_mkdir(real_l, dest_dir, so_path, name)
 
 
 def _check_binfmt_misc(executable):
-- 
2.20.1




[PATCH v1 2/6] tests/docker: Fix typo in help message

2021-01-19 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

To have the variable properly passed, we need to set it,
ie. NOUSER=1. Fix the message displayed by 'make docker'.

Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Alex Bennée 
Message-Id: <20210119052120.522069-1-f4...@amsat.org>
---
 tests/docker/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 0779dab5b9..bdc53ddfcf 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -209,7 +209,7 @@ endif
@echo ' before running the command.'
@echo 'NETWORK=1Enable virtual network interface with 
default backend.'
@echo 'NETWORK=$$BACKEND Enable virtual network interface with 
$$BACKEND.'
-   @echo 'NOUSER   Define to disable adding current user 
to containers passwd.'
+   @echo 'NOUSER=1 Define to disable adding current user 
to containers passwd.'
@echo 'NOCACHE=1Ignore cache when build images.'
@echo 'EXECUTABLE=Include executable in image.'
@echo 'EXTRA_FILES=" [... ]"'
-- 
2.20.1




[PATCH v1 0/6] testing/next (docker binfmt tests)

2021-01-19 Thread Alex Bennée
Hi,

The testing updates keep on rolling. Promoted by some fixes from
Phillipe I decided to expand the testing of the binfmt code. This at
least ensures that any binary copied into the docker container has
enough bits to be functional.

The following need review:

 - tests/docker: add a docker-exec-copy-test
 - tests/docker: alias docker-help target for consistency
 - tests/docker: preserve original name when copying libs
 - tests/docker: make _copy_with_mkdir accept missing files

Alex Bennée (4):
  tests/docker: make _copy_with_mkdir accept missing files
  tests/docker: preserve original name when copying libs
  tests/docker: alias docker-help target for consistency
  tests/docker: add a docker-exec-copy-test

Philippe Mathieu-Daudé (2):
  tests/docker: Fix _get_so_libs() for docker-binfmt-image
  tests/docker: Fix typo in help message

 tests/docker/Makefile.include | 26 +++---
 tests/docker/docker.py| 23 +--
 tests/docker/dockerfiles/empty.docker |  8 
 3 files changed, 48 insertions(+), 9 deletions(-)
 create mode 100644 tests/docker/dockerfiles/empty.docker

-- 
2.20.1




[PATCH v1 3/6] tests/docker: make _copy_with_mkdir accept missing files

2021-01-19 Thread Alex Bennée
Depending on the linker/ldd setup we might get a file with no path.
Typically this is the psuedo library linux-vdso.so which doesn't
actually exist on the disk. Rather than try and catch these distro
specific edge cases just shout about it and try and continue.

Signed-off-by: Alex Bennée 
---
 tests/docker/docker.py | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 0b4f6167b3..fb3de41c0b 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -103,7 +103,12 @@ def _copy_with_mkdir(src, root_dir, sub_path='.'):
 pass
 
 dest_file = "%s/%s" % (dest_dir, os.path.basename(src))
-copy(src, dest_file)
+
+try:
+copy(src, dest_file)
+except FileNotFoundError:
+print("Couldn't copy %s to %s" % (src, dest_file))
+pass
 
 
 def _get_so_libs(executable):
-- 
2.20.1




Re: [RFC PATCH] tests/docker: Allow passing --network option when building images

2021-01-19 Thread Alex Bennée


Daniel P. Berrangé  writes:

> On Tue, Jan 19, 2021 at 03:40:50PM +0100, Philippe Mathieu-Daudé wrote:
>> On 1/19/21 3:20 PM, Daniel P. Berrangé wrote:
>> > On Tue, Jan 19, 2021 at 02:40:13PM +0100, Philippe Mathieu-Daudé wrote:
>> >> On 1/19/21 12:27 PM, Alex Bennée wrote:
>> >>> Philippe Mathieu-Daudé  writes:
>> >>>
>> >>>> When using the Docker engine, build fails because the container is
>> >>>> unable to resolve hostnames:
>> >>>>
>> >>>>   $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
>> >>>> BUILD   debian10
>> >>>>   #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
>> >>>>   #6 9.679   Temporary failure resolving 'deb.debian.org'
>> >>>>   #6 16.69 Err:2 http://security.debian.org/debian-security 
>> >>>> buster/updates InRelease
>> >>>>   #6 16.69   Temporary failure resolving 'security.debian.org'
>> >>>>   #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
>> >>>>   #6 22.69   Temporary failure resolving 'deb.debian.org'
>> >>>>   #6 22.74 W: Failed to fetch 
>> >>>> http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure 
>> >>>> resolving 'deb.debian.org'
>> >>>>   #6 22.74 W: Failed to fetch 
>> >>>> http://security.debian.org/debian-security/dists/buster/updates/InRelease
>> >>>>   Temporary failure resolving 'security.debian.org'
>> >>>>   #6 22.74 W: Failed to fetch 
>> >>>> http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary 
>> >>>> failure resolving 'deb.debian.org'
>> >>>>   #6 22.74 W: Some index files failed to download. They have been
>> >>>>   ignored, or old ones used instead.
>> >>>
>> >>> I'm confused by this one as it currently works for me. That said I
>> >>> thought the actual behaviour was meant to be networking is enabled by
>> >>> default and explicitly disabled by the run step (which shouldn't be
>> >>> pulling extra stuff down).
>> >>>
>> >>> This was last tweaked by Daniel in 8a2390a4f47
>> >>>
>> >>> Have the defaults for docker engine changed?
>> >>
>> >> No idea as I'm not following their development, but TBH it
>> >> becomes harder and harder to use without tricks (I had to
>> >> add systemd.unified_cgroup_hierarchy=0 to kernel cmdline
>> >> to keep using it).
>> >>
>> >> Maybe I should switch to podman which is the recommended
>> >> engine on Fedora.
>> >>
>> >> Cc'ing Marc-André who added podman support (Daniel is in Cc).
>> > 
>> > I'm using podman exclusively since Docker doesn't work well with
>> > modern distros that use Cgroups v2.
>> 
>> OK this probably explains it.
>> 
>> Ideally we could add a check for this ("modern distro" -> docker
>> engine not recommended) but I guess I'm the only one using this
>> feature on Fedora (as nobody complained) so not a problem. I'll
>> see how to use podman.
>
> I'm not sure we need to block it. If someone has docker installed
> then its reasonable to assume they have ti working. We prefer
> podman if both are installed.

>From my point of view podman is the odd man out (I run upstream
docker.com packages on Debian Buster). I had to jump through some hoops
to get podman installed on my Gentoo box but I think it's currently
broken because it's Gentoo.

IOW I assume the people that really care about podman will shout if it
breaks. It would be nice if we could catch cases in the CI though.

>
>
> Regards,
> Daniel


-- 
Alex Bennée



Re: [PULL 21/30] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

2021-01-19 Thread Alex Bennée


Claudio Fontana  writes:

> On 1/19/21 3:50 PM, Alex Bennée wrote:
>> 
>> Claudio Fontana  writes:
>> 
>>> Hi Alex,
>>>
>>> after updating to latest master today, I am getting the following error with
>>>
>>> make check-tcg
>>>
>>> qemu-system-aarch64: -gdb 
>>> unix:path=/tmp/tmp9ru5tgk8qemu-gdbstub/gdbstub.socket,server: info: QEMU 
>>> waiting for connection on: 
>>> disconnected:unix:/tmp/tmp9ru5tgk8qemu-gdbstub/gdbstub.socket,server
>>> warning: while parsing target description (at line 47): Vector "svevhf" 
>>> references undefined type "ieee_half"
>>> warning: Could not load XML target description; ignoring
>>> qemu-system-aarch64: QEMU: Terminated via GDBstub
>>>
>>> Seems to indicate it is "ieee_half" -related?
>> 
>> *sigh*
>> 
>> yes - it is. I thought this was solved by the GDB version check in
>> 14/30. What does your gdb report?
>
>
> $ gdb --version
> GNU gdb (GDB; openSUSE Leap 15.2) 8.3.1
> Copyright (C) 2019 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
>
> gdb --configuration
> This GDB was configured as follows:
>configure --host=x86_64-suse-linux --target=x86_64-suse-linux
>  --with-auto-load-dir=$debugdir:$datadir/auto-load
>  --with-auto-load-safe-path=$debugdir:$datadir/auto-load
>  --with-expat
>  --with-gdb-datadir=/usr/share/gdb
>  --with-jit-reader-dir=/usr/lib64/gdb
>  --without-libunwind-ia64
>  --with-lzma
>  --without-babeltrace
>  --with-intel-pt
>  --disable-libmcheck
>  --with-mpfr
>  --with-python=/usr
>  --without-guile
>  --disable-source-highlight
>  --with-separate-debug-dir=/usr/lib/debug
>  --with-system-gdbinit=/etc/gdbinit
>
>
> does this help?

So it looks like TDESC_TYPE_IEEE_HALF was only implemented in GDB 9.1
and there is no probing possible during the gdbstub connection. I guess
I can either go back to stubbing it out (which would break gdb's SVE
understanding) or up our minimum GDB version check for running tests.
That would mean less people test GDB (or at least until the distros
catch up) but considering it was zero people not too long ago maybe
that's acceptable?

>
> Let me know if more info is needed. Thanks!
>
> Claudio
>
>
>> 
>>>
>>> Thanks,
>>>
>>> Claudio
>>>
>>> On 1/15/21 2:08 PM, Alex Bennée wrote:
>>>> While GDB can work with any XML description given to it there is
>>>> special handling for SVE registers on the GDB side which makes the
>>>> users life a little better. The changes aren't that major and all the
>>>> registers save the $vg reported the same. All that changes is:
>>>>
>>>>   - report org.gnu.gdb.aarch64.sve
>>>>   - use gdb nomenclature for names and types
>>>>   - minor re-ordering of the types to match reference
>>>>   - re-enable ieee_half (as we know gdb supports it now)
>>>>   - $vg is now a 64 bit int
>>>>   - check $vN and $zN aliasing in test
>>>>
>>>> Signed-off-by: Alex Bennée 
>>>> Reviewed-by: Luis Machado 
>>>> Message-Id: <20210108224256.2321-11-alex.ben...@linaro.org>
>>>>
>>>> diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
>>>> index 866595b4f1..a8fff2a3d0 100644
>>>> --- a/target/arm/gdbstub.c
>>>> +++ b/target/arm/gdbstub.c
>>>> @@ -195,22 +195,17 @@ static const struct TypeSize vec_lanes[] = {
>>>>  { "uint128", 128, 'q', 'u' },
>>>>  { "int128", 128, 'q', 's' },
>>>>  /* 64 bit */
>>>> +{ "ieee_double", 64, 'd', 'f' },
>>>>  { "uint64", 64, 'd', 'u' },
>>>>  { "int64", 64, 'd', 's' },
>>>> -{ "ieee_double", 64, 'd', 'f' },
>>>>  /* 32 bit */
>>>> +{ "ieee_single", 32, 's', 'f' },
>>>>  { "uint32", 32, 's', 'u' },
>>>>  { "int32", 32, 's', 's' },
>>>> -{ "ieee_single", 32, 's', 'f' },
>>>>  /* 16 bit */
>>>> +{ "ieee_half&

Re: [PULL 21/30] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

2021-01-19 Thread Alex Bennée


Claudio Fontana  writes:

> Hi Alex,
>
> after updating to latest master today, I am getting the following error with
>
> make check-tcg
>
> qemu-system-aarch64: -gdb 
> unix:path=/tmp/tmp9ru5tgk8qemu-gdbstub/gdbstub.socket,server: info: QEMU 
> waiting for connection on: 
> disconnected:unix:/tmp/tmp9ru5tgk8qemu-gdbstub/gdbstub.socket,server
> warning: while parsing target description (at line 47): Vector "svevhf" 
> references undefined type "ieee_half"
> warning: Could not load XML target description; ignoring
> qemu-system-aarch64: QEMU: Terminated via GDBstub
>
> Seems to indicate it is "ieee_half" -related?

*sigh*

yes - it is. I thought this was solved by the GDB version check in
14/30. What does your gdb report?

>
> Thanks,
>
> Claudio
>
> On 1/15/21 2:08 PM, Alex Bennée wrote:
>> While GDB can work with any XML description given to it there is
>> special handling for SVE registers on the GDB side which makes the
>> users life a little better. The changes aren't that major and all the
>> registers save the $vg reported the same. All that changes is:
>> 
>>   - report org.gnu.gdb.aarch64.sve
>>   - use gdb nomenclature for names and types
>>   - minor re-ordering of the types to match reference
>>   - re-enable ieee_half (as we know gdb supports it now)
>>   - $vg is now a 64 bit int
>>   - check $vN and $zN aliasing in test
>> 
>> Signed-off-by: Alex Bennée 
>> Reviewed-by: Luis Machado 
>> Message-Id: <20210108224256.2321-11-alex.ben...@linaro.org>
>> 
>> diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
>> index 866595b4f1..a8fff2a3d0 100644
>> --- a/target/arm/gdbstub.c
>> +++ b/target/arm/gdbstub.c
>> @@ -195,22 +195,17 @@ static const struct TypeSize vec_lanes[] = {
>>  { "uint128", 128, 'q', 'u' },
>>  { "int128", 128, 'q', 's' },
>>  /* 64 bit */
>> +{ "ieee_double", 64, 'd', 'f' },
>>  { "uint64", 64, 'd', 'u' },
>>  { "int64", 64, 'd', 's' },
>> -{ "ieee_double", 64, 'd', 'f' },
>>  /* 32 bit */
>> +{ "ieee_single", 32, 's', 'f' },
>>  { "uint32", 32, 's', 'u' },
>>  { "int32", 32, 's', 's' },
>> -{ "ieee_single", 32, 's', 'f' },
>>  /* 16 bit */
>> +{ "ieee_half", 16, 'h', 'f' },
>>  { "uint16", 16, 'h', 'u' },
>>  { "int16", 16, 'h', 's' },
>> -/*
>> - * TODO: currently there is no reliable way of telling
>> - * if the remote gdb actually understands ieee_half so
>> - * we don't expose it in the target description for now.
>> - * { "ieee_half", 16, 'h', 'f' },
>> - */
>>  /* bytes */
>>  { "uint8", 8, 'b', 'u' },
>>  { "int8", 8, 'b', 's' },
>> @@ -223,17 +218,16 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int 
>> base_reg)
>>  GString *s = g_string_new(NULL);
>>  DynamicGDBXMLInfo *info = >dyn_svereg_xml;
>>  g_autoptr(GString) ts = g_string_new("");
>> -int i, bits, reg_width = (cpu->sve_max_vq * 128);
>> +int i, j, bits, reg_width = (cpu->sve_max_vq * 128);
>>  info->num = 0;
>>  g_string_printf(s, "");
>>  g_string_append_printf(s, "> \"gdb-target.dtd\">");
>> -g_string_append_printf(s, "> name=\"org.qemu.gdb.aarch64.sve\">");
>> +g_string_append_printf(s, "");
>>  
>>  /* First define types and totals in a whole VL */
>>  for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
>>  int count = reg_width / vec_lanes[i].size;
>> -g_string_printf(ts, "vq%d%c%c", count,
>> -vec_lanes[i].sz, vec_lanes[i].suffix);
>> +g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, 
>> vec_lanes[i].suffix);
>>  g_string_append_printf(s,
>> "> count=\"%d\"/>",
>> ts->str, vec_lanes[i].gdb_type, count);
>> @@ -243,39 +237,37 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int 
>> base_reg)
>>   * signed and potentially float versions of each size from 128 to
>>   * 8 bits.
>>   */
>> -for (bits = 128; bits >= 8; bits /= 2) {
>> -int count = reg_width / bits;
>> -g_string_append_printf(s, "", 

Re: [RFC PATCH] tests/docker: Allow passing --network option when building images

2021-01-19 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> When using the Docker engine, build fails because the container is
> unable to resolve hostnames:
>
>   $ make docker-image-debian-s390x-cross NETWORK=host ENGINE=docker
> BUILD   debian10
>   #6 9.679 Err:1 http://deb.debian.org/debian buster InRelease
>   #6 9.679   Temporary failure resolving 'deb.debian.org'
>   #6 16.69 Err:2 http://security.debian.org/debian-security buster/updates 
> InRelease
>   #6 16.69   Temporary failure resolving 'security.debian.org'
>   #6 22.69 Err:3 http://deb.debian.org/debian buster-updates InRelease
>   #6 22.69   Temporary failure resolving 'deb.debian.org'
>   #6 22.74 W: Failed to fetch 
> http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure 
> resolving 'deb.debian.org'
>   #6 22.74 W: Failed to fetch 
> http://security.debian.org/debian-security/dists/buster/updates/InRelease  
> Temporary failure resolving 'security.debian.org'
>   #6 22.74 W: Failed to fetch 
> http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary 
> failure resolving 'deb.debian.org'
>   #6 22.74 W: Some index files failed to download. They have been
>   ignored, or old ones used instead.

I'm confused by this one as it currently works for me. That said I
thought the actual behaviour was meant to be networking is enabled by
default and explicitly disabled by the run step (which shouldn't be
pulling extra stuff down).

This was last tweaked by Daniel in 8a2390a4f47

Have the defaults for docker engine changed?

>   Traceback (most recent call last):
> File "./tests/docker/docker.py", line 709, in 
>   sys.exit(main())
> File "./tests/docker/docker.py", line 705, in main
>   return args.cmdobj.run(args, argv)
> File "./tests/docker/docker.py", line 498, in run
>   dkr.build_image(tag, docker_dir, dockerfile,
> File "./tests/docker/docker.py", line 353, in build_image
>   self._do_check(build_args,
> File "./tests/docker/docker.py", line 244, in _do_check
>   return subprocess.check_call(self._command + cmd, **kwargs)
> File "/usr/lib64/python3.8/subprocess.py", line 364, in check_call
>   raise CalledProcessError(retcode, cmd)
>   make: *** [tests/docker/Makefile.include:61: docker-image-debian10] Error 1
>
> Fix by passing the NETWORK variable with --network= argument.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/docker/Makefile.include | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index bdc53ddfcf9..b65fd684011 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -63,6 +63,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
>   $(if $V,,--quiet) \
>   $(if $(NOCACHE),--no-cache, \
>   $(if $(DOCKER_REGISTRY),--registry $(DOCKER_REGISTRY))) 
> \
> + $(if $(NETWORK),$(if $(subst
> $(NETWORK),,1),--network=$(NETWORK))) \

which if it has we'll need to tweak both build and run steps?

>   $(if $(NOUSER),,--add-current-user) \
>   $(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
>   $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\


-- 
Alex Bennée



Re: [PATCH] tests/docker: Fix typo in help message

2021-01-19 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> To have the variable properly passed, we need to set it,
> ie. NOUSER=1. Fix the message displayed by 'make docker'.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Queued to testing/next, thanks.

> ---
>  tests/docker/Makefile.include | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index 0779dab5b96..bdc53ddfcf9 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -209,7 +209,7 @@ endif
>   @echo ' before running the command.'
>   @echo 'NETWORK=1Enable virtual network interface with 
> default backend.'
>   @echo 'NETWORK=$$BACKEND Enable virtual network interface with 
> $$BACKEND.'
> - @echo 'NOUSER   Define to disable adding current user 
> to containers passwd.'
> + @echo 'NOUSER=1 Define to disable adding current user 
> to containers passwd.'
>   @echo 'NOCACHE=1Ignore cache when build images.'
>   @echo 'EXECUTABLE=Include executable in image.'
>   @echo 'EXTRA_FILES=" [... ]"'


-- 
Alex Bennée



Re: [PATCH] tests/docker: Fix _get_so_libs() for docker-binfmt-image

2021-01-19 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> Fix a variable rename mistake from commit 5e33f7fead5:
>
>   Traceback (most recent call last):
> File "./tests/docker/docker.py", line 710, in 
>   sys.exit(main())
> File "./tests/docker/docker.py", line 706, in main
>   return args.cmdobj.run(args, argv)
> File "./tests/docker/docker.py", line 489, in run
>   _copy_binary_with_libs(args.include_executable,
> File "./tests/docker/docker.py", line 149, in _copy_binary_with_libs
>   libs = _get_so_libs(src)
> File "./tests/docker/docker.py", line 123, in _get_so_libs
>   libs.append(s.group(1))
>   NameError: name 's' is not defined
>
> Fixes: 5e33f7fead5 ("tests/docker: better handle symlinked libs")
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> "Tested-by" but apparently not enough... Well actually it was on
> Debian, now using Fedora.

Also we don't notice if we use static binaries (which I do most of the time).

Queued to testing/next, thanks.

> ---
>  tests/docker/docker.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 884dfeb29c4..0b4f6167b3d 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -120,7 +120,7 @@ def _get_so_libs(executable):
>  search = ldd_re.search(line)
>  if search:
>  try:
> -libs.append(s.group(1))
> +    libs.append(search.group(1))
>  except IndexError:
>  pass
>  except subprocess.CalledProcessError:


-- 
Alex Bennée



Re: [PULL 05/30] Makefile: wrap ctags in quiet-command calls

2021-01-19 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> Hi Alex,
>
> On Fri, Jan 15, 2021 at 2:08 PM Alex Bennée  wrote:
>>
>> For prettier output.
>>
>> Signed-off-by: Alex Bennée 
>> Reviewed-by: Willian Rampazzo 
>> Reviewed-by: Philippe Mathieu-Daudé 
>> Message-Id: <20210114165730.31607-6-alex.ben...@linaro.org>
>>
>> diff --git a/Makefile b/Makefile
>> index 0c509a7704..bbab640b31 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -250,8 +250,13 @@ find-src-path = find "$(SRC_PATH)/" -path 
>> "$(SRC_PATH)/meson" -prune -o \( -name
>>
>>  .PHONY: ctags
>>  ctags:
>> -   rm -f "$(SRC_PATH)/"tags
>> -   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
>> +   $(call quiet-command,   \
>> +   rm -f "$(SRC_PATH)/"tags,   \
>> +   "CTAGS", "Remove old tags")
>> +   $(call quiet-command, \
>> +   $(find-src-path) -exec ctags\
>> +   -f "$(SRC_PATH)/"tags --append {} +,\
>> +   "CTAGS", "Re-index $(SRC_PATH)")
>>
>>  .PHONY: gtags
>>  gtags:
>> --
>> 2.20.1
>>
>
> Build now fails if ctags is not installed:
>
> $ if test -n "$MAKE_CHECK_ARGS"; then make -j"$JOBS" $MAKE_CHECK_ARGS ; fi
> CTAGS Remove old tags
> CTAGS Re-index /builds/philmd/qemu
> find: 'ctags': No such file or directory
> find: 'ctags': No such file or directory
> find: 'ctags': No such file or directory
> make: *** [Makefile:254: ctags] Error 1
> make: *** Waiting for unfinished jobs

Wait what, how? Have you got ctags in your MAKE_CHECK_ARGS? How did it
not fail before?

I suppose we could add checks for all the tooling in meson but it seems
a little overkill for a developer convenience.  

-- 
Alex Bennée



Re: [PATCH] tests/acceptance: Test PMON with Loongson-3A1000 CPU

2021-01-18 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> Hi Jiaxun, Alex,
>
> On 1/12/21 3:07 AM, Jiaxun Yang wrote:
>> Test booting of PMON bootloader on loongson3-virt platform.
>> 
>> $ (venv) AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
>> avocado --show=app,console \
>>   run -t machine:loongson3-virt tests/acceptance
>> Fetching asset from 
>> tests/acceptance/machine_mips_loongson3v.py:MipsLoongson3v.test_pmon_serial_console
>> JOB ID : 8e202b3727847c9104d0d3d6546ed225d35f6706
>> JOB LOG: 
>> /home/flygoat/avocado/job-results/job-2021-01-12T10.02-8e202b3/job.log
> ...
>> console: This software may be redistributed under the BSD copyright.
>> console: Copyright 2000-2002, Opsycon AB, Sweden.
>> console: Copyright 2005, ICT CAS.
>> console: CPU GODSON3 BogoMIPS: 1327
>> PASS (3.89 s)
>> RESULTS: PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | 
>> CANCEL 0
>> JOB TIME   : 4.38 s
>> 
>> Signed-off-by: Jiaxun Yang 
>> ---
>>  MAINTAINERS |  1 +
>>  tests/acceptance/machine_mips_loongson3v.py | 39 +
>>  2 files changed, 40 insertions(+)
>>  create mode 100644 tests/acceptance/machine_mips_loongson3v.py
>> 
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 4be087b88e..f38882f997 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -1164,6 +1164,7 @@ F: hw/intc/loongson_liointc.c
>>  F: hw/mips/loongson3_bootp.c
>>  F: hw/mips/loongson3_bootp.h
>>  F: hw/mips/loongson3_virt.c
>> +F: tests/acceptance/machine_mips_loongson3v.py
>>  
>>  Boston
>>  M: Paul Burton 
>> diff --git a/tests/acceptance/machine_mips_loongson3v.py 
>> b/tests/acceptance/machine_mips_loongson3v.py
>> new file mode 100644
>> index 00..17a85de69f
>> --- /dev/null
>> +++ b/tests/acceptance/machine_mips_loongson3v.py
>> @@ -0,0 +1,39 @@
>> +# Functional tests for the Generic Loongson-3 Platform.
>> +#
>> +# Copyright (c) 2020 Philippe Mathieu-Daudé 
>
> 2021 Jiaxun Yang ? :D
>
>> +#
>> +# This work is licensed under the terms of the GNU GPL, version 2 or later.
>> +# See the COPYING file in the top-level directory.
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +import os
>> +import time
>> +
>> +from avocado import skipUnless
>> +from avocado_qemu import Test
>> +from avocado_qemu import wait_for_console_pattern
>> +
>> +class MipsLoongson3v(Test):
>> +@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
>
> The source code is published [1], you provided reproducible
> workflow [2] and a tag [3] with a public build artifacts [4],
> so my understanding is this is "trustable" binary.
>
> Alex, would it be OK to add this test without the UNTRUSTED tag
> (amending the links in the commit description)?

It's a subjective call. Having open source code is a minimum step to
being "trusted" but really the trust is in the community that hosts the
code. The upstream distros (e.g. Debian/Fedora) are trusted because
people install their software on their desktops and basically give the
software publisher root on their machines. There has to be a level of
trust that the distros won't abuse that to steal information from their
users.

I personally have no idea about the loongson community because it's not
one I interact with so I have no idea what sort of place it is. Is it a
code dump for semi-proprietary non-upstreamed kernels or is it a place
that has a good development culture with a sane security process that is
responsive to problems and moderately conservative with what they merge?

If you would trust your keys to a machine running this communities
software then by all means treated it as a trusted source.

>
> [1] https://github.com/loongson-community/pmon/
> [2]
> https://github.com/loongson-community/pmon/blob/master/.github/workflows/compile.yml
> [3] https://github.com/loongson-community/pmon/releases/tag/20210112
> [4] https://github.com/loongson-community/pmon/actions/runs/479132723
>
>> +def test_pmon_serial_console(self):
>> +"""
>> +:avocado: tags=arch:mips64el
>> +:avocado: tags=endian:little
>> +:avocado: tags=machine:loongson3-virt
>> +:avocado: tags=cpu:Loongson-3A1000
>> +:avocado: tags=device:liointc
>> +:avocado: tags=device:goldfish_rtc
>> +"""
>> +
>> +pmon_hash = '7c8b45dd81ccfc55ff28f5aa267a41c3'
>> +pmon_path = 
>> self.fetch_asset('https://github.com/loongson-community/pmon/'
>> +
>> 'releases/download/20210112/pmon-3avirt.bin',
>> + asset_hash=pmon_hash, algorithm='md5')
>> +
>> +self.vm.set_console()
>> +self.vm.add_args('-bios', pmon_path)
>> +self.vm.launch()
>> +wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. 
>> Standby...')
>> +wait_for_console_pattern(self, 'Copy PMON to execute location 
>> done.')
>> +wait_for_console_pattern(self, 'CPU GODSON3 BogoMIPS:')
>> 


-- 
Alex Bennée



Re: [PULL 00/30] testing, gdbstub and semihosting

2021-01-18 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> Hi Alex,
>
> On 1/18/21 1:18 PM, Alex Bennée wrote:
>> 
>> Peter Maydell  writes:
>> 
>>> On Fri, 15 Jan 2021 at 13:08, Alex Bennée  wrote:
>>>>
>>>> The following changes since commit 
>>>> 7c79721606be11b5bc556449e5bcbc331ef6867d:
>>>>
>>>>   Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210113' 
>>>> into staging (2021-01-14 09:54:29 +)
>>>>
>>>> are available in the Git repository at:
>>>>
>>>>   https://github.com/stsquad/qemu.git tags/pull-testing-and-misc-150121-1
>>>>
>>>> for you to fetch changes up to be846761ca8b5a7e2e7b7108c8c156126b799824:
>>>>
>>>>   semihosting: Implement SYS_ISERROR (2021-01-15 11:12:34 +)
>>>>
>>>> 
>>>> Testing, gdbstub and semihosting patches:
>>>>
>>>>   - clean-ups to docker images
>>>>   - drop duplicate jobs from shippable
>>>>   - prettier tag generation (+gtags)
>>>>   - generate browsable source tree
>>>>   - more Travis->GitLab migrations
>>>>   - fix checkpatch to deal with commits
>>>>   - gate gdbstub tests on 8.3.1, expand tests
>>>>   - support Xfer:auxv:read gdb packet
>>>>   - better gdbstub cleanup
>>>>   - use GDB's SVE register layout
>>>>   - make arm-compat-semihosting common
>>>>   - add riscv semihosting support
>>>>   - add HEAPINFO, ELAPSED, TICKFREQ, TMPNAM and ISERROR to semihosting
>>>
>>> Fails to build, netbsd:
>>>
>>> ../src/gdbstub.c: In function 'handle_query_xfer_auxv':
>>> ../src/gdbstub.c:2258:26: error: 'struct image_info' has no member
>>> named 'saved_auxv'
>>>  saved_auxv = ts->info->saved_auxv;
>>>   ^~
>>> ../src/gdbstub.c:2259:24: error: 'struct image_info' has no member
>>> named 'auxv_len'
>>>  auxv_len = ts->info->auxv_len;
>> 
>> I've:
>> 
>> #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER)
>> 
>> around the code so it won't build for the *BSDs.
>
> CONFIG_LINUX_USER implies CONFIG_USER_ONLY, right?

Probably could in a clean-up patch.

>
> Maybe long-term this can become:
>
> #if defined(CONFIG_LINUX_USER)
> #elif defined(...BSD...)
> #endif

Well the failure is missing the data in our own structures. I don't know
if BSD does support auxv, I guess if it's a POSIX thing. I guess we'll
see when we get the BSD rewrite.

> (maybe worth to fix if the pullreq isn't processed,
> else not a big deal).

Already merged so ¯\_(ツ)_/¯...

-- 
Alex Bennée



Re: [PATCH v3] hw/core/qdev-properties-system: Rewrite set_pci_host_devaddr using GLib

2021-01-18 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> set_pci_host_devaddr() is hard to follow, thus bug-prone.
>
> For example, a bug was introduced in commit bccb20c49df, as
> the same line might be used to parse a bus (up to 0xff) or
> a slot (up to 0x1f).
>
> Instead of making things worst, rewrite using g_strsplit().

This no longer applies to my tip of tree but in general I'm a fan. Do we
have any unit tests for the qdev parsing? I couldn't see any but I'm not
sure if the generic QOM tests would exercise this code.

Generally when re-writing a parser it's nice to have a unit test just so
you can check you've covered all the corner cases (witness the number of
iterations the dfilter logic took to get right :-/).

>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> v3: Rebased
> v2: Free g_strsplit() with g_auto(GStrv) (Daniel)
> ---
>  hw/core/qdev-properties-system.c | 62 ++--
>  1 file changed, 27 insertions(+), 35 deletions(-)
>
> diff --git a/hw/core/qdev-properties-system.c 
> b/hw/core/qdev-properties-system.c
> index 9d80a07d26f..79408e32289 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -857,11 +857,11 @@ static void set_pci_host_devaddr(Object *obj, Visitor 
> *v, const char *name,
>  DeviceState *dev = DEVICE(obj);
>  Property *prop = opaque;
>  PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
> -char *str, *p;
> -char *e;
> +g_autofree char *str = NULL;
> +g_auto(GStrv) col_s0 = NULL;
> +g_auto(GStrv) dot_s = NULL;
> +char **col_s;
>  unsigned long val;
> -unsigned long dom = 0, bus = 0;
> -unsigned int slot = 0, func = 0;
>  
>  if (dev->realized) {
>  qdev_prop_set_after_realize(dev, name, errp);
> @@ -872,58 +872,50 @@ static void set_pci_host_devaddr(Object *obj, Visitor 
> *v, const char *name,
>  return;
>  }
>  
> -p = str;
> -val = strtoul(p, , 16);
> -if (e == p || *e != ':') {
> +col_s = col_s0 = g_strsplit(str, ":", 3);
> +if (!col_s || !col_s[0] || !col_s[1]) {

I'm not sure you want max_tokens 3 because 1:2:3:4 would end up with the
malformed ["1", "2", "3:4"]. You could just make your test:

  cols_s = g_strsplit(str, ":", -1);
  if (!cols_s || g_strv_length(cols_s) != 3) {
error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);  
return;
  }

>  goto inval;
>  }
> -bus = val;
>  
> -p = e + 1;
> -val = strtoul(p, , 16);
> -if (e == p) {
> -goto inval;
> -}
> -if (*e == ':') {
> -dom = bus;
> -bus = val;
> -p = e + 1;
> -val = strtoul(p, , 16);
> -if (e == p) {
> +/* domain */
> +if (col_s[2]) {
> +if (qemu_strtoul(col_s[0], NULL, 16, ) < 0 || val > 0x) {
>  goto inval;
>  }
> +addr->domain = val;
> +col_s++;
> +} else {
> +addr->domain = 0;
>  }
> -slot = val;

Hmm ok PCI ids are more complex than I knew. Maybe the test above needs
to be:

  cols_s = g_strsplit(str, ":", -1);
  cols_l = g_strv_length(cols_s);
  if (!cols_s || !(cols_l == 2 || cols_l ==3)) {
error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);  
return;
  }
  

>  
> -if (*e != '.') {
> +/* bus */
> +if (qemu_strtoul(col_s[0], NULL, 16, ) < 0 || val > 0xff) {
>  goto inval;
>  }
> -p = e + 1;
> -val = strtoul(p, , 10);
> -if (e == p) {
> -goto inval;
> -}
> -func = val;
> +addr->bus = val;
>  
> -if (dom > 0x || bus > 0xff || slot > 0x1f || func > 7) {
> +/* . */
> +dot_s = g_strsplit(col_s[1], ".", 2);
> +if (!dot_s || !dot_s[0] || !dot_s[1]) {
>  goto inval;
>  }

I think there is a similar length validation needed here.

>  
> -if (*e) {
> +/* slot */
> +if (qemu_strtoul(dot_s[0], NULL, 16, ) < 0 || val > 0x1f) {
>  goto inval;
>  }
> +addr->slot = val;
>  
> -addr->domain = dom;
> -addr->bus = bus;
> -addr->slot = slot;
> -addr->function = func;
> +/* func */
> +if (qemu_strtoul(dot_s[1], NULL, 10, ) < 0 || val > 7) {
> +goto inval;
> +}
> +addr->function = val;
>  
> -g_free(str);
>  return;
>  
>  inval:
>  error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
> -g_free(str);
>  }
>  
>  const PropertyInfo qdev_prop_pci_host_devaddr = {


-- 
Alex Bennée



Re: [PULL 00/30] testing, gdbstub and semihosting

2021-01-18 Thread Alex Bennée


Peter Maydell  writes:

> On Fri, 15 Jan 2021 at 13:08, Alex Bennée  wrote:
>>
>> The following changes since commit 7c79721606be11b5bc556449e5bcbc331ef6867d:
>>
>>   Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210113' 
>> into staging (2021-01-14 09:54:29 +)
>>
>> are available in the Git repository at:
>>
>>   https://github.com/stsquad/qemu.git tags/pull-testing-and-misc-150121-1
>>
>> for you to fetch changes up to be846761ca8b5a7e2e7b7108c8c156126b799824:
>>
>>   semihosting: Implement SYS_ISERROR (2021-01-15 11:12:34 +)
>>
>> 
>> Testing, gdbstub and semihosting patches:
>>
>>   - clean-ups to docker images
>>   - drop duplicate jobs from shippable
>>   - prettier tag generation (+gtags)
>>   - generate browsable source tree
>>   - more Travis->GitLab migrations
>>   - fix checkpatch to deal with commits
>>   - gate gdbstub tests on 8.3.1, expand tests
>>   - support Xfer:auxv:read gdb packet
>>   - better gdbstub cleanup
>>   - use GDB's SVE register layout
>>   - make arm-compat-semihosting common
>>   - add riscv semihosting support
>>   - add HEAPINFO, ELAPSED, TICKFREQ, TMPNAM and ISERROR to semihosting
>
> Fails to build, netbsd:
>
> ../src/gdbstub.c: In function 'handle_query_xfer_auxv':
> ../src/gdbstub.c:2258:26: error: 'struct image_info' has no member
> named 'saved_auxv'
>  saved_auxv = ts->info->saved_auxv;
>   ^~
> ../src/gdbstub.c:2259:24: error: 'struct image_info' has no member
> named 'auxv_len'
>  auxv_len = ts->info->auxv_len;

I've:

#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER)

around the code so it won't build for the *BSDs.

Sent v2

> ^~
>
> thanks
> -- PMM


-- 
Alex Bennée



[PULL v2 00/30] testing, gdbstub and semihosting

2021-01-18 Thread Alex Bennée
The following changes since commit 825a215c003cd028e26c7d19aa5049d957345f43:

  Merge remote-tracking branch 
'remotes/kraxel/tags/audio-20210115-pull-request' into staging (2021-01-15 
22:21:21 +)

are available in the Git repository at:

  https://github.com/stsquad/qemu.git tags/pull-testing-and-misc-180121-2

for you to fetch changes up to 767ba049b8f8f8ebfebe90ecaf1b5a9cf8c865ff:

  semihosting: Implement SYS_ISERROR (2021-01-18 10:05:06 +)


Testing, gdbstub and semihosting patches:

  - clean-ups to docker images
  - drop duplicate jobs from shippable
  - prettier tag generation (+gtags)
  - generate browsable source tree
  - more Travis->GitLab migrations
  - fix checkpatch to deal with commits
  - gate gdbstub tests on 8.3.1, expand tests
  - support Xfer:auxv:read gdb packet
  - better gdbstub cleanup
  - use GDB's SVE register layout
  - make arm-compat-semihosting common
  - add riscv semihosting support
  - add HEAPINFO, ELAPSED, TICKFREQ, TMPNAM and ISERROR to semihosting


Alessandro Di Federico (1):
  Add newline when generating Dockerfile

Alex Bennée (16):
  Makefile: add GNU global tags support
  Makefile: wrap ctags in quiet-command calls
  Makefile: wrap etags in quiet-command calls
  Makefile: wrap cscope in quiet-command calls
  docker: expand debian-amd64 image to include tag tools
  gitlab: move docs and tools build across from Travis
  gitlab: migrate the minimal tools and unit tests from Travis
  scripts/checkpatch.pl: fix git-show invocation to include diffstat
  test/guest-debug: echo QEMU command as well
  configure: gate our use of GDB to 8.3.1 or above
  Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1 
test"
  gdbstub: implement a softmmu based test
  gdbstub: drop CPUEnv from gdb_exit()
  gdbstub: drop gdbserver_cleanup in favour of gdb_exit
  gdbstub: ensure we clean-up when terminated
  target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

Keith Packard (8):
  semihosting: Move ARM semihosting code to shared directories
  semihosting: Change common-semi API to be architecture-independent
  semihosting: Change internal common-semi interfaces to use CPUState *
  semihosting: Support SYS_HEAPINFO when env->boot_info is not set
  riscv: Add semihosting support
  semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ
  semihosting: Implement SYS_TMPNAM
  semihosting: Implement SYS_ISERROR

Kito Cheng (1):
  riscv: Add semihosting support for user mode

Lirong Yuan (1):
  gdbstub: add support to Xfer:auxv:read: packet

Lukas Straub (1):
  Fix build with new yank feature by adding stubs

Philippe Mathieu-Daudé (2):
  tests/docker: Remove Debian 9 remnant lines
  shippable.yml: Remove jobs duplicated on Gitlab-CI

 configure  |   7 +-
 Makefile   |  46 +-
 default-configs/devices/arm-softmmu.mak|   1 +
 default-configs/devices/riscv32-softmmu.mak|   2 +
 default-configs/devices/riscv64-softmmu.mak|   2 +
 default-configs/targets/aarch64-linux-user.mak |   1 +
 default-configs/targets/aarch64_be-linux-user.mak  |   1 +
 default-configs/targets/arm-linux-user.mak |   1 +
 default-configs/targets/armeb-linux-user.mak   |   1 +
 default-configs/targets/riscv32-linux-user.mak |   1 +
 default-configs/targets/riscv64-linux-user.mak |   1 +
 hw/semihosting/common-semi.h   |  39 ++
 include/exec/gdbstub.h |  14 +-
 include/qemu/timer.h   |   2 +
 linux-user/qemu.h  |   4 +-
 target/arm/cpu.h   |   8 -
 target/riscv/cpu_bits.h|   1 +
 bsd-user/syscall.c |   6 +-
 gdbstub.c  |  65 ++-
 .../arm-semi.c => hw/semihosting/arm-compat-semi.c | 525 ++---
 linux-user/aarch64/cpu_loop.c  |   3 +-
 linux-user/arm/cpu_loop.c  |   3 +-
 linux-user/exit.c  |   2 +-
 linux-user/riscv/cpu_loop.c|   5 +
 linux-user/{arm => }/semihost.c|   8 +-
 softmmu/runstate.c |   2 +-
 stubs/yank.c   |  29 ++
 target/arm/gdbstub.c   |  75 ++-
 target/arm/helper.c|   7 +-
 target/arm/m_helper.c  |   7 +-
 target/m68k/m68k-semi.c|   2 +-
 target/nios2/nios2-semi.c  |   2 +-
 target/riscv/cpu_helper.c 

[PULL 24/30] semihosting: Change internal common-semi interfaces to use CPUState *

2021-01-15 Thread Alex Bennée
From: Keith Packard 

This makes all of the internal interfaces architecture-independent and
renames the internal functions to use the 'common_semi' prefix instead
of 'arm' or 'arm_semi'.

To do this, some new architecture-specific internal helper functions
were created:

static inline target_ulong
common_semi_arg(CPUState *cs, int argno)

Returns the argno'th semihosting argument, where argno can be
either 0 or 1.

static inline void
common_semi_set_ret(CPUState *cs, target_ulong ret)

Sets the semihosting return value.

static inline bool
common_semi_sys_exit_extended(CPUState *cs, int nr)

This detects whether the specified semihosting call, which
is either TARGET_SYS_EXIT or TARGET_SYS_EXIT_EXTENDED should
be executed using the TARGET_SYS_EXIT_EXTENDED semantics.

static inline target_ulong
common_semi_rambase(CPUState *cs)

Returns the base of RAM region used for heap and stack. This
is used to construct plausible values for the SYS_HEAPINFO
call.

In addition, several existing functions have been changed to flag
areas of code which are architecture specific:

static target_ulong
common_semi_flen_buf(CPUState *cs)

Returns the current stack pointer minus 64, which is
where a stat structure will be placed on the stack

#define GET_ARG(n)

This fetches arguments from the semihosting command's argument
block. The address of this is available implicitly through the
local 'args' variable. This is *mostly* architecture
independent, but does depend on the current ABI's notion of
the size of a 'long' parameter, which may need run-time checks
(as it does on AARCH64)

#define SET_ARG(n, val)

This mirrors GET_ARG and stores data back into the argument
block.

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Reviewed-by: Alistair Francis 
Message-Id: <20210107170717.2098982-4-kei...@keithp.com>
Message-Id: <20210108224256.2321-15-alex.ben...@linaro.org>

diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index 2e959aba08..ac1271545e 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -32,15 +32,18 @@
 #include "cpu.h"
 #include "hw/semihosting/semihost.h"
 #include "hw/semihosting/console.h"
+#include "hw/semihosting/common-semi.h"
 #include "qemu/log.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
-#define ARM_ANGEL_HEAP_SIZE (128 * 1024 * 1024)
+#define COMMON_SEMI_HEAP_SIZE (128 * 1024 * 1024)
 #else
 #include "exec/gdbstub.h"
 #include "qemu/cutils.h"
+#ifdef TARGET_ARM
 #include "hw/arm/boot.h"
+#endif
 #include "hw/boards.h"
 #endif
 
@@ -134,6 +137,50 @@ typedef struct GuestFD {
 
 static GArray *guestfd_array;
 
+#ifdef TARGET_ARM
+static inline target_ulong
+common_semi_arg(CPUState *cs, int argno)
+{
+ARMCPU *cpu = ARM_CPU(cs);
+CPUARMState *env = >env;
+if (is_a64(env)) {
+return env->xregs[argno];
+} else {
+return env->regs[argno];
+}
+}
+
+static inline void
+common_semi_set_ret(CPUState *cs, target_ulong ret)
+{
+ARMCPU *cpu = ARM_CPU(cs);
+CPUARMState *env = >env;
+if (is_a64(env)) {
+env->xregs[0] = ret;
+} else {
+env->regs[0] = ret;
+}
+}
+
+static inline bool
+common_semi_sys_exit_extended(CPUState *cs, int nr)
+{
+return (nr == TARGET_SYS_EXIT_EXTENDED || is_a64(cs->env_ptr));
+}
+
+#ifndef CONFIG_USER_ONLY
+#include "hw/arm/boot.h"
+static inline target_ulong
+common_semi_rambase(CPUState *cs)
+{
+CPUArchState *env = cs->env_ptr;
+const struct arm_boot_info *info = env->boot_info;
+return info->loader_start;
+}
+#endif
+
+#endif /* TARGET_ARM */
+
 /*
  * Allocate a new guest file descriptor and return it; if we
  * couldn't allocate a new fd then return -1.
@@ -239,11 +286,10 @@ static target_ulong syscall_err;
 #include "exec/softmmu-semi.h"
 #endif
 
-static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code)
+static inline uint32_t set_swi_errno(CPUState *cs, uint32_t code)
 {
 if (code == (uint32_t)-1) {
 #ifdef CONFIG_USER_ONLY
-CPUState *cs = env_cpu(env);
 TaskState *ts = cs->opaque;
 
 ts->swi_errno = errno;
@@ -254,10 +300,9 @@ static inline uint32_t set_swi_errno(CPUARMState *env, 
uint32_t code)
 return code;
 }
 
-static inline uint32_t get_swi_errno(CPUARMState *env)
+static inline uint32_t get_swi_errno(CPUState *cs)
 {
 #ifdef CONFIG_USER_ONLY
-CPUState *cs = env_cpu(env);
 TaskState *ts = cs->opaque;
 
 return ts->swi_errno;
@@ -266,24 +311,22 @@ static inline uint32_t get_swi_errno(CPUARMState *env)
 #endif
 }
 
-static target_ulong arm_semi_syscall_len;
+static target_ulong comm

[PULL 12/30] scripts/checkpatch.pl: fix git-show invocation to include diffstat

2021-01-15 Thread Alex Bennée
Without this checkpatch keeps complaining about new/changed files even
when MAINTAINERS has been updated. Normal invocations of checkpatch on
patch files rather than commit IDs are unaffected.

Signed-off-by: Alex Bennée 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-13-alex.ben...@linaro.org>

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88c858f67c..e47ad878d8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -399,7 +399,7 @@ if ($chk_branch) {
my $num_patches = @patches;
for my $hash (@patches) {
my $FILE;
-   open($FILE, '-|', "git", "show", $hash) ||
+   open($FILE, '-|', "git", "show", "--patch-with-stat", $hash) ||
die "$P: git show $hash - $!\n";
while (<$FILE>) {
chomp;
-- 
2.20.1




[PULL 23/30] semihosting: Change common-semi API to be architecture-independent

2021-01-15 Thread Alex Bennée
From: Keith Packard 

The public API is now defined in
hw/semihosting/common-semi.h. do_common_semihosting takes CPUState *
instead of CPUARMState *. All internal functions have been renamed
common_semi_ instead of arm_semi_ or arm_. Aside from the API change,
there are no functional changes in this patch.

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Reviewed-by: Alistair Francis 
Message-Id: <20210107170717.2098982-3-kei...@keithp.com>
Message-Id: <20210108224256.2321-14-alex.ben...@linaro.org>

diff --git a/hw/semihosting/common-semi.h b/hw/semihosting/common-semi.h
new file mode 100644
index 00..bc53e92c79
--- /dev/null
+++ b/hw/semihosting/common-semi.h
@@ -0,0 +1,36 @@
+/*
+ *  Semihosting support for systems modeled on the Arm "Angel"
+ *  semihosting syscalls design.
+ *
+ *  Copyright (c) 2005, 2007 CodeSourcery.
+ *  Copyright (c) 2019 Linaro
+ *  Written by Paul Brook.
+ *
+ *  Copyright © 2020 by Keith Packard 
+ *  Adapted for systems other than ARM, including RISC-V, by Keith Packard
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  ARM Semihosting is documented in:
+ * Semihosting for AArch32 and AArch64 Release 2.0
+ * https://static.docs.arm.com/100863/0200/semihosting.pdf
+ *
+ */
+
+#ifndef COMMON_SEMI_H
+#define COMMON_SEMI_H
+
+target_ulong do_common_semihosting(CPUState *cs);
+
+#endif /* COMMON_SEMI_H */
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index f3bca73d98..84cc2de3b1 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1068,14 +1068,6 @@ static inline void aarch64_sve_change_el(CPUARMState 
*env, int o,
 static inline void aarch64_add_sve_properties(Object *obj) { }
 #endif
 
-#if !defined(CONFIG_TCG)
-static inline target_ulong do_arm_semihosting(CPUARMState *env)
-{
-g_assert_not_reached();
-}
-#else
-target_ulong do_arm_semihosting(CPUARMState *env);
-#endif
 void aarch64_sync_32_to_64(CPUARMState *env);
 void aarch64_sync_64_to_32(CPUARMState *env);
 
diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index 93360e28c7..2e959aba08 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -1,10 +1,14 @@
 /*
- *  Arm "Angel" semihosting syscalls
+ *  Semihosting support for systems modeled on the Arm "Angel"
+ *  semihosting syscalls design.
  *
  *  Copyright (c) 2005, 2007 CodeSourcery.
  *  Copyright (c) 2019 Linaro
  *  Written by Paul Brook.
  *
+ *  Copyright © 2020 by Keith Packard 
+ *  Adapted for systems other than ARM, including RISC-V, by Keith Packard
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -373,12 +377,12 @@ static target_ulong arm_gdb_syscall(ARMCPU *cpu, 
gdb_syscall_complete_cb cb,
  * do anything with its return value, because it is not necessarily
  * the result of the syscall, but could just be the old value of X0.
  * The only thing safe to do with this is that the callers of
- * do_arm_semihosting() will write it straight back into X0.
+ * do_common_semihosting() will write it straight back into X0.
  * (In linux-user mode, the callback will have happened before
  * gdb_do_syscallv() returns.)
  *
  * We should tidy this up so neither this function nor
- * do_arm_semihosting() return a value, so the mistake of
+ * do_common_semihosting() return a value, so the mistake of
  * doing something with the return value is not possible to make.
  */
 
@@ -675,10 +679,10 @@ static const GuestFDFunctions guestfd_fns[] = {
  * leave the register unchanged. We use 0xdeadbeef as the return value
  * when there isn't a defined return value for the call.
  */
-target_ulong do_arm_semihosting(CPUARMState *env)
+target_ulong do_common_semihosting(CPUState *cs)
 {
-ARMCPU *cpu = env_archcpu(env);
-CPUState *cs = env_cpu(env);
+ARMCPU *cpu = ARM_CPU(cs);
+CPUARMState *env = >env;
 target_ulong args;
 target_ulong arg0, arg1, arg2, arg3;
 char * s;
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index bbe9fefca8..42b9c15f53 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -22,6 +22,7

[PULL 09/30] gitlab: move docs and tools build across from Travis

2021-01-15 Thread Alex Bennée
While we are at it we might as well check the tag generation. For
bonus points we run GNU globals htags into the public pages directory
for publishing with the auto generated pages.

Signed-off-by: Alex Bennée 
Reviewed-by: Wainer dos Santos Moschetta 
Reviewed-by: Willian Rampazzo 
Acked-by: Thomas Huth 
Message-Id: <20210114165730.31607-10-alex.ben...@linaro.org>

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4532f1718a..bd60f3e741 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,7 +79,6 @@ build-system-ubuntu:
 TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
   moxie-softmmu microblazeel-softmmu mips64el-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -111,7 +110,6 @@ build-system-debian:
 TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
   riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -126,6 +124,17 @@ check-system-debian:
 IMAGE: debian-amd64
 MAKE_CHECK_ARGS: check
 
+build-tools-and-docs-debian:
+  <<: *native_build_job_definition
+  variables:
+IMAGE: debian-amd64
+MAKE_CHECK_ARGS: ctags TAGS cscope
+CONFIGURE_ARGS: --disable-system --disable-user --enable-docs 
--enable-tools
+  artifacts:
+expire_in: 2 days
+paths:
+  - build
+
 acceptance-system-debian:
   <<: *native_test_job_definition
   needs:
@@ -596,14 +605,21 @@ build-libvhost-user:
 - meson
 - ninja
 
+# Prepare for GitLab pages deployment. Anything copied into the
+# "public" directory will be deployed to $USER.gitlab.io/$PROJECT
 pages:
-  image: $CI_REGISTRY_IMAGE/qemu/ubuntu2004:latest
+  image: $CI_REGISTRY_IMAGE/qemu/debian-amd64:latest
   stage: test
   needs:
-- job: build-system-ubuntu
-  artifacts: true
+- job: build-tools-and-docs-debian
   script:
-- mkdir public
+- mkdir -p public
+# HTML-ised source tree
+- make gtags
+- htags -anT --tree-view=filetree -m qemu_init
+-t "Welcome to the QEMU sourcecode"
+- mv HTML public/src
+# Project documentation
 - mv build/docs/index.html public/
 - for i in devel interop specs system tools user ; do mv build/docs/$i 
public/ ; done
   artifacts:
diff --git a/.travis.yml b/.travis.yml
index f2a101936c..3b574a5968 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -148,22 +148,6 @@ jobs:
 - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
 
 
-# Check we can build docs and tools (out of tree)
-- name: "tools and docs (bionic)"
-  dist: bionic
-  env:
-- BUILD_DIR="out-of-tree/build/dir" SRC_DIR="../../.."
-- BASE_CONFIG="--enable-tools --enable-docs"
-- CONFIG="--target-list=x86_64-softmmu,aarch64-linux-user"
-- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
-  addons:
-apt:
-  packages:
-- ninja-build
-- python3-sphinx
-- perl
-
-
 # Test with Clang for compile portability (Travis uses clang-5.0)
 - name: "Clang (user)"
   env:
-- 
2.20.1




[PULL 15/30] Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1 test"

2021-01-15 Thread Alex Bennée
We won't attempt to run the test now it's gated on a newer version of
gdb.

This reverts commit a930cadd83b4681a98ce72abf530a791ee2e42a6.

Signed-off-by: Alex Bennée 
Message-Id: <20210108224256.2321-5-alex.ben...@linaro.org>

diff --git a/tests/tcg/multiarch/Makefile.target 
b/tests/tcg/multiarch/Makefile.target
index 230eb9a95e..cb49cc9ccb 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -54,9 +54,7 @@ run-gdbstub-sha1: sha1
--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
"basic gdbstub support")
 
-# Disable this for now -- it provokes a gdb internal-error on
-# Ubuntu gdb 8.1.1-0ubuntu1.
-# EXTRA_RUNS += run-gdbstub-sha1
+EXTRA_RUNS += run-gdbstub-sha1
 endif
 
 
-- 
2.20.1




[PULL 20/30] gdbstub: ensure we clean-up when terminated

2021-01-15 Thread Alex Bennée
If you kill the inferior from GDB we end up leaving our socket lying
around. Fix this by calling gdb_exit() first.

Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210108224256.2321-10-alex.ben...@linaro.org>

diff --git a/gdbstub.c b/gdbstub.c
index bab8476357..8c301edf32 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1978,6 +1978,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void 
*user_ctx)
 /* Kill the target */
 put_packet("OK");
 error_report("QEMU: Terminated via GDBstub");
+gdb_exit(0);
 exit(0);
 }
 
@@ -2539,6 +2540,7 @@ static int gdb_handle_packet(const char *line_buf)
 case 'k':
 /* Kill the target */
 error_report("QEMU: Terminated via GDBstub");
+gdb_exit(0);
 exit(0);
 case 'D':
 {
-- 
2.20.1




[PULL 27/30] riscv: Add semihosting support for user mode

2021-01-15 Thread Alex Bennée
From: Kito Cheng 

This could made testing more easier and ARM/AArch64 has supported on
their linux user mode too, so I think it should be reasonable.

Verified GCC testsuite with newlib/semihosting.

Signed-off-by: Kito Cheng 
Signed-off-by: Alex Bennée 
Reviewed-by: Keith Packard 
Reviewed-by: Alistair Francis 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210107170717.2098982-7-kei...@keithp.com>
Message-Id: <20210108224256.2321-18-alex.ben...@linaro.org>

diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
index aa9e437875..9665dabb09 100644
--- a/linux-user/riscv/cpu_loop.c
+++ b/linux-user/riscv/cpu_loop.c
@@ -23,6 +23,7 @@
 #include "qemu.h"
 #include "cpu_loop-common.h"
 #include "elf.h"
+#include "hw/semihosting/common-semi.h"
 
 void cpu_loop(CPURISCVState *env)
 {
@@ -91,6 +92,10 @@ void cpu_loop(CPURISCVState *env)
 sigcode = TARGET_SEGV_MAPERR;
 sigaddr = env->badaddr;
 break;
+case RISCV_EXCP_SEMIHOST:
+env->gpr[xA0] = do_common_semihosting(cs);
+env->pc += 4;
+break;
 case EXCP_DEBUG:
 gdbstep:
 signum = TARGET_SIGTRAP;
-- 
2.20.1




[PULL 26/30] riscv: Add semihosting support

2021-01-15 Thread Alex Bennée
From: Keith Packard 

Adapt the arm semihosting support code for RISCV. This implementation
is based on the standard for RISC-V semihosting version 0.2 as
documented in

   https://github.com/riscv/riscv-semihosting-spec/releases/tag/0.2

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Reviewed-by: Alistair Francis 
Message-Id: <20210107170717.2098982-6-kei...@keithp.com>
Message-Id: <20210108224256.2321-17-alex.ben...@linaro.org>

diff --git a/default-configs/devices/riscv32-softmmu.mak 
b/default-configs/devices/riscv32-softmmu.mak
index 94a236c9c2..d847bd5692 100644
--- a/default-configs/devices/riscv32-softmmu.mak
+++ b/default-configs/devices/riscv32-softmmu.mak
@@ -3,6 +3,8 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
+CONFIG_SEMIHOSTING=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/default-configs/devices/riscv64-softmmu.mak 
b/default-configs/devices/riscv64-softmmu.mak
index 76b6195648..d5eec75f05 100644
--- a/default-configs/devices/riscv64-softmmu.mak
+++ b/default-configs/devices/riscv64-softmmu.mak
@@ -3,6 +3,8 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
+CONFIG_SEMIHOSTING=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/default-configs/targets/riscv32-linux-user.mak 
b/default-configs/targets/riscv32-linux-user.mak
index dfb259e8aa..6a9d1b1bc1 100644
--- a/default-configs/targets/riscv32-linux-user.mak
+++ b/default-configs/targets/riscv32-linux-user.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=riscv32
 TARGET_BASE_ARCH=riscv
 TARGET_ABI_DIR=riscv
 TARGET_XML_FILES= gdb-xml/riscv-32bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml 
gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-32bit-csr.xml 
gdb-xml/riscv-32bit-virtual.xml
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/default-configs/targets/riscv64-linux-user.mak 
b/default-configs/targets/riscv64-linux-user.mak
index b13895f3b0..0a92849a1b 100644
--- a/default-configs/targets/riscv64-linux-user.mak
+++ b/default-configs/targets/riscv64-linux-user.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=riscv64
 TARGET_BASE_ARCH=riscv
 TARGET_ABI_DIR=riscv
 TARGET_XML_FILES= gdb-xml/riscv-64bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml 
gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-64bit-csr.xml 
gdb-xml/riscv-64bit-virtual.xml
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/hw/semihosting/common-semi.h b/hw/semihosting/common-semi.h
index bc53e92c79..0bfab1c669 100644
--- a/hw/semihosting/common-semi.h
+++ b/hw/semihosting/common-semi.h
@@ -1,6 +1,6 @@
 /*
  *  Semihosting support for systems modeled on the Arm "Angel"
- *  semihosting syscalls design.
+ *  semihosting syscalls design. This includes Arm and RISC-V processors
  *
  *  Copyright (c) 2005, 2007 CodeSourcery.
  *  Copyright (c) 2019 Linaro
@@ -26,6 +26,9 @@
  * Semihosting for AArch32 and AArch64 Release 2.0
  * https://static.docs.arm.com/100863/0200/semihosting.pdf
  *
+ *  RISC-V Semihosting is documented in:
+ * RISC-V Semihosting
+ * 
https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc
  */
 
 #ifndef COMMON_SEMI_H
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 534753ca12..17aa992165 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -109,6 +109,8 @@ typedef struct TaskState {
 /* FPA state */
 FPA11 fpa;
 # endif
+#endif
+#if defined(TARGET_ARM) || defined(TARGET_RISCV)
 int swi_errno;
 #endif
 #if defined(TARGET_I386) && !defined(TARGET_X86_64)
@@ -122,7 +124,7 @@ typedef struct TaskState {
 #ifdef TARGET_M68K
 abi_ulong tp_value;
 #endif
-#if defined(TARGET_ARM) || defined(TARGET_M68K)
+#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_RISCV)
 /* Extra fields for semihosted binaries.  */
 abi_ulong heap_base;
 abi_ulong heap_limit;
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
index b41e8836c3..4196ef8b69 100644
--- a/target/riscv/cpu_bits.h
+++ b/target/riscv/cpu_bits.h
@@ -542,6 +542,7 @@
 #define RISCV_EXCP_INST_PAGE_FAULT   0xc /* since: priv-1.10.0 */
 #define RISCV_EXCP_LOAD_PAGE_FAULT   0xd /* since: priv-1.10.0 */
 #define RISCV_EXCP_STORE_PAGE_FAULT  0xf /* since: priv-1.10.0 */
+#define RISCV_EXCP_SEMIHOST  0x10
 #define RISCV_EXCP_INST_GUEST_PAGE_FAULT 0x14
 #define RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT   0x15
 #define RISCV_EXCP_VIRT_INSTRUCTION_FAULT0x16
diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index 293791f721..5fcb8663c6 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -1,6 +1,6 @@
 /*
  *  Semihosting support for systems modeled on the Arm "Angel"
- *  semihosting syscalls design.
+ *  semihosting syscalls design. This includes Arm and RISC-V processors
  *
  *  Copyright (c) 2005, 2007 CodeSourcery.
  *  Copyright (c) 2019 Linaro

[PULL 10/30] Fix build with new yank feature by adding stubs

2021-01-15 Thread Alex Bennée
From: Lukas Straub 

Fixes: 50186051f42 ("Introduce yank feature")
Signed-off-by: Lukas Straub 
[AJB: tweak MAINTAINERS]
Signed-off-by: Alex Bennée 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114141918.5201c...@gecko.fritz.box>
Message-Id: <20210114165730.31607-11-alex.ben...@linaro.org>

diff --git a/stubs/yank.c b/stubs/yank.c
new file mode 100644
index 00..6090416065
--- /dev/null
+++ b/stubs/yank.c
@@ -0,0 +1,29 @@
+#include "qemu/osdep.h"
+#include "qemu/yank.h"
+
+bool yank_register_instance(const YankInstance *instance, Error **errp)
+{
+return true;
+}
+
+void yank_unregister_instance(const YankInstance *instance)
+{
+}
+
+void yank_register_function(const YankInstance *instance,
+YankFn *func,
+void *opaque)
+{
+}
+
+void yank_unregister_function(const YankInstance *instance,
+  YankFn *func,
+  void *opaque)
+{
+}
+
+void yank_generic_iochannel(void *opaque)
+{
+}
+
+
diff --git a/MAINTAINERS b/MAINTAINERS
index cb0656aec3..07e4851aa4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2736,6 +2736,7 @@ Yank feature
 M: Lukas Straub 
 S: Odd fixes
 F: util/yank.c
+F: stubs/yank.c
 F: include/qemu/yank.h
 F: qapi/yank.json
 
diff --git a/stubs/meson.build b/stubs/meson.build
index 80b1d81a31..1a656cd070 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -47,6 +47,7 @@ stub_ss.add(files('vm-stop.c'))
 stub_ss.add(files('win32-kbd-hook.c'))
 stub_ss.add(files('cpu-synchronize-state.c'))
 if have_block
+  stub_ss.add(files('yank.c'))
   stub_ss.add(files('replay-tools.c'))
 endif
 if have_system
-- 
2.20.1




[PULL 22/30] semihosting: Move ARM semihosting code to shared directories

2021-01-15 Thread Alex Bennée
From: Keith Packard 

This commit renames two files which provide ARM semihosting support so
that they can be shared by other architectures:

 1. target/arm/arm-semi.c -> hw/semihosting/common-semi.c
 2. linux-user/arm/semihost.c -> linux-user/semihost.c

The build system was modified use a new config variable,
CONFIG_ARM_COMPATIBLE_SEMIHOSTING, which has been added to the ARM
softmmu and linux-user default configs. The contents of the source
files has not been changed in this patch.

Signed-off-by: Keith Packard 
[AJB: rename arm-compat-semi, select SEMIHOSTING]
Signed-off-by: Alex Bennée 
Reviewed-by: Alistair Francis 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210107170717.2098982-2-kei...@keithp.com>
Message-Id: <20210108224256.2321-13-alex.ben...@linaro.org>

diff --git a/default-configs/devices/arm-softmmu.mak 
b/default-configs/devices/arm-softmmu.mak
index 08a32123b4..0500156a0c 100644
--- a/default-configs/devices/arm-softmmu.mak
+++ b/default-configs/devices/arm-softmmu.mak
@@ -42,4 +42,5 @@ CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
 CONFIG_SEMIHOSTING=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 CONFIG_ALLWINNER_H3=y
diff --git a/default-configs/targets/aarch64-linux-user.mak 
b/default-configs/targets/aarch64-linux-user.mak
index 163c9209f4..4713253709 100644
--- a/default-configs/targets/aarch64-linux-user.mak
+++ b/default-configs/targets/aarch64-linux-user.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=aarch64
 TARGET_BASE_ARCH=arm
 TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml 
gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml 
gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml
 TARGET_HAS_BFLT=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/default-configs/targets/aarch64_be-linux-user.mak 
b/default-configs/targets/aarch64_be-linux-user.mak
index 4c953cf8c5..fae831558d 100644
--- a/default-configs/targets/aarch64_be-linux-user.mak
+++ b/default-configs/targets/aarch64_be-linux-user.mak
@@ -3,3 +3,4 @@ TARGET_BASE_ARCH=arm
 TARGET_WORDS_BIGENDIAN=y
 TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml 
gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml 
gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml
 TARGET_HAS_BFLT=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/default-configs/targets/arm-linux-user.mak 
b/default-configs/targets/arm-linux-user.mak
index c7cd872e86..e741ffd4d3 100644
--- a/default-configs/targets/arm-linux-user.mak
+++ b/default-configs/targets/arm-linux-user.mak
@@ -3,3 +3,4 @@ TARGET_SYSTBL_ABI=common,oabi
 TARGET_SYSTBL=syscall.tbl
 TARGET_XML_FILES= gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml 
gdb-xml/arm-vfp3.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml
 TARGET_HAS_BFLT=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/default-configs/targets/armeb-linux-user.mak 
b/default-configs/targets/armeb-linux-user.mak
index 79bf10e99b..255e44e8b0 100644
--- a/default-configs/targets/armeb-linux-user.mak
+++ b/default-configs/targets/armeb-linux-user.mak
@@ -4,3 +4,4 @@ TARGET_SYSTBL=syscall.tbl
 TARGET_WORDS_BIGENDIAN=y
 TARGET_XML_FILES= gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml 
gdb-xml/arm-vfp3.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml
 TARGET_HAS_BFLT=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/target/arm/arm-semi.c b/hw/semihosting/arm-compat-semi.c
similarity index 100%
rename from target/arm/arm-semi.c
rename to hw/semihosting/arm-compat-semi.c
diff --git a/linux-user/arm/semihost.c b/linux-user/semihost.c
similarity index 100%
rename from linux-user/arm/semihost.c
rename to linux-user/semihost.c
diff --git a/hw/semihosting/Kconfig b/hw/semihosting/Kconfig
index efe0a30734..eaf3a20ef5 100644
--- a/hw/semihosting/Kconfig
+++ b/hw/semihosting/Kconfig
@@ -1,3 +1,7 @@
 
 config SEMIHOSTING
bool
+
+config ARM_COMPATIBLE_SEMIHOSTING
+   bool
+   select SEMIHOSTING
diff --git a/hw/semihosting/meson.build b/hw/semihosting/meson.build
index f40ac574c4..ea8090abe3 100644
--- a/hw/semihosting/meson.build
+++ b/hw/semihosting/meson.build
@@ -2,3 +2,6 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
   'config.c',
   'console.c',
 ))
+
+specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],
+   if_true: files('arm-compat-semi.c'))
diff --git a/linux-user/arm/meson.build b/linux-user/arm/meson.build
index 432984b58e..5a93c925cf 100644
--- a/linux-user/arm/meson.build
+++ b/linux-user/arm/meson.build
@@ -1,6 +1,3 @@
-linux_user_ss.add(when: 'TARGET_AARCH64', if_true: files('semihost.c'))
-linux_user_ss.add(when: 'TARGET_ARM', if_true: files('semihost.c'))
-
 subdir('nwfpe')
 
 syscall_nr_generators += {
diff --git a/linux-user/meson.build b/linux-user/meson.build
index 2b94e4ba24..7fe28d659e 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -16,6 +16,7 @@ linux_user_ss.add(rt)
 
 linux_user_ss.add(when: 'TARGET_HAS_BFLT', if_true: files('flatload.c'))
 linux_user_ss.add(when: 'TARGET_I386', if_t

[PULL 08/30] docker: expand debian-amd64 image to include tag tools

2021-01-15 Thread Alex Bennée
This is going to be helpful when we want to both test the tool
integration and in the case of global generate a xref doc build.

Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-9-alex.ben...@linaro.org>

diff --git a/tests/docker/dockerfiles/debian-amd64.docker 
b/tests/docker/dockerfiles/debian-amd64.docker
index 55075d9fce..a98314757d 100644
--- a/tests/docker/dockerfiles/debian-amd64.docker
+++ b/tests/docker/dockerfiles/debian-amd64.docker
@@ -1,7 +1,7 @@
 #
 # Docker x86_64 target
 #
-# This docker target builds on the debian Stretch base image. Further
+# This docker target builds on the Debian Buster base image. Further
 # libraries which are not widely available are installed by hand.
 #
 FROM qemu/debian10
@@ -14,7 +14,10 @@ RUN apt update && \
 RUN apt update && \
 DEBIAN_FRONTEND=noninteractive eatmydata \
 apt install -y --no-install-recommends \
+cscope \
 genisoimage \
+exuberant-ctags \
+global \
 libbz2-dev \
 liblzo2-dev \
 libgcrypt20-dev \
-- 
2.20.1




[PULL 11/30] gitlab: migrate the minimal tools and unit tests from Travis

2021-01-15 Thread Alex Bennée
These tests are good at shaking out missing stubs which otherwise work
if we have built targets. Rather than create a new job just add the
checks to the existing tools-and-docs build.

Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Thomas Huth 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-12-alex.ben...@linaro.org>

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bd60f3e741..fd0162ad29 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -124,11 +124,13 @@ check-system-debian:
 IMAGE: debian-amd64
 MAKE_CHECK_ARGS: check
 
+# No targets are built here, just tools, docs, and unit tests. This
+# also feeds into the eventual documentation deployment steps later
 build-tools-and-docs-debian:
   <<: *native_build_job_definition
   variables:
 IMAGE: debian-amd64
-MAKE_CHECK_ARGS: ctags TAGS cscope
+MAKE_CHECK_ARGS: check-unit check-softfloat ctags TAGS cscope
 CONFIGURE_ARGS: --disable-system --disable-user --enable-docs 
--enable-tools
   artifacts:
 expire_in: 2 days
diff --git a/.travis.yml b/.travis.yml
index 3b574a5968..5f1dea873e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,15 +119,6 @@ after_script:
 
 jobs:
   include:
-# Just build tools and run minimal unit and softfloat checks
-- name: "GCC check-unit and check-softfloat"
-  env:
-- BASE_CONFIG="--enable-tools"
-- CONFIG="--disable-user --disable-system"
-- TEST_CMD="make check-unit check-softfloat -j${JOBS}"
-- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
-
-
 # --enable-debug implies --enable-debug-tcg, also runs quite a bit slower
 - name: "GCC debug (main-softmmu)"
   env:
-- 
2.20.1




[PULL 19/30] gdbstub: drop gdbserver_cleanup in favour of gdb_exit

2021-01-15 Thread Alex Bennée
Despite it's name it didn't actually clean-up so let us document
gdb_exit() better and use that.

Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210108224256.2321-9-alex.ben...@linaro.org>

diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index 492db0f512..ff0b7bc45e 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -46,7 +46,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char 
*fmt, ...);
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *cpu);
-void gdb_exit(int);
+
+/**
+ * gdb_exit: exit gdb session, reporting inferior status
+ * @code: exit code reported
+ *
+ * This closes the session and sends a final packet to GDB reporting
+ * the exit status of the program. It also cleans up any connections
+ * detritus before returning.
+ */
+void gdb_exit(int code);
+
 #ifdef CONFIG_USER_ONLY
 /**
  * gdb_handlesig: yield control to gdb
@@ -187,8 +197,6 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, 
int len)
  */
 int gdbserver_start(const char *port_or_device);
 
-void gdbserver_cleanup(void);
-
 /**
  * gdb_has_xml:
  * This is an ugly hack to cope with both new and old gdb.
diff --git a/gdbstub.c b/gdbstub.c
index afa553e8fc..bab8476357 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3547,13 +3547,6 @@ int gdbserver_start(const char *device)
 return 0;
 }
 
-void gdbserver_cleanup(void)
-{
-if (gdbserver_state.init) {
-put_packet("W00");
-}
-}
-
 static void register_types(void)
 {
 type_register_static(_gdb_type_info);
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index 636aab0add..6177693a30 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -775,7 +775,7 @@ void qemu_init_subsystems(void)
 
 void qemu_cleanup(void)
 {
-gdbserver_cleanup();
+gdb_exit(0);
 
 /*
  * cleaning up the migration object cancels any existing migration
-- 
2.20.1




[PULL 29/30] semihosting: Implement SYS_TMPNAM

2021-01-15 Thread Alex Bennée
From: Keith Packard 

Part of Semihosting for AArch32 and AArch64 Release 2.0

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Message-Id: <20210107170717.2098982-9-kei...@keithp.com>
Message-Id: <20210108224256.2321-20-alex.ben...@linaro.org>

diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index 3d6604dcdd..a631904fb0 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -835,6 +835,7 @@ target_ulong do_common_semihosting(CPUState *cs)
 CPUArchState *env = cs->env_ptr;
 target_ulong args;
 target_ulong arg0, arg1, arg2, arg3;
+target_ulong ul_ret;
 char * s;
 int nr;
 uint32_t ret;
@@ -998,8 +999,24 @@ target_ulong do_common_semihosting(CPUState *cs)
 
 return guestfd_fns[gf->type].flenfn(cs, gf);
 case TARGET_SYS_TMPNAM:
-qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func__);
-return -1;
+GET_ARG(0);
+GET_ARG(1);
+GET_ARG(2);
+if (asprintf(, "/tmp/qemu-%x%02x", getpid(),
+ (int) (arg1 & 0xff)) < 0) {
+return -1;
+}
+ul_ret = (target_ulong) -1;
+
+/* Make sure there's enough space in the buffer */
+if (strlen(s) < arg2) {
+char *output = lock_user(VERIFY_WRITE, arg0, arg2, 0);
+strcpy(output, s);
+unlock_user(output, arg0, arg2);
+ul_ret = 0;
+}
+free(s);
+return ul_ret;
 case TARGET_SYS_REMOVE:
 GET_ARG(0);
 GET_ARG(1);
-- 
2.20.1




[PULL 14/30] configure: gate our use of GDB to 8.3.1 or above

2021-01-15 Thread Alex Bennée
The support of socket based debugging which we need for linux-user
testing is only really stable as of 8.3.1 so lets gate our use of GDB
on having a relatively modern version.

For direct testing you can just point to a locally compiled version of
gdb via configure, e.g.:

  ../../configure --gdb=$HOME/src/binutils-gdb.git/builds/all/install/bin/gdb

Signed-off-by: Alex Bennée 
Message-Id: <20210108224256.2321-4-alex.ben...@linaro.org>

diff --git a/configure b/configure
index 155dda124c..9f016b06b5 100755
--- a/configure
+++ b/configure
@@ -6166,8 +6166,11 @@ if test "$plugins" = "yes" ; then
 fi
 fi
 
-if test -n "$gdb_bin" ; then
-echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
+if test -n "$gdb_bin"; then
+gdb_version=$($gdb_bin --version | head -n 1)
+if version_ge ${gdb_version##* } 8.3.1; then
+echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
+fi
 fi
 
 if test "$secret_keyring" = "yes" ; then
-- 
2.20.1




[PULL 13/30] test/guest-debug: echo QEMU command as well

2021-01-15 Thread Alex Bennée
This helps with debugging.

Signed-off-by: Alex Bennée 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210108224256.2321-3-alex.ben...@linaro.org>

diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 71c5569054..0c4f5c3808 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -53,6 +53,7 @@ if __name__ == '__main__':
 cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name,
   args.binary)
 
+print("QEMU CMD: %s" % (cmd))
 inferior = subprocess.Popen(shlex.split(cmd))
 
 # Now launch gdb with our test and collect the result
-- 
2.20.1




[PULL 28/30] semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ

2021-01-15 Thread Alex Bennée
From: Keith Packard 

These are part of Semihosting for AArch32 and AArch64 Release 2.0

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Message-Id: <20210107170717.2098982-8-kei...@keithp.com>
Message-Id: <20210108224256.2321-19-alex.ben...@linaro.org>

diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 61296ea980..1678238384 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -808,6 +808,8 @@ static inline int64_t get_clock_realtime(void)
 return tv.tv_sec * 10LL + (tv.tv_usec * 1000);
 }
 
+extern int64_t clock_start;
+
 /* Warning: don't insert tracepoints into these functions, they are
also used by simpletrace backend and tracepoints would cause
an infinite recursion! */
diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index 5fcb8663c6..3d6604dcdd 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -38,6 +38,7 @@
 #include "hw/semihosting/console.h"
 #include "hw/semihosting/common-semi.h"
 #include "qemu/log.h"
+#include "qemu/timer.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
@@ -73,6 +74,8 @@
 #define TARGET_SYS_EXIT0x18
 #define TARGET_SYS_SYNCCACHE   0x19
 #define TARGET_SYS_EXIT_EXTENDED 0x20
+#define TARGET_SYS_ELAPSED 0x30
+#define TARGET_SYS_TICKFREQ0x31
 
 /* ADP_Stopped_ApplicationExit is used for exit(0),
  * anything else is implemented as exit(1) */
@@ -837,6 +840,7 @@ target_ulong do_common_semihosting(CPUState *cs)
 uint32_t ret;
 uint32_t len;
 GuestFD *gf;
+int64_t elapsed;
 
 (void) env; /* Used implicitly by arm lock_user macro */
 nr = common_semi_arg(cs, 0) & 0xU;
@@ -1246,6 +1250,18 @@ target_ulong do_common_semihosting(CPUState *cs)
 }
 gdb_exit(ret);
 exit(ret);
+case TARGET_SYS_ELAPSED:
+elapsed = get_clock() - clock_start;
+if (sizeof(target_ulong) == 8) {
+SET_ARG(0, elapsed);
+} else {
+SET_ARG(0, (uint32_t) elapsed);
+SET_ARG(1, (uint32_t) (elapsed >> 32));
+}
+return 0;
+case TARGET_SYS_TICKFREQ:
+/* qemu always uses nsec */
+return 10;
 case TARGET_SYS_SYNCCACHE:
 /*
  * Clean the D-cache and invalidate the I-cache for the specified
diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c
index baf3317f74..cc1326f726 100644
--- a/util/qemu-timer-common.c
+++ b/util/qemu-timer-common.c
@@ -27,6 +27,8 @@
 /***/
 /* real time host monotonic timer */
 
+int64_t clock_start;
+
 #ifdef _WIN32
 
 int64_t clock_freq;
@@ -41,6 +43,7 @@ static void __attribute__((constructor)) init_get_clock(void)
 exit(1);
 }
 clock_freq = freq.QuadPart;
+clock_start = get_clock();
 }
 
 #else
@@ -55,5 +58,6 @@ static void __attribute__((constructor)) init_get_clock(void)
 if (clock_gettime(CLOCK_MONOTONIC, ) == 0) {
 use_rt_clock = 1;
 }
+clock_start = get_clock();
 }
 #endif
-- 
2.20.1




[PULL 07/30] Makefile: wrap cscope in quiet-command calls

2021-01-15 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-8-alex.ben...@linaro.org>

diff --git a/Makefile b/Makefile
index f7e9eb9f08..2a926aaeb0 100644
--- a/Makefile
+++ b/Makefile
@@ -282,9 +282,17 @@ TAGS:
 
 .PHONY: cscope
 cscope:
-   rm -f "$(SRC_PATH)"/cscope.*
-   $(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
-   cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"cscope.* ,  \
+   "cscope", "Remove old $@ files")
+   $(call quiet-command,   \
+   ($(find-src-path) -print | sed -e 's,^\./,,'\
+   > "$(SRC_PATH)/cscope.files"),  \
+   "cscope", "Create file list")
+   $(call quiet-command,   \
+   cscope -b -i"$(SRC_PATH)/cscope.files"  \
+   -f"$(SRC_PATH)"/cscope.out, \
+   "cscope", "Re-index $(SRC_PATH)")
 
 # Needed by "meson install"
 export DESTDIR
-- 
2.20.1




[PULL 30/30] semihosting: Implement SYS_ISERROR

2021-01-15 Thread Alex Bennée
From: Keith Packard 

Part of Semihosting for AArch32 and AArch64 Release 2.0

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Message-Id: <20210107170717.2098982-10-kei...@keithp.com>
Message-Id: <20210108224256.2321-21-alex.ben...@linaro.org>

diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index a631904fb0..23c6e3edcb 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -59,6 +59,7 @@
 #define TARGET_SYS_WRITE   0x05
 #define TARGET_SYS_READ0x06
 #define TARGET_SYS_READC   0x07
+#define TARGET_SYS_ISERROR 0x08
 #define TARGET_SYS_ISTTY   0x09
 #define TARGET_SYS_SEEK0x0a
 #define TARGET_SYS_FLEN0x0c
@@ -967,6 +968,9 @@ target_ulong do_common_semihosting(CPUState *cs)
 return guestfd_fns[gf->type].readfn(cs, gf, arg1, len);
 case TARGET_SYS_READC:
 return qemu_semihosting_console_inc(cs->env_ptr);
+case TARGET_SYS_ISERROR:
+GET_ARG(0);
+return (target_long) arg0 < 0 ? 1 : 0;
 case TARGET_SYS_ISTTY:
 GET_ARG(0);
 
-- 
2.20.1




[PULL 18/30] gdbstub: drop CPUEnv from gdb_exit()

2021-01-15 Thread Alex Bennée
gdb_exit() has never needed anything from env and I doubt we are going
to start now.

Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 
Reviewed-by: Laurent Vivier 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210108224256.2321-8-alex.ben...@linaro.org>

diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index 94d8f83e92..492db0f512 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -46,7 +46,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char 
*fmt, ...);
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *cpu);
-void gdb_exit(CPUArchState *, int);
+void gdb_exit(int);
 #ifdef CONFIG_USER_ONLY
 /**
  * gdb_handlesig: yield control to gdb
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index d38ec7a162..adc3d21b54 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, 
abi_long arg1,
 #ifdef CONFIG_GPROF
 _mcleanup();
 #endif
-gdb_exit(cpu_env, arg1);
+gdb_exit(arg1);
 qemu_plugin_atexit_cb();
 /* XXX: should free thread stack and CPU env */
 _exit(arg1);
@@ -435,7 +435,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long 
arg1,
 #ifdef CONFIG_GPROF
 _mcleanup();
 #endif
-gdb_exit(cpu_env, arg1);
+gdb_exit(arg1);
 qemu_plugin_atexit_cb();
 /* XXX: should free thread stack and CPU env */
 _exit(arg1);
@@ -514,7 +514,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, 
abi_long arg1,
 #ifdef CONFIG_GPROF
 _mcleanup();
 #endif
-gdb_exit(cpu_env, arg1);
+gdb_exit(arg1);
 qemu_plugin_atexit_cb();
 /* XXX: should free thread stack and CPU env */
 _exit(arg1);
diff --git a/gdbstub.c b/gdbstub.c
index 15d3a8e1f5..afa553e8fc 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3068,7 +3068,7 @@ static void gdb_read_byte(uint8_t ch)
 }
 
 /* Tell the remote gdb that the process has exited.  */
-void gdb_exit(CPUArchState *env, int code)
+void gdb_exit(int code)
 {
   char buf[4];
 
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 1594015444..70b344048c 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -34,6 +34,6 @@ void preexit_cleanup(CPUArchState *env, int code)
 #ifdef CONFIG_GCOV
 __gcov_dump();
 #endif
-gdb_exit(env, code);
+gdb_exit(code);
 qemu_plugin_atexit_cb();
 }
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index f7b7bff522..93360e28c7 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -1101,7 +1101,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
  */
 ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1;
 }
-gdb_exit(env, ret);
+gdb_exit(ret);
 exit(ret);
 case TARGET_SYS_SYNCCACHE:
 /*
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 27600e0cc0..d919245e4f 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -195,7 +195,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
 args = env->dregs[1];
 switch (nr) {
 case HOSTED_EXIT:
-gdb_exit(env, env->dregs[0]);
+gdb_exit(env->dregs[0]);
 exit(env->dregs[0]);
 case HOSTED_OPEN:
 GET_ARG(0);
diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index d7a80dd303..e508b2fafc 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -215,7 +215,7 @@ void do_nios2_semihosting(CPUNios2State *env)
 args = env->regs[R_ARG1];
 switch (nr) {
 case HOSTED_EXIT:
-gdb_exit(env, env->regs[R_ARG0]);
+gdb_exit(env->regs[R_ARG0]);
 exit(env->regs[R_ARG0]);
 case HOSTED_OPEN:
 GET_ARG(0);
-- 
2.20.1




[PULL 21/30] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

2021-01-15 Thread Alex Bennée
While GDB can work with any XML description given to it there is
special handling for SVE registers on the GDB side which makes the
users life a little better. The changes aren't that major and all the
registers save the $vg reported the same. All that changes is:

  - report org.gnu.gdb.aarch64.sve
  - use gdb nomenclature for names and types
  - minor re-ordering of the types to match reference
  - re-enable ieee_half (as we know gdb supports it now)
  - $vg is now a 64 bit int
  - check $vN and $zN aliasing in test

Signed-off-by: Alex Bennée 
Reviewed-by: Luis Machado 
Message-Id: <20210108224256.2321-11-alex.ben...@linaro.org>

diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
index 866595b4f1..a8fff2a3d0 100644
--- a/target/arm/gdbstub.c
+++ b/target/arm/gdbstub.c
@@ -195,22 +195,17 @@ static const struct TypeSize vec_lanes[] = {
 { "uint128", 128, 'q', 'u' },
 { "int128", 128, 'q', 's' },
 /* 64 bit */
+{ "ieee_double", 64, 'd', 'f' },
 { "uint64", 64, 'd', 'u' },
 { "int64", 64, 'd', 's' },
-{ "ieee_double", 64, 'd', 'f' },
 /* 32 bit */
+{ "ieee_single", 32, 's', 'f' },
 { "uint32", 32, 's', 'u' },
 { "int32", 32, 's', 's' },
-{ "ieee_single", 32, 's', 'f' },
 /* 16 bit */
+{ "ieee_half", 16, 'h', 'f' },
 { "uint16", 16, 'h', 'u' },
 { "int16", 16, 'h', 's' },
-/*
- * TODO: currently there is no reliable way of telling
- * if the remote gdb actually understands ieee_half so
- * we don't expose it in the target description for now.
- * { "ieee_half", 16, 'h', 'f' },
- */
 /* bytes */
 { "uint8", 8, 'b', 'u' },
 { "int8", 8, 'b', 's' },
@@ -223,17 +218,16 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg)
 GString *s = g_string_new(NULL);
 DynamicGDBXMLInfo *info = >dyn_svereg_xml;
 g_autoptr(GString) ts = g_string_new("");
-int i, bits, reg_width = (cpu->sve_max_vq * 128);
+int i, j, bits, reg_width = (cpu->sve_max_vq * 128);
 info->num = 0;
 g_string_printf(s, "");
 g_string_append_printf(s, "");
-g_string_append_printf(s, "");
+g_string_append_printf(s, "");
 
 /* First define types and totals in a whole VL */
 for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
 int count = reg_width / vec_lanes[i].size;
-g_string_printf(ts, "vq%d%c%c", count,
-vec_lanes[i].sz, vec_lanes[i].suffix);
+g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suffix);
 g_string_append_printf(s,
"",
ts->str, vec_lanes[i].gdb_type, count);
@@ -243,39 +237,37 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg)
  * signed and potentially float versions of each size from 128 to
  * 8 bits.
  */
-for (bits = 128; bits >= 8; bits /= 2) {
-int count = reg_width / bits;
-g_string_append_printf(s, "", count);
-for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
-if (vec_lanes[i].size == bits) {
-g_string_append_printf(s, "",
-   vec_lanes[i].suffix,
-   count,
-   vec_lanes[i].sz, vec_lanes[i].suffix);
+for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) {
+const char suf[] = { 'q', 'd', 's', 'h', 'b' };
+g_string_append_printf(s, "", suf[i]);
+for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) {
+if (vec_lanes[j].size == bits) {
+g_string_append_printf(s, "",
+   vec_lanes[j].suffix,
+   vec_lanes[j].sz, vec_lanes[j].suffix);
 }
 }
 g_string_append(s, "");
 }
 /* And now the final union of unions */
-g_string_append(s, "");
-for (bits = 128; bits >= 8; bits /= 2) {
-int count = reg_width / bits;
-for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
-if (vec_lanes[i].size == bits) {
-g_string_append_printf(s, "",
-   vec_lanes[i].sz, count);
-break;
-}
-}
+g_string_append(s, "");
+for (bits = 128, i = 0; bits >= 8; bits /= 2, i++) {
+const char suf[] = { 'q', 'd', 's', 'h', 'b' };
+g_string_append_printf(s, "",
+   suf[i], suf[i]);
 }
 g_string_append(s, "");
 
+/* Finally the sve prefix type */
+g_string_append_printf(s,
+   "

[PULL 05/30] Makefile: wrap ctags in quiet-command calls

2021-01-15 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-6-alex.ben...@linaro.org>

diff --git a/Makefile b/Makefile
index 0c509a7704..bbab640b31 100644
--- a/Makefile
+++ b/Makefile
@@ -250,8 +250,13 @@ find-src-path = find "$(SRC_PATH)/" -path 
"$(SRC_PATH)/meson" -prune -o \( -name
 
 .PHONY: ctags
 ctags:
-   rm -f "$(SRC_PATH)/"tags
-   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"tags,   \
+   "CTAGS", "Remove old tags")
+   $(call quiet-command, \
+   $(find-src-path) -exec ctags\
+   -f "$(SRC_PATH)/"tags --append {} +,\
+   "CTAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: gtags
 gtags:
-- 
2.20.1




[PULL 16/30] gdbstub: implement a softmmu based test

2021-01-15 Thread Alex Bennée
This adds a new tests that allows us to test softmmu only features
including watchpoints. To do achieve this we need to:

  - add _exit: labels to the boot codes
  - write a memory.py test case
  - plumb the test case into the build system
  - tweak the run_test script to:
- re-direct output when asked
- use socket based connection for all tests
- add a small pause before connection

Signed-off-by: Alex Bennée 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210108224256.2321-6-alex.ben...@linaro.org>

diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 0c4f5c3808..8b91ff95af 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -16,6 +16,7 @@ import subprocess
 import shutil
 import shlex
 import os
+from time import sleep
 from tempfile import TemporaryDirectory
 
 def get_args():
@@ -27,10 +28,21 @@ def get_args():
 required=True)
 parser.add_argument("--test", help="GDB test script",
 required=True)
-parser.add_argument("--gdb", help="The gdb binary to use", default=None)
+parser.add_argument("--gdb", help="The gdb binary to use",
+default=None)
+parser.add_argument("--output", help="A file to redirect output to")
 
 return parser.parse_args()
 
+
+def log(output, msg):
+if output:
+output.write(msg + "\n")
+output.flush()
+else:
+print(msg)
+
+
 if __name__ == '__main__':
 args = get_args()
 
@@ -42,18 +54,25 @@ if __name__ == '__main__':
 if not args.gdb:
 print("We need gdb to run the test")
 exit(-1)
+if args.output:
+output = open(args.output, "w")
+else:
+output = None
 
 socket_dir = TemporaryDirectory("qemu-gdbstub")
 socket_name = os.path.join(socket_dir.name, "gdbstub.socket")
 
 # Launch QEMU with binary
 if "system" in args.qemu:
-cmd = "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary)
+cmd = "%s %s %s -gdb unix:path=%s,server" % (args.qemu,
+ args.qargs,
+ args.binary,
+ socket_name)
 else:
 cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name,
   args.binary)
 
-print("QEMU CMD: %s" % (cmd))
+log(output, "QEMU CMD: %s" % (cmd))
 inferior = subprocess.Popen(shlex.split(cmd))
 
 # Now launch gdb with our test and collect the result
@@ -63,16 +82,15 @@ if __name__ == '__main__':
 # disable prompts in case of crash
 gdb_cmd += " -ex 'set confirm off'"
 # connect to remote
-if "system" in args.qemu:
-gdb_cmd += " -ex 'target remote localhost:1234'"
-else:
-gdb_cmd += " -ex 'target remote %s'" % (socket_name)
+gdb_cmd += " -ex 'target remote %s'" % (socket_name)
 # finally the test script itself
 gdb_cmd += " -x %s" % (args.test)
 
-print("GDB CMD: %s" % (gdb_cmd))
 
-result = subprocess.call(gdb_cmd, shell=True);
+sleep(1)
+log(output, "GDB CMD: %s" % (gdb_cmd))
+
+result = subprocess.call(gdb_cmd, shell=True, stdout=output)
 
 # A negative result is the result of an internal gdb failure like
 # a crash. We force a return of 0 so we don't fail the test on
diff --git a/tests/tcg/aarch64/Makefile.softmmu-target 
b/tests/tcg/aarch64/Makefile.softmmu-target
index 1057a8ac49..a7286ac295 100644
--- a/tests/tcg/aarch64/Makefile.softmmu-target
+++ b/tests/tcg/aarch64/Makefile.softmmu-target
@@ -15,6 +15,7 @@ CRT_PATH=$(AARCH64_SYSTEM_SRC)
 LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld
 LDFLAGS=-Wl,-T$(LINK_SCRIPT)
 TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS)
+EXTRA_RUNS+=$(MULTIARCH_RUNS)
 CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
 LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 
diff --git a/tests/tcg/aarch64/system/boot.S b/tests/tcg/aarch64/system/boot.S
index b14e94f332..e190b1efa6 100644
--- a/tests/tcg/aarch64/system/boot.S
+++ b/tests/tcg/aarch64/system/boot.S
@@ -197,6 +197,7 @@ __start:
bl  main
 
/* pass return value to sys exit */
+_exit:
movx1, x0
ldrx0, =0x20026 /* ADP_Stopped_ApplicationExit */
stpx0, x1, [sp, #-16]!
diff --git a/tests/tcg/i386/Makefile.softmmu-target 
b/tests/tcg/i386/Makefile.softmmu-target
index 1c8790eecd..5266f2335a 100644
--- a/tests/tcg/i386/Makefile.softmmu-target
+++ b/tests/tcg/i386/Makefile.softmmu-target
@@ -19,6 +19,7 @@ CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
 LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 
 TESTS+=$(MULTIARC

[PULL 25/30] semihosting: Support SYS_HEAPINFO when env->boot_info is not set

2021-01-15 Thread Alex Bennée
From: Keith Packard 

env->boot_info is only set in some ARM startup paths, so we cannot
rely on it to support the SYS_HEAPINFO semihosting function. When not
available, fallback to finding a RAM memory region containing the
current stack and use the base of that.

Signed-off-by: Keith Packard 
Signed-off-by: Alex Bennée 
Message-Id: <20210107170717.2098982-5-kei...@keithp.com>
Message-Id: <20210108224256.2321-16-alex.ben...@linaro.org>

diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c
index ac1271545e..293791f721 100644
--- a/hw/semihosting/arm-compat-semi.c
+++ b/hw/semihosting/arm-compat-semi.c
@@ -137,6 +137,36 @@ typedef struct GuestFD {
 
 static GArray *guestfd_array;
 
+#ifndef CONFIG_USER_ONLY
+#include "exec/address-spaces.h"
+/*
+ * Find the base of a RAM region containing the specified address
+ */
+static inline hwaddr
+common_semi_find_region_base(hwaddr addr)
+{
+MemoryRegion *subregion;
+
+/*
+ * Find the chunk of R/W memory containing the address.  This is
+ * used for the SYS_HEAPINFO semihosting call, which should
+ * probably be using information from the loaded application.
+ */
+QTAILQ_FOREACH(subregion, _system_memory()->subregions,
+   subregions_link) {
+if (subregion->ram && !subregion->readonly) {
+Int128 top128 = int128_add(int128_make64(subregion->addr),
+   subregion->size);
+Int128 addr128 = int128_make64(addr);
+if (subregion->addr <= addr && int128_lt(addr128, top128)) {
+return subregion->addr;
+}
+}
+}
+return 0;
+}
+#endif
+
 #ifdef TARGET_ARM
 static inline target_ulong
 common_semi_arg(CPUState *cs, int argno)
@@ -175,7 +205,18 @@ common_semi_rambase(CPUState *cs)
 {
 CPUArchState *env = cs->env_ptr;
 const struct arm_boot_info *info = env->boot_info;
-return info->loader_start;
+target_ulong sp;
+
+if (info) {
+return info->loader_start;
+}
+
+if (is_a64(env)) {
+sp = env->xregs[31];
+} else {
+sp = env->regs[13];
+}
+return common_semi_find_region_base(sp);
 }
 #endif
 
-- 
2.20.1




[PULL 06/30] Makefile: wrap etags in quiet-command calls

2021-01-15 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-7-alex.ben...@linaro.org>

diff --git a/Makefile b/Makefile
index bbab640b31..f7e9eb9f08 100644
--- a/Makefile
+++ b/Makefile
@@ -272,8 +272,13 @@ gtags:
 
 .PHONY: TAGS
 TAGS:
-   rm -f "$(SRC_PATH)/"TAGS
-   $(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"TAGS,   \
+   "TAGS", "Remove old $@")
+   $(call quiet-command,   \
+   $(find-src-path) -exec etags\
+   -f "$(SRC_PATH)/"TAGS --append {} +,\
+   "TAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: cscope
 cscope:
-- 
2.20.1




[PULL 17/30] gdbstub: add support to Xfer:auxv:read: packet

2021-01-15 Thread Alex Bennée
From: Lirong Yuan 

This allows gdb to access the target’s auxiliary vector,
which can be helpful for telling system libraries important details
about the hardware, operating system, and process.

Signed-off-by: Lirong Yuan 
[AJB: minor tweaks to test case, update MAINTAINERS]
Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 
Message-Id: <20200730193932.3654677-1-yua...@google.com>
Message-Id: <20210108224256.2321-7-alex.ben...@linaro.org>

diff --git a/gdbstub.c b/gdbstub.c
index d99bc0bf2e..15d3a8e1f5 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2172,6 +2172,12 @@ static void handle_query_supported(GdbCmdContext 
*gdb_ctx, void *user_ctx)
 ";ReverseStep+;ReverseContinue+");
 }
 
+#ifdef CONFIG_USER_ONLY
+if (gdbserver_state.c_cpu->opaque) {
+g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+");
+}
+#endif
+
 if (gdb_ctx->num_params &&
 strstr(gdb_ctx->params[0].data, "multiprocess+")) {
 gdbserver_state.multiprocess = true;
@@ -2233,6 +2239,46 @@ static void handle_query_xfer_features(GdbCmdContext 
*gdb_ctx, void *user_ctx)
   gdbserver_state.str_buf->len, true);
 }
 
+#ifdef CONFIG_USER_ONLY
+static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
+{
+TaskState *ts;
+unsigned long offset, len, saved_auxv, auxv_len;
+const char *mem;
+
+if (gdb_ctx->num_params < 2) {
+put_packet("E22");
+return;
+}
+
+offset = gdb_ctx->params[0].val_ul;
+len = gdb_ctx->params[1].val_ul;
+ts = gdbserver_state.c_cpu->opaque;
+saved_auxv = ts->info->saved_auxv;
+auxv_len = ts->info->auxv_len;
+mem = (const char *)(saved_auxv + offset);
+if (offset > auxv_len) {
+put_packet("E00");
+return;
+}
+
+if (len > (MAX_PACKET_LENGTH - 5) / 2) {
+len = (MAX_PACKET_LENGTH - 5) / 2;
+}
+
+if (len < auxv_len - offset) {
+g_string_assign(gdbserver_state.str_buf, "m");
+memtox(gdbserver_state.str_buf, mem, len);
+} else {
+g_string_assign(gdbserver_state.str_buf, "l");
+memtox(gdbserver_state.str_buf, mem, auxv_len - offset);
+}
+
+put_packet_binary(gdbserver_state.str_buf->str,
+  gdbserver_state.str_buf->len, true);
+}
+#endif
+
 static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx)
 {
 put_packet(GDB_ATTACHED);
@@ -2338,6 +2384,14 @@ static GdbCmdParseEntry gdb_gen_query_table[] = {
 .cmd_startswith = 1,
 .schema = "s:l,l0"
 },
+#ifdef CONFIG_USER_ONLY
+{
+.handler = handle_query_xfer_auxv,
+.cmd = "Xfer:auxv:read::",
+.cmd_startswith = 1,
+.schema = "l,l0"
+},
+#endif
 {
 .handler = handle_query_attached,
 .cmd = "Attached:",
diff --git a/MAINTAINERS b/MAINTAINERS
index 07e4851aa4..3216387521 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2322,6 +2322,7 @@ R: Philippe Mathieu-Daudé 
 S: Maintained
 F: gdbstub*
 F: gdb-xml/
+F: tests/tcg/multiarch/gdbstub/
 
 Memory API
 M: Paolo Bonzini 
diff --git a/tests/tcg/multiarch/Makefile.target 
b/tests/tcg/multiarch/Makefile.target
index cb49cc9ccb..1dd0f64d23 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -55,6 +55,15 @@ run-gdbstub-sha1: sha1
"basic gdbstub support")
 
 EXTRA_RUNS += run-gdbstub-sha1
+
+run-gdbstub-qxfer-auxv-read: sha1
+   $(call run-test, $@, $(GDB_SCRIPT) \
+   --gdb $(HAVE_GDB_BIN) \
+   --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
+   --bin $< --test 
$(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
+   "basic gdbstub qXfer:auxv:read support")
+
+EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read
 endif
 
 
diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py 
b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
new file mode 100644
index 00..d91e8fdf19
--- /dev/null
+++ b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
@@ -0,0 +1,57 @@
+from __future__ import print_function
+#
+# Test auxiliary vector is loaded via gdbstub
+#
+# This is launched via tests/guest-debug/run-test.py
+#
+
+import gdb
+import sys
+
+failcount = 0
+
+def report(cond, msg):
+"Report success/fail of test"
+if cond:
+print ("PASS: %s" % (msg))
+else:
+print ("FAIL: %s" % (msg))
+global failcount
+failcount += 1
+
+def run_test():
+"Run through the tests one by one"
+
+auxv = gdb.execute("info auxv", False, True)
+report(isinstance(auxv, str), "Fetched auxv from inferior")
+report(auxv.find("sha1"), "Found test binary name in auxv")
+

[PULL 03/30] shippable.yml: Remove jobs duplicated on Gitlab-CI

2021-01-15 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

The following jobs are duplicated on Gitlab-CI since commit
6bcb5fc0f7a ("gitlab-ci: Add cross-compiling build tests"):

- IMAGE=debian-armel-cross

  TARGET_LIST=arm-softmmu   -> cross-armel-system
  TARGET_LIST=arm-linux-user-> cross-armel-user
  TARGET_LIST=armeb-linux-user  -> cross-armel-user

- IMAGE=debian-armhf-cross

  TARGET_LIST=arm-softmmu   -> cross-armhf-system
  TARGET_LIST=arm-linux-user-> cross-armhf-user
  TARGET_LIST=armeb-linux-user  -> cross-armhf-user

- IMAGE=debian-arm64-cross

  TARGET_LIST=aarch64-softmmu   -> cross-arm64-system
  TARGET_LIST=aarch64-linux-user-> cross-arm64-user

- IMAGE=debian-s390x-cross

  TARGET_LIST=s390x-softmmu -> cross-s390x-system
  TARGET_LIST=s390x-linux-user  -> cross-s390x-user

- IMAGE=debian-mips-cross

  TARGET_LIST=mipsel-linux-user -> cross-mips-user

- IMAGE=debian-mips64el-cross

  TARGET_LIST=mips64el-softmmu  -> cross-mips64el-system
  TARGET_LIST=mips64el-linux-user   -> cross-mips64el-user

- IMAGE=debian-ppc64el-cross

  TARGET_LIST=ppc64-softmmu -> cross-ppc64el-system
  TARGET_LIST=ppc64-linux-user  -> cross-ppc64el-user
  TARGET_LIST=ppc64abi32-linux-user -> cross-ppc64el-user

Remove them from Shippable CI.

Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Alex Bennée 
Acked-by: Alex Bennée 
Message-Id: <20210108145103.269353-1-f4...@amsat.org>
Message-Id: <20210114165730.31607-4-alex.ben...@linaro.org>

diff --git a/.shippable.yml b/.shippable.yml
index 14350e6de8..97bfa2a0f3 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -7,20 +7,8 @@ env:
   matrix:
 - IMAGE=debian-amd64
   TARGET_LIST=x86_64-softmmu,x86_64-linux-user
-- IMAGE=debian-armel-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-armhf-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-arm64-cross
-  TARGET_LIST=aarch64-softmmu,aarch64-linux-user
-- IMAGE=debian-s390x-cross
-  TARGET_LIST=s390x-softmmu,s390x-linux-user
 - IMAGE=debian-mips-cross
-  TARGET_LIST=mips-softmmu,mipsel-linux-user
-- IMAGE=debian-mips64el-cross
-  TARGET_LIST=mips64el-softmmu,mips64el-linux-user
-- IMAGE=debian-ppc64el-cross
-  TARGET_LIST=ppc64-softmmu,ppc64-linux-user,ppc64abi32-linux-user
+  TARGET_LIST=mips-softmmu
 build:
   pre_ci_boot:
 image_name: registry.gitlab.com/qemu-project/qemu/qemu/${IMAGE}
-- 
2.20.1




[PULL 00/30] testing, gdbstub and semihosting

2021-01-15 Thread Alex Bennée
The following changes since commit 7c79721606be11b5bc556449e5bcbc331ef6867d:

  Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210113' into 
staging (2021-01-14 09:54:29 +)

are available in the Git repository at:

  https://github.com/stsquad/qemu.git tags/pull-testing-and-misc-150121-1

for you to fetch changes up to be846761ca8b5a7e2e7b7108c8c156126b799824:

  semihosting: Implement SYS_ISERROR (2021-01-15 11:12:34 +)


Testing, gdbstub and semihosting patches:

  - clean-ups to docker images
  - drop duplicate jobs from shippable
  - prettier tag generation (+gtags)
  - generate browsable source tree
  - more Travis->GitLab migrations
  - fix checkpatch to deal with commits
  - gate gdbstub tests on 8.3.1, expand tests
  - support Xfer:auxv:read gdb packet
  - better gdbstub cleanup
  - use GDB's SVE register layout
  - make arm-compat-semihosting common
  - add riscv semihosting support
  - add HEAPINFO, ELAPSED, TICKFREQ, TMPNAM and ISERROR to semihosting


Alessandro Di Federico (1):
  Add newline when generating Dockerfile

Alex Bennée (16):
  Makefile: add GNU global tags support
  Makefile: wrap ctags in quiet-command calls
  Makefile: wrap etags in quiet-command calls
  Makefile: wrap cscope in quiet-command calls
  docker: expand debian-amd64 image to include tag tools
  gitlab: move docs and tools build across from Travis
  gitlab: migrate the minimal tools and unit tests from Travis
  scripts/checkpatch.pl: fix git-show invocation to include diffstat
  test/guest-debug: echo QEMU command as well
  configure: gate our use of GDB to 8.3.1 or above
  Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1 
test"
  gdbstub: implement a softmmu based test
  gdbstub: drop CPUEnv from gdb_exit()
  gdbstub: drop gdbserver_cleanup in favour of gdb_exit
  gdbstub: ensure we clean-up when terminated
  target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

Keith Packard (8):
  semihosting: Move ARM semihosting code to shared directories
  semihosting: Change common-semi API to be architecture-independent
  semihosting: Change internal common-semi interfaces to use CPUState *
  semihosting: Support SYS_HEAPINFO when env->boot_info is not set
  riscv: Add semihosting support
  semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ
  semihosting: Implement SYS_TMPNAM
  semihosting: Implement SYS_ISERROR

Kito Cheng (1):
  riscv: Add semihosting support for user mode

Lirong Yuan (1):
  gdbstub: add support to Xfer:auxv:read: packet

Lukas Straub (1):
  Fix build with new yank feature by adding stubs

Philippe Mathieu-Daudé (2):
  tests/docker: Remove Debian 9 remnant lines
  shippable.yml: Remove jobs duplicated on Gitlab-CI

 configure  |   7 +-
 Makefile   |  46 +-
 default-configs/devices/arm-softmmu.mak|   1 +
 default-configs/devices/riscv32-softmmu.mak|   2 +
 default-configs/devices/riscv64-softmmu.mak|   2 +
 default-configs/targets/aarch64-linux-user.mak |   1 +
 default-configs/targets/aarch64_be-linux-user.mak  |   1 +
 default-configs/targets/arm-linux-user.mak |   1 +
 default-configs/targets/armeb-linux-user.mak   |   1 +
 default-configs/targets/riscv32-linux-user.mak |   1 +
 default-configs/targets/riscv64-linux-user.mak |   1 +
 hw/semihosting/common-semi.h   |  39 ++
 include/exec/gdbstub.h |  14 +-
 include/qemu/timer.h   |   2 +
 linux-user/qemu.h  |   4 +-
 target/arm/cpu.h   |   8 -
 target/riscv/cpu_bits.h|   1 +
 bsd-user/syscall.c |   6 +-
 gdbstub.c  |  65 ++-
 .../arm-semi.c => hw/semihosting/arm-compat-semi.c | 525 ++---
 linux-user/aarch64/cpu_loop.c  |   3 +-
 linux-user/arm/cpu_loop.c  |   3 +-
 linux-user/exit.c  |   2 +-
 linux-user/riscv/cpu_loop.c|   5 +
 linux-user/{arm => }/semihost.c|   8 +-
 softmmu/runstate.c |   2 +-
 stubs/yank.c   |  29 ++
 target/arm/gdbstub.c   |  75 ++-
 target/arm/helper.c|   7 +-
 target/arm/m_helper.c  |   7 +-
 target/m68k/m68k-semi.c|   2 +-
 target/nios2/nios2-semi.c  |   2 +-
 target/riscv/cpu_helper.c 

[PULL 04/30] Add newline when generating Dockerfile

2021-01-15 Thread Alex Bennée
From: Alessandro Di Federico 

Signed-off-by: Alessandro Di Federico 
Signed-off-by: Alex Bennée 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <1610080146-14968-36-git-send-email-tsimp...@quicinc.com>
Message-Id: <20210114165730.31607-5-alex.ben...@linaro.org>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 36b7868406..884dfeb29c 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -332,9 +332,9 @@ class Docker(object):
  (uname, uid, uname))
 
 tmp_df.write("\n")
-tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" % (checksum))
+tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s\n" % (checksum))
 for f, c in extra_files_cksum:
-tmp_df.write("LABEL com.qemu.%s-checksum=%s" % (f, c))
+tmp_df.write("LABEL com.qemu.%s-checksum=%s\n" % (f, c))
 
 tmp_df.flush()
 
-- 
2.20.1




[PULL 02/30] Makefile: add GNU global tags support

2021-01-15 Thread Alex Bennée
GNU Global is another tags engine which is more like cscope in being
able to support finding both references and definitions. You will be
un-surprised to know it also integrates well with Emacs.

The main benefit of integrating it into find-src-path is it takes less
time to rebuild the database from scratch when you have a lot of build
directories under your source tree.

Signed-off-by: Alex Bennée 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20210114165730.31607-3-alex.ben...@linaro.org>

diff --git a/Makefile b/Makefile
index fb9923ff22..0c509a7704 100644
--- a/Makefile
+++ b/Makefile
@@ -253,6 +253,18 @@ ctags:
rm -f "$(SRC_PATH)/"tags
$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
 
+.PHONY: gtags
+gtags:
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"GTAGS;  \
+   rm -f "$(SRC_PATH)/"GRTAGS; \
+   rm -f "$(SRC_PATH)/"GPATH,  \
+   "GTAGS", "Remove old $@ files")
+   $(call quiet-command,   \
+   (cd $(SRC_PATH) &&  \
+$(find-src-path) | gtags -f -),\
+   "GTAGS", "Re-index $(SRC_PATH)")
+
 .PHONY: TAGS
 TAGS:
rm -f "$(SRC_PATH)/"TAGS
@@ -279,7 +291,7 @@ help:
$(call print-help,all,Build all)
$(call print-help,dir/file.o,Build specified target only)
$(call print-help,install,Install QEMU, documentation and tools)
-   $(call print-help,ctags/TAGS,Generate tags file for editors)
+   $(call print-help,ctags/gtags/TAGS,Generate tags file for editors)
$(call print-help,cscope,Generate cscope index)
$(call print-help,sparse,Run sparse on the QEMU source)
@echo  ''
diff --git a/.gitignore b/.gitignore
index b32bca1315..75a4be0724 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,9 @@
 cscope.*
 tags
 TAGS
+GPATH
+GRTAGS
+GTAGS
 *~
 *.ast_raw
 *.depend_raw
-- 
2.20.1




[PULL 01/30] tests/docker: Remove Debian 9 remnant lines

2021-01-15 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

Debian 9 base container has been removed in commits
e3755276d1f and c9d78b06c06. Remove the last remnants.

Fixes: e3755276d1f ("tests/docker: Remove old Debian 9 containers")
Signed-off-by: Philippe Mathieu-Daudé 
Signed-off-by: Alex Bennée 
Reviewed-by: Thomas Huth 
Reviewed-by: Willian Rampazzo 
Message-Id: <20210107072933.3828450-1-f4...@amsat.org>
Message-Id: <20210114165730.31607-2-alex.ben...@linaro.org>

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c254ac38d0..0779dab5b9 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -108,7 +108,6 @@ ifneq ($(HOST_ARCH),x86_64)
 DOCKER_PARTIAL_IMAGES += debian-mips-cross debian-mipsel-cross 
debian-mips64el-cross
 DOCKER_PARTIAL_IMAGES += debian-ppc64el-cross
 DOCKER_PARTIAL_IMAGES += debian-s390x-cross
-DOCKER_PARTIAL_IMAGES += debian-win32-cross debian-win64-cross
 DOCKER_PARTIAL_IMAGES += fedora travis
 endif
 
-- 
2.20.1




Re: [PATCH v2 10/12] Fix build with new yank feature by adding stubs

2021-01-14 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> On 1/14/21 5:57 PM, Alex Bennée wrote:
>> From: Lukas Straub 
>> 
>
> Again:
>
> Fixes: 50186051f42 ("Introduce yank feature")
>
> Reviewed-by: Philippe Mathieu-Daudé 

Hmm I need to improve my tooling to pick up the Fixes and add a TODO.

>
>> Signed-off-by: Lukas Straub 
>> [AJB: tweak MAINTAINERS]
>> Signed-off-by: Alex Bennée 
>> Message-Id: <20210114141918.5201c...@gecko.fritz.box>
>> ---
>>  stubs/yank.c  | 29 +
>>  MAINTAINERS   |  1 +
>>  stubs/meson.build |  1 +
>>  3 files changed, 31 insertions(+)
>>  create mode 100644 stubs/yank.c
>> 
>> diff --git a/stubs/yank.c b/stubs/yank.c
>> new file mode 100644
>> index 00..6090416065
>> --- /dev/null
>> +++ b/stubs/yank.c
>> @@ -0,0 +1,29 @@
>> +#include "qemu/osdep.h"
>> +#include "qemu/yank.h"
>> +
>> +bool yank_register_instance(const YankInstance *instance, Error **errp)
>> +{
>> +return true;
>> +}
>> +
>> +void yank_unregister_instance(const YankInstance *instance)
>> +{
>> +}
>> +
>> +void yank_register_function(const YankInstance *instance,
>> +YankFn *func,
>> +void *opaque)
>> +{
>> +}
>> +
>> +void yank_unregister_function(const YankInstance *instance,
>> +  YankFn *func,
>> +  void *opaque)
>> +{
>> +}
>> +
>> +void yank_generic_iochannel(void *opaque)
>> +{
>> +}
>> +
>> +
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index cb0656aec3..07e4851aa4 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -2736,6 +2736,7 @@ Yank feature
>>  M: Lukas Straub 
>>  S: Odd fixes
>>  F: util/yank.c
>> +F: stubs/yank.c
>>  F: include/qemu/yank.h
>>  F: qapi/yank.json
>>  
>> diff --git a/stubs/meson.build b/stubs/meson.build
>> index 80b1d81a31..1a656cd070 100644
>> --- a/stubs/meson.build
>> +++ b/stubs/meson.build
>> @@ -47,6 +47,7 @@ stub_ss.add(files('vm-stop.c'))
>>  stub_ss.add(files('win32-kbd-hook.c'))
>>  stub_ss.add(files('cpu-synchronize-state.c'))
>>  if have_block
>> +  stub_ss.add(files('yank.c'))
>>stub_ss.add(files('replay-tools.c'))
>>  endif
>>  if have_system
>> 


-- 
Alex Bennée



Re: Fwd: VirtioSound device emulation implementation

2021-01-14 Thread Alex Bennée


Shreyansh Chouhan  writes:

> Just an update:
>
> I've studied the virtio specification along with the source code and I now
> understand what the device implementation is
> going to look like. Also I understand the source code a lot better. I am
> now reading about the qemu vhost-user protocol.
>
> Although I haven't read about the vhost-user daemon in detail, from what
> little I have read, I would say that the daemon
> would get the virtqueues from the virtio device and forward it to the sound
> device of the host. (This is the hard part
> I think, since an in QEMU device would use code already written for
> processing these queues.)

I can't comment on the difficulty there but this does point more towards
using the in-QEMU approach given we have a bunch of utility functions already.

> I think only the tx and rx
> queues would be shared, and although I do not know exactly how the sharing
> will be implemented, I think the memory
> will be shared to the vhost-user daemon too? So now the virtqueue memory is
> shared between the virtio driver in guest
> OS, the virtio device in QEMU, and the vhost-user daemon running in the
> host userspace.

QEMU uses a memfd file descriptor to share the guests entire memory map
with the daemon.

> As for the configuration part, the driver will negotiate features with the
> virtio device in QEMU, which in turn will communicate
> with the vhost-user daemon (via sockets) to get the features supported I
> think.
>
> This is what I think it will roughly look like. (Of course modulo the
> implementation details.) I do not yet understand how
> much more difficult will implementing the vhost-user daemon be, and since I
> was already
> warned about the difficulty, I will not risk making any hasty decisions
> that later hinder the project. I will read up
> about the vhost-user daemon and how it's implemented to get a better idea,
> and then make the final call.

If you want to see an example of a branch new vhost-user daemon being
built up from scratch see my recent virtio-rpmb series. The first few
patches of in-QEMU code will be the same boilerplate either way I think:

  https://patchew.org/QEMU/20200925125147.26943-1-alex.ben...@linaro.org/

> Anyways I am super excited about the project. I got to learn about some
> really cool things in the past couple of days,
> and I can not wait to implement it. :)


-- 
Alex Bennée



[PATCH v2 09/12] gitlab: move docs and tools build across from Travis

2021-01-14 Thread Alex Bennée
While we are at it we might as well check the tag generation. For
bonus points we run GNU globals htags into the public pages directory
for publishing with the auto generated pages.

Signed-off-by: Alex Bennée 
Reviewed-by: Wainer dos Santos Moschetta 
Acked-by: Thomas Huth 

---
v2
  - explicit disable-system/user
  - add some comments, reduce size of HTML dump
---
 .gitlab-ci.yml | 28 ++--
 .travis.yml| 16 
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4532f1718a..bd60f3e741 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,7 +79,6 @@ build-system-ubuntu:
 TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
   moxie-softmmu microblazeel-softmmu mips64el-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -111,7 +110,6 @@ build-system-debian:
 TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
   riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -126,6 +124,17 @@ check-system-debian:
 IMAGE: debian-amd64
 MAKE_CHECK_ARGS: check
 
+build-tools-and-docs-debian:
+  <<: *native_build_job_definition
+  variables:
+IMAGE: debian-amd64
+MAKE_CHECK_ARGS: ctags TAGS cscope
+CONFIGURE_ARGS: --disable-system --disable-user --enable-docs 
--enable-tools
+  artifacts:
+expire_in: 2 days
+paths:
+  - build
+
 acceptance-system-debian:
   <<: *native_test_job_definition
   needs:
@@ -596,14 +605,21 @@ build-libvhost-user:
 - meson
 - ninja
 
+# Prepare for GitLab pages deployment. Anything copied into the
+# "public" directory will be deployed to $USER.gitlab.io/$PROJECT
 pages:
-  image: $CI_REGISTRY_IMAGE/qemu/ubuntu2004:latest
+  image: $CI_REGISTRY_IMAGE/qemu/debian-amd64:latest
   stage: test
   needs:
-- job: build-system-ubuntu
-  artifacts: true
+- job: build-tools-and-docs-debian
   script:
-- mkdir public
+- mkdir -p public
+# HTML-ised source tree
+- make gtags
+- htags -anT --tree-view=filetree -m qemu_init
+-t "Welcome to the QEMU sourcecode"
+- mv HTML public/src
+# Project documentation
 - mv build/docs/index.html public/
 - for i in devel interop specs system tools user ; do mv build/docs/$i 
public/ ; done
   artifacts:
diff --git a/.travis.yml b/.travis.yml
index f2a101936c..3b574a5968 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -148,22 +148,6 @@ jobs:
 - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
 
 
-# Check we can build docs and tools (out of tree)
-- name: "tools and docs (bionic)"
-  dist: bionic
-  env:
-- BUILD_DIR="out-of-tree/build/dir" SRC_DIR="../../.."
-- BASE_CONFIG="--enable-tools --enable-docs"
-- CONFIG="--target-list=x86_64-softmmu,aarch64-linux-user"
-- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
-  addons:
-apt:
-  packages:
-- ninja-build
-- python3-sphinx
-- perl
-
-
 # Test with Clang for compile portability (Travis uses clang-5.0)
 - name: "Clang (user)"
   env:
-- 
2.20.1




[PATCH v2 06/12] Makefile: wrap etags in quiet-command calls

2021-01-14 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index bbab640b31..f7e9eb9f08 100644
--- a/Makefile
+++ b/Makefile
@@ -272,8 +272,13 @@ gtags:
 
 .PHONY: TAGS
 TAGS:
-   rm -f "$(SRC_PATH)/"TAGS
-   $(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"TAGS,   \
+   "TAGS", "Remove old $@")
+   $(call quiet-command,   \
+   $(find-src-path) -exec etags\
+   -f "$(SRC_PATH)/"TAGS --append {} +,\
+   "TAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: cscope
 cscope:
-- 
2.20.1




[PATCH v2 04/12] Add newline when generating Dockerfile

2021-01-14 Thread Alex Bennée
From: Alessandro Di Federico 

Signed-off-by: Alessandro Di Federico 
Signed-off-by: Alex Bennée 
Message-Id: <1610080146-14968-36-git-send-email-tsimp...@quicinc.com>
---
 tests/docker/docker.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 36b7868406..884dfeb29c 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -332,9 +332,9 @@ class Docker(object):
  (uname, uid, uname))
 
 tmp_df.write("\n")
-tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" % (checksum))
+tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s\n" % (checksum))
 for f, c in extra_files_cksum:
-tmp_df.write("LABEL com.qemu.%s-checksum=%s" % (f, c))
+tmp_df.write("LABEL com.qemu.%s-checksum=%s\n" % (f, c))
 
 tmp_df.flush()
 
-- 
2.20.1




[PATCH v2 01/12] tests/docker: Remove Debian 9 remnant lines

2021-01-14 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

Debian 9 base container has been removed in commits
e3755276d1f and c9d78b06c06. Remove the last remnants.

Fixes: e3755276d1f ("tests/docker: Remove old Debian 9 containers")
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20210107072933.3828450-1-f4...@amsat.org>
Signed-off-by: Alex Bennée 
Reviewed-by: Thomas Huth 
---
 tests/docker/Makefile.include | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c254ac38d0..0779dab5b9 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -108,7 +108,6 @@ ifneq ($(HOST_ARCH),x86_64)
 DOCKER_PARTIAL_IMAGES += debian-mips-cross debian-mipsel-cross 
debian-mips64el-cross
 DOCKER_PARTIAL_IMAGES += debian-ppc64el-cross
 DOCKER_PARTIAL_IMAGES += debian-s390x-cross
-DOCKER_PARTIAL_IMAGES += debian-win32-cross debian-win64-cross
 DOCKER_PARTIAL_IMAGES += fedora travis
 endif
 
-- 
2.20.1




[PATCH v2 07/12] Makefile: wrap cscope in quiet-command calls

2021-01-14 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index f7e9eb9f08..2a926aaeb0 100644
--- a/Makefile
+++ b/Makefile
@@ -282,9 +282,17 @@ TAGS:
 
 .PHONY: cscope
 cscope:
-   rm -f "$(SRC_PATH)"/cscope.*
-   $(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
-   cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"cscope.* ,  \
+   "cscope", "Remove old $@ files")
+   $(call quiet-command,   \
+   ($(find-src-path) -print | sed -e 's,^\./,,'\
+   > "$(SRC_PATH)/cscope.files"),  \
+   "cscope", "Create file list")
+   $(call quiet-command,   \
+   cscope -b -i"$(SRC_PATH)/cscope.files"  \
+   -f"$(SRC_PATH)"/cscope.out, \
+   "cscope", "Re-index $(SRC_PATH)")
 
 # Needed by "meson install"
 export DESTDIR
-- 
2.20.1




[PATCH v2 11/12] gitlab: migrate the minimal tools and unit tests from Travis

2021-01-14 Thread Alex Bennée
These tests are good at shaking out missing stubs which otherwise work
if we have built targets. Rather than create a new job just add the
checks to the existing tools-and-docs build.

Signed-off-by: Alex Bennée 
---
 .gitlab-ci.yml | 4 +++-
 .travis.yml| 9 -
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bd60f3e741..a686bc40cf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -124,11 +124,13 @@ check-system-debian:
 IMAGE: debian-amd64
 MAKE_CHECK_ARGS: check
 
+# No targets are built here, just tools and docs. This also feeds into
+# the eventual documentation deployment steps later
 build-tools-and-docs-debian:
   <<: *native_build_job_definition
   variables:
 IMAGE: debian-amd64
-MAKE_CHECK_ARGS: ctags TAGS cscope
+MAKE_CHECK_ARGS: check-unit check-softfloat ctags TAGS cscope
 CONFIGURE_ARGS: --disable-system --disable-user --enable-docs 
--enable-tools
   artifacts:
 expire_in: 2 days
diff --git a/.travis.yml b/.travis.yml
index 3b574a5968..5f1dea873e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,15 +119,6 @@ after_script:
 
 jobs:
   include:
-# Just build tools and run minimal unit and softfloat checks
-- name: "GCC check-unit and check-softfloat"
-  env:
-- BASE_CONFIG="--enable-tools"
-- CONFIG="--disable-user --disable-system"
-- TEST_CMD="make check-unit check-softfloat -j${JOBS}"
-- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
-
-
 # --enable-debug implies --enable-debug-tcg, also runs quite a bit slower
 - name: "GCC debug (main-softmmu)"
   env:
-- 
2.20.1




[PATCH v2 08/12] docker: expand debian-amd64 image to include tag tools

2021-01-14 Thread Alex Bennée
This is going to be helpful when we want to both test the tool
integration and in the case of global generate a xref doc build.

Signed-off-by: Alex Bennée 
---
 tests/docker/dockerfiles/debian-amd64.docker | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/debian-amd64.docker 
b/tests/docker/dockerfiles/debian-amd64.docker
index 55075d9fce..a98314757d 100644
--- a/tests/docker/dockerfiles/debian-amd64.docker
+++ b/tests/docker/dockerfiles/debian-amd64.docker
@@ -1,7 +1,7 @@
 #
 # Docker x86_64 target
 #
-# This docker target builds on the debian Stretch base image. Further
+# This docker target builds on the Debian Buster base image. Further
 # libraries which are not widely available are installed by hand.
 #
 FROM qemu/debian10
@@ -14,7 +14,10 @@ RUN apt update && \
 RUN apt update && \
 DEBIAN_FRONTEND=noninteractive eatmydata \
 apt install -y --no-install-recommends \
+cscope \
 genisoimage \
+exuberant-ctags \
+global \
 libbz2-dev \
 liblzo2-dev \
 libgcrypt20-dev \
-- 
2.20.1




[PATCH v2 05/12] Makefile: wrap ctags in quiet-command calls

2021-01-14 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0c509a7704..bbab640b31 100644
--- a/Makefile
+++ b/Makefile
@@ -250,8 +250,13 @@ find-src-path = find "$(SRC_PATH)/" -path 
"$(SRC_PATH)/meson" -prune -o \( -name
 
 .PHONY: ctags
 ctags:
-   rm -f "$(SRC_PATH)/"tags
-   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"tags,   \
+   "CTAGS", "Remove old tags")
+   $(call quiet-command, \
+   $(find-src-path) -exec ctags\
+   -f "$(SRC_PATH)/"tags --append {} +,\
+   "CTAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: gtags
 gtags:
-- 
2.20.1




[PATCH v2 12/12] scripts/checkpatch.pl: fix git-show invocation to include diffstat

2021-01-14 Thread Alex Bennée
Without this checkpatch keeps complaining about new/changed files even
when MAINTAINERS has been updated. Normal invocations of checkpatch on
patch files rather than commit IDs are unaffected.

Signed-off-by: Alex Bennée 
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88c858f67c..e47ad878d8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -399,7 +399,7 @@ if ($chk_branch) {
my $num_patches = @patches;
for my $hash (@patches) {
my $FILE;
-   open($FILE, '-|', "git", "show", $hash) ||
+   open($FILE, '-|', "git", "show", "--patch-with-stat", $hash) ||
die "$P: git show $hash - $!\n";
while (<$FILE>) {
chomp;
-- 
2.20.1




[PATCH v2 02/12] Makefile: add GNU global tags support

2021-01-14 Thread Alex Bennée
GNU Global is another tags engine which is more like cscope in being
able to support finding both references and definitions. You will be
un-surprised to know it also integrates well with Emacs.

The main benefit of integrating it into find-src-path is it takes less
time to rebuild the database from scratch when you have a lot of build
directories under your source tree.

Signed-off-by: Alex Bennée 

---
v2
  - run in SRC_PATH
  - wrap in quiet-command
---
 Makefile   | 14 +-
 .gitignore |  3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index fb9923ff22..0c509a7704 100644
--- a/Makefile
+++ b/Makefile
@@ -253,6 +253,18 @@ ctags:
rm -f "$(SRC_PATH)/"tags
$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
 
+.PHONY: gtags
+gtags:
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"GTAGS;  \
+   rm -f "$(SRC_PATH)/"GRTAGS; \
+   rm -f "$(SRC_PATH)/"GPATH,  \
+   "GTAGS", "Remove old $@ files")
+   $(call quiet-command,   \
+   (cd $(SRC_PATH) &&  \
+$(find-src-path) | gtags -f -),\
+   "GTAGS", "Re-index $(SRC_PATH)")
+
 .PHONY: TAGS
 TAGS:
rm -f "$(SRC_PATH)/"TAGS
@@ -279,7 +291,7 @@ help:
$(call print-help,all,Build all)
$(call print-help,dir/file.o,Build specified target only)
$(call print-help,install,Install QEMU, documentation and tools)
-   $(call print-help,ctags/TAGS,Generate tags file for editors)
+   $(call print-help,ctags/gtags/TAGS,Generate tags file for editors)
$(call print-help,cscope,Generate cscope index)
$(call print-help,sparse,Run sparse on the QEMU source)
@echo  ''
diff --git a/.gitignore b/.gitignore
index b32bca1315..75a4be0724 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,9 @@
 cscope.*
 tags
 TAGS
+GPATH
+GRTAGS
+GTAGS
 *~
 *.ast_raw
 *.depend_raw
-- 
2.20.1




[PATCH v2 10/12] Fix build with new yank feature by adding stubs

2021-01-14 Thread Alex Bennée
From: Lukas Straub 

Signed-off-by: Lukas Straub 
[AJB: tweak MAINTAINERS]
Signed-off-by: Alex Bennée 
Message-Id: <20210114141918.5201c...@gecko.fritz.box>
---
 stubs/yank.c  | 29 +
 MAINTAINERS   |  1 +
 stubs/meson.build |  1 +
 3 files changed, 31 insertions(+)
 create mode 100644 stubs/yank.c

diff --git a/stubs/yank.c b/stubs/yank.c
new file mode 100644
index 00..6090416065
--- /dev/null
+++ b/stubs/yank.c
@@ -0,0 +1,29 @@
+#include "qemu/osdep.h"
+#include "qemu/yank.h"
+
+bool yank_register_instance(const YankInstance *instance, Error **errp)
+{
+return true;
+}
+
+void yank_unregister_instance(const YankInstance *instance)
+{
+}
+
+void yank_register_function(const YankInstance *instance,
+YankFn *func,
+void *opaque)
+{
+}
+
+void yank_unregister_function(const YankInstance *instance,
+  YankFn *func,
+  void *opaque)
+{
+}
+
+void yank_generic_iochannel(void *opaque)
+{
+}
+
+
diff --git a/MAINTAINERS b/MAINTAINERS
index cb0656aec3..07e4851aa4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2736,6 +2736,7 @@ Yank feature
 M: Lukas Straub 
 S: Odd fixes
 F: util/yank.c
+F: stubs/yank.c
 F: include/qemu/yank.h
 F: qapi/yank.json
 
diff --git a/stubs/meson.build b/stubs/meson.build
index 80b1d81a31..1a656cd070 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -47,6 +47,7 @@ stub_ss.add(files('vm-stop.c'))
 stub_ss.add(files('win32-kbd-hook.c'))
 stub_ss.add(files('cpu-synchronize-state.c'))
 if have_block
+  stub_ss.add(files('yank.c'))
   stub_ss.add(files('replay-tools.c'))
 endif
 if have_system
-- 
2.20.1




[PATCH v2 00/12] testing/next (tags!, shippable/travis deprecation, regression fixes, checkpatch)

2021-01-14 Thread Alex Bennée
Hi,

The main changes from v1:

  https://patchew.org/QEMU/20210113151408.27939-1-alex.ben...@linaro.org/

 - squeeze the size of the htags generation to fit pages
 - move one more job from Travis
 - include regression fix for yank
 - fix a problem with checkpatch and commit ids

The following need review:

 - scripts/checkpatch.pl: fix git-show invocation to include diffstat
 - gitlab: migrate the minimal tools and unit tests from Travis
 - docker: expand debian-amd64 image to include tag tools
 - Makefile: wrap cscope in quiet-command calls
 - Makefile: wrap etags in quiet-command calls
 - Makefile: wrap ctags in quiet-command calls
 - Makefile: add GNU global tags support

Alessandro Di Federico (1):
  Add newline when generating Dockerfile

Alex Bennée (8):
  Makefile: add GNU global tags support
  Makefile: wrap ctags in quiet-command calls
  Makefile: wrap etags in quiet-command calls
  Makefile: wrap cscope in quiet-command calls
  docker: expand debian-amd64 image to include tag tools
  gitlab: move docs and tools build across from Travis
  gitlab: migrate the minimal tools and unit tests from Travis
  scripts/checkpatch.pl: fix git-show invocation to include diffstat

Lukas Straub (1):
  Fix build with new yank feature by adding stubs

Philippe Mathieu-Daudé (2):
  tests/docker: Remove Debian 9 remnant lines
  shippable.yml: Remove jobs duplicated on Gitlab-CI

 Makefile | 46 
 stubs/yank.c | 29 
 .gitignore   |  3 ++
 .gitlab-ci.yml   | 30 ++---
 .shippable.yml   | 14 +-
 .travis.yml  | 25 ---
 MAINTAINERS  |  1 +
 scripts/checkpatch.pl|  2 +-
 stubs/meson.build|  1 +
 tests/docker/Makefile.include|  1 -
 tests/docker/docker.py   |  4 +-
 tests/docker/dockerfiles/debian-amd64.docker |  5 ++-
 12 files changed, 104 insertions(+), 57 deletions(-)
 create mode 100644 stubs/yank.c

-- 
2.20.1




[PATCH v2 03/12] shippable.yml: Remove jobs duplicated on Gitlab-CI

2021-01-14 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

The following jobs are duplicated on Gitlab-CI since commit
6bcb5fc0f7a ("gitlab-ci: Add cross-compiling build tests"):

- IMAGE=debian-armel-cross

  TARGET_LIST=arm-softmmu   -> cross-armel-system
  TARGET_LIST=arm-linux-user-> cross-armel-user
  TARGET_LIST=armeb-linux-user  -> cross-armel-user

- IMAGE=debian-armhf-cross

  TARGET_LIST=arm-softmmu   -> cross-armhf-system
  TARGET_LIST=arm-linux-user-> cross-armhf-user
  TARGET_LIST=armeb-linux-user  -> cross-armhf-user

- IMAGE=debian-arm64-cross

  TARGET_LIST=aarch64-softmmu   -> cross-arm64-system
  TARGET_LIST=aarch64-linux-user-> cross-arm64-user

- IMAGE=debian-s390x-cross

  TARGET_LIST=s390x-softmmu -> cross-s390x-system
  TARGET_LIST=s390x-linux-user  -> cross-s390x-user

- IMAGE=debian-mips-cross

  TARGET_LIST=mipsel-linux-user -> cross-mips-user

- IMAGE=debian-mips64el-cross

  TARGET_LIST=mips64el-softmmu  -> cross-mips64el-system
  TARGET_LIST=mips64el-linux-user   -> cross-mips64el-user

- IMAGE=debian-ppc64el-cross

  TARGET_LIST=ppc64-softmmu -> cross-ppc64el-system
  TARGET_LIST=ppc64-linux-user  -> cross-ppc64el-user
  TARGET_LIST=ppc64abi32-linux-user -> cross-ppc64el-user

Remove them from Shippable CI.

Signed-off-by: Philippe Mathieu-Daudé 
Acked-by: Alex Bennée 
Message-Id: <20210108145103.269353-1-f4...@amsat.org>
Signed-off-by: Alex Bennée 
---
 .shippable.yml | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/.shippable.yml b/.shippable.yml
index 14350e6de8..97bfa2a0f3 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -7,20 +7,8 @@ env:
   matrix:
 - IMAGE=debian-amd64
   TARGET_LIST=x86_64-softmmu,x86_64-linux-user
-- IMAGE=debian-armel-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-armhf-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-arm64-cross
-  TARGET_LIST=aarch64-softmmu,aarch64-linux-user
-- IMAGE=debian-s390x-cross
-  TARGET_LIST=s390x-softmmu,s390x-linux-user
 - IMAGE=debian-mips-cross
-  TARGET_LIST=mips-softmmu,mipsel-linux-user
-- IMAGE=debian-mips64el-cross
-  TARGET_LIST=mips64el-softmmu,mips64el-linux-user
-- IMAGE=debian-ppc64el-cross
-  TARGET_LIST=ppc64-softmmu,ppc64-linux-user,ppc64abi32-linux-user
+  TARGET_LIST=mips-softmmu
 build:
   pre_ci_boot:
 image_name: registry.gitlab.com/qemu-project/qemu/qemu/${IMAGE}
-- 
2.20.1




Re: [PATCH] Fix build with new yank feature by adding stubs

2021-01-14 Thread Alex Bennée


Lukas Straub  writes:

> Signed-off-by: Lukas Straub 

Tested-by: Alex Bennée 
Reviewed-by: Alex Bennée 


I'm also going to pull this into my testing/next as I need the fix as a
prerequisite.

> ---
>  stubs/meson.build |  1 +
>  stubs/yank.c  | 29 +
>  2 files changed, 30 insertions(+)
>  create mode 100644 stubs/yank.c
>
> diff --git a/stubs/meson.build b/stubs/meson.build
> index 80b1d81a31..1a656cd070 100644
> --- a/stubs/meson.build
> +++ b/stubs/meson.build
> @@ -47,6 +47,7 @@ stub_ss.add(files('vm-stop.c'))
>  stub_ss.add(files('win32-kbd-hook.c'))
>  stub_ss.add(files('cpu-synchronize-state.c'))
>  if have_block
> +  stub_ss.add(files('yank.c'))
>stub_ss.add(files('replay-tools.c'))
>  endif
>  if have_system
> diff --git a/stubs/yank.c b/stubs/yank.c
> new file mode 100644
> index 00..6090416065
> --- /dev/null
> +++ b/stubs/yank.c
> @@ -0,0 +1,29 @@
> +#include "qemu/osdep.h"
> +#include "qemu/yank.h"
> +
> +bool yank_register_instance(const YankInstance *instance, Error **errp)
> +{
> +return true;
> +}
> +
> +void yank_unregister_instance(const YankInstance *instance)
> +{
> +}
> +
> +void yank_register_function(const YankInstance *instance,
> +YankFn *func,
> +void *opaque)
> +{
> +}
> +
> +void yank_unregister_function(const YankInstance *instance,
> +      YankFn *func,
> +  void *opaque)
> +{
> +}
> +
> +void yank_generic_iochannel(void *opaque)
> +{
> +}
> +
> +


-- 
Alex Bennée



Re: [qemu-web PATCH v2] Use GitLab repo URLs instead of git.qemu.org URLs

2021-01-14 Thread Alex Bennée


Stefan Hajnoczi  writes:

> Switch to GitLab repo URLs to reduce qemu.org bandwidth.
>
> Signed-off-by: Stefan Hajnoczi 

Reviewed-by: Alex Bennée 

> ---
> v2:
>  * Added missing URL in _posts/2018-06-28-tcg-testing.md. Mark
>Cave-Ayland  and Alex Bennée
> figured out the issue was that the gitweb
>link referenced a blob object (not a commit) whereas GitLab needs the
>commit object. Therefore the hash hash in the URL has changed.
> ---
>  _download/source.html   | 4 ++--
>  _posts/2017-02-04-the-new-qemu-website-is-up.md | 8 
>  _posts/2017-10-04-qemu-2-10-1.md| 4 ++--
>  _posts/2018-02-09-understanding-qemu-devices.md | 2 +-
>  _posts/2018-06-28-tcg-testing.md| 4 ++--
>  contribute.md   | 2 +-
>  contribute/security-process.md  | 4 ++--
>  documentation.md| 2 +-
>  support.md  | 2 +-
>  9 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/_download/source.html b/_download/source.html
> index 5798633..14fb6dc 100644
> --- a/_download/source.html
> +++ b/_download/source.html
> @@ -9,7 +9,7 @@
>   {% include releases.html %}
>   
>   or stay on the bleeding edge with the
> -https://git.qemu.org/?p=qemu.git;>git repository!
> +https://gitlab.com/qemu-project/qemu.git;>git 
> repository!
>  
>   Build instructions
>  
> @@ -24,7 +24,7 @@ make
>   {% endfor %}
>  
>   To download and build QEMU from git:
> -git clone https://git.qemu.org/git/qemu.git
> +git clone https://gitlab.com/qemu-project/qemu.git
>  cd qemu
>  git submodule init
>  git submodule update --recursive
> diff --git a/_posts/2017-02-04-the-new-qemu-website-is-up.md 
> b/_posts/2017-02-04-the-new-qemu-website-is-up.md
> index b9455a0..e7ed349 100644
> --- a/_posts/2017-02-04-the-new-qemu-website-is-up.md
> +++ b/_posts/2017-02-04-the-new-qemu-website-is-up.md
> @@ -15,7 +15,7 @@ developers to share information quickly with the rest of 
> the community.
>  We tried to test the website on most browsers and to make it lightweight
>  and responsive.  It is built using [Jekyll](https://jekyllrb.com/)
>  and the source code for the website can be cloned from the
> -[qemu-web.git](https://git.qemu.org/?p=qemu-web.git;a=summary)
> +[qemu-web.git](https://gitlab.com/qemu-project/qemu-web.git)
>  repository.  Just like for any other project hosted by QEMU, the best way
>  to propose or contribute a new change is by sending a patch through the
>  [qemu-devel@nongnu.org](https://lists.nongnu.org/mailman/listinfo/qemu-devel)
> @@ -25,10 +25,10 @@ confuse it with a qemu.git patch (if you run `git config 
> format.subjectprefix
>  
>  For example, if you would like to add a new screenshot to the homepage,
>  you can clone the `qemu-web.git` repository, add a PNG file to the
> -[`screenshots/`](https://git.qemu.org/?p=qemu-web.git;a=tree;f=screenshots;hb=HEAD)
> -directory, and edit the 
> [`_data/screenshots.yml`](https://git.qemu.org/?p=qemu-web.git;a=blob;f=_data/screenshots.yml;hb=HEAD)
> +[`screenshots/`](https://gitlab.com/qemu-project/qemu-web/-/tree/master/screenshots)
> +directory, and edit the 
> [`_data/screenshots.yml`](https://gitlab.com/qemu-project/qemu-web/-/tree/master/_data/screenshots.yml)
>  file to include the new screenshot.
>  
>  Blog posts about QEMU are also welcome; they are simple HTML or Markdown
> -files and are stored in the 
> [`_posts/`](https://git.qemu.org/?p=qemu-web.git;a=tree;f=_posts;hb=HEAD)
> +files and are stored in the 
> [`_posts/`](https://gitlab.com/qemu-project/qemu-web/-/tree/master/_posts)
>  directory of the repository.
> diff --git a/_posts/2017-10-04-qemu-2-10-1.md 
> b/_posts/2017-10-04-qemu-2-10-1.md
> index 6fa00fa..f20adce 100644
> --- a/_posts/2017-10-04-qemu-2-10-1.md
> +++ b/_posts/2017-10-04-qemu-2-10-1.md
> @@ -9,9 +9,9 @@ is now available! You can grab the tarball from our
>  [download page](https://www.qemu.org/download/#source).
>  
>  Version 2.10.1 is now tagged in the official
> -[qemu.git repository](https://git.qemu.org/?p=qemu.git;a=shortlog;h=v2.10.1)
> +[qemu.git 
> repository](https://gitlab.com/qemu-project/qemu/-/commits/v2.10.1/)
>  (where you can also find the changelog with details), and the
> -[stable-2.10 
> branch](https://git.qemu.org/?p=qemu.git;a=shortlog;h=refs/heads/stable-2.10)
> +[stable-2.10 
> branch](https://gitlab.com/qemu-project/qemu/-/commits/stable-2.10)
>  has been updated accordingly.
>  
>  Apart from the normal range of general fixes, this update contains security
> diff --git a/_posts/2018-02-09-understan

Re: [PULL 0/7] Yank patches patches for 2021-01-13

2021-01-14 Thread Alex Bennée


Peter Maydell  writes:

> On Wed, 13 Jan 2021 at 09:31, Markus Armbruster  wrote:
>>
>> This pull request is on behalf of Lukas.  Hope that's okay.
>>
>> The following changes since commit f8e1d8852e393b3fd524fb005e38590063d99bc0:
>>
>>   Merge remote-tracking branch 
>> 'remotes/pmaydell/tags/pull-target-arm-20210112-1' into staging (2021-01-12 
>> 21:23:25 +)
>>
>> are available in the Git repository at:
>>
>>   git://repo.or.cz/qemu/armbru.git tags/pull-yank-2021-01-13
>>
>> for you to fetch changes up to 91d48e520a4a4f72e97aeb333029694f5d57cc93:
>>
>>   tests/test-char.c: Wait for the chardev to connect in 
>> char_socket_client_dupid_test (2021-01-13 10:21:17 +0100)
>>
>> 
>> Yank patches patches for 2021-01-13
>>
>> 
>> Lukas Straub (7):
>>   Introduce yank feature
>>   block/nbd.c: Add yank feature
>>   chardev/char-socket.c: Add yank feature
>>   migration: Add yank feature
>>   io/channel-tls.c: make qio_channel_tls_shutdown thread-safe
>>   io: Document qmp oob suitability of qio_channel_shutdown and 
>> io_shutdown
>>   tests/test-char.c: Wait for the chardev to connect in 
>> char_socket_client_dupid_test
>
>
> Applied, thanks.

This broke the check-unit and check-softfloat build task in Travis

  https://travis-ci.org/github/qemu/qemu/jobs/754436018

Likely because of missing stubs for the yank commands:

  FAILED: qemu-io 

  gcc  -o qemu-io qemu-io.p/qemu-io.c.o -Wl,--as-needed -Wl,--no-undefined -pie 
-Wl,--whole-archive libblock.fa libcrypto.fa libauthz.fa libqom.fa libio.fa 
-Wl,--no-whole-archive -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -m64 
-fstack-protector-strong -Wl,--start-group libqemuutil.a 
subprojects/libvhost-user/libvhost-user-glib.a 
subprojects/libvhost-user/libvhost-user.a libblock.fa libcrypto.fa libauthz.fa 
libqom.fa libio.fa @block.syms -lgnutls -pthread -lutil -lm -lgthread-2.0 
-lglib-2.0 -lgthread-2.0 -lglib-2.0 -lxml2 
/usr/lib/x86_64-linux-gnu/libiscsi.so -laio -lgthread-2.0 -lglib-2.0 
/usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libnfs.so 
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libzstd.so -lssh 
/usr/lib/x86_64-linux-gnu/libcurl.so 
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libbz2.so -lgnutls 
-lnettle -lgnutls -lpam -lgnutls -Wl,--end-group

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_close':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:2358: undefined reference 
to `yank_unregister_instance'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_client_handshake':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:1879: undefined reference 
to `yank_unregister_function'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_reconnect_attempt':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:605: undefined reference to 
`yank_unregister_function'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function 
`nbd_co_establish_connection':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:453: undefined reference to 
`yank_register_function'

  /usr/bin/ld: /home/travis/build/qemu/qemu/build/../block/nbd.c:491: undefined 
reference to `yank_register_function'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_connection_entry':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:765: undefined reference to 
`yank_unregister_function'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_open':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:2283: undefined reference 
to `yank_register_instance'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function 
`nbd_establish_connection':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:1799: undefined reference 
to `yank_register_function'

  /usr/bin/ld: libblock.fa(block_nbd.c.o): in function `nbd_open':

  /home/travis/build/qemu/qemu/build/../block/nbd.c:2298: undefined reference 
to `yank_unregister_instance'

  /usr/bin/ld: /home/travis/build/qemu/qemu/build/../block/nbd.c:2292: 
undefined reference to `yank_unregister_instance'

  collect2: error: ld returned 1 exit status

>
> Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
> for any user-visible changes.
>
> -- PMM


-- 
Alex Bennée



Re: [PATCH] docs/devel: Explain how acceptance tests can be skipped

2021-01-14 Thread Alex Bennée


Thomas Huth  writes:

> On 13/01/2021 20.52, Wainer dos Santos Moschetta wrote:
>> Documented under the "Acceptance tests using the Avocado Framework"
>> section in testing.rst how environment variables are used to skip tests.
>> 
>> Signed-off-by: Wainer dos Santos Moschetta 
>> ---
>> CI (success): https://gitlab.com/wainersm/qemu/-/pipelines/241249714
>> 
>>   docs/devel/testing.rst | 62 ++
>>   1 file changed, 62 insertions(+)
>> 
>> diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
>> index 0aa7a13bba..3cdb458565 100644
>> --- a/docs/devel/testing.rst
>> +++ b/docs/devel/testing.rst
>> @@ -871,6 +871,68 @@ qemu_bin
>>   
>>   The exact QEMU binary to be used on QEMUMachine.
>>   
>> +Skipping tests
>> +--
>> +The Avocado framework provides Python decorators which allow for easily skip
>> +tests running under certain conditions. For example, on the lack of a binary
>> +on the test system or when the running environment is an CI system. For 
>> further
>
> s/is an CI/is a CI/
>
>> +information about those decorators, please refer to::
>> +
>> +  
>> https://avocado-framework.readthedocs.io/en/latest/guides/writer/chapters/writing.html#skipping-tests
>> +
>> +While the conditions for skipping tests are often specifics of each one, 
>> there
>> +are recurring scenarios identified by the QEMU developers and the use of
>> +environment variables became a kind of standard way to enable/disable tests.
>> +
>> +It follows a not comprehensive list of those variables.
>
> s/It follows a/Here is a/ ?

There now follows a non-comprehensive list of those variables:

?

I'm not sure if that is idiomatic international English or just British
English - it's usually a phrase that precedes our party political
broadcasts on TV ;-)

>
>> +AVOCADO_ALLOW_LARGE_STORAGE
>> +~~~
>> +Tests which are going to fetch or produce assets considered *large* are not
>> +going to run unless that `AVOCADO_ALLOW_LARGE_STORAGE=1` is exported on
>> +the environment.
>> +
>> +The definition of *large* is a bit arbitrary here, but it usually means an
>> +asset which occupies at least 1GB of size on disk when uncompressed.
>> +
>> +AVOCADO_ALLOW_UNTRUSTED_CODE
>> +
>> +There are tests which will boot a kernel image or firmware that can be
>> +considered not safe to run on the developer's workstation, thus they are
>> +skipped by default. The definition of *not safe* is also arbitrary but
>> +usually it means a blob which either its source or build process aren't
>> +public available.
>> +
>> +You should export `AVOCADO_ALLOW_UNTRUSTED_CODE=1` on the environment in
>> +order to allow tests which make use of those assets to get running.
>
> maybe better: "... which make use of those kind of assets." ?
>
>> +AVOCADO_TIMEOUT_EXPECTED
>> +
>> +The Avocado framework has a timeout mechanism which interrupt tests to 
>> avoid the
>
> s/interrupt/interrupts/
>
>> +test suite of getting stuck. The timeout value can be set via test 
>> parameter or
>> +property defined in the test class, for further details::
>> +
>> +  
>> https://avocado-framework.readthedocs.io/en/latest/guides/writer/chapters/writing.html#setting-a-test-timeout
>> +
>> +Even though the timeout can be set by the test developer, there are some 
>> tests
>> +that may not have a well-defined limit of time to finish under certain
>> +conditions. For example, tests that take longer to execute when QEMU is
>> +compiled with debug flags. Therefore, the `AVOCADO_TIMEOUT_EXPECTED` 
>> variable
>> +has been used to determine whether those tests should run or not.
>> +
>> +GITLAB_CI
>> +~
>> +A number of tests are flagged to not run on the GitLab CI. Usually because
>> +they proved to the flaky or there are constraints on the CI environment 
>> which
>> +would make them fail. If you encounter a similar situation then use that
>> +variable as shown on the code snippet below to skip the test:
>> +
>> +.. code::
>> +
>> +  @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +  def test(self):
>> +  do_something()
>> +
>>   Uninstalling Avocado
>>   
>>   
>
>   Thomas


-- 
Alex Bennée



Re: [qemu-web PATCH] Use GitLab repo URLs instead of git.qemu.org URLs

2021-01-13 Thread Alex Bennée
rg) contains more
> diff --git a/support.md b/support.md
> index 031f045..49cbb0f 100644
> --- a/support.md
> +++ b/support.md
> @@ -12,7 +12,7 @@ rest of your Linux distribution you may be better served by 
> asking
>  through your distribution's support channels. This includes questions
>  about a specifically packaged version of QEMU. The QEMU developers are
>  generally concerned with the latest release and the current state of
> -the [master branch](https://git.qemu.org/?p=qemu.git) and do not
> +the [master branch](https://gitlab.com/qemu-project/qemu.git) and do not
>  provide support for QEMU binaries shipped by Linux distributions.
>  
>  Questions about complex configurations of networking and storage are


-- 
Alex Bennée



Re: [PATCH v1 9/9] gitlab: move docs and tools build across from Travis

2021-01-13 Thread Alex Bennée


Daniel P. Berrangé  writes:

> On Wed, Jan 13, 2021 at 03:14:08PM +0000, Alex Bennée wrote:
>> While we are at it we might as well check the tag generation. For
>> bonus points we run GNU globals htags into the public pages directory
>> for publishing with the auto generated pages.
>> 
>> Signed-off-by: Alex Bennée 
>> ---
>>  .gitlab-ci.yml | 22 --
>>  .travis.yml| 16 
>>  2 files changed, 16 insertions(+), 22 deletions(-)
>> 
>> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
>> index 4532f1718a..c07064a4f7 100644
>> --- a/.gitlab-ci.yml
>> +++ b/.gitlab-ci.yml
>> @@ -79,7 +79,6 @@ build-system-ubuntu:
>>  TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
>>moxie-softmmu microblazeel-softmmu mips64el-softmmu
>>  MAKE_CHECK_ARGS: check-build
>> -CONFIGURE_ARGS: --enable-docs
>>artifacts:
>>  expire_in: 2 days
>>  paths:
>> @@ -111,7 +110,6 @@ build-system-debian:
>>  TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
>>riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
>>  MAKE_CHECK_ARGS: check-build
>> -CONFIGURE_ARGS: --enable-docs
>>artifacts:
>>  expire_in: 2 days
>>  paths:
>> @@ -126,6 +124,17 @@ check-system-debian:
>>  IMAGE: debian-amd64
>>  MAKE_CHECK_ARGS: check
>>  
>> +build-tools-and-docs-debian:
>> +  <<: *native_build_job_definition
>> +  variables:
>> +IMAGE: debian-amd64
>> +MAKE_CHECK_ARGS: ctags gtags TAGS cscope
>> +CONFIGURE_ARGS: --enable-docs --enable-tools
>> +  artifacts:
>> +expire_in: 2 days
>> +paths:
>> +  - build
>
> Do we actually need this job at all ?
>
> Assuming the depenedancies are in the dockerfile, then all the
> build jobs will be testing docs and tools already, as meson will
> auto enable it.

I pondered making an explicit --disable-docs to save some run time but
really this is providing a golden build of the docs which can tehn be
deployed by pages.

It also ensure the tag generation works for the various tag outputs -
the GNU global output being used to also publish a HTML navigable
version of the source tree.

>
> Regards,
> Daniel


-- 
Alex Bennée



[PATCH v1 5/9] Makefile: wrap ctags in quiet-command calls

2021-01-13 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0c509a7704..bbab640b31 100644
--- a/Makefile
+++ b/Makefile
@@ -250,8 +250,13 @@ find-src-path = find "$(SRC_PATH)/" -path 
"$(SRC_PATH)/meson" -prune -o \( -name
 
 .PHONY: ctags
 ctags:
-   rm -f "$(SRC_PATH)/"tags
-   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"tags,   \
+   "CTAGS", "Remove old tags")
+   $(call quiet-command, \
+   $(find-src-path) -exec ctags\
+   -f "$(SRC_PATH)/"tags --append {} +,\
+   "CTAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: gtags
 gtags:
-- 
2.20.1




[PATCH v1 4/9] Add newline when generating Dockerfile

2021-01-13 Thread Alex Bennée
From: Alessandro Di Federico 

Signed-off-by: Alessandro Di Federico 
Message-Id: <1610080146-14968-36-git-send-email-tsimp...@quicinc.com>
---
 tests/docker/docker.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 36b7868406..884dfeb29c 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -332,9 +332,9 @@ class Docker(object):
  (uname, uid, uname))
 
 tmp_df.write("\n")
-tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" % (checksum))
+tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s\n" % (checksum))
 for f, c in extra_files_cksum:
-tmp_df.write("LABEL com.qemu.%s-checksum=%s" % (f, c))
+tmp_df.write("LABEL com.qemu.%s-checksum=%s\n" % (f, c))
 
 tmp_df.flush()
 
-- 
2.20.1




[PATCH v1 9/9] gitlab: move docs and tools build across from Travis

2021-01-13 Thread Alex Bennée
While we are at it we might as well check the tag generation. For
bonus points we run GNU globals htags into the public pages directory
for publishing with the auto generated pages.

Signed-off-by: Alex Bennée 
---
 .gitlab-ci.yml | 22 --
 .travis.yml| 16 
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4532f1718a..c07064a4f7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,7 +79,6 @@ build-system-ubuntu:
 TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
   moxie-softmmu microblazeel-softmmu mips64el-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -111,7 +110,6 @@ build-system-debian:
 TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
   riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
 MAKE_CHECK_ARGS: check-build
-CONFIGURE_ARGS: --enable-docs
   artifacts:
 expire_in: 2 days
 paths:
@@ -126,6 +124,17 @@ check-system-debian:
 IMAGE: debian-amd64
 MAKE_CHECK_ARGS: check
 
+build-tools-and-docs-debian:
+  <<: *native_build_job_definition
+  variables:
+IMAGE: debian-amd64
+MAKE_CHECK_ARGS: ctags gtags TAGS cscope
+CONFIGURE_ARGS: --enable-docs --enable-tools
+  artifacts:
+expire_in: 2 days
+paths:
+  - build
+
 acceptance-system-debian:
   <<: *native_test_job_definition
   needs:
@@ -597,13 +606,14 @@ build-libvhost-user:
 - ninja
 
 pages:
-  image: $CI_REGISTRY_IMAGE/qemu/ubuntu2004:latest
+  image: $CI_REGISTRY_IMAGE/qemu/debian-amd64:latest
   stage: test
   needs:
-- job: build-system-ubuntu
-  artifacts: true
+- job: build-tools-and-docs-debian
   script:
-- mkdir public
+- mkdir -p public/src
+- htags --suggest --tree-view=filetree -m qemu_init
+-t "Welcome to the QEMU source code" public/src
 - mv build/docs/index.html public/
 - for i in devel interop specs system tools user ; do mv build/docs/$i 
public/ ; done
   artifacts:
diff --git a/.travis.yml b/.travis.yml
index f2a101936c..3b574a5968 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -148,22 +148,6 @@ jobs:
 - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
 
 
-# Check we can build docs and tools (out of tree)
-- name: "tools and docs (bionic)"
-  dist: bionic
-  env:
-- BUILD_DIR="out-of-tree/build/dir" SRC_DIR="../../.."
-- BASE_CONFIG="--enable-tools --enable-docs"
-- CONFIG="--target-list=x86_64-softmmu,aarch64-linux-user"
-- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"
-  addons:
-apt:
-  packages:
-- ninja-build
-- python3-sphinx
-- perl
-
-
 # Test with Clang for compile portability (Travis uses clang-5.0)
 - name: "Clang (user)"
   env:
-- 
2.20.1




[PATCH v1 6/9] Makefile: wrap etags in quiet-command calls

2021-01-13 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index bbab640b31..f7e9eb9f08 100644
--- a/Makefile
+++ b/Makefile
@@ -272,8 +272,13 @@ gtags:
 
 .PHONY: TAGS
 TAGS:
-   rm -f "$(SRC_PATH)/"TAGS
-   $(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"TAGS,   \
+   "TAGS", "Remove old $@")
+   $(call quiet-command,   \
+   $(find-src-path) -exec etags\
+   -f "$(SRC_PATH)/"TAGS --append {} +,\
+   "TAGS", "Re-index $(SRC_PATH)")
 
 .PHONY: cscope
 cscope:
-- 
2.20.1




[PATCH v1 2/9] Makefile: add GNU global tags support

2021-01-13 Thread Alex Bennée
GNU Global is another tags engine which is more like cscope in being
able to support finding both references and definitions. You will be
un-surprised to know it also integrates well with Emacs.

The main benefit of integrating it into find-src-path is it takes less
time to rebuild the database from scratch when you have a lot of build
directories under your source tree.

Signed-off-by: Alex Bennée 

---
v2
  - run in SRC_PATH
  - wrap in quiet-command
---
 Makefile   | 14 +-
 .gitignore |  3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index fb9923ff22..0c509a7704 100644
--- a/Makefile
+++ b/Makefile
@@ -253,6 +253,18 @@ ctags:
rm -f "$(SRC_PATH)/"tags
$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
 
+.PHONY: gtags
+gtags:
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"GTAGS;  \
+   rm -f "$(SRC_PATH)/"GRTAGS; \
+   rm -f "$(SRC_PATH)/"GPATH,  \
+   "GTAGS", "Remove old $@ files")
+   $(call quiet-command,   \
+   (cd $(SRC_PATH) &&  \
+$(find-src-path) | gtags -f -),\
+   "GTAGS", "Re-index $(SRC_PATH)")
+
 .PHONY: TAGS
 TAGS:
rm -f "$(SRC_PATH)/"TAGS
@@ -279,7 +291,7 @@ help:
$(call print-help,all,Build all)
$(call print-help,dir/file.o,Build specified target only)
$(call print-help,install,Install QEMU, documentation and tools)
-   $(call print-help,ctags/TAGS,Generate tags file for editors)
+   $(call print-help,ctags/gtags/TAGS,Generate tags file for editors)
$(call print-help,cscope,Generate cscope index)
$(call print-help,sparse,Run sparse on the QEMU source)
@echo  ''
diff --git a/.gitignore b/.gitignore
index b32bca1315..75a4be0724 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,9 @@
 cscope.*
 tags
 TAGS
+GPATH
+GRTAGS
+GTAGS
 *~
 *.ast_raw
 *.depend_raw
-- 
2.20.1




[PATCH v1 7/9] Makefile: wrap cscope in quiet-command calls

2021-01-13 Thread Alex Bennée
For prettier output.

Signed-off-by: Alex Bennée 
---
 Makefile | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index f7e9eb9f08..2a926aaeb0 100644
--- a/Makefile
+++ b/Makefile
@@ -282,9 +282,17 @@ TAGS:
 
 .PHONY: cscope
 cscope:
-   rm -f "$(SRC_PATH)"/cscope.*
-   $(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
-   cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
+   $(call quiet-command,   \
+   rm -f "$(SRC_PATH)/"cscope.* ,  \
+   "cscope", "Remove old $@ files")
+   $(call quiet-command,   \
+   ($(find-src-path) -print | sed -e 's,^\./,,'\
+   > "$(SRC_PATH)/cscope.files"),  \
+   "cscope", "Create file list")
+   $(call quiet-command,   \
+   cscope -b -i"$(SRC_PATH)/cscope.files"  \
+   -f"$(SRC_PATH)"/cscope.out, \
+   "cscope", "Re-index $(SRC_PATH)")
 
 # Needed by "meson install"
 export DESTDIR
-- 
2.20.1




[PATCH v1 8/9] docker: expand debian-amd64 image to include tag tools

2021-01-13 Thread Alex Bennée
This is going to be helpful when we want to both test the tool
integration and in the case of global generate a xref doc build.

Signed-off-by: Alex Bennée 
---
 tests/docker/dockerfiles/debian-amd64.docker | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/debian-amd64.docker 
b/tests/docker/dockerfiles/debian-amd64.docker
index 55075d9fce..a98314757d 100644
--- a/tests/docker/dockerfiles/debian-amd64.docker
+++ b/tests/docker/dockerfiles/debian-amd64.docker
@@ -1,7 +1,7 @@
 #
 # Docker x86_64 target
 #
-# This docker target builds on the debian Stretch base image. Further
+# This docker target builds on the Debian Buster base image. Further
 # libraries which are not widely available are installed by hand.
 #
 FROM qemu/debian10
@@ -14,7 +14,10 @@ RUN apt update && \
 RUN apt update && \
 DEBIAN_FRONTEND=noninteractive eatmydata \
 apt install -y --no-install-recommends \
+cscope \
 genisoimage \
+exuberant-ctags \
+global \
 libbz2-dev \
 liblzo2-dev \
 libgcrypt20-dev \
-- 
2.20.1




[PATCH v1 0/9] testing/next (tags!, more travis/shippable deprecation)

2021-01-13 Thread Alex Bennée
Hi,

Not a lot in this tree at the moment but I did grab a few patches that
got inadvertently included in my pre-PR series for semihosting and
gdbstub. It does include Phillipe's deprecation of most of the
shippable builds. I've also moved one more test across from Travis
while trying to beef up the documentation we generate. We really need
a better "official" way to install the docs in an arbitrary directory
though.

The following need review:

 - gitlab: move docs and tools build across from Travis
 - docker: expand debian-amd64 image to include tag tools
 - Makefile: wrap cscope in quiet-command calls
 - Makefile: wrap etags in quiet-command calls
 - Makefile: wrap ctags in quiet-command calls
 - Add newline when generating Dockerfile
 - shippable.yml: Remove jobs duplicated on Gitlab-CI
 - Makefile: add GNU global tags support

Alessandro Di Federico (1):
  Add newline when generating Dockerfile

Alex Bennée (6):
  Makefile: add GNU global tags support
  Makefile: wrap ctags in quiet-command calls
  Makefile: wrap etags in quiet-command calls
  Makefile: wrap cscope in quiet-command calls
  docker: expand debian-amd64 image to include tag tools
  gitlab: move docs and tools build across from Travis

Philippe Mathieu-Daudé (2):
  tests/docker: Remove Debian 9 remnant lines
  shippable.yml: Remove jobs duplicated on Gitlab-CI

 Makefile | 46 
 .gitignore   |  3 ++
 .gitlab-ci.yml   | 22 +++---
 .shippable.yml   | 14 +-
 .travis.yml  | 16 ---
 tests/docker/Makefile.include|  1 -
 tests/docker/docker.py   |  4 +-
 tests/docker/dockerfiles/debian-amd64.docker |  5 ++-
 8 files changed, 64 insertions(+), 47 deletions(-)

-- 
2.20.1




[PATCH v1 3/9] shippable.yml: Remove jobs duplicated on Gitlab-CI

2021-01-13 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

The following jobs are duplicated on Gitlab-CI since commit
6bcb5fc0f7a ("gitlab-ci: Add cross-compiling build tests"):

- IMAGE=debian-armel-cross

  TARGET_LIST=arm-softmmu   -> cross-armel-system
  TARGET_LIST=arm-linux-user-> cross-armel-user
  TARGET_LIST=armeb-linux-user  -> cross-armel-user

- IMAGE=debian-armhf-cross

  TARGET_LIST=arm-softmmu   -> cross-armhf-system
  TARGET_LIST=arm-linux-user-> cross-armhf-user
  TARGET_LIST=armeb-linux-user  -> cross-armhf-user

- IMAGE=debian-arm64-cross

  TARGET_LIST=aarch64-softmmu   -> cross-arm64-system
  TARGET_LIST=aarch64-linux-user-> cross-arm64-user

- IMAGE=debian-s390x-cross

  TARGET_LIST=s390x-softmmu -> cross-s390x-system
  TARGET_LIST=s390x-linux-user  -> cross-s390x-user

- IMAGE=debian-mips-cross

  TARGET_LIST=mipsel-linux-user -> cross-mips-user

- IMAGE=debian-mips64el-cross

  TARGET_LIST=mips64el-softmmu  -> cross-mips64el-system
  TARGET_LIST=mips64el-linux-user   -> cross-mips64el-user

- IMAGE=debian-ppc64el-cross

  TARGET_LIST=ppc64-softmmu -> cross-ppc64el-system
  TARGET_LIST=ppc64-linux-user  -> cross-ppc64el-user
  TARGET_LIST=ppc64abi32-linux-user -> cross-ppc64el-user

Remove them from Shippable CI.

Signed-off-by: Philippe Mathieu-Daudé 
Acked-by: Alex Bennée 
Message-Id: <20210108145103.269353-1-f4...@amsat.org>
---
 .shippable.yml | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/.shippable.yml b/.shippable.yml
index 14350e6de8..97bfa2a0f3 100644
--- a/.shippable.yml
+++ b/.shippable.yml
@@ -7,20 +7,8 @@ env:
   matrix:
 - IMAGE=debian-amd64
   TARGET_LIST=x86_64-softmmu,x86_64-linux-user
-- IMAGE=debian-armel-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-armhf-cross
-  TARGET_LIST=arm-softmmu,arm-linux-user,armeb-linux-user
-- IMAGE=debian-arm64-cross
-  TARGET_LIST=aarch64-softmmu,aarch64-linux-user
-- IMAGE=debian-s390x-cross
-  TARGET_LIST=s390x-softmmu,s390x-linux-user
 - IMAGE=debian-mips-cross
-  TARGET_LIST=mips-softmmu,mipsel-linux-user
-- IMAGE=debian-mips64el-cross
-  TARGET_LIST=mips64el-softmmu,mips64el-linux-user
-- IMAGE=debian-ppc64el-cross
-  TARGET_LIST=ppc64-softmmu,ppc64-linux-user,ppc64abi32-linux-user
+  TARGET_LIST=mips-softmmu
 build:
   pre_ci_boot:
 image_name: registry.gitlab.com/qemu-project/qemu/qemu/${IMAGE}
-- 
2.20.1




[PATCH v1 1/9] tests/docker: Remove Debian 9 remnant lines

2021-01-13 Thread Alex Bennée
From: Philippe Mathieu-Daudé 

Debian 9 base container has been removed in commits
e3755276d1f and c9d78b06c06. Remove the last remnants.

Fixes: e3755276d1f ("tests/docker: Remove old Debian 9 containers")
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20210107072933.3828450-1-f4...@amsat.org>
Signed-off-by: Alex Bennée 
Reviewed-by: Thomas Huth 
---
 tests/docker/Makefile.include | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c254ac38d0..0779dab5b9 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -108,7 +108,6 @@ ifneq ($(HOST_ARCH),x86_64)
 DOCKER_PARTIAL_IMAGES += debian-mips-cross debian-mipsel-cross 
debian-mips64el-cross
 DOCKER_PARTIAL_IMAGES += debian-ppc64el-cross
 DOCKER_PARTIAL_IMAGES += debian-s390x-cross
-DOCKER_PARTIAL_IMAGES += debian-win32-cross debian-win64-cross
 DOCKER_PARTIAL_IMAGES += fedora travis
 endif
 
-- 
2.20.1




Re: [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test

2021-01-12 Thread Alex Bennée


Taylor Simpson  writes:

> ---
>  tests/tcg/multiarch/testthread.c | 21 +
>  1 file changed, 21 insertions(+)
>
> diff --git a/tests/tcg/multiarch/testthread.c 
> b/tests/tcg/multiarch/testthread.c
> index 810ba5d..b30b4b5 100644
> --- a/tests/tcg/multiarch/testthread.c
> +++ b/tests/tcg/multiarch/testthread.c
> @@ -50,8 +50,29 @@ void test_pthread(void)
>  printf("End of pthread test.\n");
>  }
>  
> +void *thread3_func(void *arg)
> +{
> +usleep(3 * 1000);
> +return 0;
> +}
> +
> +void test_cancel(void)
> +{
> +pthread_t thread;
> +void *res;
> +
> +pthread_create(, 0, thread3_func, NULL);
> +pthread_cancel(thread);
> +pthread_join(thread, );
> +if (res != PTHREAD_CANCELED) {
> +puts("ERROR: thread not cancelled");
> +exit(EXIT_FAILURE);
> +}

Aside from the signoff line which I need could you add something like:

  printf("End of pthread cancel test.\n");

just to aid debugging.

Thanks,


> +}
> +
>  int main(int argc, char **argv)
>  {
>  test_pthread();
> +test_cancel();
>  return 0;
>  }


-- 
Alex Bennée



Re: [PATCH v6 00/35] Hexagon patch series

2021-01-12 Thread Alex Bennée
ian-hexagon-cross.build-toolchain.sh|  141 ++
>  .../docker/dockerfiles/debian-hexagon-cross.docker |   18 +
>  tests/tcg/configure.sh |8 +-
>  tests/tcg/hexagon/Makefile.target  |   48 +
>  tests/tcg/hexagon/first.S  |   56 +
>  tests/tcg/hexagon/float_convs.ref  |  748 +++
>  tests/tcg/hexagon/float_madds.ref  |  768 +++
>  107 files changed, 23165 insertions(+), 6 deletions(-)
>  create mode 100644 default-configs/targets/hexagon-linux-user.mak
>  create mode 100644 linux-user/hexagon/sockbits.h
>  create mode 100644 linux-user/hexagon/syscall_nr.h
>  create mode 100644 linux-user/hexagon/target_cpu.h
>  create mode 100644 linux-user/hexagon/target_elf.h
>  create mode 100644 linux-user/hexagon/target_fcntl.h
>  create mode 100644 linux-user/hexagon/target_signal.h
>  create mode 100644 linux-user/hexagon/target_structs.h
>  create mode 100644 linux-user/hexagon/target_syscall.h
>  create mode 100644 linux-user/hexagon/termbits.h
>  create mode 100644 target/hexagon/arch.h
>  create mode 100644 target/hexagon/attribs.h
>  create mode 100644 target/hexagon/attribs_def.h
>  create mode 100644 target/hexagon/conv_emu.h
>  create mode 100644 target/hexagon/cpu-param.h
>  create mode 100644 target/hexagon/cpu.h
>  create mode 100644 target/hexagon/cpu_bits.h
>  create mode 100644 target/hexagon/decode.h
>  create mode 100644 target/hexagon/fma_emu.h
>  create mode 100644 target/hexagon/gen_tcg.h
>  create mode 100644 target/hexagon/genptr.h
>  create mode 100644 target/hexagon/helper.h
>  create mode 100644 target/hexagon/hex_arch_types.h
>  create mode 100644 target/hexagon/hex_regs.h
>  create mode 100644 target/hexagon/iclass.h
>  create mode 100644 target/hexagon/insn.h
>  create mode 100644 target/hexagon/internal.h
>  create mode 100644 target/hexagon/macros.h
>  create mode 100644 target/hexagon/opcodes.h
>  create mode 100644 target/hexagon/printinsn.h
>  create mode 100644 target/hexagon/reg_fields.h
>  create mode 100644 target/hexagon/reg_fields_def.h
>  create mode 100644 target/hexagon/translate.h
>  create mode 100644 disas/hexagon.c
>  create mode 100644 linux-user/hexagon/cpu_loop.c
>  create mode 100644 linux-user/hexagon/signal.c
>  create mode 100644 target/hexagon/arch.c
>  create mode 100644 target/hexagon/conv_emu.c
>  create mode 100644 target/hexagon/cpu.c
>  create mode 100644 target/hexagon/decode.c
>  create mode 100644 target/hexagon/fma_emu.c
>  create mode 100644 target/hexagon/gdbstub.c
>  create mode 100644 target/hexagon/gen_dectree_import.c
>  create mode 100644 target/hexagon/gen_semantics.c
>  create mode 100644 target/hexagon/genptr.c
>  create mode 100644 target/hexagon/iclass.c
>  create mode 100644 target/hexagon/op_helper.c
>  create mode 100644 target/hexagon/opcodes.c
>  create mode 100644 target/hexagon/printinsn.c
>  create mode 100644 target/hexagon/q6v_decode.c
>  create mode 100644 target/hexagon/reg_fields.c
>  create mode 100644 target/hexagon/translate.c
>  create mode 100644 tests/tcg/hexagon/atomics.c
>  create mode 100644 tests/tcg/hexagon/clrtnew.c
>  create mode 100644 tests/tcg/hexagon/dual_stores.c
>  create mode 100644 tests/tcg/hexagon/fpstuff.c
>  create mode 100644 tests/tcg/hexagon/mem_noshuf.c
>  create mode 100644 tests/tcg/hexagon/misc.c
>  create mode 100644 tests/tcg/hexagon/preg_alias.c
>  create mode 100644 tests/tcg/hexagon/pthread_cancel.c
>  create mode 100644 target/hexagon/README
>  create mode 100755 target/hexagon/dectree.py
>  create mode 100755 target/hexagon/gen_helper_funcs.py
>  create mode 100755 target/hexagon/gen_helper_protos.py
>  create mode 100755 target/hexagon/gen_op_attribs.py
>  create mode 100755 target/hexagon/gen_op_regs.py
>  create mode 100755 target/hexagon/gen_opcodes_def.py
>  create mode 100755 target/hexagon/gen_printinsn.py
>  create mode 100755 target/hexagon/gen_shortcode.py
>  create mode 100755 target/hexagon/gen_tcg_func_table.py
>  create mode 100755 target/hexagon/gen_tcg_funcs.py
>  create mode 100755 target/hexagon/hex_common.py
>  create mode 100644 target/hexagon/imported/allidefs.def
>  create mode 100644 target/hexagon/imported/alu.idef
>  create mode 100644 target/hexagon/imported/branch.idef
>  create mode 100644 target/hexagon/imported/compare.idef
>  create mode 100644 target/hexagon/imported/encode.def
>  create mode 100644 target/hexagon/imported/encode_pp.def
>  create mode 100644 target/hexagon/imported/encode_subinsn.def
>  create mode 100644 target/hexagon/imported/float.idef
>  create mode 100644 target/hexagon/imported/iclass.def
>  create mode 100644 target/hexagon/imported/ldst.idef
>  create mode 100755 target/hexagon/imported/macros.def
>  create mode 100644 target/hexagon/imported/mpy.idef
>  create mode 100644 target/hexagon/imported/shift.idef
>  create mode 100644 target/hexagon/imported/subinsns.idef
>  create mode 100644 target/hexagon/imported/system.idef
>  create mode 100644 target/hexagon/meson.build
>  create mode 100755 
> tests/docker/dockerfiles/debian-hexagon-cross.build-toolchain.sh
>  create mode 100644 tests/docker/dockerfiles/debian-hexagon-cross.docker
>  create mode 100644 tests/tcg/hexagon/Makefile.target
>  create mode 100644 tests/tcg/hexagon/first.S
>  create mode 100644 tests/tcg/hexagon/float_convs.ref
>  create mode 100644 tests/tcg/hexagon/float_madds.ref


-- 
Alex Bennée



Re: [PATCH v6 34/35] Auto-import Docker support files

2021-01-12 Thread Alex Bennée


Alessandro Di Federico  writes:

> On Tue, 12 Jan 2021 11:58:30 +
> Alex Bennée  wrote:
>
>> > -for filename in args.extra_files or []:
>> > +extra_files = args.extra_files or []
>> > +extra_files += glob(basename + ".*")
>> > +for filename in extra_files:  
>> 
>> Hmm not so sure about this magic. What's wrong with the existing
>> --extra-files mechanism? 
>
> I'd be OK with using that, but how can I automate it?
>
> It is my understanding that `--extra-files` is only set by through the
> EXTRA_FILES environment variable. Therefore the user should do
> something like this:
>
> make check-tcg \
> DOCKER_IMAGE=debian-hexagon-cross \
> DOCKER_CROSS_CC_GUEST=hexagon-unknown-linux-musl-clang \
> EXTRA_FILES="..."

I'm confused - extra-files is while building the docker image, not
running it.

>
> Or am I missing some part of how this works?

Add an explicit rule in Makefile.include:

  docker-image-debian-hexagon-cross: EXTRA_FILES=foo.bar

-- 
Alex Bennée



Re: [RFC PATCH] Makefile: add GNU global tags support

2021-01-12 Thread Alex Bennée


Ben Widawsky  writes:

> On 21-01-12 09:27:39, Alex Bennée wrote:
>> 
>> Ben Widawsky  writes:
>> 
>> > On 21-01-08 22:30:59, Alex Bennée wrote:
>> >> 
>> >> Ben Widawsky  writes:
>> >> 
>> >> > On 21-01-08 12:19:35, Alex Bennée wrote:
>> >> >> GNU Global is another tags engine which is more like cscope in being
>> >> >> able to support finding both references and definitions. You will be
>> >> >> un-surprised to know it also integrates well with Emacs.
>> >> >> 
>> >> >> The main benefit of integrating it into find-src-path is it takes less
>> >> >> time to rebuild the database from scratch when you have a lot of build
>> >> >> directories under your source tree.
>> >> >> 
>> >> >> Signed-off-by: Alex Bennée 
>> >> >
>> >> > It might be worth mentioning that the Linux kernel has supported this 
>> >> > for a long
>> >> > time now (10+ years).
>> >> >
>> >> > Having switched to gtags about 3 years ago, I think it's summarily 
>> >> > better and
>> >> > would really like this to get merged.
>> >> 
>> >> So I take it that's a reviewed-by and a tested-by tag from you?
>> >> 
>> >
>> > It doesn't actually work correctly for me, I just like the idea :-)
>> >
>> > make gtags 2>&1  | grep ignored | wc -l
>> > 6266
>> >
>> > Warning: '/home/bwidawsk/work/clk/qemu/accel/qtest/qtest.c' is out of
>> > source tree. ignored.
>> 
>> Did you run this in the build directory by any chance? I tested in the
>> source directory because that's generally where you want the tags.
>> 
>> I wonder what the best solution is to this? Always force ourselves to be
>> in the source dir? Or error out when we are not in the source tree?
>
> I was in the build directory. With ctags, that works for me in both source and
> build directory.
>
> It does indeed work from the source directory.
>
> I'm wondering how gtags can't seem to do this (I wasn't able to figure it out,
> at least).

The start of the manual states:

  Gtags recursively collects source files under the current directory,
  picks up symbols and writes the cross-reference data into the tag files
  (´GTAGS´, ´GRTAGS´ and ´GPATH´).

so I guess when it finds files outside of CWD it gets confused. While
all of my build trees are inside the source tree ("builds/foo|bar|baz")
they don't have to be. 

> I'd be in favor of error.

The other tags targets always generate to source root so I'm going to go
for:

  .PHONY: gtags
  gtags:
  $(call quiet-command, \
  rm -f "$(SRC_PATH)/"GTAGS \
  rm -f "$(SRC_PATH)/"GRTAGS \
  rm -f "$(SRC_PATH)/"GPATH, \
  "GTAGS", "Remove old")
  $(call quiet-command, \
(cd $(SRC_PATH) && $(find-src-path) | gtags -f -), \
"GTAGS", "Re-index $(SRC_PATH)")

which also makes the output a bit nicer.
>
>
>> 
>> 
>> >
>> >> >
>> >> >> ---
>> >> >>  Makefile   | 9 -
>> >> >>  .gitignore | 3 +++
>> >> >>  2 files changed, 11 insertions(+), 1 deletion(-)
>> >> >> 
>> >> >> diff --git a/Makefile b/Makefile
>> >> >> index fb9923ff22..66eec99685 100644
>> >> >> --- a/Makefile
>> >> >> +++ b/Makefile
>> >> >> @@ -253,6 +253,13 @@ ctags:
>> >> >>rm -f "$(SRC_PATH)/"tags
>> >> >>$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
>> >> >>  
>> >> >> +.PHONY: gtags
>> >> >> +gtags:
>> >> >> +  rm -f "$(SRC_PATH)/"GTAGS
>> >> >> +  rm -f "$(SRC_PATH)/"GRTAGS
>> >> >> +  rm -f "$(SRC_PATH)/"GPATH
>> >> >> +  $(find-src-path) | gtags -f -
>> >> >> +
>> >> >>  .PHONY: TAGS
>> >> >>  TAGS:
>> >> >>rm -f "$(SRC_PATH)/"TAGS
>> >> >> @@ -279,7 +286,7 @@ help:
>> >> >>$(call print-help,all,Build all)
>> >> >>$(call print-help,dir/file.o,Build specified target only)
>> >> >>$(call print-help,install,Install QEMU, documentation and tools)
>> >> >> -  $(call print-help,ctags/TAGS,Generate tags file for editors)
>> >> >> +  $(call print-help,ctags/gtags/TAGS,Generate tags file for 
>> >> >> editors)
>> >> >>$(call print-help,cscope,Generate cscope index)
>> >> >>$(call print-help,sparse,Run sparse on the QEMU source)
>> >> >>@echo  ''
>> >> >> diff --git a/.gitignore b/.gitignore
>> >> >> index b32bca1315..75a4be0724 100644
>> >> >> --- a/.gitignore
>> >> >> +++ b/.gitignore
>> >> >> @@ -7,6 +7,9 @@
>> >> >>  cscope.*
>> >> >>  tags
>> >> >>  TAGS
>> >> >> +GPATH
>> >> >> +GRTAGS
>> >> >> +GTAGS
>> >> >>  *~
>> >> >>  *.ast_raw
>> >> >>  *.depend_raw
>> >> >> -- 
>> >> >> 2.20.1
>> >> >> 
>> >> >> 
>> >> 
>> >> 
>> >> -- 
>> >> Alex Bennée
>> 
>> 
>> -- 
>> Alex Bennée


-- 
Alex Bennée



Re: [PATCH v2 2/3] tracing: convert documentation to rST

2021-01-12 Thread Alex Bennée


Stefan Hajnoczi  writes:

> This is a simple rST conversion of the documentation.
>
> Reviewed-by: Peter Maydell 
> Signed-off-by: Stefan Hajnoczi 

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH] tests/iotests: drop test 312 from auto group

2021-01-12 Thread Alex Bennée


Kevin Wolf  writes:

> Am 05.01.2021 um 11:04 hat Alex Bennée geschrieben:
>> The "auto" documentation states:
>> 
>>   That means they should run with every QEMU binary (also non-x86)
>> 
>> which is not the case as the check-system-fedora build which only
>> includes a rag tag group of rare and deprecated targets doesn't
>> support the virtio device required.
>> 
>> Signed-off-by: Alex Bennée 
>
> I think the better solution would be to do something like in 192 so that
> the test is still run at least for one binary:
>
> if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
> _notrun "Requires a PC machine"
> fi

The fix is already in so feel free to revert and fix up properly. I
wasn't quite able to follow the logic of how the qemu-system binary is
chosen it seemed a little too much to chance.

>
> Kevin


-- 
Alex Bennée



Re: [PATCH v6 31/35] Hexagon (tests/tcg/hexagon) TCG tests

2021-01-12 Thread Alex Bennée


Taylor Simpson  writes:

> Modify tests/tcg/configure.sh
> Add reference files to tests/tcg/hexagon
> Add Hexagon-specific tests
>
> Signed-off-by: Taylor Simpson 
> ---
>  tests/tcg/hexagon/atomics.c| 122 ++
>  tests/tcg/hexagon/clrtnew.c|  56 +++
>  tests/tcg/hexagon/dual_stores.c|  60 +++
>  tests/tcg/hexagon/fpstuff.c| 370 ++
>  tests/tcg/hexagon/mem_noshuf.c | 328 
>  tests/tcg/hexagon/misc.c   | 360 +
>  tests/tcg/hexagon/preg_alias.c | 106 +
>  tests/tcg/hexagon/pthread_cancel.c |  43 +++
>  tests/tcg/configure.sh |   4 +-
>  tests/tcg/hexagon/Makefile.target  |  48 +++

Could you split this patch up please. I would say:

 1: configure.sh, Makefilefile.target with multiarch tests (and float
 ref files)
 2. atomics/loadstore/mem tests
 3. additional fp tests

BTW is there enough support for a bare metal system emulation test? You
would need a minimal boot.S and a library function for outputting
characters to some device and an exit which can set the return code.



> +++ b/tests/tcg/hexagon/pthread_cancel.c
> @@ -0,0 +1,43 @@
> +/*
> + *  Copyright(c) 2019-2020 Qualcomm Innovation Center, Inc. All Rights 
> Reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +static void *func(void *arg)
> +{
> +sleep(3);
> +return 0;
> +}
> +
> +int main()
> +{
> +int err = 0;
> +pthread_t thread;
> +void *res;
> +
> +pthread_create(, 0, func, NULL);
> +pthread_cancel(thread);
> +pthread_join(thread, );
> +if (res != PTHREAD_CANCELED) {
> +err++;
> +}
> +
> +puts(err == 0 ? "PASS" : "FAIL");
> +return err == 0 ? 0 : -1;
> +}

This seems like it could be a multiarch test unless the othread cancel
semantics for Hexagon/Linux are very different.



-- 
Alex Bennée



Re: [PATCH v6 35/35] Add newline when generating Dockerfile

2021-01-12 Thread Alex Bennée


Taylor Simpson  writes:

> From: Alessandro Di Federico 
>
> Signed-off-by: Alessandro Di Federico 

Queued to testing/next, thanks.

-- 
Alex Bennée



Re: [PATCH v6 34/35] Auto-import Docker support files

2021-01-12 Thread Alex Bennée


Taylor Simpson  writes:

> From: Alessandro Di Federico 
>
> Signed-off-by: Alessandro Di Federico 
> ---
>  tests/docker/docker.py | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 36b7868..d473566 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -28,6 +28,7 @@ from io import StringIO, BytesIO
>  from shutil import copy, rmtree
>  from pwd import getpwuid
>  from datetime import datetime, timedelta
> +from glob import glob
>  
>  
>  FILTERED_ENV_NAMES = ['ftp_proxy', 'http_proxy', 'https_proxy']
> @@ -466,7 +467,8 @@ class BuildCommand(SubCommand):
>  return 1
>  
>  # Is there a .pre file to run in the build context?
> -docker_pre = os.path.splitext(args.dockerfile)[0]+".pre"
> +basename = os.path.splitext(args.dockerfile)[0]
> +docker_pre = basename + ".pre"
>  if os.path.exists(docker_pre):
>  stdout = DEVNULL if args.quiet else None
>  rc = subprocess.call(os.path.realpath(docker_pre),
> @@ -488,7 +490,9 @@ class BuildCommand(SubCommand):
>  _copy_binary_with_libs(args.include_executable,
> qpath, docker_dir)
>  
> -for filename in args.extra_files or []:
> +extra_files = args.extra_files or []
> +extra_files += glob(basename + ".*")
> +for filename in extra_files:

Hmm not so sure about this magic. What's wrong with the existing
--extra-files mechanism? 

>  _copy_with_mkdir(filename, docker_dir)
>  cksum += [(filename, _file_checksum(filename))]


-- 
Alex Bennée



Re: [PATCH] tests/acceptance: Fix race conditions in s390x tests & skip fedora on gitlab-CI

2021-01-12 Thread Alex Bennée


Cornelia Huck  writes:

> On Fri,  8 Jan 2021 19:56:45 +0100
> Thomas Huth  wrote:
>
>> There was a race condition in the first test where there was already the
>> "crw" output in the dmesg, but the "0.0.4711" entry has not been created
>> in the /sys fs yet. Fix it by waiting until it is there.
>> 
>> The second test has even more problems on gitlab-CI. Even after adding some
>> more synchronization points (that wait for some messages in the "dmesg"
>> output to make sure that the modules got loaded correctly), there are still
>> occasionally some hangs in this test when it is running in the gitlab-CI.
>> So far I was unable to reproduce these hangs locally on my computer, so
>> this issue might take a while to debug. Thus disable the 2nd test in the
>> gitlab-CI until the problems are better understood and fixed.
>> 
>> Signed-off-by: Thomas Huth 
>> ---
>>  tests/acceptance/machine_s390_ccw_virtio.py | 14 --
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tests/acceptance/machine_s390_ccw_virtio.py 
>> b/tests/acceptance/machine_s390_ccw_virtio.py
>> index eccf26b262..4028c99afc 100644
>> --- a/tests/acceptance/machine_s390_ccw_virtio.py
>> +++ b/tests/acceptance/machine_s390_ccw_virtio.py
>> @@ -12,6 +12,7 @@
>>  import os
>>  import tempfile
>>  
>> +from avocado import skipIf
>>  from avocado_qemu import Test
>>  from avocado_qemu import exec_command_and_wait_for_pattern
>>  from avocado_qemu import wait_for_console_pattern
>> @@ -133,8 +134,10 @@ class S390CCWVirtioMachine(Test):
>>  self.vm.command('device_add', driver='virtio-net-ccw',
>>  devno='fe.0.4711', id='net_4711')
>>  self.wait_for_crw_reports()
>> -exec_command_and_wait_for_pattern(self, 'ls /sys/bus/ccw/devices/',
>> -  '0.0.4711')
>> +exec_command_and_wait_for_pattern(self, 'for i in 1 2 3 4 5 6 7 ; 
>> do '
>> +'if [ -e /sys/bus/ccw/devices/*4711 ]; then break; fi ;'
>> +'sleep 1 ; done ; ls /sys/bus/ccw/devices/',
>> +'0.0.4711')
>
> I'm wondering whether we should introduce a generic helper function for
> "execute command repeatedly, if the expected result did not yet show
> up", or "wait for a file/directory to exist". It's probably not
> uncommon for a desired outcome to arrive asynchronously, and having a
> function for waiting/retrying could be handy.

We don't really want to encourage fragile shell scripts in the guest so
something that makes it easy to encode these loops in python. Currently
the _console_interaction helper fails the test if failure_message is
seen so I guess we need a slightly more liberal interaction which
accepts a command can fail so we can write something like:

  while True:
  if exec_command_and_check(self, "stat -t /sys/bus/ccw/devices/0.0.4711",
"/sys/bus/ccw/devices/0.0.4711"):
  break

?

>
>>  # and detach it again
>>  self.clear_guest_dmesg()
>>  self.vm.command('device_del', id='net_4711')


-- 
Alex Bennée



Re: [PATCH] shippable.yml: Remove jobs duplicated on Gitlab-CI

2021-01-12 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> The following jobs are duplicated on Gitlab-CI since commit
> 6bcb5fc0f7a ("gitlab-ci: Add cross-compiling build tests"):

Queued to testing/next, thanks.

-- 
Alex Bennée



Re: [RFC PATCH] Makefile: add GNU global tags support

2021-01-12 Thread Alex Bennée


Ben Widawsky  writes:

> On 21-01-08 22:30:59, Alex Bennée wrote:
>> 
>> Ben Widawsky  writes:
>> 
>> > On 21-01-08 12:19:35, Alex Bennée wrote:
>> >> GNU Global is another tags engine which is more like cscope in being
>> >> able to support finding both references and definitions. You will be
>> >> un-surprised to know it also integrates well with Emacs.
>> >> 
>> >> The main benefit of integrating it into find-src-path is it takes less
>> >> time to rebuild the database from scratch when you have a lot of build
>> >> directories under your source tree.
>> >> 
>> >> Signed-off-by: Alex Bennée 
>> >
>> > It might be worth mentioning that the Linux kernel has supported this for 
>> > a long
>> > time now (10+ years).
>> >
>> > Having switched to gtags about 3 years ago, I think it's summarily better 
>> > and
>> > would really like this to get merged.
>> 
>> So I take it that's a reviewed-by and a tested-by tag from you?
>> 
>
> It doesn't actually work correctly for me, I just like the idea :-)
>
> make gtags 2>&1  | grep ignored | wc -l
> 6266
>
> Warning: '/home/bwidawsk/work/clk/qemu/accel/qtest/qtest.c' is out of
> source tree. ignored.

Did you run this in the build directory by any chance? I tested in the
source directory because that's generally where you want the tags.

I wonder what the best solution is to this? Always force ourselves to be
in the source dir? Or error out when we are not in the source tree?


>
>> >
>> >> ---
>> >>  Makefile   | 9 -
>> >>  .gitignore | 3 +++
>> >>  2 files changed, 11 insertions(+), 1 deletion(-)
>> >> 
>> >> diff --git a/Makefile b/Makefile
>> >> index fb9923ff22..66eec99685 100644
>> >> --- a/Makefile
>> >> +++ b/Makefile
>> >> @@ -253,6 +253,13 @@ ctags:
>> >>   rm -f "$(SRC_PATH)/"tags
>> >>   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
>> >>  
>> >> +.PHONY: gtags
>> >> +gtags:
>> >> + rm -f "$(SRC_PATH)/"GTAGS
>> >> + rm -f "$(SRC_PATH)/"GRTAGS
>> >> + rm -f "$(SRC_PATH)/"GPATH
>> >> + $(find-src-path) | gtags -f -
>> >> +
>> >>  .PHONY: TAGS
>> >>  TAGS:
>> >>   rm -f "$(SRC_PATH)/"TAGS
>> >> @@ -279,7 +286,7 @@ help:
>> >>   $(call print-help,all,Build all)
>> >>   $(call print-help,dir/file.o,Build specified target only)
>> >>   $(call print-help,install,Install QEMU, documentation and tools)
>> >> - $(call print-help,ctags/TAGS,Generate tags file for editors)
>> >> + $(call print-help,ctags/gtags/TAGS,Generate tags file for editors)
>> >>   $(call print-help,cscope,Generate cscope index)
>> >>   $(call print-help,sparse,Run sparse on the QEMU source)
>> >>   @echo  ''
>> >> diff --git a/.gitignore b/.gitignore
>> >> index b32bca1315..75a4be0724 100644
>> >> --- a/.gitignore
>> >> +++ b/.gitignore
>> >> @@ -7,6 +7,9 @@
>> >>  cscope.*
>> >>  tags
>> >>  TAGS
>> >> +GPATH
>> >> +GRTAGS
>> >> +GTAGS
>> >>  *~
>> >>  *.ast_raw
>> >>  *.depend_raw
>> >> -- 
>> >> 2.20.1
>> >> 
>> >> 
>> 
>> 
>> -- 
>> Alex Bennée


-- 
Alex Bennée



Re: [PATCH 2/2] sysemu: Let VMChangeStateHandler take boolean 'running' argument

2021-01-11 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> The 'running' argument from VMChangeStateHandler does not require
> other value than 0 / 1. Make it a plain boolean.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Seems reasonable

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH 1/2] sysemu/runstate: Let runstate_is_running() return bool

2021-01-11 Thread Alex Bennée


Philippe Mathieu-Daudé  writes:

> runstate_check() returns a boolean. runstate_is_running()
> returns what runstate_check() returns, also a boolean.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH v1 10/20] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers

2021-01-11 Thread Alex Bennée


Luis Machado  writes:

> For the record, the layout looks OK to me.

So a Reviewed-by?

> Just a reminder that GDB will soon support bfloat16 types. A patch may 
> be pushed this month.

Will we be able to probe for the support - or will an older GDB silently
accept and drop any bfloat16 fields?

>
> On 1/8/21 7:42 PM, Alex Bennée wrote:
>> While GDB can work with any XML description given to it there is
>> special handling for SVE registers on the GDB side which makes the
>> users life a little better. The changes aren't that major and all the
>> registers save the $vg reported the same. All that changes is:
>> 
>>- report org.gnu.gdb.aarch64.sve
>>- use gdb nomenclature for names and types
>>- minor re-ordering of the types to match reference
>>- re-enable ieee_half (as we know gdb supports it now)
>>- $vg is now a 64 bit int
>>- check $vN and $zN aliasing in test
>> 
>> Signed-off-by: Alex Bennée 
>> Cc: Luis Machado 
>> Message-Id: <20201218112707.28348-10-alex.ben...@linaro.org>
>> Signed-off-by: Alex Bennée 
>> ---
>>   target/arm/gdbstub.c| 75 -
>>   target/arm/helper.c |  2 +-
>>   tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 11 +++
>>   3 files changed, 41 insertions(+), 47 deletions(-)
>> 
>> diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
>> index 866595b4f1..a8fff2a3d0 100644
>> --- a/target/arm/gdbstub.c
>> +++ b/target/arm/gdbstub.c
>> @@ -195,22 +195,17 @@ static const struct TypeSize vec_lanes[] = {
>>   { "uint128", 128, 'q', 'u' },
>>   { "int128", 128, 'q', 's' },
>>   /* 64 bit */
>> +{ "ieee_double", 64, 'd', 'f' },
>>   { "uint64", 64, 'd', 'u' },
>>   { "int64", 64, 'd', 's' },
>> -{ "ieee_double", 64, 'd', 'f' },
>>   /* 32 bit */
>> +{ "ieee_single", 32, 's', 'f' },
>>   { "uint32", 32, 's', 'u' },
>>   { "int32", 32, 's', 's' },
>> -{ "ieee_single", 32, 's', 'f' },
>>   /* 16 bit */
>> +{ "ieee_half", 16, 'h', 'f' },
>>   { "uint16", 16, 'h', 'u' },
>>   { "int16", 16, 'h', 's' },
>> -/*
>> - * TODO: currently there is no reliable way of telling
>> - * if the remote gdb actually understands ieee_half so
>> - * we don't expose it in the target description for now.
>> - * { "ieee_half", 16, 'h', 'f' },
>> - */
>>   /* bytes */
>>   { "uint8", 8, 'b', 'u' },
>>   { "int8", 8, 'b', 's' },
>> @@ -223,17 +218,16 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int 
>> base_reg)
>>   GString *s = g_string_new(NULL);
>>   DynamicGDBXMLInfo *info = >dyn_svereg_xml;
>>   g_autoptr(GString) ts = g_string_new("");
>> -int i, bits, reg_width = (cpu->sve_max_vq * 128);
>> +int i, j, bits, reg_width = (cpu->sve_max_vq * 128);
>>   info->num = 0;
>>   g_string_printf(s, "");
>>   g_string_append_printf(s, "> \"gdb-target.dtd\">");
>> -g_string_append_printf(s, "> name=\"org.qemu.gdb.aarch64.sve\">");
>> +g_string_append_printf(s, "");
>>   
>>   /* First define types and totals in a whole VL */
>>   for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
>>   int count = reg_width / vec_lanes[i].size;
>> -g_string_printf(ts, "vq%d%c%c", count,
>> -vec_lanes[i].sz, vec_lanes[i].suffix);
>> +g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, 
>> vec_lanes[i].suffix);
>>   g_string_append_printf(s,
>>  "> count=\"%d\"/>",
>>  ts->str, vec_lanes[i].gdb_type, count);
>> @@ -243,39 +237,37 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int 
>> base_reg)
>>* signed and potentially float versions of each size from 128 to
>>* 8 bits.
>>*/
>> -for (bits = 128; bits >= 8; bits /= 2) {
>> -int count = reg_width / bits;
>> -g_string_append_printf(s, "", count);
>> -for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) {
>> -if (vec_lanes[i].size == bits) {
>> -g_string_append_printf(s, "> type=\"vq%d%c%c\"/>",
>>

Re: check-tcg HOWTO?

2021-01-11 Thread Alex Bennée


Claudio Fontana  writes:

> Hi Alex,
>
> happy new year,
>
> I am trying to get check-tcg to run reliably,
> as I am doing some substantial refactoring of tcg cpu operations, so I need 
> to verify that TCG is fine.
>
> This is an overall getting started question, is there a how-to on how
> to use check-tcg and how to fix things when things don't go smoothly?

Not really but I could certainly add something. Generally I just run the
tests manually in gdb when I'm trying to debug stuff.

> I get different results on different machines for check-tcg, although the 
> runs are containerized,
> on one machine the tests for aarch64 tcg are SKIPPED completely (so no
> errors),

The compiles *may* be containerized - the runs are always in your host
environment. It's one of the reasons the binaries are built as static
images so you don't need to mess about with dynamic linking and
libraries.

The only reason some tests get skipped is if you have a locally
installed cross compiler which doesn't support some architecture
features (e.g. CROSS_CC_HAS_SVE).

> on the other machine I get:
>
> qemu-system-aarch64: terminating on signal 15 from pid 18583 (timeout)
> qemu-system-aarch64: terminating on signal 15 from pid 18584 (timeout)
> qemu-system-aarch64: terminating on signal 15 from pid 18585 (timeout)
> make[2]: *** [../Makefile.target:162: run-hello] Error 124
> make[2]: *** Waiting for unfinished jobs
> make[2]: *** [../Makefile.target:162: run-pauth-3] Error 124
> make[2]: *** [../Makefile.target:162: run-memory] Error 124

Given it's timing out on hello I guess it's the shutdown deadlocking.
Running with V=1 will give you the command line but the semihosting
config is setup for redirect. So I usually build my own command line. e.g.:

  ./qemu-system-aarch64 -monitor none -display none \
-chardev stdio,id=output  \
-M virt -cpu max -display none \
-semihosting-config enable=on,target=native,chardev=output \
-kernel tests/tcg/aarch64-softmmu/hello

There is nothing particularly special apart from making sure semihosting
is wired up for the output. Apart from some special cases like
test-mmap- most tests don't take any arguments.

>
> Both are configured with 
>
> configure --enable-tcg
>
> Anything more than V=1 to get more output?

The output is normally dumped in $TESTNAME.out in the appropriate
$BUILDDIR/tests/tcg/$TARGET/ directory.

> How do I debug and get logs and cores out of containers?

As I mentioned above the tests are not run in containers, just the
compiles (if local compilers are missing).

>
> in tests/tcg/ there is:
>
> a README (with no hint unfortunately) ,

Woefully out of date I'm afraid. What docs we have are in docs/devel/testing.rst

> Makefile.qemu

Links into the main tests/Makefile.include - invoked for each target

> Makefile.prereqs

This ensures docker images are built (if required) for each set of tests.

> Makefile.target

This is the main (rather simple) makefile which provides the build and
run targets. You can run directly if you are in the right build dir, eg:

  13:58:10 [alex@zen:~/l/q/b/a/t/t/aarch64-softmmu] |✔ + pwd
  /home/alex/lsrc/qemu.git/builds/arm.all/tests/tcg/aarch64-softmmu
  13:58:57 [alex@zen:~/l/q/b/a/t/t/aarch64-softmmu] |✔ +
  make  -f ~/lsrc/qemu.git/tests/tcg/Makefile.target TARGET="aarch64-softmmu" 
SRC_PATH="/home/alex/lsrc/qemu.git" run

But TBH this is functionally equivalent to calling:

  make run-tcg-tests-aarch64-softmmu

in your main build directory.

> There are a bunch of variables in these files, which seem to be
> possible to configure, am I expected to set some of those?

Not really. Most of the magic variables from:

  tests/tcg/config-$TARGET.mak

which is built by tests/tcg/configure.sh during the configure step.

> I think that it would be beneficial to have either more documentation
> or more immediately actionable information out of make check failures;

V=1 should show the command lines run and then you should be able to run
the tests directly yourself.

> Any help you could give me to make some progess?

Hope that helps.

>
> Thanks,
>
> Claudio


-- 
Alex Bennée



Re: Fwd: VirtioSound device emulation implementation

2021-01-11 Thread Alex Bennée


Shreyansh Chouhan  writes:

> -- Forwarded message -
> From: Shreyansh Chouhan 
> Date: Mon, 11 Jan 2021 at 11:59
> Subject: Re: VirtioSound device emulation implementation
> To: Gerd Hoffmann 
>
>
>
>
> On Sun, 10 Jan 2021 at 13:55, Shreyansh Chouhan <
> chouhan.shreyansh2...@gmail.com> wrote:
>
>> Hi,
>>
>> I have been reading about the virtio and vhost specifications, however I
>> have a few doubts. I tried looking for them but I still
>> do not understand them clearly enough. From what I understand, there are
>> two protocols:
>>
>> The virtio protocol: The one that specifies how we can have common
>> emulation for virtual devices. The front end drivers
>> interact with these devices, and these devices could then process the
>> information that they have received either in QEMU,
>> or somewhere else. From what I understand the front driver uses mmaps to
>> communicate with the virtio device.
>>
>> The vhost protocol: The one that specifies how we can _offload_ the
>> processing from QEMU to a separate process. We
>> want to offload so that we do not have to stop the guest when we are
>> processing information passed to a virtio device. This
>> service could either be implemented in the host kernel or the host
>> userspace. Now when we offload the processing, we map the
>> memory of the device to this vhost service, so that this service has all
>> the information that it should process.
>>   Also, this process can generate the vCPU interrupts, and this process
>> responds to the ioeventfd notifications.
>>
>> What I do not understand is, once we have this vhost service, either in
>> userspace or in kernel space, which does the information processing,
>> why do we need a virtio device still emulated in QEMU? Is it only to pass
>> on the configurations between the driver and the
>> vhost service? I know that the vhost service doesn't emulate anything, but
>> then what is the difference between "processing" the
>> information and "emulating" a device?
>>
>> Also, from article[3], moving the vhost-net service to userspace was
>> faster somehow. I am assuming this was only the case for
>> networking devices, and would not be true in general. Since there would be
>> more context switches between user and kernel space?
>> (KVM receives the irq/ioevent notification and then transfers control back
>> to user space, as opposed to when vhost was in kernel
>> space.)
>>
>> For context, I've been reading the following:
>> [1]
>> https://www.redhat.com/en/blog/introduction-virtio-networking-and-vhost-net
>> [2]
>> https://www.redhat.com/en/blog/deep-dive-virtio-networking-and-vhost-net
>> [3] https://www.redhat.com/en/blog/journey-vhost-users-realm
>>
>>
> Found the answers in this blog:
> http://blog.vmsplice.net/2011/09/qemu-internals-vhost-architecture.html
> In short, yes, the configuration plane still remains with QEMU. The
> frontend driver interacts with the PCI
> adapter emulated in QEMU, for configurations and memory map setup. Only the
> data plane is forwarded
> to the vhost service. This makes sense since we would only want to
> configure the device once, and hence
> having that emulated in QEMU is not a performance issue, as much as having
> the data plane was.

Also if you are running a pure TCG emulation QEMU can pass along the
signalled events from the guest to the vhost-user daemon as well.

> There is still a little confusion in my mind regarding a few things, but I
> think looking at the source code
> of the already implemented drivers will clear that up for me. So that is
> what I will be doing next.
>
> I will start looking at the source code for in-QEMU and vhost
> implementations of other virtio drivers, and then decide which one I'd like
> to
> go with. I will probably follow that decision with an implementation
> plan/timeline so that everyone can follow the progress on the
> development of this project.


-- 
Alex Bennée



[PATCH v1 16/20] riscv: Add semihosting support

2021-01-08 Thread Alex Bennée
From: Keith Packard 

Adapt the arm semihosting support code for RISCV. This implementation
is based on the standard for RISC-V semihosting version 0.2 as
documented in

   https://github.com/riscv/riscv-semihosting-spec/releases/tag/0.2

Signed-off-by: Keith Packard 
Message-Id: <20210107170717.2098982-6-kei...@keithp.com>
Signed-off-by: Alex Bennée 
---
 default-configs/devices/riscv32-softmmu.mak   |  2 +
 default-configs/devices/riscv64-softmmu.mak   |  2 +
 .../targets/riscv32-linux-user.mak|  1 +
 .../targets/riscv64-linux-user.mak|  1 +
 hw/semihosting/common-semi.h  |  5 +-
 linux-user/qemu.h |  4 +-
 target/riscv/cpu_bits.h   |  1 +
 hw/semihosting/common-semi.c  | 82 ++-
 linux-user/semihost.c |  8 +-
 target/riscv/cpu_helper.c | 10 +++
 target/riscv/translate.c  | 11 +++
 .../riscv/insn_trans/trans_privileged.c.inc   | 37 -
 qemu-options.hx   | 10 ++-
 13 files changed, 162 insertions(+), 12 deletions(-)

diff --git a/default-configs/devices/riscv32-softmmu.mak 
b/default-configs/devices/riscv32-softmmu.mak
index 94a236c9c2..d847bd5692 100644
--- a/default-configs/devices/riscv32-softmmu.mak
+++ b/default-configs/devices/riscv32-softmmu.mak
@@ -3,6 +3,8 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
+CONFIG_SEMIHOSTING=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/default-configs/devices/riscv64-softmmu.mak 
b/default-configs/devices/riscv64-softmmu.mak
index 76b6195648..d5eec75f05 100644
--- a/default-configs/devices/riscv64-softmmu.mak
+++ b/default-configs/devices/riscv64-softmmu.mak
@@ -3,6 +3,8 @@
 # Uncomment the following lines to disable these optional devices:
 #
 #CONFIG_PCI_DEVICES=n
+CONFIG_SEMIHOSTING=y
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
 
 # Boards:
 #
diff --git a/default-configs/targets/riscv32-linux-user.mak 
b/default-configs/targets/riscv32-linux-user.mak
index dfb259e8aa..6a9d1b1bc1 100644
--- a/default-configs/targets/riscv32-linux-user.mak
+++ b/default-configs/targets/riscv32-linux-user.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=riscv32
 TARGET_BASE_ARCH=riscv
 TARGET_ABI_DIR=riscv
 TARGET_XML_FILES= gdb-xml/riscv-32bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml 
gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-32bit-csr.xml 
gdb-xml/riscv-32bit-virtual.xml
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/default-configs/targets/riscv64-linux-user.mak 
b/default-configs/targets/riscv64-linux-user.mak
index b13895f3b0..0a92849a1b 100644
--- a/default-configs/targets/riscv64-linux-user.mak
+++ b/default-configs/targets/riscv64-linux-user.mak
@@ -2,3 +2,4 @@ TARGET_ARCH=riscv64
 TARGET_BASE_ARCH=riscv
 TARGET_ABI_DIR=riscv
 TARGET_XML_FILES= gdb-xml/riscv-64bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml 
gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-64bit-csr.xml 
gdb-xml/riscv-64bit-virtual.xml
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
diff --git a/hw/semihosting/common-semi.h b/hw/semihosting/common-semi.h
index bc53e92c79..0bfab1c669 100644
--- a/hw/semihosting/common-semi.h
+++ b/hw/semihosting/common-semi.h
@@ -1,6 +1,6 @@
 /*
  *  Semihosting support for systems modeled on the Arm "Angel"
- *  semihosting syscalls design.
+ *  semihosting syscalls design. This includes Arm and RISC-V processors
  *
  *  Copyright (c) 2005, 2007 CodeSourcery.
  *  Copyright (c) 2019 Linaro
@@ -26,6 +26,9 @@
  * Semihosting for AArch32 and AArch64 Release 2.0
  * https://static.docs.arm.com/100863/0200/semihosting.pdf
  *
+ *  RISC-V Semihosting is documented in:
+ * RISC-V Semihosting
+ * 
https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc
  */
 
 #ifndef COMMON_SEMI_H
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 534753ca12..17aa992165 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -109,6 +109,8 @@ typedef struct TaskState {
 /* FPA state */
 FPA11 fpa;
 # endif
+#endif
+#if defined(TARGET_ARM) || defined(TARGET_RISCV)
 int swi_errno;
 #endif
 #if defined(TARGET_I386) && !defined(TARGET_X86_64)
@@ -122,7 +124,7 @@ typedef struct TaskState {
 #ifdef TARGET_M68K
 abi_ulong tp_value;
 #endif
-#if defined(TARGET_ARM) || defined(TARGET_M68K)
+#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_RISCV)
 /* Extra fields for semihosted binaries.  */
 abi_ulong heap_base;
 abi_ulong heap_limit;
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
index b41e8836c3..4196ef8b69 100644
--- a/target/riscv/cpu_bits.h
+++ b/target/riscv/cpu_bits.h
@@ -542,6 +542,7 @@
 #define RISCV_EXCP_INST_PAGE_FAULT   0xc /* since: priv-1.10.0 */
 #define RISCV_EXCP_LOAD_PAGE_FAULT   0xd /* since: priv-1.10.0 */
 #define RISCV_EXCP_STORE_PAGE_FAULT  0xf /* since: priv-1.10.0 */
+#de

[PATCH v1 17/20] riscv: Add semihosting support for user mode

2021-01-08 Thread Alex Bennée
From: Kito Cheng 

This could made testing more easier and ARM/AArch64 has supported on
their linux user mode too, so I think it should be reasonable.

Verified GCC testsuite with newlib/semihosting.

Signed-off-by: Kito Cheng 
Reviewed-by: Keith Packard 
Message-Id: <20210107170717.2098982-7-kei...@keithp.com>
Signed-off-by: Alex Bennée 
---
 linux-user/riscv/cpu_loop.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
index aa9e437875..9665dabb09 100644
--- a/linux-user/riscv/cpu_loop.c
+++ b/linux-user/riscv/cpu_loop.c
@@ -23,6 +23,7 @@
 #include "qemu.h"
 #include "cpu_loop-common.h"
 #include "elf.h"
+#include "hw/semihosting/common-semi.h"
 
 void cpu_loop(CPURISCVState *env)
 {
@@ -91,6 +92,10 @@ void cpu_loop(CPURISCVState *env)
 sigcode = TARGET_SEGV_MAPERR;
 sigaddr = env->badaddr;
 break;
+case RISCV_EXCP_SEMIHOST:
+env->gpr[xA0] = do_common_semihosting(cs);
+env->pc += 4;
+break;
 case EXCP_DEBUG:
 gdbstep:
 signum = TARGET_SIGTRAP;
-- 
2.20.1




  1   2   3   4   5   6   7   8   9   10   >