qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Thomas Huth <thuth@redhat.com>, Yi Min Zhao <zyimin@linux.ibm.com>
Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
	pmorel@linux.ibm.com, qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] s390x/pci: add common fmb
Date: Tue, 23 Oct 2018 23:25:17 +0200	[thread overview]
Message-ID: <20181023232517.6b93085b.cohuck@redhat.com> (raw)
In-Reply-To: <698a7fdd-47cc-cb3e-a280-3c4b656d92ef@redhat.com>

On Mon, 22 Oct 2018 13:17:34 +0100
Thomas Huth <thuth@redhat.com> wrote:

> On 2018-10-22 10:02, Yi Min Zhao wrote:
> > Common function measurement block is used to report counters of
> > successfully issued pcilg/stg/stb and rpcit instructions. This patch
> > introduces a new struct ZpciFmb and schedules a timer callback to
> > copy fmb to the guest memory at a interval time which is set to
> > 4s by default. While attemping to update fmb failed, an event error
> > would be generated. After pcilg/stg/stb and rpcit interception
> > handlers issue successfully, increase the related counter. The guest
> > could pass null address to switch off FMB and stop corresponding
> > timer.
> > 
> > Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
> > Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
> > ---  
> [...]
> > +static int fmb_do_update(S390PCIBusDevice *pbdev, uint8_t offset, int len)
> > +{
> > +    MemTxResult ret;
> > +
> > +    ret = address_space_write(&address_space_memory,
> > +                              pbdev->fmb_addr + (uint64_t)offset,
> > +                              MEMTXATTRS_UNSPECIFIED,
> > +                              (uint8_t *)&pbdev->fmb + offset,
> > +                              len);
> > +    if (ret) {
> > +        s390_pci_generate_error_event(ERR_EVENT_FMBA, pbdev->fh, pbdev->fid,
> > +                                      pbdev->fmb_addr, 0);
> > +        fmb_timer_free(pbdev);
> > +    }
> > +
> > +    return ret;
> > +}
> > +
> > +static void fmb_update(void *opaque)
> > +{
> > +    S390PCIBusDevice *pbdev = opaque;
> > +    int64_t t = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);
> > +    uint8_t offset = offsetof(ZpciFmb, last_update);
> > +
> > +    /* Update U bit */
> > +    pbdev->fmb.last_update |= UPDATE_U_BIT;
> > +    if (fmb_do_update(pbdev, offset, sizeof(uint64_t))) {
> > +        return;
> > +    }
> > +
> > +    /* Update FMB counters */
> > +    pbdev->fmb.sample++;
> > +    if (fmb_do_update(pbdev, 0, sizeof(ZpciFmb))) {
> > +        return;
> > +    }
> > +
> > +    /* Clear U bit and update the time */
> > +    pbdev->fmb.last_update = time2tod(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
> > +    pbdev->fmb.last_update &= ~UPDATE_U_BIT;
> > +    if (fmb_do_update(pbdev, offset, sizeof(uint64_t))) {
> > +        return;
> > +    }
> > +
> > +    timer_mod(pbdev->fmb_timer, t + DEFAULT_MUI);
> > +}  
> 
> Sorry for noticing this in v1 already, but is this code endianess-safe?
> I.e. can this also work with qemu-system-s390x running with TCG on a x86
> host? I think you might have to use something like this here instead:
> 
>   pbdev->fmb.sample = cpu_to_be32(be32_to_cpu(pbdev->fmb.sample) + 1);
> 
> etc.

Agreed, that may need some endianness handling.

I would test this with tcg on a LE host, but how can I verify this? Yi
Min, do you have some kind of test tooling you can share?

  parent reply	other threads:[~2018-10-23 21:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22  9:02 [Qemu-devel] [PATCH v2] s390x/pci: add common fmb Yi Min Zhao
2018-10-22 12:17 ` Thomas Huth
2018-10-23  7:50   ` Yi Min Zhao
2018-10-23 21:25   ` Cornelia Huck [this message]
2018-10-24  3:58     ` Yi Min Zhao
2018-10-31 10:49       ` Cornelia Huck
2018-11-30  9:23         ` Pierre Morel
2018-11-30  9:27           ` Cornelia Huck
2018-12-12 20:25             ` Collin Walling
2018-12-13 14:59               ` Cornelia Huck

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=20181023232517.6b93085b.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=pmorel@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=zyimin@linux.ibm.com \
    /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).