All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miroslav Rezanina <mrezanin@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Riku Voipio <riku.voipio@iki.fi>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	Laurent Vivier <laurent@vivier.eu>
Subject: Re: [Qemu-devel] [RFC PATCH 06/11] target/arm: use the common interface for WRITE0/WRITEC in arm-semi
Date: Fri, 31 May 2019 07:28:09 -0400 (EDT)	[thread overview]
Message-ID: <833530119.25503992.1559302089822.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <87sgsu51bd.fsf@zen.linaroharston>



----- Original Message -----
> From: "Alex Bennée" <alex.bennee@linaro.org>
> To: "Miroslav Rezanina" <mrezanin@redhat.com>
> Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>, "Riku Voipio" <riku.voipio@iki.fi>,
> qemu-arm@nongnu.org, "Laurent Vivier" <laurent@vivier.eu>
> Sent: Friday, May 31, 2019 1:08:06 PM
> Subject: Re: [Qemu-devel] [RFC PATCH 06/11] target/arm: use the common interface for WRITE0/WRITEC in arm-semi
> 
> 
> Miroslav Rezanina <mrezanin@redhat.com> writes:
> 
> > On Tue, May 14, 2019 at 04:52:56PM +0100, Alex Bennée wrote:
> >> Now we have a common semihosting console interface use that for our
> >> string output. However ARM is currently unique in also supporting
> >> semihosting for linux-user so we need to replicate the API in
> >> linux-user. If other architectures gain this support we can move the
> >> file later.
> >>
> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> >> ---
> >>  linux-user/Makefile.objs  |  2 ++
> >>  linux-user/arm/semihost.c | 24 ++++++++++++++++++++++++
> >>  target/arm/arm-semi.c     | 31 ++++++-------------------------
> >>  3 files changed, 32 insertions(+), 25 deletions(-)
> >>  create mode 100644 linux-user/arm/semihost.c
> >>
> >> diff --git a/linux-user/Makefile.objs b/linux-user/Makefile.objs
> >> index 769b8d83362..285c5dfa17a 100644
> >> --- a/linux-user/Makefile.objs
> >> +++ b/linux-user/Makefile.objs
> >> @@ -6,4 +6,6 @@ obj-y = main.o syscall.o strace.o mmap.o signal.o \
> >>  obj-$(TARGET_HAS_BFLT) += flatload.o
> >>  obj-$(TARGET_I386) += vm86.o
> >>  obj-$(TARGET_ARM) += arm/nwfpe/
> >> +obj-$(TARGET_ARM) += arm/semihost.o
> >> +obj-$(TARGET_AARCH64) += arm/semihost.o
> >>  obj-$(TARGET_M68K) += m68k-sim.o
> >> diff --git a/linux-user/arm/semihost.c b/linux-user/arm/semihost.c
> >> new file mode 100644
> >> index 00000000000..9554102a855
> >> --- /dev/null
> >> +++ b/linux-user/arm/semihost.c
> >> @@ -0,0 +1,24 @@
> >> +/*
> >> + * ARM Semihosting Console Support
> >> + *
> >> + * Copyright (c) 2019 Linaro Ltd
> >> + *
> >> + * Currently ARM is unique in having support for semihosting support
> >> + * in linux-user. So for now we implement the common console API but
> >> + * just for arm linux-user.
> >> + *
> >> + * SPDX-License-Identifier: GPL-2.0-or-later
> >> + */
> >> +
> >> +#include "qemu/osdep.h"
> >> +#include "cpu.h"
> >> +#include "hw/semihosting/console.h"
> >> +#include "qemu.h"
> >> +
> >> +int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr,
> >> int len)
> >> +{
> >> +    void *s = lock_user_string(addr);
> >> +    len = write(STDERR_FILENO, s, len ? len : strlen(s));
> >> +    unlock_user(s, addr, 0);
> >> +    return len;
> >> +}
> >> diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
> >> index 9e5a414dd89..253c66b172a 100644
> >> --- a/target/arm/arm-semi.c
> >> +++ b/target/arm/arm-semi.c
> >> @@ -27,6 +27,7 @@
> >>
> >>  #include "cpu.h"
> >>  #include "hw/semihosting/semihost.h"
> >> +#include "hw/semihosting/console.h"
> >>  #ifdef CONFIG_USER_ONLY
> >>  #include "qemu.h"
> >>
> >> @@ -314,32 +315,12 @@ target_ulong do_arm_semihosting(CPUARMState *env)
> >>              return set_swi_errno(ts, close(arg0));
> >>          }
> >>      case TARGET_SYS_WRITEC:
> >> -        {
> >> -          char c;
> >> -
> >> -          if (get_user_u8(c, args))
> >> -              /* FIXME - should this error code be -TARGET_EFAULT ? */
> >> -              return (uint32_t)-1;
> >> -          /* Write to debug console.  stderr is near enough.  */
> >> -          if (use_gdb_syscalls()) {
> >> -                return arm_gdb_syscall(cpu, arm_semi_cb, "write,2,%x,1",
> >> args);
> >> -          } else {
> >> -                return write(STDERR_FILENO, &c, 1);
> >> -          }
> >> -        }
> >> +    {
> >> +        qemu_semihosting_console_out(env, args, 1);
> >> +        return 0xdeadbeef;
> >> +    }
> >>      case TARGET_SYS_WRITE0:
> >> -        if (!(s = lock_user_string(args)))
> >> -            /* FIXME - should this error code be -TARGET_EFAULT ? */
> >> -            return (uint32_t)-1;
> >> -        len = strlen(s);
> >> -        if (use_gdb_syscalls()) {
> >> -            return arm_gdb_syscall(cpu, arm_semi_cb, "write,2,%x,%x",
> >> -                                   args, len);
> >> -        } else {
> >> -            ret = write(STDERR_FILENO, s, len);
> >> -        }
> >> -        unlock_user(s, args, 0);
> >> -        return ret;
> >> +        return qemu_semihosting_console_out(env, args, 0);
> >>      case TARGET_SYS_WRITE:
> >>          GET_ARG(0);
> >>          GET_ARG(1);
> >> --
> >> 2.20.1
> >>
> >>
> >
> > Hi Alex,
> >
> > this patch breaks build for softmmu target when CONFIG_SEMIHOSTING is not
> > enabled as qemu_semihosting_console_out
> > is not defined in such case - neither linux-user/arm/semihost.c nor
> > hw/semihosting/console.c compiled and function
> > is not in stubs/semihost.c
> 
> How do you do that? I tried ../../configure --without-default-devices
> and that still builds for me.

