From: Paolo Bonzini <pbonzini@redhat.com>
To: Le Tan <tamlokveer@gmail.com>, qemu-devel@nongnu.org
Cc: Jan Kiszka <jan.kiszka@web.de>,
Alex Williamson <alex.williamson@redhat.com>,
Knut Omang <knut.omang@oracle.com>,
Anthony Liguori <aliguori@amazon.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] intel-iommu: introduce Intel IOMMU (VT-d) emulation
Date: Wed, 23 Jul 2014 09:58:10 +0200 [thread overview]
Message-ID: <53CF6B12.5070700@redhat.com> (raw)
In-Reply-To: <1406044070-25667-2-git-send-email-tamlokveer@gmail.com>
Il 22/07/2014 17:47, Le Tan ha scritto:
> +static inline void define_quad(IntelIOMMUState *s, hwaddr addr, uint64_t val,
> + uint64_t wmask, uint64_t w1cmask)
> +{
> + *((uint64_t *)&s->csr[addr]) = val;
All these casts are not endian-safe. Please use ldl_le_p, ldq_le_p,
stl_le_p, stq_le_p.
> + *((uint64_t *)&s->wmask[addr]) = wmask;
> + *((uint64_t *)&s->w1cmask[addr]) = w1cmask;
> +}
> +
> +static inline void define_quad_wo(IntelIOMMUState *s, hwaddr addr,
> + uint64_t mask)
> +{
> + *((uint64_t *)&s->womask[addr]) = mask;
> +}
> +
> +static inline void define_long(IntelIOMMUState *s, hwaddr addr, uint32_t val,
> + uint32_t wmask, uint32_t w1cmask)
> +{
> + *((uint32_t *)&s->csr[addr]) = val;
> + *((uint32_t *)&s->wmask[addr]) = wmask;
> + *((uint32_t *)&s->w1cmask[addr]) = w1cmask;
> +}
> +
> +static inline void define_long_wo(IntelIOMMUState *s, hwaddr addr,
> + uint32_t mask)
> +{
> + *((uint32_t *)&s->womask[addr]) = mask;
> +}
> +
> +/* "External" get/set operations */
> +static inline void set_quad(IntelIOMMUState *s, hwaddr addr, uint64_t val)
> +{
> + uint64_t oldval = *((uint64_t *)&s->csr[addr]);
> + uint64_t wmask = *((uint64_t *)&s->wmask[addr]);
> + uint64_t w1cmask = *((uint64_t *)&s->w1cmask[addr]);
> + *((uint64_t *)&s->csr[addr]) =
> + ((oldval & ~wmask) | (val & wmask)) & ~(w1cmask & val);
> +}
> +
> +static inline void set_long(IntelIOMMUState *s, hwaddr addr, uint32_t val)
> +{
> + uint32_t oldval = *((uint32_t *)&s->csr[addr]);
> + uint32_t wmask = *((uint32_t *)&s->wmask[addr]);
> + uint32_t w1cmask = *((uint32_t *)&s->w1cmask[addr]);
> + *((uint32_t *)&s->csr[addr]) =
> + ((oldval & ~wmask) | (val & wmask)) & ~(w1cmask & val);
> +}
> +
> +static inline uint64_t get_quad(IntelIOMMUState *s, hwaddr addr)
> +{
> + uint64_t val = *((uint64_t *)&s->csr[addr]);
> + uint64_t womask = *((uint64_t *)&s->womask[addr]);
> + return val & ~womask;
> +}
> +
> +
> +static inline uint32_t get_long(IntelIOMMUState *s, hwaddr addr)
> +{
> + uint32_t val = *((uint32_t *)&s->csr[addr]);
> + uint32_t womask = *((uint32_t *)&s->womask[addr]);
> + return val & ~womask;
> +}
> +
> +
> +
> +/* "Internal" get/set operations */
> +static inline uint64_t __get_quad(IntelIOMMUState *s, hwaddr addr)
get_quad_raw?
> +{
> + return *((uint64_t *)&s->csr[addr]);
> +}
> +
> +static inline uint32_t __get_long(IntelIOMMUState *s, hwaddr addr)
get_long_raw?
> +{
> + return *((uint32_t *)&s->csr[addr]);
> +}
> +
> +
> +/* val = (val & ~clear) | mask */
> +static inline uint32_t set_mask_long(IntelIOMMUState *s, hwaddr addr,
set_clear_long?
> + uint32_t clear, uint32_t mask)
> +{
> + uint32_t *ptr = (uint32_t *)&s->csr[addr];
> + uint32_t val = (*ptr & ~clear) | mask;
> + *ptr = val;
> + return val;
> +}
> +
> +/* val = (val & ~clear) | mask */
> +static inline uint64_t set_mask_quad(IntelIOMMUState *s, hwaddr addr,
set_clear_quad?
> + uint64_t clear, uint64_t mask)
> +{
> + uint64_t *ptr = (uint64_t *)&s->csr[addr];
> + uint64_t val = (*ptr & ~clear) | mask;
> + *ptr = val;
> + return val;
> +}
> +
> +
next prev parent reply other threads:[~2014-07-23 7:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 15:47 [Qemu-devel] [PATCH 0/3] intel-iommu: introduce Intel IOMMU (VT-d) emulation to q35 chipset Le Tan
2014-07-22 15:47 ` [Qemu-devel] [PATCH 1/3] intel-iommu: introduce Intel IOMMU (VT-d) emulation Le Tan
2014-07-22 20:05 ` Michael S. Tsirkin
2014-07-23 1:25 ` Le Tan
2014-07-23 7:58 ` Paolo Bonzini [this message]
2014-07-23 23:21 ` Le Tan
2014-07-23 20:29 ` Stefan Weil
2014-07-23 23:24 ` Le Tan
2014-08-03 15:16 ` Knut Omang
2014-07-22 15:47 ` [Qemu-devel] [PATCH 2/3] intel-iommu: add DMAR table to ACPI tables Le Tan
2014-07-22 15:47 ` [Qemu-devel] [PATCH 3/3] intel-iommu: add Intel IOMMU emulation to q35 and add a machine option "vtd" as a switch Le Tan
2014-07-26 8:47 ` Jan Kiszka
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=53CF6B12.5070700@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=aliguori@amazon.com \
--cc=jan.kiszka@web.de \
--cc=knut.omang@oracle.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tamlokveer@gmail.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).