Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-05-02 Thread Paolo Bonzini


On 29/04/2017 14:36, Alexey Kardashevskiy wrote:
>> Checking PATCH 1/1: memory/iommu: QOM'fy IOMMU MemoryRegion...
>> ERROR: spaces required around that '*' (ctx:WxO)
>> #156: FILE: hw/dma/rc4030.c:720:
>> +DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr)
> 
> What does the script really want here? I am confused.

It's confused because rc4030_dma doesn't look like a type.  It thinks
it's a multiplication and wants you to write "rc4030_dma * *dmas".

Paolo




Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-30 Thread David Gibson
On Sun, Apr 30, 2017 at 09:11:04PM +0800, Fam Zheng wrote:
> On Sat, 04/29 22:36, Alexey Kardashevskiy wrote:
> > > === OUTPUT BEGIN ===
> > > Checking PATCH 1/1: memory/iommu: QOM'fy IOMMU MemoryRegion...
> > > ERROR: spaces required around that '*' (ctx:WxO)
> > > #156: FILE: hw/dma/rc4030.c:720:
> > > +DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr)
> > 
> > 
> > What does the script really want here? I am confused.
> 
> Must be a false positive here.

Yeah.  I think it thinks that's a multiply * rather than a pointer *.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-30 Thread Fam Zheng
On Sat, 04/29 22:36, Alexey Kardashevskiy wrote:
> > === OUTPUT BEGIN ===
> > Checking PATCH 1/1: memory/iommu: QOM'fy IOMMU MemoryRegion...
> > ERROR: spaces required around that '*' (ctx:WxO)
> > #156: FILE: hw/dma/rc4030.c:720:
> > +DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr)
> 
> 
> What does the script really want here? I am confused.

Must be a false positive here.

Fam



Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-29 Thread Alexey Kardashevskiy
On 29/04/17 22:28, no-re...@patchew.org wrote:
> Hi,
> 
> This series seems to have some coding style problems. See output below for
> more information:
> 
> Subject: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion
> Message-id: 20170429115509.27551-1-...@ozlabs.ru
> Type: series
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> 
> BASE=base
> n=1
> total=$(git log --oneline $BASE.. | wc -l)
> failed=0
> 
> # Useful git options
> git config --local diff.renamelimit 0
> git config --local diff.renames True
> 
> commits="$(git log --format=%H --reverse $BASE..)"
> for c in $commits; do
> echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
> if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; 
> then
> failed=1
> echo
> fi
> n=$((n+1))
> done
> 
> exit $failed
> === TEST SCRIPT END ===
> 
> Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
> Switched to a new branch 'test'
> 72187b4 memory/iommu: QOM'fy IOMMU MemoryRegion
> 
> === OUTPUT BEGIN ===
> Checking PATCH 1/1: memory/iommu: QOM'fy IOMMU MemoryRegion...
> ERROR: spaces required around that '*' (ctx:WxO)
> #156: FILE: hw/dma/rc4030.c:720:
> +DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr)


What does the script really want here? I am confused.



>  ^
> 
> total: 1 errors, 0 warnings, 828 lines checked
> 
> Your patch has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 
> === OUTPUT END ===
> 
> Test command exited with code: 1
> 
> 
> ---
> Email generated automatically by Patchew [http://patchew.org/].
> Please send your feedback to patchew-de...@freelists.org
> 


-- 
Alexey



Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-29 Thread no-reply
Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion
Message-id: 20170429115509.27551-1-...@ozlabs.ru
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
72187b4 memory/iommu: QOM'fy IOMMU MemoryRegion

=== OUTPUT BEGIN ===
Checking PATCH 1/1: memory/iommu: QOM'fy IOMMU MemoryRegion...
ERROR: spaces required around that '*' (ctx:WxO)
#156: FILE: hw/dma/rc4030.c:720:
+DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr)
 ^

total: 1 errors, 0 warnings, 828 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@freelists.org

Re: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-29 Thread no-reply
Hi,

This series failed build test on s390x host. Please find the details below.