It's usual RHEL way - use --without-default-devices and use specific
list of enabled devices (this mean disable CONFIG_SEMIHOSTING in
default_config/* file).

> 
> But I suspect what's needed is to change:
> 
> #ifndef CONFIG_USER_ONLY
> 
> to
> 
> #ifdef CONFIG_SEMIHOSTING
> 
> to the relevant headers and helper bits.

Yeah, have to find out what are relevant pieces.

Mirek

> 
> >
> > Mirek
> 
> 
> --
> Alex Bennée
> 

-- 
Miroslav Rezanina
Software Engineer - Virtualization Team Maintainer



  reply	other threads:[~2019-05-31 11:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 15:52 [Qemu-devel] [RFC PATCH 00/11] semihosting cleanup and re-factor Alex Bennée
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 01/11] semihosting: move semihosting configuration into its own directory Alex Bennée
2019-05-14 16:23   ` Philippe Mathieu-Daudé
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 02/11] semihosting: introduce CONFIG_SEMIHOSTING Alex Bennée
2019-05-14 16:25   ` Philippe Mathieu-Daudé
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 03/11] semihosting: implement a semihosting console Alex Bennée
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 04/11] semihosting: enable chardev backed output for console Alex Bennée
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 05/11] target/arm: fixup some of the commentary for arm-semi Alex Bennée
2019-05-14 16:56   ` Philippe Mathieu-Daudé
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 06/11] target/arm: use the common interface for WRITE0/WRITEC in arm-semi Alex Bennée
2019-05-31  9:12   ` Miroslav Rezanina
2019-05-31 10:42     ` Philippe Mathieu-Daudé
2019-05-31 10:44       ` Philippe Mathieu-Daudé
2019-05-31 10:53       ` Miroslav Rezanina
2019-05-31 11:08     ` Alex Bennée
2019-05-31 11:28       ` Miroslav Rezanina [this message]
2019-05-31 13:16         ` Alex Bennée
2019-05-31 13:59           ` Miroslav Rezanina
2019-05-31 14:28             ` Alex Bennée
2019-05-31 14:38               ` Peter Maydell
2019-05-31 16:47                 ` Miroslav Rezanina
2019-05-31 16:50               ` Miroslav Rezanina
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 07/11] target/arm: add LOG_UNIMP messages to arm-semi Alex Bennée
2019-05-14 16:15   ` Philippe Mathieu-Daudé
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 08/11] target/arm: correct return values for WRITE/READ in arm-semi Alex Bennée
2019-05-14 16:57   ` Philippe Mathieu-Daudé
2019-05-14 15:52 ` [Qemu-devel] [RFC PATCH 09/11] target/mips: only build mips-semi for softmmu Alex Bennée
2019-05-14 16:59   ` Philippe Mathieu-Daudé
2019-05-20 15:53   ` Aleksandar Markovic
2019-05-14 15:53 ` [Qemu-devel] [RFC PATCH 10/11] target/mips: convert UHI_plog to use common semihosting code Alex Bennée
2019-05-20 15:53   ` Aleksandar Markovic
2019-05-14 15:53 ` [Qemu-devel] [RFC PATCH 11/11] MAINTAINERS: update for semihostings new home Alex Bennée
2019-05-14 17:00   ` Philippe Mathieu-Daudé
2019-05-20 13:03 ` [Qemu-devel] [RFC PATCH 00/11] semihosting cleanup and re-factor Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=833530119.25503992.1559302089822.JavaMail.zimbra@redhat.com \
    --to=mrezanin@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.