All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Chris Friedt <cfriedt@meta.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Alexander Bulekov <alxndr@bu.edu>,
	Chris Friedt <chrisfriedt@gmail.com>,
	"jslaby@suse.cz" <jslaby@suse.cz>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [v2] hw: misc: edu: fix 2 off-by-one errors
Date: Tue, 18 Oct 2022 07:11:28 +0100	[thread overview]
Message-ID: <874jw1ek29.fsf@linaro.org> (raw)
In-Reply-To: <84F27875-816B-4E87-8D8B-E57852185512@meta.com>


Chris Friedt <cfriedt@meta.com> writes:

>> On Oct 17, 2022, at 1:22 PM, Alex Bennée <alex.bennee@linaro.org> wrote:
>> 
>> > 
>> 
>> Peter Maydell <peter.maydell@linaro.org> writes:
>> 
>>>> On Mon, 17 Oct 2022 at 14:50, Alexander Bulekov <alxndr@bu.edu> wrote:
>>>> 
>>>> On 221015 1710, Chris Friedt wrote:
>>>>> From: Christopher Friedt <cfriedt@meta.com>
>>>>> 
>>>> Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
>>>> 
>>>> As a side-note, seems strange that edu_check_range will abort the entire
>>>> VM if the check fails, rather than handling the error more elegantly.
>>> 
>>> Yes, this is bad for a device model, though we have a lot of
>>> older device models that still do it. The preferred pattern is:
>>> * for situations which are "if this happens there is a
>>>   bug in QEMU itself", use assert. hw_error() is a kind of
>>>   assert that prints a bunch of guest register state: sometimes
>>>   you want that, but more often you just want normal assert()
>>> * for situations where the guest has misprogrammed the device,
>>>   log that with qemu_log_mask(LOG_GUEST_ERROR, ...)
>>>   and continue with whatever the real hardware would do, or
>>>   some reasonable choice if the h/w spec is vague
>>> * for situations where the guest is correct but is trying to
>>>   get the device to do something our model doesn't implement
>>>   yet, same as above but with LOG_UNIMP.
>>> 
>>> Probably most hw_error() uses in the codebase should be
>>> replaced with one of the above options.
>> 
>> We should probably document this best practice somewhere in docs/devel
>> but I guess we really need a "guide to writing device emulation"
>> section.
>
> Should I make a separate PR for that or attach it to the existing
> series (at v3 now)?

I don't think improving our developer documentation needs to be part of
this fix. However if you want to take a run at improving it in a new
series be my guest ;-)

>
> Thanks,
>
> C


-- 
Alex Bennée


  reply	other threads:[~2022-10-18  6:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15 21:10 [v2] hw: misc: edu: fix 2 off-by-one errors Chris Friedt
2022-10-17  6:22 ` Jiri Slaby
2022-10-17 16:36   ` Christopher Friedt
2022-11-01 18:59     ` Christopher Friedt
2022-10-17 13:44 ` Alexander Bulekov
2022-10-17 14:13   ` Peter Maydell
2022-10-17 17:21     ` Alex Bennée
2022-10-17 22:05       ` Chris Friedt
2022-10-18  6:11         ` Alex Bennée [this message]
2022-10-18  6:30     ` Jiri Slaby
2022-10-18  9:18       ` Alex Bennée
2022-10-18  9:30         ` Peter Maydell
2022-10-18 12:11           ` Alex Bennée
2022-10-18  6:27   ` Jiri Slaby

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=874jw1ek29.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=alxndr@bu.edu \
    --cc=cfriedt@meta.com \
    --cc=chrisfriedt@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=peter.maydell@linaro.org \
    --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 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.