Type: series
Message-id: 20170429115509.27551-1-...@ozlabs.ru
Subject: [Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
CC=$HOME/bin/cc
INSTALL=$PWD/install
BUILD=$PWD/build
echo -n "Using CC: "
realpath $CC
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL
make -j4
# XXX: we need reliable clean up
# make check -j4 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/20170429115509.27551-1-...@ozlabs.ru -> 
patchew/20170429115509.27551-1-...@ozlabs.ru
Switched to a new branch 'test'
72187b4 memory/iommu: QOM'fy IOMMU MemoryRegion

=== OUTPUT BEGIN ===
=== ENV ===
XDG_SESSION_ID=28455
SHELL=/bin/sh
USER=fam
PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug
PATH=/usr/bin:/bin
PWD=/var/tmp/patchew-tester-tmp-w3fetk26/src
LANG=en_US.UTF-8
HOME=/home/fam
SHLVL=2
LOGNAME=fam
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus
XDG_RUNTIME_DIR=/run/user/1012
_=/usr/bin/env
=== PACKAGES ===
gpg-pubkey-873529b8-54e386ff
xz-libs-5.2.2-2.fc24.s390x
libxshmfence-1.2-3.fc24.s390x
giflib-4.1.6-15.fc24.s390x
trousers-lib-0.3.13-6.fc24.s390x
ncurses-base-6.0-6.20160709.fc25.noarch
gmp-6.1.1-1.fc25.s390x
libidn-1.33-1.fc25.s390x
slang-2.3.0-7.fc25.s390x
libsemanage-2.5-8.fc25.s390x
pkgconfig-0.29.1-1.fc25.s390x
alsa-lib-1.1.1-2.fc25.s390x
yum-metadata-parser-1.1.4-17.fc25.s390x
python3-slip-dbus-0.6.4-4.fc25.noarch
python2-cssselect-0.9.2-1.fc25.noarch
python-fedora-0.8.0-2.fc25.noarch
createrepo_c-libs-0.10.0-6.fc25.s390x
initscripts-9.69-1.fc25.s390x
wget-1.18-2.fc25.s390x
dhcp-client-4.3.5-1.fc25.s390x
parted-3.2-21.fc25.s390x
flex-2.6.0-3.fc25.s390x
colord-libs-1.3.4-1.fc25.s390x
python-osbs-client-0.33-3.fc25.noarch
perl-Pod-Simple-3.35-1.fc25.noarch
python2-simplejson-3.10.0-1.fc25.s390x
brltty-5.4-2.fc25.s390x
librados2-10.2.4-2.fc25.s390x
tcp_wrappers-7.6-83.fc25.s390x
libcephfs_jni1-10.2.4-2.fc25.s390x
nettle-devel-3.3-1.fc25.s390x
bzip2-devel-1.0.6-21.fc25.s390x
libuuid-2.28.2-2.fc25.s390x
mesa-libglapi-13.0.3-5.fc25.s390x
pcre-cpp-8.40-5.fc25.s390x
pango-1.40.4-1.fc25.s390x
python3-magic-5.29-3.fc25.noarch
python3-dnf-1.1.10-6.fc25.noarch
cryptsetup-libs-1.7.4-1.fc25.s390x
texlive-kpathsea-doc-svn41139-33.fc25.1.noarch
netpbm-10.77.00-3.fc25.s390x
openssh-7.4p1-4.fc25.s390x
kernel-headers-4.10.5-200.fc25.s390x
texlive-kpathsea-bin-svn40473-33.20160520.fc25.1.s390x
texlive-graphics-svn41015-33.fc25.1.noarch
texlive-dvipdfmx-def-svn40328-33.fc25.1.noarch
texlive-mfware-svn40768-33.fc25.1.noarch
texlive-texlive-scripts-svn41433-33.fc25.1.noarch
texlive-euro-svn22191.1.1-33.fc25.1.noarch
texlive-etex-svn37057.0-33.fc25.1.noarch
texlive-iftex-svn29654.0.2-33.fc25.1.noarch
texlive-palatino-svn31835.0-33.fc25.1.noarch
texlive-texlive-docindex-svn41430-33.fc25.1.noarch
texlive-xunicode-svn30466.0.981-33.fc25.1.noarch
texlive-koma-script-svn41508-33.fc25.1.noarch
texlive-pst-grad-svn15878.1.06-33.fc25.1.noarch
texlive-pst-blur-svn15878.2.0-33.fc25.1.noarch
texlive-jknapltx-svn19440.0-33.fc25.1.noarch
netpbm-progs-10.77.00-3.fc25.s390x
mesa-libgbm-devel-13.0.3-5.fc25.s390x
texinfo-6.1-4.fc25.s390x
openssl-devel-1.0.2k-1.fc25.s390x
python2-sssdconfig-1.15.2-1.fc25.noarch
libaio-0.3.110-6.fc24.s390x
libfontenc-1.1.3-3.fc24.s390x
lzo-2.08-8.fc24.s390x
isl-0.14-5.fc24.s390x
libXau-1.0.8-6.fc24.s390x
linux-atm-libs-2.5.1-14.fc24.s390x
libXext-1.3.3-4.fc24.s390x
libXxf86vm-1.1.4-3.fc24.s390x
bison-3.0.4-4.fc24.s390x
perl-srpm-macros-1-20.fc25.noarch
gawk-4.1.3-8.fc25.s390x
libwayland-client-1.12.0-1.fc25.s390x
perl-Exporter-5.72-366.fc25.noarch
perl-version-0.99.17-1.fc25.s390x
fftw-libs-double-3.3.5-3.fc25.s390x
libssh2-1.8.0-1.fc25.s390x
ModemManager-glib-1.6.4-1.fc25.s390x
newt-python3-0.52.19-2.fc25.s390x
python-munch-2.0.4-3.fc25.noarch
python-bugzilla-1.2.2-4.fc25.noarch
libedit-3.1-16.20160618cvs.fc25.s390x
python-pycurl-7.43.0-4.fc25.s390x
createrepo_c-0.10.0-6.fc25.s390x
device-mapper-multipath-libs-0.4.9-83.fc25.s390x
yum-3.4.3-510.fc25.noarch
dhcp-common-4.3.5-1.fc25.noarch
dracut-config-rescue-044-78.fc25.s390x
teamd-1.26-1.fc25.s390x
mozjs17-17.0.0-16.fc25.s390x
libselinux-2.5-13.fc25.s390x
libgo-devel-6.3.1-1.fc25.s390x
NetworkManager-libnm-1.4.4-3.fc25.s390x
python2-pyparsing-2.1.10-1.fc25.noarch
cairo-gobject-1.14.8-1.fc25.s390x
kernel-devel-4.9.3-200.fc25.s390x
ethtool-4.8-1.fc25.s390x
xorg-x11-proto-devel-7.7-20.fc25.noarch
brlapi-0.6.5-2.fc25.s390x
librados-devel-10.2.4-2.fc25.s390x
libXinerama-devel-1.1.3-6.fc24.s390x
quot

[Qemu-devel] [PATCH qemu v4] memory/iommu: QOM'fy IOMMU MemoryRegion

2017-04-29 Thread Alexey Kardashevskiy
This defines new QOM object - IOMMUMemoryRegion - with MemoryRegion
as a parent.

This moves IOMMU-related fields from MR to IOMMU MR. However to avoid
dymanic QOM casting in fast path (address_space_translate, etc),
this adds an @is_iommu boolean flag to MR and provides new helper to
do simple cast to IOMMU MR - memory_region_get_iommu. The flag
is set in the instance init callback. This defines
memory_region_is_iommu as memory_region_get_iommu()!=NULL.

This switches MemoryRegion to IOMMUMemoryRegion in most places except
the ones where MemoryRegion may be an alias.

This defines memory_region_init_iommu_type() to allow creating
IOMMUMemoryRegion subclasses. In order to support custom QOM type,
this splits memory_region_init() to object_initialize() +
memory_region_do_init.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v4:
* fixed compiling of alpha, mips64el and sparc

v3:
* rebased on sha1 81b2d5ceb0

v2:
* added mr->is_iommu
* updated i386/x86_64/s390/sun
---
 hw/s390x/s390-pci-bus.h   |   2 +-
 include/exec/memory.h |  77 +++---
 include/hw/i386/intel_iommu.h |   2 +-
 include/hw/mips/mips.h|   2 +-
 include/hw/ppc/spapr.h|   3 +-
 include/hw/vfio/vfio-common.h |   2 +-
 include/qemu/typedefs.h   |   1 +
 exec.c|  16 +++---
 hw/alpha/typhoon.c|   8 ++-
 hw/dma/rc4030.c   |   8 +--
 hw/i386/amd_iommu.c   |   9 +--
 hw/i386/intel_iommu.c |  17 +++---
 hw/mips/mips_jazz.c   |   2 +-
 hw/pci-host/apb.c |   2 +-
 hw/ppc/spapr_iommu.c  |  20 ---
 hw/s390x/s390-pci-bus.c   |   6 +-
 hw/s390x/s390-pci-inst.c  |   8 +--
 hw/vfio/common.c  |  12 ++--
 hw/vfio/spapr.c   |   3 +-
 memory.c  | 124 +-
 20 files changed, 211 insertions(+), 113 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h
index cf142a3e68..6a599ed353 100644
--- a/hw/s390x/s390-pci-bus.h
+++ b/hw/s390x/s390-pci-bus.h
@@ -266,7 +266,7 @@ typedef struct S390PCIIOMMU {
 S390PCIBusDevice *pbdev;
 AddressSpace as;
 MemoryRegion mr;
-MemoryRegion iommu_mr;
+IOMMUMemoryRegion iommu_mr;
 bool enabled;
 uint64_t g_iota;
 uint64_t pba;
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 99e0f54d86..a2d6f60380 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -37,6 +37,10 @@
 #define MEMORY_REGION(obj) \
 OBJECT_CHECK(MemoryRegion, (obj), TYPE_MEMORY_REGION)
 
+#define TYPE_IOMMU_MEMORY_REGION "qemu:iommu-memory-region"
+#define IOMMU_MEMORY_REGION(obj) \
+OBJECT_CHECK(IOMMUMemoryRegion, (obj), TYPE_IOMMU_MEMORY_REGION)
+
 typedef struct MemoryRegionOps MemoryRegionOps;
 typedef struct MemoryRegionMmio MemoryRegionMmio;
 
@@ -186,15 +190,16 @@ typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
 
 struct MemoryRegionIOMMUOps {
 /* Return a TLB entry that contains a given address. */
-IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool 
is_write);
+IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr,
+   bool is_write);
 /* Returns minimum supported page size */
-uint64_t (*get_min_page_size)(MemoryRegion *iommu);
+uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu);
 /* Called when IOMMU Notifier flag changed */
