qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Leon Alrae <leon.alrae@imgtec.com>
To: Matthew Fortune <Matthew.Fortune@imgtec.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "aurelien@aurel32.net" <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 2/4] target-mips: add Unified Hosting Interface (UHI) support
Date: Mon, 2 Mar 2015 17:31:39 +0000	[thread overview]
Message-ID: <54F49E7B.5020809@imgtec.com> (raw)
In-Reply-To: <6D39441BF12EF246A7ABCE6654B0235320FE477C@LEMAIL01.le.imgtec.org>

Hi Matthew,

On 01/03/2015 22:17, Matthew Fortune wrote:
> Hi Leon,
> 
> Many thanks for implementing this interface in QEMU. I haven't reviewed
> in great detail as I am not familiar enough with QEMU internals to do
> so. Overall it seems to match the UHI spec. The one potential issue is
> translation of errno values, I suspect some do not map 1:1.
> 
> A couple of minor review comments below:
> 
>> + * Copyright (c) 2014 Imagination Technologies
> 
> Dates need updating.
> 
>> +static int write_to_file(CPUMIPSState *env, target_ulong fd,
>> target_ulong vaddr,
>> +                         target_ulong len, target_ulong offset) {
>> +    int num_of_bytes;
>> +    void *dst = lock_user(VERIFY_READ, vaddr, len, 1);
>> +    if (!dst) {
>> +        return 0;
>> +    }
> 
> Ideally I think this this should return -1 and fake an errno but I
> may not understand what case this code is dealing with.

Indeed, indicating an error by returning -1 would be better. Thanks for
spotting that.

>> +static int read_from_file(CPUMIPSState *env, target_ulong fd,
>> +                          target_ulong vaddr, target_ulong len,
>> +                          target_ulong offset) {
>> +    int num_of_bytes;
>> +    void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0);
>> +    if (!dst) {
>> +        return 0;
>> +    }
> 
> Likewise.
> 
>> +    case UHI_plog:
>> +        GET_TARGET_STRING(p, gpr[4]);
>> +        p2 = strstr(p, "%d");
>> +        if (p2) {
>> +            int char_num = p2 - p;
>> +            char *buf = g_malloc(char_num + 1);
>> +            strncpy(buf, p, char_num);
>> +            buf[char_num] = '\0';
>> +            gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2);
>> +            g_free(buf);
>> +        } else {
>> +            gpr[2] = printf("%s", p);
>> +        }
> 
> Is all this necessary vs just: printf(p, (int)gpr[5])? I guess you
> may want to do the scan for %d and choose between that and just
> printf(p).

I don't think we should use p as a format string directly as it might
contain more/different format specifiers. Presumably we would need
additional logic for checking this and returning an error for such cases
-- and this new implementation wouldn't be much simpler than current I
believe.

Current implementation allows any string given by the guest to be
printed out. If there are multiple format specifiers then only the first
occurrence of %d will be replaced with the integer.

Leon

  reply	other threads:[~2015-03-02 17:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 17:00 [Qemu-devel] [PATCH 0/4] target-mips: add UHI semihosting support Leon Alrae
2015-02-27 17:00 ` [Qemu-devel] [PATCH 1/4] include/softmmu-semi.h: Make semihosting support 64-bit clean Leon Alrae
2015-02-27 17:00 ` [Qemu-devel] [PATCH 2/4] target-mips: add Unified Hosting Interface (UHI) support Leon Alrae
2015-03-01 22:17   ` Matthew Fortune
2015-03-02 17:31     ` Leon Alrae [this message]
2015-03-02 20:44       ` Matthew Fortune
2015-02-27 17:00 ` [Qemu-devel] [PATCH 3/4] target-mips: add "-semihosting-arg" option and implement UHI Arg* ops Leon Alrae
2015-03-01 22:39   ` Matthew Fortune
2015-02-27 17:00 ` [Qemu-devel] [PATCH 4/4] hw/mips: Do not clear BEV for MIPS malta kernel load Leon Alrae

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=54F49E7B.5020809@imgtec.com \
    --to=leon.alrae@imgtec.com \
    --cc=Matthew.Fortune@imgtec.com \
    --cc=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).