-void (*notify_flag_changed)(MemoryRegion *iommu,
+void (*notify_flag_changed)(IOMMUMemoryRegion *iommu,
 IOMMUNotifierFlag old_flags,
 IOMMUNotifierFlag new_flags);
 /* Set this up to provide customized IOMMU replay function */
-void (*replay)(MemoryRegion *iommu, IOMMUNotifier *notifier);
+void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
 };
 
 typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -216,7 +221,6 @@ struct MemoryRegion {
 uint8_t dirty_log_mask;
 RAMBlock *ram_block;
 Object *owner;
-const MemoryRegionIOMMUOps *iommu_ops;
 
 const MemoryRegionOps *ops;
 void *opaque;
@@ -239,6 +243,13 @@ struct MemoryRegion {
 const char *name;
 unsigned ioeventfd_nb;
 MemoryRegionIoeventfd *ioeventfds;
+bool is_iommu;
+};
+
+struct IOMMUMemoryRegion {
+MemoryRegion parent_obj;
+
+const MemoryRegionIOMMUOps *iommu_ops;
 QLIST_HEAD(, IOMMUNotifier) iommu_notify;
 IOMMUNotifierFlag iommu_notify_flags;
 };
@@ -579,19 +590,40 @@ static inline void 
memory_region_init_reservation(MemoryRegion *mr,
 }
 
 /**
+ * memory_region_init_iommu_type: Initialize a memory region of a custom type
+ * that translates addresses
+ *
+ * An IOMMU region translates addresses and forwards accesses to a target
+ * memory region.
+ *
+ * @typename: QOM class name
+ * @iommumr: the #IOMMUMemoryRegion to be initialized
+ * @owner: the object that tracks the