Re: [Qemu-devel] [RFC v5 05/26] qjson: add "opaque" field to JSONMessageParser

2017-12-14 Thread Peter Xu
On Wed, Dec 13, 2017 at 03:37:02PM +, Stefan Hajnoczi wrote:
> On Tue, Dec 05, 2017 at 01:51:39PM +0800, Peter Xu wrote:
> > diff --git a/qga/main.c b/qga/main.c
> > index 62a62755bd..3b5ebbc1ee 100644
> > --- a/qga/main.c
> > +++ b/qga/main.c
> > @@ -593,7 +593,8 @@ static void process_command(GAState *s, QDict *req)
> >  }
> >  
> >  /* handle requests/control events coming in over the channel */
> > -static void process_event(JSONMessageParser *parser, GQueue *tokens)
> > +static void process_event(JSONMessageParser *parser, GQueue *tokens,
> > +  void *opaque)
> >  {
> >  GAState *s = container_of(parser, GAState, parser);
> >  QDict *qdict;
> > @@ -1320,7 +1321,7 @@ static int run_agent(GAState *s, GAConfig *config, 
> > int socket_activation)
> >  s->command_state = ga_command_state_new();
> >  ga_command_state_init(s, s->command_state);
> >  ga_command_state_init_all(s->command_state);
> > -json_message_parser_init(>parser, process_event);
> > +json_message_parser_init(>parser, process_event, NULL);
> 
> This patch leaves the code with 2 ways of getting at state from the
> parser pointer:
> 1. Use container_of() like existing users.
> 2. Use the new (unused) opaque argument.
> 
> Given that #1 exists, is this patch really necessary?

I didn't really notice that.  Thanks for pointing out.

However even if so I would still prefer the opaque way to do it if
asked.  Existing #1 of course works but IMHO is less flexible and has
dependency between structure layouts.

How about I append another patch to convert existing users (or, I can
post as separate patches after this series)?  It's not really a lot,
and the conversion would be obvious:

*** qga/main.c:
run_agent[1324]json_message_parser_init(>parser, 
process_event, NULL);
*** qobject/qjson.c:
qobject_from_jsonv[45] json_message_parser_init(, 
parse_json, NULL);
*** tests/libqtest.c:
qmp_fd_receive[438]json_message_parser_init(, 
qmp_response, NULL);

Though, if you still insist, I can drop it too.

> 
> Please explain in the commit description, don't make me look ahead in
> the patch series.

I will add some comments if this patch is still alive in next
version.  Thanks,

-- 
Peter Xu



[Qemu-devel] [Bug 1738283] Re: 'Less than' (<), 'more than' (>), and 'pipe' (|) can't be typed via VNC

2017-12-14 Thread Michal Nowak
Well, if virt-manager is configured to run the VM with `-k en-us` I
can't enter <>| even in virt-manager. keycodemapdb?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1738283

Title:
  'Less than' (<), 'more than' (>), and 'pipe' (|) can't be typed via
  VNC

Status in QEMU:
  New

Bug description:
  If I start QEMU 2.11 (from
  https://build.opensuse.org/package/show/Virtualization/qemu) VM with
  VNC, I am unable to type following three characters: 'less than' (<),
  'more than' (>), and 'pipe' (|) on en_US QWERTY keyboard. Other
  characters work fine. QEMu version 2.10.1 worked fine.

  /usr/bin/qemu-kvm -m 2048 -cpu kvm64 -drive
  media=cdrom,if=none,id=cd0,format=raw,file=OI-hipster-
  minimal-20171031.iso -device ide-cd,drive=cd0 -boot once=d,menu=on
  ,splash-time=5000 -device usb-ehci -device usb-tablet -smp 1 -enable-
  kvm -vnc :91,share=force-shared

  The ISO can be downloaded here: https://www.openindiana.org/download/

  Also tried Fedora-Server-dvd-x86_64-25-1.3.iso and it's the same
  situation.

  If I run the same command without '-vnc :91,share=force-shared',
  everything works just fine.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1738283/+subscriptions



Re: [Qemu-devel] [Qemu-ppc] [PATCH] ppc/pnv: change powernv_ prefix to pnv_ for overall naming consistency

2017-12-14 Thread Cédric Le Goater
On 12/15/2017 07:43 AM, Alexey Kardashevskiy wrote:
> On 15/12/17 17:17, Cédric Le Goater wrote:
>> Signed-off-by: Cédric Le Goater 
>> ---
>>  hw/ppc/pnv.c | 84 
>> ++--
>>  hw/ppc/pnv_core.c|  8 ++---
>>  hw/ppc/pnv_lpc.c |  2 +-
>>  include/hw/ppc/pnv.h |  8 ++---
>>  4 files changed, 51 insertions(+), 51 deletions(-)
>>
>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
>> index c35c439d816b..4bc5f61d0da7 100644
>> --- a/hw/ppc/pnv.c
>> +++ b/hw/ppc/pnv.c
>> @@ -77,7 +77,7 @@ static const char *pnv_chip_core_typename(const PnvChip *o)
>>   * that has a different "affinity". In practice, it means one range
>>   * per chip.
>>   */
>> -static void powernv_populate_memory_node(void *fdt, int chip_id, hwaddr 
>> start,
>> +static void pnv_populate_memory_node(void *fdt, int chip_id, hwaddr start,
>>   hwaddr size)
> 
> You may also want to fix indentations like the line above.

yes. I missed that. I should run indent after using sed.

While I am at it, I can also change the name of the routines 
populating the device tree. 

David, 

are you following more or less this pattern :

_dt_

Thanks,

C.



[Qemu-devel] [Bug 1738283] Re: 'Less than' (<), 'more than' (>), and 'pipe' (|) can't be typed via VNC

2017-12-14 Thread Michal Nowak
Should have mention I use openSUSE Leap 42.3 with above mentioned
virtualization repo.

Removed the 0026-Fix-tigervnc-long-press-issue patch and rebuilt QEMU
but no change.

But I noticed that if I run the ISO via libvirt and connect to it via
virt-manager (virt-manager-1.4.1-4.1.noarch), the keys are there as
expected:

/usr/bin/qemu-system-x86_64 -machine accel=kvm -name guest=OI,debug-
threads=on -S -object
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-OI
/master-key.aes -machine pc-i440fx-2.11,accel=kvm,usb=off,vmport=off
,dump-guest-core=off -cpu kvm64 -m 2048 -realtime mlock=off -smp
1,sockets=1,cores=1,threads=1 -uuid 5664149e-26ad-4ee8-8170-16701f107b4b
-no-user-config -nodefaults -chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-2-OI/monitor.sock,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc
base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=delay -no-
hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global
PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-
ehci1,id=usb,bus=pci.0,addr=0x3.0x7 -device ich9-usb-
uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x3
-device ich9-usb-
uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x3.0x1 -device ich9
-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x3.0x2 -drive
file=/var/lib/libvirt/images/OI-hipster-
minimal-20171031.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on
-device ide-cd,bus=ide.0,unit=0,drive=drive-
ide0-0-0,id=ide0-0-0,bootindex=1 -vnc 127.0.0.1:0 -device
VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 -device virtio-balloon-
pci,id=balloon0,bus=pci.0,addr=0x4 -msg timestamp=on

Connection via TigerVNC (tigervnc-1.6.0-21.1.x86_64) to the same VM is
unable to write those characters.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1738283

Title:
  'Less than' (<), 'more than' (>), and 'pipe' (|) can't be typed via
  VNC

Status in QEMU:
  New

Bug description:
  If I start QEMU 2.11 (from
  https://build.opensuse.org/package/show/Virtualization/qemu) VM with
  VNC, I am unable to type following three characters: 'less than' (<),
  'more than' (>), and 'pipe' (|) on en_US QWERTY keyboard. Other
  characters work fine. QEMu version 2.10.1 worked fine.

  /usr/bin/qemu-kvm -m 2048 -cpu kvm64 -drive
  media=cdrom,if=none,id=cd0,format=raw,file=OI-hipster-
  minimal-20171031.iso -device ide-cd,drive=cd0 -boot once=d,menu=on
  ,splash-time=5000 -device usb-ehci -device usb-tablet -smp 1 -enable-
  kvm -vnc :91,share=force-shared

  The ISO can be downloaded here: https://www.openindiana.org/download/

  Also tried Fedora-Server-dvd-x86_64-25-1.3.iso and it's the same
  situation.

  If I run the same command without '-vnc :91,share=force-shared',
  everything works just fine.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1738283/+subscriptions



Re: [Qemu-devel] [Qemu-ppc] [PATCH] ppc/pnv: change powernv_ prefix to pnv_ for overall naming consistency

2017-12-14 Thread Alexey Kardashevskiy
On 15/12/17 17:17, Cédric Le Goater wrote:
> Signed-off-by: Cédric Le Goater 
> ---
>  hw/ppc/pnv.c | 84 
> ++--
>  hw/ppc/pnv_core.c|  8 ++---
>  hw/ppc/pnv_lpc.c |  2 +-
>  include/hw/ppc/pnv.h |  8 ++---
>  4 files changed, 51 insertions(+), 51 deletions(-)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index c35c439d816b..4bc5f61d0da7 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -77,7 +77,7 @@ static const char *pnv_chip_core_typename(const PnvChip *o)
>   * that has a different "affinity". In practice, it means one range
>   * per chip.
>   */
> -static void powernv_populate_memory_node(void *fdt, int chip_id, hwaddr 
> start,
> +static void pnv_populate_memory_node(void *fdt, int chip_id, hwaddr start,
>   hwaddr size)

You may also want to fix indentations like the line above.




-- 
Alexey



[Qemu-devel] [Bug 1705118] Re: qemu user mode does not support catching SIGSEGV on some architectures

2017-12-14 Thread Bruno Haible
I confirm that in qemu-2.11, the ppc and s390x cases are fixed, however
the sparc64 case is still failing:

$ ~/inst-qemu/2.11.0/bin/qemu-ppc testsigsegv-ppc
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-ppc64 testsigsegv-ppc64
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-ppc64le testsigsegv-ppc64le
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-s390x testsigsegv-s390x
$ echo $?
0
$ ~/inst-qemu/2.11.0/bin/qemu-s390x testsigsegv-s390x-a
$ echo $?
3

$ ~/inst-qemu/2.11.0/bin/qemu-sparc64 testsigsegv-sparc64
setup_rt_frame: not implemented
Segmentation fault (core dumped)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1705118

Title:
  qemu user mode does not support catching SIGSEGV on some architectures

Status in QEMU:
  Confirmed

Bug description:
  The documentation
   says that
  qemu in user mode supports POSIX signal handling.

  Catching SIGSEGV according to POSIX, however, does not work on
ppc, ppc64, ppc64le, s390x, sparc64.
  It does work, however, on
aarch64, alpha, arm, hppa, m68k, mips, mips64, sh4.

  How to reproduce:
  The attached program runs fine (exits with code 0) on
- real hardware Linux/PowerPC64 (in 32-bit and 64-bit mode),
- real hardware Linux/PowerPC64LE,
- qemu-system-s390x emulated Linux/s390x,
- real hardware Linux/SPARC64.
  $ gcc -O -Wall testsigsegv.c; ./a.out; echo $?
  0

  For ppc:
  $ powerpc-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-ppc
  $ ~/inst-qemu/2.9.0/bin/qemu-ppc testsigsegv-ppc
  $ echo $?
  3

  For ppc64:
  $ powerpc64-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o 
testsigsegv-ppc64
  $ ~/inst-qemu/2.9.0/bin/qemu-ppc64 testsigsegv-ppc64
  $ echo $?
  3

  For ppc64le:
  $ powerpc64le-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o 
testsigsegv-ppc64le
  $ ~/inst-qemu/2.9.0/bin/qemu-ppc64le testsigsegv-ppc64le
  $ echo $?
  3

  For s390x:
  $ s390x-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-s390x
  $ ~/inst-qemu/2.9.0/bin/qemu-s390x testsigsegv-s390x
  $ echo $?
  3
  $ s390x-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c 
-DAVOID_LINUX_S390X_COMPAT -o testsigsegv-s390x-a
  $ ~/inst-qemu/2.9.0/bin/qemu-s390x testsigsegv-s390x-a
  $ echo $?
  0
  So, the test fails here because the Linux/s390x kernel omits the least
  significant 12 bits of the fault address in the 'si_addr' field. But
  qemu-s390x is not compatible with the Linux/s390x behaviour: it puts
  the complete fault address in the 'si_addr' field.

  For sparc64:
  $ sparc64-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o 
testsigsegv-sparc64
  $ ~/inst-qemu/2.9.0/bin/qemu-sparc64 testsigsegv-sparc64
  Segmentation fault (core dumped)

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1705118/+subscriptions



[Qemu-devel] [Bug 1701974] Re: pwrite does not work right under qemu-sh4

2017-12-14 Thread Bruno Haible
Works fine in qemu-2.11:
$ ~/inst-qemu/2.11.0/bin/qemu-sh4 test-pwrite
buf = 01W3456789


** Changed in: qemu
   Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1701974

Title:
  pwrite does not work right under qemu-sh4

Status in QEMU:
  Fix Released

Bug description:
  The pwrite system call has no effect when writing to a non-zero file
  position, in a program running under qemu-sh4 (version 2.9.0).

  How to reproduce:
  - Compile the program:
sh4-linux-gnu-gcc-5 -O -Wall -static -o test-pwrite test-pwrite.c
  - Set environment variable for using qemu-sh4 (actually not needed, since the 
program is statically linked here).
  - ~/inst-qemu/2.9.0/bin/qemu-sh4 test-pwrite

  Expected output:
  buf = 01W3456789

  Actual output:
  buf = 0123456789
  test-pwrite.c:56: assertion 'strcmp ("01W3456789",buf) == 0' failed
  qemu: uncaught target signal 6 (Aborted) - core dumped

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1701974/+subscriptions



[Qemu-devel] [Bug 1704658] Re: O_CLOEXEC not handled in dup3 system call in user mode

2017-12-14 Thread Bruno Haible
The behaviour in qemu-2.11 is the same as in qemu-2.9.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1704658

Title:
  O_CLOEXEC not handled in dup3 system call in user mode

Status in QEMU:
  New

Bug description:
  In qemu user mode, for hppa and sparc64 targets, the parameter of the
  dup3 is not passed correctly when it contains the O_CLOEXEC flag.

  When the attached program runs, the expected output is:
  errno=9=EBADF

  How to reproduce on hppa:
  - Compile the program: hppa-linux-gnu-gcc-5 -O -Wall -static testdup3.c -o 
testdup3-hppa
  - Set environment variables for running qemu-hppa.
  - ~/inst-qemu/2.9.0/bin/qemu-hppa testdup3-hppa
  errno=22=EINVAL
  testdup3.c:54: assertion 'errno == EBADF' failed

  How to reproduce on sparc64:
  - Compile the program: sparc64-linux-gnu-gcc-5 -O -Wall -static testdup3.c -o 
testdup3-sparc64
  - Set environment variables for running qemu-sparc64.
  - ~/inst-qemu/2.9.0/bin/qemu-sparc64 testdup3-sparc64
  errno=22=EINVAL
  testdup3.c:54: assertion 'errno == EBADF' failed

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1704658/+subscriptions



[Qemu-devel] [Bug 1704638] Re: weak symbol access makes qemu in user mode hang for mips, mips64

2017-12-14 Thread Bruno Haible
This is fixed in qemu-2.11:
$ ~/inst-qemu/2.11.0/bin/qemu-mips testpthsigmask-mips
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
$ ~/inst-qemu/2.11.0/bin/qemu-mips64 testpthsigmask-mips64
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)


** Changed in: qemu
   Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1704638

Title:
  weak symbol access makes qemu in user mode hang for mips, mips64

Status in QEMU:
  Fix Released

Bug description:
  A program that is statically linked and invokes a weak pointer should
  crash (because the weak pointer evaluates to NULL).

  With qemu in user mode, for mips and mips64, it hangs. The process
  needs to be killed with "kill -9".

  How to reproduce for mips:
  - Compile the program: mips-linux-gnu-gcc-5 -O -Wall -static -o 
testpthsigmask-mips testpthsigmask.c -pthread
  - Set environment variables for running qemu-mips.
  - ~/inst-qemu/2.9.0/bin/qemu-mips testpthsigmask-mips

  How to reproduce for mips64:
  - Compile the program: mips64-linux-gnuabi64-gcc-5 -O -Wall -static -o 
testpthsigmask-mips64 testpthsigmask.c -lpthread
  - Set environment variables for running qemu-mips64.
  - ~/inst-qemu/2.9.0/bin/qemu-mips64 testpthsigmask-mips64

  When I attach gdb to the process, I see that it is hanging inside
  'gen_intermediate_code':

  $ gdb /home/bruno/inst-qemu/2.9.0/bin/qemu-mips 9726
  ...
  Reading symbols from /home/bruno/inst-qemu/2.9.0/bin/qemu-mips...done.
  Attaching to program: /home/bruno/inst-qemu/2.9.0/bin/qemu-mips, process 9726
  ...
  (gdb) info threads
Id   Target Id Frame 
  * 1Thread 0x7f1e7e535740 (LWP 9726) "qemu-mips" __lll_lock_wait () at 
../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
2Thread 0x7f1e7d0ad700 (LWP 9727) "qemu-mips" syscall () at 
../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  (gdb) where
  #0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
  #1  0x7f1e7d6f1dbd in __GI___pthread_mutex_lock 
(mutex=mutex@entry=0x55de1c7ff830 ) at 
../nptl/pthread_mutex_lock.c:80
  #2  0x55de1c527199 in qemu_mutex_lock (mutex=mutex@entry=0x55de1c7ff830 
)
  at /media/develdata/devel/build/qemu-2.9.0/util/qemu-thread-posix.c:60
  #3  0x55de1c435083 in tb_lock () at 
/media/develdata/devel/build/qemu-2.9.0/translate-all.c:167
  #4  cpu_restore_state (cpu=cpu@entry=0x55de1e915cb0, 
retaddr=retaddr@entry=94412445741769) at 
/media/develdata/devel/build/qemu-2.9.0/translate-all.c:350
  #5  0x55de1c4658d0 in handle_cpu_signal (old_set=0x7ffe5ffd8ea8, 
is_write=0, address=0, pc=94412445741767)
  at /media/develdata/devel/build/qemu-2.9.0/user-exec.c:124
  #6  cpu_mips_signal_handler (host_signum=host_signum@entry=11, 
pinfo=pinfo@entry=0x7ffe5ffd8eb0, puc=puc@entry=0x7ffe5ffd8d80)
  at /media/develdata/devel/build/qemu-2.9.0/user-exec.c:229
  #7  0x55de1c4803be in host_signal_handler (host_signum=11, 
info=0x7ffe5ffd8eb0, puc=0x7ffe5ffd8d80)
  at /media/develdata/devel/build/qemu-2.9.0/linux-user/signal.c:646
  #8  
  #9  __bswap_32 (__bsx=) at 
/usr/include/x86_64-linux-gnu/bits/byteswap.h:47
  #10 bswap32 (x=) at 
/media/develdata/devel/build/qemu-2.9.0/include/qemu/bswap.h:21
  #11 ldl_be_p (ptr=) at 
/media/develdata/devel/build/qemu-2.9.0/include/qemu/bswap.h:434
  #12 cpu_ldl_code (env=0x55de1e91df48, ptr=0) at 
/media/develdata/devel/build/qemu-2.9.0/include/exec/cpu_ldst_useronly_template.h:68
  #13 gen_intermediate_code (env=env@entry=0x55de1e91df48, 
tb=tb@entry=0x7f1e7b288e58)
  at /media/develdata/devel/build/qemu-2.9.0/target/mips/translate.c:19962
  #14 0x55de1c4352e6 in tb_gen_code (cpu=cpu@entry=0x55de1e915cb0, 
pc=pc@entry=0, cs_base=cs_base@entry=0, flags=flags@entry=162, 
cflags=, 
  cflags@entry=0) at 
/media/develdata/devel/build/qemu-2.9.0/translate-all.c:1295
  #15 0x55de1c436a7a in tb_find (tb_exit=0, last_tb=0x0, cpu=) at /media/develdata/devel/build/qemu-2.9.0/cpu-exec.c:365
  #16 cpu_exec (cpu=) at 
/media/develdata/devel/build/qemu-2.9.0/cpu-exec.c:673
  #17 0x55de1c466278 in cpu_loop (env=0x55de1e91df48) at 
/media/develdata/devel/build/qemu-2.9.0/linux-user/main.c:2236
  #18 0x55de1c433103 in main (argc=, argv=0x7ffe5ffd9de8, 
envp=)
  at /media/develdata/devel/build/qemu-2.9.0/linux-user/main.c:4860
  (gdb) thread 2
  [Switching to thread 2 (Thread 0x7f1e7d0ad700 (LWP 9727))]
  #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  38  ../sysdeps/unix/sysv/linux/x86_64/syscall.S: Datei oder Verzeichnis 
nicht gefunden.
  (gdb) where
  #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  #1  0x55de1c527605 in qemu_futex_wait (val=, f=) at /media/develdata/devel/build/qemu-2.9.0/include/qemu/futex.h:26
  #2  

[Qemu-devel] [PATCH qemu v2] RFC: vfio-pci: Allow mmap of MSIX BAR

2017-12-14 Thread Alexey Kardashevskiy
This makes use of a new VFIO_REGION_INFO_CAP_MSIX_MAPPABLE capability
which tells that a region with MSIX data can be mapped entirely, i.e.
the VFIO PCI driver won't prevent MSIX vectors area from being mapped.

With this change, all BARs are mapped in a single chunk and MSIX vectors
are emulated on top unless the machine requests not to by defining and
enabling a new "vfio-no-msix-emulation" property. At the moment only
sPAPR machine does so - it prohibits MSIX emulation and does not allow
enabling it as it does not define the "set" callback for the new property;
the new property also does not appear in "-machine pseries,help".

If the new capability is present, this puts MSIX IO memory region under
mapped memory region. If the capability is not there, it falls back to
the old behaviour with the sparse capability.

In MSIX vectors section is not aligned to the page size, the KVM memory
listener does not register it with the KVM as a memory slot and MSIX is
emulated by QEMU as before.

This requires the kernel change - "vfio-pci: Allow mapping MSIX BAR" -
for the new capability: https://www.spinics.net/lists/kvm/msg160282.html

Signed-off-by: Alexey Kardashevskiy 
---

This is mtree and flatview BEFORE this patch:

"info mtree":
memory-region: p...@8002000.mmio
  - (prio 0, i/o): p...@8002000.mmio
2100-2100 (prio 1, i/o): 0001:03:00.0 BAR 1
  2100e000-2100e5ff (prio 0, i/o): msix-table
  2100f000-2100f00f (prio 0, i/o): msix-pba [disabled]
2104-2107 (prio 1, i/o): 0001:03:00.0 BAR 3
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 
mmaps[0]

"info mtree -f":
FlatView #0
 AS "memory", root: system
 AS "cpu-memory", root: system
 Root memory region: system
  -7fff (prio 0, ram): ppc_spapr.ram
  2100-2100dfff (prio 1, i/o): 0001:03:00.0 BAR 1
  2100e000-2100e5ff (prio 0, i/o): msix-table
  2100e600-2100 (prio 1, i/o): 0001:03:00.0 BAR 1 
@e600
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 mmaps[0]



This is AFTER this patch applied:

"info mtree":
memory-region: p...@8002000.mmio
  - (prio 0, i/o): p...@8002000.mmio
2100-2100 (prio 1, i/o): 0001:03:00.0 BAR 1
  2100-2100 (prio 0, ramd): 0001:03:00.0 BAR 1 
mmaps[0]
2100e000-2100e5ff (prio 0, i/o): msix-table [disabled]
2100f000-2100f00f (prio 0, i/o): msix-pba [disabled]
2104-2107 (prio 1, i/o): 0001:03:00.0 BAR 3
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 
mmaps[0]


"info mtree -f":
FlatView #2
 AS "memory", root: system
 AS "cpu-memory", root: system
 Root memory region: system
  -7fff (prio 0, ram): ppc_spapr.ram
  2100-2100 (prio 0, ramd): 0001:03:00.0 BAR 1 mmaps[0]
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 mmaps[0]



This is AFTER this patch applied AND spapr_get_msix_emulation() patched
to enable emulation:

"info mtree":
memory-region: p...@8002000.mmio
  - (prio 0, i/o): p...@8002000.mmio
2100-2100 (prio 1, i/o): 0001:03:00.0 BAR 1
  2100-2100 (prio 0, ramd): 0001:03:00.0 BAR 1 
mmaps[0]
2100e000-2100e5ff (prio 0, i/o): msix-table
2100f000-2100f00f (prio 0, i/o): msix-pba [disabled]
2104-2107 (prio 1, i/o): 0001:03:00.0 BAR 3
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 
mmaps[0]

"info mtree -f":
FlatView #1
 AS "memory", root: system
 AS "cpu-memory", root: system
 Root memory region: system
  -7fff (prio 0, ram): ppc_spapr.ram
  2100-2100dfff (prio 0, ramd): 0001:03:00.0 BAR 1 mmaps[0]
  2100e000-2100e5ff (prio 0, i/o): msix-table
  2100e600-2100 (prio 0, ramd): 0001:03:00.0 BAR 1 mmaps[0] 
@e600
  2104-2107 (prio 0, ramd): 0001:03:00.0 BAR 3 mmaps[0]
---
 include/hw/vfio/vfio-common.h |  1 +
 linux-headers/linux/vfio.h|  5 +
 hw/ppc/spapr.c|  8 
 hw/vfio/common.c  | 15 +++
 hw/vfio/pci.c | 23 +--
 5 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index f3a2ac9..927d600 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -171,6 +171,7 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index,
  struct 

[Qemu-devel] [Bug 1701835] Re: floating-point operation bugs in qemu-alpha

2017-12-14 Thread Bruno Haible
The behaviour in qemu-2.11 is the same as in qemu-2.9.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1701835

Title:
  floating-point operation bugs in qemu-alpha

Status in QEMU:
  New

Bug description:
  When running the gnulib testsuite, I'm seeing test failures in the tests for 
libm functions
cbrt
cbrtf
ceil
ceilf
coshf
exp2
exp2f
floor
floorf
fma
fmaf
fmal
frexp
frexpf
hypot
hypotf
hypotl
ilogb
ilogbf
isfinite
isinf
isnan
isnand
isnanf
ldexp
ldexpf
ldexpl
log1p
log1pf
log2
log2f
logb
logbf
logbl
rint
rintf
rintl
signbit
sqrt
sqrtf
strtod
  that I don't see when running the same (statically linked) executables in a 
VM, through qemu-system-alpha.

  How to reproduce:
  - Using gnulib, run ./gnulib-tool --create-testdir --dir=../testdir-math 
--single-configure cbrt cbrtf ceil ceilf coshf exp2 exp2f float floor floorf 
fma fmaf fmal frexp frexpf hypot hypotf hypotl ilogb ilogbf isfinite isinf 
isnan isnand isnanf ldexp ldexpf ldexpl log1p log1pf log2 log2f logb logbf 
logbl math printf-frexp rint rintf rintl round roundf signbit sqrt sqrtf strtod 
trunc truncf
  - Copy the resulting directory to a VM running Linux 2.6.26 with 
qemu-system-alpha.
  - There, configure and build the package:
mkdir build-native-static; cd build-native-static; ../configure 
CPPFLAGS="-Wall" LDFLAGS="-static"; make; make check
Only 4 tests fail.
  - Copy the resulting binaries back to the original x86_64 machine.
  - Set environment variables for using qemu-alpha.
  - Here, 50 tests fail that did not fail originally:

  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-cbrt
  ../../gltests/test-cbrt.h:39: assertion 'err > - L_(4.0) * L_(16.0) / 
TWO_MANT_DIG && err < L_(4.0) * L_(16.0) / TWO_MANT_DIG' failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ceil1
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ceil2
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ceilf1
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ceilf2
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-coshf 
  ../../gltests/test-coshf.c:37: assertion 'y >= 1.1854652f && y <= 1.1854653f' 
failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-float
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-floor1
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-floor2
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-floorf1
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-floorf2
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-fma1   
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-fma2
  ../../gltests/test-fma2.h:116: assertion 'result == expected' failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-fmaf1
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-fmaf2
  ../../gltests/test-fma2.h:116: assertion 'result == expected' failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-fmal2
  ../../gltests/test-fma2.h:116: assertion 'result == expected' failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-frexp
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-frexpf
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-hypot 
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-hypotf
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-hypotl
  ../../gltests/test-hypot.h:41: assertion 'z == HUGEVAL' failed
  Aborted (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ilogb 
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ilogbf
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isfinite
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isinf   
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isnan
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isnand-nolibm
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isnand   
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isnanf-nolibm
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-isnanf   
  Floating point exception (core dumped)
  $ ~/inst-qemu/2.9.0/bin/qemu-alpha test-ldexp 
  Floating point exception 

[Qemu-devel] [Bug 1701973] Re: pread does not work right under qemu-sh4

2017-12-14 Thread Bruno Haible
With qemu-2.11:
$ ~/inst-qemu/2.11.0/bin/qemu-sh4 test-pread
ret=1 errno=2

The value of errno is actually irrelevant here. So, the bug is fixed.

** Changed in: qemu
   Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1701973

Title:
  pread does not work right under qemu-sh4

Status in QEMU:
  Fix Released

Bug description:
  The pread system call returns a wrong value in some case, in a program
  running under qemu-sh4 (version 2.9.0).

  How to reproduce:
  - Compile the program:
sh4-linux-gnu-gcc-5 -O -Wall -static -o test-pread test-pread.c
  - Set environment variable for using qemu-sh4 (actually not needed, since the 
program is statically linked here).
  - ~/inst-qemu/2.9.0/bin/qemu-sh4 test-pread

  Expected output:
  ret=1 errno=0

  Actual output:
  ret=0 errno=2
  test-pread.c:44: assertion 'ret == 1' failed
  qemu: uncaught target signal 6 (Aborted) - core dumped

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1701973/+subscriptions



[Qemu-devel] [PATCH] ppc/pnv: change powernv_ prefix to pnv_ for overall naming consistency

2017-12-14 Thread Cédric Le Goater
Signed-off-by: Cédric Le Goater 
---
 hw/ppc/pnv.c | 84 ++--
 hw/ppc/pnv_core.c|  8 ++---
 hw/ppc/pnv_lpc.c |  2 +-
 include/hw/ppc/pnv.h |  8 ++---
 4 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c35c439d816b..4bc5f61d0da7 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -77,7 +77,7 @@ static const char *pnv_chip_core_typename(const PnvChip *o)
  * that has a different "affinity". In practice, it means one range
  * per chip.
  */
-static void powernv_populate_memory_node(void *fdt, int chip_id, hwaddr start,
+static void pnv_populate_memory_node(void *fdt, int chip_id, hwaddr start,
  hwaddr size)
 {
 char *mem_name;
@@ -119,7 +119,7 @@ static int get_cpus_node(void *fdt)
  * device tree, used in XSCOM to address cores and in interrupt
  * servers.
  */
-static void powernv_create_core_node(PnvChip *chip, PnvCore *pc, void *fdt)
+static void pnv_create_core_node(PnvChip *chip, PnvCore *pc, void *fdt)
 {
 CPUState *cs = CPU(DEVICE(pc->threads));
 DeviceClass *dc = DEVICE_GET_CLASS(cs);
@@ -228,7 +228,7 @@ static void powernv_create_core_node(PnvChip *chip, PnvCore 
*pc, void *fdt)
servers_prop, sizeof(servers_prop;
 }
 
-static void powernv_populate_icp(PnvChip *chip, void *fdt, uint32_t pir,
+static void pnv_populate_icp(PnvChip *chip, void *fdt, uint32_t pir,
  uint32_t nr_threads)
 {
 uint64_t addr = PNV_ICP_BASE(chip) | (pir << 12);
@@ -277,7 +277,7 @@ static int pnv_chip_lpc_offset(PnvChip *chip, void *fdt)
 return offset;
 }
 
-static void powernv_populate_chip(PnvChip *chip, void *fdt)
+static void pnv_populate_chip(PnvChip *chip, void *fdt)
 {
 const char *typename = pnv_chip_core_typename(chip);
 size_t typesize = object_type_get_instance_size(typename);
@@ -298,20 +298,20 @@ static void powernv_populate_chip(PnvChip *chip, void 
*fdt)
 for (i = 0; i < chip->nr_cores; i++) {
 PnvCore *pnv_core = PNV_CORE(chip->cores + i * typesize);
 
-powernv_create_core_node(chip, pnv_core, fdt);
+pnv_create_core_node(chip, pnv_core, fdt);
 
 /* Interrupt Control Presenters (ICP). One per core. */
-powernv_populate_icp(chip, fdt, pnv_core->pir,
+pnv_populate_icp(chip, fdt, pnv_core->pir,
  CPU_CORE(pnv_core)->nr_threads);
 }
 
 if (chip->ram_size) {
-powernv_populate_memory_node(fdt, chip->chip_id, chip->ram_start,
+pnv_populate_memory_node(fdt, chip->chip_id, chip->ram_start,
  chip->ram_size);
 }
 }
 
-static void powernv_populate_rtc(ISADevice *d, void *fdt, int lpc_off)
+static void pnv_populate_rtc(ISADevice *d, void *fdt, int lpc_off)
 {
 uint32_t io_base = d->ioport_id;
 uint32_t io_regs[] = {
@@ -331,7 +331,7 @@ static void powernv_populate_rtc(ISADevice *d, void *fdt, 
int lpc_off)
 _FDT((fdt_setprop_string(fdt, node, "compatible", "pnpPNP,b00")));
 }
 
-static void powernv_populate_serial(ISADevice *d, void *fdt, int lpc_off)
+static void pnv_populate_serial(ISADevice *d, void *fdt, int lpc_off)
 {
 const char compatible[] = "ns16550\0pnpPNP,501";
 uint32_t io_base = d->ioport_id;
@@ -362,7 +362,7 @@ static void powernv_populate_serial(ISADevice *d, void 
*fdt, int lpc_off)
 _FDT((fdt_setprop_string(fdt, node, "device_type", "serial")));
 }
 
-static void powernv_populate_ipmi_bt(ISADevice *d, void *fdt, int lpc_off)
+static void pnv_populate_ipmi_bt(ISADevice *d, void *fdt, int lpc_off)
 {
 const char compatible[] = "bt\0ipmi-bt";
 uint32_t io_base;
@@ -401,17 +401,17 @@ typedef struct ForeachPopulateArgs {
 int offset;
 } ForeachPopulateArgs;
 
-static int powernv_populate_isa_device(DeviceState *dev, void *opaque)
+static int pnv_populate_isa_device(DeviceState *dev, void *opaque)
 {
 ForeachPopulateArgs *args = opaque;
 ISADevice *d = ISA_DEVICE(dev);
 
 if (object_dynamic_cast(OBJECT(dev), TYPE_MC146818_RTC)) {
-powernv_populate_rtc(d, args->fdt, args->offset);
+pnv_populate_rtc(d, args->fdt, args->offset);
 } else if (object_dynamic_cast(OBJECT(dev), TYPE_ISA_SERIAL)) {
-powernv_populate_serial(d, args->fdt, args->offset);
+pnv_populate_serial(d, args->fdt, args->offset);
 } else if (object_dynamic_cast(OBJECT(dev), "isa-ipmi-bt")) {
-powernv_populate_ipmi_bt(d, args->fdt, args->offset);
+pnv_populate_ipmi_bt(d, args->fdt, args->offset);
 } else {
 error_report("unknown isa device %s@i%x", qdev_fw_name(dev),
  d->ioport_id);
@@ -420,7 +420,7 @@ static int powernv_populate_isa_device(DeviceState *dev, 
void *opaque)
 return 0;
 }
 
-static void powernv_populate_isa(ISABus *bus, void *fdt, int lpc_offset)
+static void pnv_populate_isa(ISABus *bus, void *fdt, int 

Re: [Qemu-devel] [PATCH 0/2] vhost: two fixes

2017-12-14 Thread Zhoujian (jay)
Hi Michael,

> -Original Message-
> From: Zhoujian (jay)
> Sent: Friday, December 15, 2017 12:52 PM
> To: 'Michael S. Tsirkin' 
> Cc: Dr. David Alan Gilbert ; qemu-devel@nongnu.org;
> Huangweidong (C) ; Gonglei (Arei)
> ; wangxin (U) ;
> Liuzhe (Cloud Open Labs, NFV) ; Igor Mammedov
> 
> Subject: RE: [PATCH 0/2] vhost: two fixes
> 
> Hi Michael,
> 
> > -Original Message-
> > From: Michael S. Tsirkin [mailto:m...@redhat.com]
> > Sent: Friday, December 15, 2017 12:36 PM
> > To: Zhoujian (jay) 
> > Cc: Dr. David Alan Gilbert ;
> > qemu-devel@nongnu.org; Huangweidong (C) ;
> > Gonglei (Arei) ; wangxin (U)
> > ; Liuzhe (Cloud Open Labs, NFV)
> > ; Igor Mammedov 
> > Subject: Re: [PATCH 0/2] vhost: two fixes
> >
> > On Fri, Dec 15, 2017 at 02:38:35AM +, Zhoujian (jay) wrote:
> > > Hi Dave,
> > >
> > > > -Original Message-
> > > > From: Dr. David Alan Gilbert [mailto:dgilb...@redhat.com]
> > > > Sent: Friday, December 15, 2017 3:49 AM
> > > > To: Michael S. Tsirkin 
> > > > Cc: Zhoujian (jay) ;
> > > > qemu-devel@nongnu.org; Huangweidong (C)
> > > > ; Gonglei (Arei)
> > > > ; wangxin (U)
> > > > ; Liuzhe (Cloud Open Labs, NFV)
> > > > ; Igor Mammedov 
> > > > Subject: Re: [PATCH 0/2] vhost: two fixes
> > > >
> > > > * Michael S. Tsirkin (m...@redhat.com) wrote:
> > > > > On Fri, Dec 15, 2017 at 12:36:30AM +0800, Jay Zhou wrote:
> > > > > > Jay Zhou (2):
> > > > > >   vhost: add used memslot number for vhost-user
> > > > > >   vhost: double check memslot number
> > > > > >
> > > > > >  hw/virtio/vhost-user.c| 31
> +
> > > > > >  hw/virtio/vhost.c | 49
> > > > ++-
> > > > > >  include/hw/virtio/vhost-backend.h |  4 
> > > > > >  3 files changed, 78 insertions(+), 6 deletions(-)
> > > > >
> > > > > Cc two developers working on these files right now.
> > > >
> > > > I have to admit to not understanding the 'used_memslots' variable.
> > > >
> > > > * It's a global in vhost.c
> > > > * but set by vhost_set_memory that's called from the listener
> > associated
> > > >   with each individual vhost
> > > > * While they're probably always the same, the merging code calls
> > > >   the vhost_backend_can_merge method for each device, so the number
> > > >   of regions can be different.
> > > >
> > >
> > > Your mean for some devices the new added MemoryRegionSection can be
> > > merged, but for others it can not be merged? IIUC the vhost_mem for
> > > each vhost_dev is the same.
> > >
> > > Meanwhile, I think it is more reasonable to add globals in
> > > vhost-backend.c and vhost-user.c respectively instead of
> > > 'used_memslots'. The reason is explained in patch 1. What do you think?
> > >
> > > Regards,
> > > Jay
> >
> > I'd rather avoid globals completely if possible.
> >
> 
> It is possible, we could add a 'used_memslots' variable in struct
> vhost_dev for per device. I will try to do it in v2.
> 

If the globals don't exist, the disadvantage I found is that the check
"if memslots number exceeds" will be moved from the beginning to the end
in vhost_dev_init, does it acceptable? Or are there other ideas to avoid
globals?

To be honest, I prefer to add globals in vhost-backend.c and vhost-user.c
respectively, the value of used_memslots for the same type of backend is the
same.

Regards,
Jay



Re: [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1

2017-12-14 Thread David Gibson
On Tue, Dec 12, 2017 at 04:16:19PM +1100, Alexey Kardashevskiy wrote:
> The vfio_iommu_spapr_tce driver advertises kernel's support for
> v1 and v2 IOMMU support, however it is not always possible to use
> the requested IOMMU type. For example, a pseries host platform does not
> support dynamic DMA windows so v2 cannot initialize and QEMU fails to
> start.
> 
> This adds a fallback to the v1 IOMMU if v2 cannot be used.
> 
> Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU 
> v2)"
> Signed-off-by: Alexey Kardashevskiy 

Reviewed-by: David Gibson 

Alex, will you take this through your tree, or should I take it
through mine?

> ---
> Changes:
> v2:
> * updated commit log
> 
> ---
>  hw/vfio/common.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7b2924c..cd81cc9 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, 
> AddressSpace *as,
>  v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
>  ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
>  if (ret) {
> +container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
> +v2 = false;
> +ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
> +}
> +if (ret) {
>  error_setg_errno(errp, errno, "failed to set iommu for 
> container");
>  ret = -errno;
>  goto free_container_exit;

-- 
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 v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1

2017-12-14 Thread Alexey Kardashevskiy
On 15/12/17 17:01, David Gibson wrote:
> On Tue, Dec 12, 2017 at 04:16:19PM +1100, Alexey Kardashevskiy wrote:
>> The vfio_iommu_spapr_tce driver advertises kernel's support for
>> v1 and v2 IOMMU support, however it is not always possible to use
>> the requested IOMMU type. For example, a pseries host platform does not
>> support dynamic DMA windows so v2 cannot initialize and QEMU fails to
>> start.
>>
>> This adds a fallback to the v1 IOMMU if v2 cannot be used.
>>
>> Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU 
>> v2)"
>> Signed-off-by: Alexey Kardashevskiy 
> 
> Reviewed-by: David Gibson 
> 
> Alex, will you take this through your tree, or should I take it
> through mine?


It is already in upstream.

> 
>> ---
>> Changes:
>> v2:
>> * updated commit log
>>
>> ---
>>  hw/vfio/common.c | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>> index 7b2924c..cd81cc9 100644
>> --- a/hw/vfio/common.c
>> +++ b/hw/vfio/common.c
>> @@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, 
>> AddressSpace *as,
>>  v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
>>  ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
>>  if (ret) {
>> +container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
>> +v2 = false;
>> +ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
>> +}
>> +if (ret) {
>>  error_setg_errno(errp, errno, "failed to set iommu for 
>> container");
>>  ret = -errno;
>>  goto free_container_exit;
> 


-- 
Alexey



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 3/4] colo: compare the packet based on the tcp sequence number

2017-12-14 Thread Mao Zhongyi

[...]

+
+/* It doesn't look very sociable, in theory they should in a
+ * common loop, fix old loop make it suit the tcp comparison
+ * is the best way. But, given the performence of tcp 
comparison,
+ * the method of tcp comparison is completely different to the
+ * queue processing with others, so there is no way they can 
merge
+ * into a loop. Then split tcp in a single route. If possible, 
in
+ * the future, icmp and udp should be implemented use the same
+ * way to keep the code processing process consistent.
+ */


Why no way can merge all comparison function in one loop?

I think you can try this way :

 static void colo_compare_connection(void *opaque, void *user_data)
{

pri:
if (g_queue_is_empty(>primary_list)) {
return;
}
ppkt = g_queue_pop_head(>primary_list);

sec:
 if (g_queue_is_empty(>secondary_list)) {
 g_queue_push_head(>primary_list, ppkt);
 return;
 }

 switch (conn->ip_proto) {
case IPPROTO_TCP:
 if (colo_compare_tcp(s, conn)) {
goto pri;
 } else {
goto sec;
 }
case IPPROTO_UDP:
 if (colo_packet_compare_udp()) {
   goto pri;
 } else {
   goto sec;
 }
case 
 
  }
 }


Thanks for the clarification.

In this way, it will reduce the performance of udp & icmp in my
multiple test if we implement the udp & icmp comparison method
with the same way of tcp.

I have had a similar implementation locally:




Hi, Chen


I don't think it will sensible reduce the performance of udp & icmp


Actually, from the beginning to implement the tcp pkt comparison based
on the seq I basically determined if the same method to implement udp &
icmp, which performance certainly not as good as the original. Later test
confirmed my idea.

The reason is simple: udp & icmp pkt comparison are based on size, in the
secondary queue to find a packet same as one from primary queue can use
the-off-shelf g_queue_find_custom() directly. However, if you want to use
the same method as tcp to implement it, when a pkt from primary side is
compared with secondary side, the extra pop & push of secondary queue is
costed in each one comparsion, and the extra maintenance is required to
record what position currently compared.

Especially when the pkt of secondary queue same as primary side, it will
be deleted, and when the packet from the head of secondary queue is not
same, it will be pushed to the tail of queue so that to get a new pkt to
continue the next comparison. These factors lead to the secondary queue
constantly changing, increasing the complexity of location records and
reducing the efficiency of icmp & udp.

But, using the original method does not exist this problem. It has good
performance and code readability. Perhaps the code process flow of current
implementation looks a little inconsistent, but it's not worth if over-pursuing
code consistency and to ignore efficiency and readability.


Do you have already test the new loop?


Yes, I did it in local before the v1 patch was sent.

Thanks,
Mao



But in my mind, your similar implementation is OK for this job.
So don't easy to say " there is no way.".

Thanks
Zhang Chen




colo_compare_comnon(arg1, arg2, callback)
{
pri:
 if (g_queue_is_empty(>primary_list)) {
 return;
 }
 ppkt = g_queue_pop_head(>primary_list);

sec:
  if (g_queue_is_empty(>secondary_list)) {
  g_queue_push_head(>primary_list, ppkt);
  return;
  }

}

colo_compare_connection(void *opaque, void *user_data)
{
  switch (conn->ip_proto) {
 case IPPROTO_TCP:
  colo_compare_common(s, conn, colo_comapre_tcp)
 case IPPROTO_UDP:
  colo_compare_common(s, conn, colo_comapre_udp)
 case IPPROTO_ICMP:
  colo_compare_common(s, conn, colo_comapre_icmp)

 case 
  
  }
}


Thanks
Zhang Chen





+if (conn->ip_proto == IPPROTO_TCP) {
+colo_compare_tcp(s, conn);
+return;
+}

 while (!g_queue_is_empty(>primary_list) &&
!g_queue_is_empty(>secondary_list)) {
 

[Qemu-devel] [PULL 17/24] spapr: introduce a spapr_qirq() helper

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

xics_get_qirq() is only used by the sPAPR machine. Let's move it there
and change its name to reflect its scope. It will be useful for XIVE
support which will use its own set of qirqs.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Signed-off-by: David Gibson 
---
 hw/intc/xics.c  | 12 
 hw/ppc/spapr.c  | 11 +++
 hw/ppc/spapr_events.c   | 12 +---
 hw/ppc/spapr_pci.c  |  2 +-
 include/hw/pci-host/spapr.h |  2 +-
 include/hw/ppc/spapr.h  |  1 +
 include/hw/ppc/spapr_vio.h  |  2 +-
 include/hw/ppc/xics.h   |  1 -
 8 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 700f6baa13..e73e623e3b 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -713,18 +713,6 @@ static const TypeInfo xics_fabric_info = {
 /*
  * Exported functions
  */
-qemu_irq xics_get_qirq(XICSFabric *xi, int irq)
-{
-XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
-ICSState *ics = xic->ics_get(xi, irq);
-
-if (ics) {
-return ics->qirqs[irq - ics->offset];
-}
-
-return NULL;
-}
-
 ICPState *xics_icp_get(XICSFabric *xi, int server)
 {
 XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 02cc7ffd4d..8a6a59f098 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3680,6 +3680,17 @@ void spapr_irq_free(sPAPRMachineState *spapr, int irq, 
int num)
 }
 }
 
+qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq)
+{
+ICSState *ics = spapr->ics;
+
+if (ics_valid_irq(ics, irq)) {
+return ics->qirqs[irq - ics->offset];
+}
+
+return NULL;
+}
+
 static void spapr_pic_print_info(InterruptStatsProvider *obj,
  Monitor *mon)
 {
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index cead596f3e..7dc87fc7bd 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -472,9 +472,8 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)
 
 rtas_event_log_queue(spapr, entry);
 
-qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
- rtas_event_log_to_irq(spapr,
-   RTAS_LOG_TYPE_EPOW)));
+qemu_irq_pulse(spapr_qirq(spapr,
+   rtas_event_log_to_irq(spapr, RTAS_LOG_TYPE_EPOW)));
 }
 
 static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
@@ -556,9 +555,8 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t 
hp_action,
 
 rtas_event_log_queue(spapr, entry);
 
-qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
- rtas_event_log_to_irq(spapr,
-   
RTAS_LOG_TYPE_HOTPLUG)));
+qemu_irq_pulse(spapr_qirq(spapr,
+   rtas_event_log_to_irq(spapr, RTAS_LOG_TYPE_HOTPLUG)));
 }
 
 void spapr_hotplug_req_add_by_index(sPAPRDRConnector *drc)
@@ -678,7 +676,7 @@ static void check_exception(PowerPCCPU *cpu, 
sPAPRMachineState *spapr,
 spapr_event_sources_get_source(spapr->event_sources, i);
 
 g_assert(source->enabled);
-qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), source->irq));
+qemu_irq_pulse(spapr_qirq(spapr, source->irq));
 }
 }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index e0ef77a480..39134f0ef0 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -723,7 +723,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,
 
 trace_spapr_pci_msi_write(addr, data, irq);
 
-qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), irq));
+qemu_irq_pulse(spapr_qirq(spapr, irq));
 }
 
 static const MemoryRegionOps spapr_msi_ops = {
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 38470b2f0e..0fae4fc6a4 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -108,7 +108,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct 
sPAPRPHBState *phb, int pin)
 {
 sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
 
-return xics_get_qirq(XICS_FABRIC(spapr), phb->lsi_table[pin].irq);
+return spapr_qirq(spapr, phb->lsi_table[pin].irq);
 }
 
 PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index);
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 895f48471e..6b8e04c787 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -712,5 +712,6 @@ int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, 
bool lsi,
 int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi,
   bool align, Error **errp);
 void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num);
+qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq);
 
 #endif /* HW_SPAPR_H */
diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h

[Qemu-devel] [PULL 18/24] spapr: replace numa_get_node() with lookup in pc-dimm list

2017-12-14 Thread David Gibson
From: Igor Mammedov 

SPAPR is the last user of numa_get_node() and a bunch of
supporting code to maintain numa_info[x].addr list.

Get LMB node id from pc-dimm list, which allows to
remove ~80LOC maintaining dynamic address range
lookup list.

It also removes pc-dimm dependency on numa_[un]set_mem_node_id()
and makes pc-dimms a sole source of information about which
node it belongs to and removes duplicate data from global
numa_info.

Signed-off-by: Igor Mammedov 
Signed-off-by: David Gibson 
---
 hw/mem/pc-dimm.c  |  2 --
 hw/ppc/spapr.c| 29 +++-
 include/sysemu/numa.h | 10 --
 numa.c| 94 ---
 4 files changed, 28 insertions(+), 107 deletions(-)

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 66eace5a5c..6e74b61cb6 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -109,7 +109,6 @@ void pc_dimm_memory_plug(DeviceState *dev, 
MemoryHotplugState *hpms,
 
 memory_region_add_subregion(>mr, addr - hpms->base, mr);
 vmstate_register_ram(vmstate_mr, dev);
-numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node);
 
 out:
 error_propagate(errp, local_err);
@@ -122,7 +121,6 @@ void pc_dimm_memory_unplug(DeviceState *dev, 
MemoryHotplugState *hpms,
 PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
 MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
 
-numa_unset_mem_node_id(dimm->addr, memory_region_size(mr), dimm->node);
 memory_region_del_subregion(>mr, mr);
 vmstate_unregister_ram(vmstate_mr, dev);
 }
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8a6a59f098..306875e123 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -641,6 +641,26 @@ static void spapr_populate_cpus_dt_node(void *fdt, 
sPAPRMachineState *spapr)
 
 }
 
+static uint32_t spapr_pc_dimm_node(MemoryDeviceInfoList *list, ram_addr_t addr)
+{
+MemoryDeviceInfoList *info;
+
+for (info = list; info; info = info->next) {
+MemoryDeviceInfo *value = info->value;
+
+if (value && value->type == MEMORY_DEVICE_INFO_KIND_DIMM) {
+PCDIMMDeviceInfo *pcdimm_info = value->u.dimm.data;
+
+if (pcdimm_info->addr >= addr &&
+addr < (pcdimm_info->addr + pcdimm_info->size)) {
+return pcdimm_info->node;
+}
+}
+}
+
+return -1;
+}
+
 /*
  * Adds ibm,dynamic-reconfiguration-memory node.
  * Refer to docs/specs/ppc-spapr-hotplug.txt for the documentation
@@ -658,6 +678,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState 
*spapr, void *fdt)
lmb_size;
 uint32_t *int_buf, *cur_index, buf_len;
 int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1;
+MemoryDeviceInfoList *dimms = NULL;
 
 /*
  * Don't create the node if there is no hotpluggable memory
@@ -692,6 +713,11 @@ static int spapr_populate_drconf_memory(sPAPRMachineState 
*spapr, void *fdt)
 goto out;
 }
 
+if (hotplug_lmb_start) {
+MemoryDeviceInfoList **prev = 
+qmp_pc_dimm_device_list(qdev_get_machine(), );
+}
+
 /* ibm,dynamic-memory */
 int_buf[0] = cpu_to_be32(nr_lmbs);
 cur_index++;
@@ -709,7 +735,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState 
*spapr, void *fdt)
 dynamic_memory[1] = cpu_to_be32(addr & 0x);
 dynamic_memory[2] = cpu_to_be32(spapr_drc_index(drc));
 dynamic_memory[3] = cpu_to_be32(0); /* reserved */
-dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL));
+dynamic_memory[4] = cpu_to_be32(spapr_pc_dimm_node(dimms, addr));
 if (memory_region_present(get_system_memory(), addr)) {
 dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED);
 } else {
@@ -732,6 +758,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState 
*spapr, void *fdt)
 
 cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE;
 }
+qapi_free_MemoryDeviceInfoList(dimms);
 ret = fdt_setprop(fdt, offset, "ibm,dynamic-memory", int_buf, buf_len);
 if (ret < 0) {
 goto out;
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index 5c6df2820b..b3545215f6 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -10,17 +10,10 @@
 extern int nb_numa_nodes;   /* Number of NUMA nodes */
 extern bool have_numa_distance;
 
-struct numa_addr_range {
-ram_addr_t mem_start;
-ram_addr_t mem_end;
-QLIST_ENTRY(numa_addr_range) entry;
-};
-
 struct node_info {
 uint64_t node_mem;
 struct HostMemoryBackend *node_memdev;
 bool present;
-QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */
 uint8_t distance[MAX_NODES];
 };
 
@@ -33,9 +26,6 @@ extern NodeInfo numa_info[MAX_NODES];
 void parse_numa_opts(MachineState *ms);
 void query_numa_node_mem(NumaNodeMem node_mem[]);
 extern QemuOptsList qemu_numa_opts;

[Qemu-devel] [PULL 22/24] spapr: Rename machine init functions for clarity

2017-12-14 Thread David Gibson
Machine objects have two init functions - the generic QOM level
instance_init which should only do static object initialization, and
the Machine specific MachineClass::init which does the actual
construction of the machine.

In spapr the functions implementing these two have names -
ppc_machine_initfn() and ppc_spapr_init() - which don't correspond closely
to either of those.  To prevent people (read, me) from confusing which is
which, rename them spapr_instance_init() and spapr_machine_init() to
make it clearer which is which.

While we're there rename ppc_spapr_reset() to spapr_machine_reset() to
match.

Signed-off-by: David Gibson 
Reviewed-by: Cédric Le Goater 
Reviewed-by: Greg Kurz 
Reviewed-by: Suraj Jitindar Singh 
---
 hw/ppc/spapr.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 306875e123..42d6a2302a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1454,7 +1454,7 @@ static int spapr_reset_drcs(Object *child, void *opaque)
 return 0;
 }
 
-static void ppc_spapr_reset(void)
+static void spapr_machine_reset(void)
 {
 MachineState *machine = MACHINE(qdev_get_machine());
 sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
@@ -2292,7 +2292,7 @@ out:
 }
 
 /* pSeries LPAR / sPAPR hardware init */
-static void ppc_spapr_init(MachineState *machine)
+static void spapr_machine_init(MachineState *machine)
 {
 sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
 sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
@@ -2820,7 +2820,7 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, const 
char *name,
 visit_type_uint32(v, name, (uint32_t *)opaque, errp);
 }
 
-static void spapr_machine_initfn(Object *obj)
+static void spapr_instance_init(Object *obj)
 {
 sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
 
@@ -3777,8 +3777,8 @@ static void spapr_machine_class_init(ObjectClass *oc, 
void *data)
  * functions for the specific versioned machine types can override
  * these details for backwards compatibility
  */
-mc->init = ppc_spapr_init;
-mc->reset = ppc_spapr_reset;
+mc->init = spapr_machine_init;
+mc->reset = spapr_machine_reset;
 mc->block_default_type = IF_SCSI;
 mc->max_cpus = 1024;
 mc->no_parallel = 1;
@@ -3825,7 +3825,7 @@ static const TypeInfo spapr_machine_info = {
 .parent= TYPE_MACHINE,
 .abstract  = true,
 .instance_size = sizeof(sPAPRMachineState),
-.instance_init = spapr_machine_initfn,
+.instance_init = spapr_instance_init,
 .instance_finalize = spapr_machine_finalizefn,
 .class_size= sizeof(sPAPRMachineClass),
 .class_init= spapr_machine_class_init,
-- 
2.14.3




[Qemu-devel] [PULL 19/24] spapr: fix LSI interrupt specifiers in the device tree

2017-12-14 Thread David Gibson
From: Greg Kurz 

LoPAPR 1.1 B.6.9.1.2 describes the "#interrupt-cells" property of the
PowerPC External Interrupt Source Controller node as follows:

“#interrupt-cells”

  Standard property name to define the number of cells in an interrupt-
  specifier within an interrupt domain.

  prop-encoded-array: An integer, encoded as with encode-int, that denotes
  the number of cells required to represent an interrupt specifier in its
  child nodes.

  The value of this property for the PowerPC External Interrupt option shall
  be 2. Thus all interrupt specifiers (as used in the standard “interrupts”
  property) shall consist of two cells, each containing an integer encoded
  as with encode-int. The first integer represents the interrupt number the
  second integer is the trigger code: 0 for edge triggered, 1 for level
  triggered.

This patch fixes the interrupt specifiers in the "interrupt-map" property
of the PHB node, that were setting the second cell to 8 (confusion with
IRQ_TYPE_LEVEL_LOW ?) instead of 1.

VIO devices and RTAS event sources use the same format for interrupt
specifiers: while here, we introduce a common helper to handle the
encoding details.

Signed-off-by: Greg Kurz 
Reviewed-by: Cédric Le Goater 
Tested-by: Cédric Le Goater 
--
v3: - reference public LoPAPR instead of internal PAPR+ in changelog
- change helper name to spapr_dt_xics_irq()

v2: - drop the erroneous changes to the "interrupts" prop in PCI device nodes
- introduce a common helper to encode interrupt specifiers
Signed-off-by: David Gibson 
---
 hw/ppc/spapr_events.c  |  3 +--
 hw/ppc/spapr_pci.c |  3 +--
 hw/ppc/spapr_vio.c |  3 ++-
 include/hw/ppc/spapr.h | 10 ++
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 7dc87fc7bd..c7a64e6b8d 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -282,8 +282,7 @@ void spapr_dt_events(sPAPRMachineState *spapr, void *fdt)
 continue;
 }
 
-interrupts[0] = cpu_to_be32(source->irq);
-interrupts[1] = 0;
+spapr_dt_xics_irq(interrupts, source->irq, false);
 
 _FDT(node_offset = fdt_add_subnode(fdt, event_sources, source_name));
 _FDT(fdt_setprop(fdt, node_offset, "interrupts", interrupts,
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 39134f0ef0..88797b3d36 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -2121,8 +2121,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
 irqmap[2] = 0;
 irqmap[3] = cpu_to_be32(j+1);
 irqmap[4] = cpu_to_be32(xics_phandle);
-irqmap[5] = cpu_to_be32(phb->lsi_table[lsi_num].irq);
-irqmap[6] = cpu_to_be32(0x8);
+spapr_dt_xics_irq([5], phb->lsi_table[lsi_num].irq, true);
 }
 }
 /* Write interrupt map */
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index bb7ed2c537..472dd6f33a 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -126,8 +126,9 @@ static int vio_make_devnode(VIOsPAPRDevice *dev,
 }
 
 if (dev->irq) {
-uint32_t ints_prop[] = {cpu_to_be32(dev->irq), 0};
+uint32_t ints_prop[2];
 
+spapr_dt_xics_irq(ints_prop, dev->irq, false);
 ret = fdt_setprop(fdt, node_off, "interrupts", ints_prop,
   sizeof(ints_prop));
 if (ret < 0) {
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 6b8e04c787..14757b805e 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -590,6 +590,16 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *fdt, 
hwaddr addr);
 
 #define RTAS_EVENT_SCAN_RATE1
 
+/* This helper should be used to encode interrupt specifiers when the related
+ * "interrupt-controller" node has its "#interrupt-cells" property set to 2 
(ie,
+ * VIO devices, RTAS event sources and PHBs).
+ */
+static inline void spapr_dt_xics_irq(uint32_t *intspec, int irq, bool is_lsi)
+{
+intspec[0] = cpu_to_be32(irq);
+intspec[1] = is_lsi ? cpu_to_be32(1) : 0;
+}
+
 typedef struct sPAPRTCETable sPAPRTCETable;
 
 #define TYPE_SPAPR_TCE_TABLE "spapr-tce-table"
-- 
2.14.3




[Qemu-devel] [PULL 14/24] ppc/xics: assign of the CPU 'intc' pointer under the core

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

The 'intc' pointer of the CPU references the interrupt presenter in
the XICS interrupt mode. When the XIVE interrupt mode is available and
activated, the machine will need to reassign this pointer to reflect
the change.

Moving this assignment under the realize routine of the CPU will ease
the process when the interrupt mode is toggled.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Reviewed-by: Greg Kurz 
Signed-off-by: David Gibson 
---
 hw/intc/xics.c  | 1 -
 hw/ppc/pnv_core.c   | 2 +-
 hw/ppc/spapr_cpu_core.c | 3 ++-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index bfc6b5bb23..700f6baa13 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -334,7 +334,6 @@ static void icp_realize(DeviceState *dev, Error **errp)
 }
 
 cpu = POWERPC_CPU(obj);
-cpu->intc = OBJECT(icp);
 icp->cs = CPU(obj);
 
 env = >env;
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 8d966e0802..03317db853 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -133,7 +133,7 @@ static void pnv_core_realize_child(Object *child, 
XICSFabric *xi, Error **errp)
 return;
 }
 
-icp_create(child, TYPE_PNV_ICP, xi, _err);
+cpu->intc = icp_create(child, TYPE_PNV_ICP, xi, _err);
 if (local_err) {
 error_propagate(errp, local_err);
 return;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 70e757f808..032438b9ce 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -121,7 +121,8 @@ static void spapr_cpu_core_realize_child(Object *child,
 goto error;
 }
 
-icp_create(child, spapr->icp_type, XICS_FABRIC(spapr), _err);
+cpu->intc = icp_create(child, spapr->icp_type, XICS_FABRIC(spapr),
+   _err);
 if (local_err) {
 goto error;
 }
-- 
2.14.3




[Qemu-devel] [PULL 21/24] target/ppc: introduce the PPC_BIT() macro

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

and use them in a couple of obvious places. Other macros will be used
in the model of the XIVE interrupt controller.

Signed-off-by: Cédric Le Goater 
Signed-off-by: David Gibson 
---
 target/ppc/cpu.h | 105 +--
 1 file changed, 56 insertions(+), 49 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 989761b795..370b05e76e 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -87,6 +87,13 @@
 #define PPC_ELF_MACHINE EM_PPC
 #endif
 
+#define PPC_BIT(bit)(0x8000UL >> (bit))
+#define PPC_BIT32(bit)  (0x8000UL >> (bit))
+#define PPC_BIT8(bit)   (0x80UL >> (bit))
+#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))
+#define PPC_BITMASK32(bs, be)   ((PPC_BIT32(bs) - PPC_BIT32(be)) | \
+ PPC_BIT32(bs))
+
 /*/
 /* Exception vectors definitions */
 enum {
@@ -371,10 +378,10 @@ struct ppc_slb_t {
 #define MSR_LE   0  /* Little-endian mode   1 hflags */
 
 /* LPCR bits */
-#define LPCR_VPM0 (1ull << (63 - 0))
-#define LPCR_VPM1 (1ull << (63 - 1))
-#define LPCR_ISL  (1ull << (63 - 2))
-#define LPCR_KBV  (1ull << (63 - 3))
+#define LPCR_VPM0 PPC_BIT(0)
+#define LPCR_VPM1 PPC_BIT(1)
+#define LPCR_ISL  PPC_BIT(2)
+#define LPCR_KBV  PPC_BIT(3)
 #define LPCR_DPFD_SHIFT   (63 - 11)
 #define LPCR_DPFD (0x7ull << LPCR_DPFD_SHIFT)
 #define LPCR_VRMASD_SHIFT (63 - 16)
@@ -382,41 +389,41 @@ struct ppc_slb_t {
 /* P9: Power-saving mode Exit Cause Enable (Upper Section) Mask */
 #define LPCR_PECE_U_SHIFT (63 - 19)
 #define LPCR_PECE_U_MASK  (0x7ull << LPCR_PECE_U_SHIFT)
-#define LPCR_HVEE (1ull << (63 - 17)) /* Hypervisor Virt Exit Enable */
+#define LPCR_HVEE PPC_BIT(17) /* Hypervisor Virt Exit Enable */
 #define LPCR_RMLS_SHIFT   (63 - 37)
 #define LPCR_RMLS (0xfull << LPCR_RMLS_SHIFT)
-#define LPCR_ILE  (1ull << (63 - 38))
+#define LPCR_ILE  PPC_BIT(38)
 #define LPCR_AIL_SHIFT(63 - 40)  /* Alternate interrupt location */
 #define LPCR_AIL  (3ull << LPCR_AIL_SHIFT)
-#define LPCR_UPRT (1ull << (63 - 41)) /* Use Process Table */
-#define LPCR_EVIRT(1ull << (63 - 42)) /* Enhanced Virtualisation */
-#define LPCR_ONL  (1ull << (63 - 45))
-#define LPCR_LD   (1ull << (63 - 46)) /* Large Decrementer */
-#define LPCR_P7_PECE0 (1ull << (63 - 49))
-#define LPCR_P7_PECE1 (1ull << (63 - 50))
-#define LPCR_P7_PECE2 (1ull << (63 - 51))
-#define LPCR_P8_PECE0 (1ull << (63 - 47))
-#define LPCR_P8_PECE1 (1ull << (63 - 48))
-#define LPCR_P8_PECE2 (1ull << (63 - 49))
-#define LPCR_P8_PECE3 (1ull << (63 - 50))
-#define LPCR_P8_PECE4 (1ull << (63 - 51))
+#define LPCR_UPRT PPC_BIT(41) /* Use Process Table */
+#define LPCR_EVIRTPPC_BIT(42) /* Enhanced Virtualisation */
+#define LPCR_ONL  PPC_BIT(45)
+#define LPCR_LD   PPC_BIT(46) /* Large Decrementer */
+#define LPCR_P7_PECE0 PPC_BIT(49)
+#define LPCR_P7_PECE1 PPC_BIT(50)
+#define LPCR_P7_PECE2 PPC_BIT(51)
+#define LPCR_P8_PECE0 PPC_BIT(47)
+#define LPCR_P8_PECE1 PPC_BIT(48)
+#define LPCR_P8_PECE2 PPC_BIT(49)
+#define LPCR_P8_PECE3 PPC_BIT(50)
+#define LPCR_P8_PECE4 PPC_BIT(51)
 /* P9: Power-saving mode Exit Cause Enable (Lower Section) Mask */
 #define LPCR_PECE_L_SHIFT (63 - 51)
 #define LPCR_PECE_L_MASK  (0x1full << LPCR_PECE_L_SHIFT)
-#define LPCR_PDEE (1ull << (63 - 47)) /* Privileged Doorbell Exit EN */
-#define LPCR_HDEE (1ull << (63 - 48)) /* Hyperv Doorbell Exit Enable */
-#define LPCR_EEE  (1ull << (63 - 49)) /* External Exit Enable*/
-#define LPCR_DEE  (1ull << (63 - 50)) /* Decrementer Exit Enable */
-#define LPCR_OEE  (1ull << (63 - 51)) /* Other Exit Enable   */
-#define LPCR_MER  (1ull << (63 - 52))
-#define LPCR_GTSE (1ull << (63 - 53)) /* Guest Translation Shootdown */
-#define LPCR_TC   (1ull << (63 - 54))
-#define LPCR_HEIC (1ull << (63 - 59)) /* HV Extern Interrupt Control */
-#define LPCR_LPES0(1ull << (63 - 60))
-#define LPCR_LPES1(1ull << (63 - 61))
-#define LPCR_RMI  (1ull << (63 - 62))
-#define LPCR_HVICE(1ull << (63 - 62)) /* HV Virtualisation Int Enable 
*/
-#define LPCR_HDICE(1ull << (63 - 63))
+#define LPCR_PDEE PPC_BIT(47) /* Privileged Doorbell Exit EN */
+#define LPCR_HDEE PPC_BIT(48) /* Hyperv Doorbell Exit Enable */
+#define LPCR_EEE  PPC_BIT(49) /* External Exit Enable*/
+#define LPCR_DEE  PPC_BIT(50) /* Decrementer Exit Enable */
+#define 

[Qemu-devel] [PULL 24/24] spapr: don't initialize PATB entry if max-cpu-compat < power9

2017-12-14 Thread David Gibson
From: Laurent Vivier 

if KVM is enabled and KVM capabilities MMU radix is available,
the partition table entry (patb_entry) for the radix mode is
initialized by default in ppc_spapr_reset().

It's a problem if we want to migrate the guest to a POWER8 host
while the kernel is not started to set the value to the one
expected for a POWER8 CPU.

The "-machine max-cpu-compat=power8" should allow to migrate
a POWER9 KVM host to a POWER8 KVM host, but because patb_entry
is set, the destination QEMU tries to enable radix mode on the
POWER8 host. This fails and cancels the migration:

Process table config unsupported by the host
error while loading state for instance 0x0 of device 'spapr'
load of migration failed: Invalid argument

This patch doesn't set the PATB entry if the user provides
a CPU compatibility mode that doesn't support radix mode.

Signed-off-by: Laurent Vivier 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4f354a8760..6785a90c60 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1466,7 +1466,10 @@ static void spapr_machine_reset(void)
 /* Check for unknown sysbus devices */
 foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
 
-if (kvm_enabled() && kvmppc_has_cap_mmu_radix()) {
+first_ppc_cpu = POWERPC_CPU(first_cpu);
+if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
+ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
+ spapr->max_compat_pvr)) {
 /* If using KVM with radix mode available, VCPUs can be started
  * without a HPT because KVM will start them in radix mode.
  * Set the GR bit in PATB so that we know there is no HPT. */
@@ -1525,7 +1528,6 @@ static void spapr_machine_reset(void)
 g_free(fdt);
 
 /* Set up the entry state */
-first_ppc_cpu = POWERPC_CPU(first_cpu);
 first_ppc_cpu->env.gpr[3] = fdt_addr;
 first_ppc_cpu->env.gpr[5] = 0;
 first_cpu->halted = 0;
-- 
2.14.3




[Qemu-devel] [PULL 09/24] e500: fix pci host bridge class/type

2017-12-14 Thread David Gibson
From: Michael Davidsaver 

Correct some confusion wrt. the PCI facing
side of the PCI host bridge (not PCIe root complex).
The ref. manual for the mpc8533 (as well as
mpc8540 and mpc8540) give the class code as
PCI_CLASS_PROCESSOR_POWERPC.
While the PCI_HEADER_TYPE field is oddly omitted,
the tables in the "PCI Configuration Header"
section shows a type 0 layout using all 6 BAR
registers (as 2x 32, and 2x 64 bit regions)

So 997505065dc92e533debf5cb23012ba4e673d387
seems to be in error.  Although there was
perhaps some confusion as the mpc8533
has a separate PCIe root complex.
With PCIe, a root complex has PCI_HEADER_TYPE=1.

Neither the PCI host bridge, nor the PCIe
root complex advertise class PCI_CLASS_BRIDGE_PCI.

This was confusing Linux guests, which try
to interpret the host bridge as a pci-pci
bridge, but get confused and re-enumerate
the bus when the primary/secondary/subordinate
bus registers don't have valid values.

Signed-off-by: Michael Davidsaver 
Signed-off-by: David Gibson 
---
 hw/pci-host/ppce500.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index 39cd24464d..279badc894 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -423,11 +423,6 @@ static void e500_pcihost_bridge_realize(PCIDevice *d, 
Error **errp)
 PPCE500CCSRState *ccsr = CCSR(container_get(qdev_get_machine(),
   "/e500-ccsr"));
 
-pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
-d->config[PCI_HEADER_TYPE] =
-(d->config[PCI_HEADER_TYPE] & PCI_HEADER_TYPE_MULTI_FUNCTION) |
-PCI_HEADER_TYPE_BRIDGE;
-
 memory_region_init_alias(>bar0, OBJECT(ccsr), "e500-pci-bar0", 
>ccsr_space,
  0, int128_get64(ccsr->ccsr_space.size));
 pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, >bar0);
-- 
2.14.3




[Qemu-devel] [PULL 20/24] spapr_events: drop bogus cell from "interrupt-ranges" property

2017-12-14 Thread David Gibson
From: Greg Kurz 

According to LoPAPR 1.1 B.6.12, the "/event-sources" node has an "interrupt-
ranges" property, the format of which is described in B.6.9.1.2 as follows:

“interrupt-ranges”
 Standard property name that defines the interrupt number(s) and range(s)
 handled by this unit.

 prop-encoded-array: List of (int-number, range) specifications.

 Int-number is encoded as with encode-int.
 Range is encoded as with encode-int.

 The first entry in this list shall contain the int-number associated with
 the first “reg” property entry. The int-num-ber is the value representing
 the interrupt source as would appear in the PowerPC External Interrupt
 Architecture XISR. The range shall be the number of sequential interrupt
 numbers which this unit can generate.

There's no such thing as a cell count at the end of the array, like the
one introduced by commit ffbb1705a33d in QEMU 2.8. It doesn't seem it had
any impact on existing guests and I couldn't find any related workaround
in linux. So, let's just drop the bogus lines.

Signed-off-by: Greg Kurz 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr_events.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index c7a64e6b8d..86836f0626 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -292,9 +292,6 @@ void spapr_dt_events(sPAPRMachineState *spapr, void *fdt)
 irq_ranges[count++] = cpu_to_be32(1);
 }
 
-irq_ranges[count] = cpu_to_be32(count);
-count++;
-
 _FDT((fdt_setprop(fdt, event_sources, "interrupt-controller", NULL, 0)));
 _FDT((fdt_setprop_cell(fdt, event_sources, "#interrupt-cells", 2)));
 _FDT((fdt_setprop(fdt, event_sources, "interrupt-ranges",
-- 
2.14.3




[Qemu-devel] [PULL 05/24] e500: name openpic and pci host bridge

2017-12-14 Thread David Gibson
From: Michael Davidsaver 

Signed-off-by: Michael Davidsaver 
Signed-off-by: David Gibson 
---
 hw/ppc/e500.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 5cf0dabef3..c4fe06ea2a 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -685,6 +685,8 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500Params 
*params,
 int i, j, k;
 
 dev = qdev_create(NULL, TYPE_OPENPIC);
+object_property_add_child(qdev_get_machine(), "pic", OBJECT(dev),
+  _fatal);
 qdev_prop_set_uint32(dev, "model", params->mpic_version);
 qdev_prop_set_uint32(dev, "nb_cpus", smp_cpus);
 
@@ -884,6 +886,8 @@ void ppce500_init(MachineState *machine, PPCE500Params 
*params)
 
 /* PCI */
 dev = qdev_create(NULL, "e500-pcihost");
+object_property_add_child(qdev_get_machine(), "pci-host", OBJECT(dev),
+  _abort);
 qdev_prop_set_uint32(dev, "first_slot", params->pci_first_slot);
 qdev_prop_set_uint32(dev, "first_pin_irq", pci_irq_nrs[0]);
 qdev_init_nofail(dev);
-- 
2.14.3




[Qemu-devel] [PULL 10/24] spapr/rtas: disable the decrementer interrupt when a CPU is unplugged

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

When a CPU is stopped with the 'stop-self' RTAS call, its state
'halted' is switched to 1 and, in this case, the MSR is not taken into
account anymore in the cpu_has_work() routine. Only the pending
hardware interrupts are checked with their LPCR:PECE* enablement bit.

If the DECR timer fires after 'stop-self' is called and before the CPU
'stop' state is reached, the nearly-dead CPU will have some work to do
and the guest will crash. This case happens very frequently with the
not yet upstream P9 XIVE exploitation mode. In XICS mode, the DECR is
occasionally fired but after 'stop' state, so no work is to be done
and the guest survives.

I suspect there is a race between the QEMU mainloop triggering the
timers and the TCG CPU thread but I could not quite identify the root
cause. To be safe, let's disable in the LPCR all the exceptions which
can cause an exit while the CPU is in power-saving mode and reenable
them when the CPU is started.

Signed-off-by: Cédric Le Goater 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr_rtas.c | 11 +++
 target/ppc/translate_init.c |  9 ++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index cdf0b607a0..858adb1bf3 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -162,6 +162,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, 
sPAPRMachineState *spapr,
 if (cpu != NULL) {
 CPUState *cs = CPU(cpu);
 CPUPPCState *env = >env;
+PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
 if (!cs->halted) {
 rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
@@ -174,6 +175,10 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, 
sPAPRMachineState *spapr,
 kvm_cpu_synchronize_state(cs);
 
 env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
+
+/* Enable Power-saving mode Exit Cause exceptions for the new CPU */
+env->spr[SPR_LPCR] |= pcc->lpcr_pm;
+
 env->nip = start;
 env->gpr[3] = r3;
 cs->halted = 0;
@@ -197,6 +202,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, 
sPAPRMachineState *spapr,
 {
 CPUState *cs = CPU(cpu);
 CPUPPCState *env = >env;
+PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
 cs->halted = 1;
 qemu_cpu_kick(cs);
@@ -210,6 +216,11 @@ static void rtas_stop_self(PowerPCCPU *cpu, 
sPAPRMachineState *spapr,
  * no need to bother with specific bits, we just clear it.
  */
 env->msr = 0;
+
+/* Disable Power-saving mode Exit Cause exceptions for the CPU.
+ * This could deliver an interrupt on a dying CPU and crash the
+ * guest */
+env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;
 }
 
 static inline int sysparm_st(target_ulong addr, target_ulong len,
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index 074c3a1d45..70ff15a51a 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -8911,6 +8911,7 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, 
PPCVirtualHypervisor *vhyp)
 CPUPPCState *env = >env;
 ppc_spr_t *lpcr = >spr_cb[SPR_LPCR];
 ppc_spr_t *amor = >spr_cb[SPR_AMOR];
+CPUState *cs = CPU(cpu);
 
 cpu->vhyp = vhyp;
 
@@ -8953,10 +8954,12 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, 
PPCVirtualHypervisor *vhyp)
 }
 }
 
-/* Also set the power-saving mode bits which depend on the CPU
- * family
+/* Only enable Power-saving mode Exit Cause exceptions on the boot
+ * CPU. The RTAS command start-cpu will enable them on secondaries.
  */
-lpcr->default_value |= pcc->lpcr_pm;
+if (cs == first_cpu) {
+lpcr->default_value |= pcc->lpcr_pm;
+}
 
 /* We should be followed by a CPU reset but update the active value
  * just in case...
-- 
2.14.3




[Qemu-devel] [PULL 23/24] spapr: Assume msi_nonbroken

2017-12-14 Thread David Gibson
We conditionally adjust part of the guest device tree based on the
global msi_nonbroken flag.  However, the main machine type code
initializes msi_nonbroken to true and there's nothing that would set
it to false again.

So replace the test with an assert().

Signed-off-by: David Gibson 
Reviewed-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 42d6a2302a..4f354a8760 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -943,9 +943,8 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, void 
*fdt)
 _FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate",
   RTAS_EVENT_SCAN_RATE));
 
-if (msi_nonbroken) {
-_FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0));
-}
+g_assert(msi_nonbroken);
+_FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0));
 
 /*
  * According to PAPR, rtas ibm,os-term does not guarantee a return
-- 
2.14.3




[Qemu-devel] [PULL 08/24] openpic: debug w/ info_report()

2017-12-14 Thread David Gibson
From: Michael Davidsaver 

Replace *printf() with *_report().
Remove trailing new lines.

Signed-off-by: Michael Davidsaver 
Signed-off-by: David Gibson 
---
 hw/intc/openpic.c | 102 +++---
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index 10d6e871fb..9159a06f07 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -46,6 +46,7 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/log.h"
 #include "qemu/timer.h"
+#include "qemu/error-report.h"
 
 //#define DEBUG_OPENPIC
 
@@ -58,8 +59,7 @@ static const int debug_openpic = 0;
 static int get_current_cpu(void);
 #define DPRINTF(fmt, ...) do { \
 if (debug_openpic) { \
-printf("Core%d: ", get_current_cpu()); \
-printf(fmt , ## __VA_ARGS__); \
+info_report("Core%d: " fmt, get_current_cpu(), ## __VA_ARGS__); \
 } \
 } while (0)
 
@@ -173,7 +173,7 @@ static int inttgt_to_output(int inttgt)
 }
 }
 
-fprintf(stderr, "%s: unsupported inttgt %d\n", __func__, inttgt);
+error_report("%s: unsupported inttgt %d", __func__, inttgt);
 return OPENPIC_OUTPUT_INT;
 }
 
@@ -372,7 +372,7 @@ static void IRQ_check(OpenPICState *opp, IRQQueue *q)
 break;
 }
 
-DPRINTF("IRQ_check: irq %d set ivpr_pr=%d pr=%d\n",
+DPRINTF("IRQ_check: irq %d set ivpr_pr=%d pr=%d",
 irq, IVPR_PRIORITY(opp->src[irq].ivpr), priority);
 
 if (IVPR_PRIORITY(opp->src[irq].ivpr) > priority) {
@@ -403,11 +403,11 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, 
int n_IRQ,
 dst = >dst[n_CPU];
 src = >src[n_IRQ];
 
-DPRINTF("%s: IRQ %d active %d was %d\n",
+DPRINTF("%s: IRQ %d active %d was %d",
 __func__, n_IRQ, active, was_active);
 
 if (src->output != OPENPIC_OUTPUT_INT) {
-DPRINTF("%s: output %d irq %d active %d was %d count %d\n",
+DPRINTF("%s: output %d irq %d active %d was %d count %d",
 __func__, src->output, n_IRQ, active, was_active,
 dst->outputs_active[src->output]);
 
@@ -417,13 +417,13 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, 
int n_IRQ,
  */
 if (active) {
 if (!was_active && dst->outputs_active[src->output]++ == 0) {
-DPRINTF("%s: Raise OpenPIC output %d cpu %d irq %d\n",
+DPRINTF("%s: Raise OpenPIC output %d cpu %d irq %d",
 __func__, src->output, n_CPU, n_IRQ);
 qemu_irq_raise(dst->irqs[src->output]);
 }
 } else {
 if (was_active && --dst->outputs_active[src->output] == 0) {
-DPRINTF("%s: Lower OpenPIC output %d cpu %d irq %d\n",
+DPRINTF("%s: Lower OpenPIC output %d cpu %d irq %d",
 __func__, src->output, n_CPU, n_IRQ);
 qemu_irq_lower(dst->irqs[src->output]);
 }
@@ -446,7 +446,7 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, 
int n_IRQ,
 IRQ_check(opp, >raised);
 
 if (active && priority <= dst->ctpr) {
-DPRINTF("%s: IRQ %d priority %d too low for ctpr %d on CPU %d\n",
+DPRINTF("%s: IRQ %d priority %d too low for ctpr %d on CPU %d",
 __func__, n_IRQ, priority, dst->ctpr, n_CPU);
 active = 0;
 }
@@ -454,10 +454,10 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, 
int n_IRQ,
 if (active) {
 if (IRQ_get_next(opp, >servicing) >= 0 &&
 priority <= dst->servicing.priority) {
-DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d\n",
+DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d",
 __func__, n_IRQ, dst->servicing.next, n_CPU);
 } else {
-DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d/%d\n",
+DPRINTF("%s: Raise OpenPIC INT output cpu %d irq %d/%d",
 __func__, n_CPU, n_IRQ, dst->raised.next);
 qemu_irq_raise(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]);
 }
@@ -465,12 +465,12 @@ static void IRQ_local_pipe(OpenPICState *opp, int n_CPU, 
int n_IRQ,
 IRQ_get_next(opp, >servicing);
 if (dst->raised.priority > dst->ctpr &&
 dst->raised.priority > dst->servicing.priority) {
-DPRINTF("%s: IRQ %d inactive, IRQ %d prio %d above %d/%d, CPU 
%d\n",
+DPRINTF("%s: IRQ %d inactive, IRQ %d prio %d above %d/%d, CPU %d",
 __func__, n_IRQ, dst->raised.next, dst->raised.priority,
 dst->ctpr, dst->servicing.priority, n_CPU);
 /* IRQ line stays asserted */
 } else {
-DPRINTF("%s: IRQ %d inactive, current prio %d/%d, CPU %d\n",
+DPRINTF("%s: IRQ %d inactive, current prio %d/%d, CPU %d",
 

[Qemu-devel] [PULL 11/24] spapr/rtas: fix reboot of a a SMP TCG guest

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

Just like for hot unplug CPUs, when a guest is rebooted, the secondary
CPUs can be awaken by the decrementer and start entering SLOF at the
same time the boot CPU is.

To be safe, let's disable on the secondaries all the exceptions which
can cause an exit while the CPU is in power-saving mode.

Based on previous work from Nikunj A Dadhania 

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr_cpu_core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 588f9b4571..1ea0e295dd 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -26,6 +26,7 @@ static void spapr_cpu_reset(void *opaque)
 PowerPCCPU *cpu = opaque;
 CPUState *cs = CPU(cpu);
 CPUPPCState *env = >env;
+PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
 cpu_reset(cs);
 
@@ -35,6 +36,13 @@ static void spapr_cpu_reset(void *opaque)
 cs->halted = 1;
 
 env->spr[SPR_HIOR] = 0;
+
+/* Disable Power-saving mode Exit Cause exceptions for the CPU.
+ * This can cause issues when rebooting the guest if a secondary
+ * is awaken */
+if (cs != first_cpu) {
+env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;
+}
 }
 
 static void spapr_cpu_destroy(PowerPCCPU *cpu)
-- 
2.14.3




[Qemu-devel] [PULL 15/24] spapr: move the IRQ allocation routines under the machine

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

Also change the prototype to use a sPAPRMachineState and prefix them
with spapr_irq_. It will let us synchronise the IRQ allocation with
the XIVE interrupt mode when available.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Reviewed-by: Greg Kurz 
Signed-off-by: David Gibson 
---
 hw/intc/trace-events   |   4 --
 hw/intc/xics_spapr.c   | 114 -
 hw/ppc/spapr.c | 114 +
 hw/ppc/spapr_events.c  |   4 +-
 hw/ppc/spapr_pci.c |   8 ++--
 hw/ppc/spapr_vio.c |   2 +-
 hw/ppc/trace-events|   4 ++
 include/hw/ppc/spapr.h |   6 +++
 include/hw/ppc/xics.h  |   4 --
 9 files changed, 131 insertions(+), 129 deletions(-)

diff --git a/hw/intc/trace-events b/hw/intc/trace-events
index b298fac7c6..7077aaaee6 100644
--- a/hw/intc/trace-events
+++ b/hw/intc/trace-events
@@ -64,10 +64,6 @@ xics_ics_simple_set_irq_lsi(int srcno, int nr) "set_irq_lsi: 
srcno %d [irq 0x%x]
 xics_ics_simple_write_xive(int nr, int srcno, int server, uint8_t priority) 
"ics_write_xive: irq 0x%x [src %d] server 0x%x prio 0x%x"
 xics_ics_simple_reject(int nr, int srcno) "reject irq 0x%x [src %d]"
 xics_ics_simple_eoi(int nr) "ics_eoi: irq 0x%x"
-xics_alloc(int irq) "irq %d"
-xics_alloc_block(int first, int num, bool lsi, int align) "first irq %d, %d 
irqs, lsi=%d, alignnum %d"
-xics_ics_free(int src, int irq, int num) "Source#%d, first irq %d, %d irqs"
-xics_ics_free_warn(int src, int irq) "Source#%d, irq %d is already free"
 
 # hw/intc/s390_flic_kvm.c
 flic_create_device(int err) "flic: create device failed %d"
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index e8c0a1b3e9..5a0967caf4 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -245,120 +245,6 @@ void xics_spapr_init(sPAPRMachineState *spapr)
 spapr_register_hypercall(H_IPOLL, h_ipoll);
 }
 
-#define ICS_IRQ_FREE(ics, srcno)   \
-(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
-
-static int ics_find_free_block(ICSState *ics, int num, int alignnum)
-{
-int first, i;
-
-for (first = 0; first < ics->nr_irqs; first += alignnum) {
-if (num > (ics->nr_irqs - first)) {
-return -1;
-}
-for (i = first; i < first + num; ++i) {
-if (!ICS_IRQ_FREE(ics, i)) {
-break;
-}
-}
-if (i == (first + num)) {
-return first;
-}
-}
-
-return -1;
-}
-
-int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp)
-{
-int irq;
-
-if (!ics) {
-return -1;
-}
-if (irq_hint) {
-if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) {
-error_setg(errp, "can't allocate IRQ %d: already in use", 
irq_hint);
-return -1;
-}
-irq = irq_hint;
-} else {
-irq = ics_find_free_block(ics, 1, 1);
-if (irq < 0) {
-error_setg(errp, "can't allocate IRQ: no IRQ left");
-return -1;
-}
-irq += ics->offset;
-}
-
-ics_set_irq_type(ics, irq - ics->offset, lsi);
-trace_xics_alloc(irq);
-
-return irq;
-}
-
-/*
- * Allocate block of consecutive IRQs, and return the number of the first IRQ 
in
- * the block. If align==true, aligns the first IRQ number to num.
- */
-int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi,
-  bool align, Error **errp)
-{
-int i, first = -1;
-
-if (!ics) {
-return -1;
-}
-
-/*
- * MSIMesage::data is used for storing VIRQ so
- * it has to be aligned to num to support multiple
- * MSI vectors. MSI-X is not affected by this.
- * The hint is used for the first IRQ, the rest should
- * be allocated continuously.
- */
-if (align) {
-assert((num == 1) || (num == 2) || (num == 4) ||
-   (num == 8) || (num == 16) || (num == 32));
-first = ics_find_free_block(ics, num, num);
-} else {
-first = ics_find_free_block(ics, num, 1);
-}
-if (first < 0) {
-error_setg(errp, "can't find a free %d-IRQ block", num);
-return -1;
-}
-
-for (i = first; i < first + num; ++i) {
-ics_set_irq_type(ics, i, lsi);
-}
-first += ics->offset;
-
-trace_xics_alloc_block(first, num, lsi, align);
-
-return first;
-}
-
-static void ics_free(ICSState *ics, int srcno, int num)
-{
-int i;
-
-for (i = srcno; i < srcno + num; ++i) {
-if (ICS_IRQ_FREE(ics, i)) {
-trace_xics_ics_free_warn(0, i + ics->offset);
-}
-memset(>irqs[i], 0, sizeof(ICSIRQState));
-}
-}
-
-void spapr_ics_free(ICSState *ics, int irq, int num)
-{
-if (ics_valid_irq(ics, irq)) {
-trace_xics_ics_free(0, irq, num);
-ics_free(ics, irq - ics->offset, num);
-}
-}
-
 void spapr_dt_xics(int 

[Qemu-devel] [PULL 04/24] spapr_cpu_core: instantiate CPUs separately

2017-12-14 Thread David Gibson
From: Greg Kurz 

The current code assumes that only the CPU core object holds a
reference on each individual CPU object, and happily frees their
allocated memory when the core is unrealized. This is dangerous
as some other code can legitimely keep a pointer to a CPU if it
calls object_ref(), but it would end up with a dangling pointer.

Let's allocate all CPUs with object_new() and let QOM free them
when their reference count reaches zero. This greatly simplify the
code as we don't have to fiddle with the instance size anymore.

Signed-off-by: Greg Kurz 
Acked-by: Igor Mammedov 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr.c  | 11 +++
 hw/ppc/spapr_cpu_core.c | 19 +++
 include/hw/ppc/spapr_cpu_core.h |  2 +-
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8881f2f1e8..f1b96a4e92 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3180,12 +3180,10 @@ void spapr_core_release(DeviceState *dev)
 
 if (smc->pre_2_10_has_unused_icps) {
 sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
-sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc));
-size_t size = object_type_get_instance_size(scc->cpu_type);
 int i;
 
 for (i = 0; i < cc->nr_threads; i++) {
-CPUState *cs = CPU(sc->threads + i * size);
+CPUState *cs = CPU(sc->threads[i]);
 
 pre_2_10_vmstate_register_dummy_icp(cs->cpu_index);
 }
@@ -3231,7 +3229,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, 
DeviceState *dev,
 sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
 sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
 CPUCore *cc = CPU_CORE(dev);
-CPUState *cs = CPU(core->threads);
+CPUState *cs = CPU(core->threads[0]);
 sPAPRDRConnector *drc;
 Error *local_err = NULL;
 int smt = kvmppc_smt_threads();
@@ -3276,15 +3274,12 @@ static void spapr_core_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
 core_slot->cpu = OBJECT(dev);
 
 if (smc->pre_2_10_has_unused_icps) {
-sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc));
-size_t size = object_type_get_instance_size(scc->cpu_type);
 int i;
 
 for (i = 0; i < cc->nr_threads; i++) {
 sPAPRCPUCore *sc = SPAPR_CPU_CORE(dev);
-void *obj = sc->threads + i * size;
 
-cs = CPU(obj);
+cs = CPU(sc->threads[i]);
 pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index);
 }
 }
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 3a4c174012..588f9b4571 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -79,13 +79,11 @@ const char *spapr_get_cpu_core_type(const char *cpu_type)
 static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
 {
 sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
-sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
-size_t size = object_type_get_instance_size(scc->cpu_type);
 CPUCore *cc = CPU_CORE(dev);
 int i;
 
 for (i = 0; i < cc->nr_threads; i++) {
-void *obj = sc->threads + i * size;
+Object *obj = OBJECT(sc->threads[i]);
 DeviceState *dev = DEVICE(obj);
 CPUState *cs = CPU(dev);
 PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -146,9 +144,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error 
**errp)
 sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
 sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
 CPUCore *cc = CPU_CORE(OBJECT(dev));
-size_t size;
 Error *local_err = NULL;
-void *obj;
+Object *obj;
 int i, j;
 
 if (!spapr) {
@@ -156,18 +153,16 @@ static void spapr_cpu_core_realize(DeviceState *dev, 
Error **errp)
 return;
 }
 
-size = object_type_get_instance_size(scc->cpu_type);
-sc->threads = g_malloc0(size * cc->nr_threads);
+sc->threads = g_new(PowerPCCPU *, cc->nr_threads);
 for (i = 0; i < cc->nr_threads; i++) {
 char id[32];
 CPUState *cs;
 PowerPCCPU *cpu;
 
-obj = sc->threads + i * size;
+obj = object_new(scc->cpu_type);
 
-object_initialize(obj, size, scc->cpu_type);
 cs = CPU(obj);
-cpu = POWERPC_CPU(cs);
+cpu = sc->threads[i] = POWERPC_CPU(obj);
 cs->cpu_index = cc->core_id + i;
 cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i;
 if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) {
@@ -192,7 +187,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error 
**errp)
 }
 
 for (j = 0; j < cc->nr_threads; j++) {
-obj = sc->threads + j * size;
+obj = OBJECT(sc->threads[j]);
 
 spapr_cpu_core_realize_child(obj, spapr, _err);
 if (local_err) {
@@ -203,7 +198,7 @@ static void 

[Qemu-devel] [PULL 07/24] pcc: define the Power-saving mode Exit Cause Enable bits in PowerPCCPUClass

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

and use the value to define precisely the default value of the LPCR in
the helper routine cpu_ppc_set_papr()

Signed-off-by: Cédric Le Goater 
Signed-off-by: David Gibson 
---
 target/ppc/cpu-qom.h|  1 +
 target/ppc/translate_init.c | 23 +++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index 429b47f959..deaa46a14b 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -191,6 +191,7 @@ typedef struct PowerPCCPUClass {
 uint64_t insns_flags;
 uint64_t insns_flags2;
 uint64_t msr_mask;
+uint64_t lpcr_pm;   /* Power-saving mode Exit Cause Enable bits */
 powerpc_mmu_t   mmu_model;
 powerpc_excp_t  excp_model;
 powerpc_input_t bus_model;
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index 4e11e6f489..074c3a1d45 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -8535,6 +8535,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 pcc->l1_dcache_size = 0x8000;
 pcc->l1_icache_size = 0x8000;
 pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
+pcc->lpcr_pm = LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2;
 }
 
 static void init_proc_POWER8(CPUPPCState *env)
@@ -8704,6 +8705,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
 pcc->l1_dcache_size = 0x8000;
 pcc->l1_icache_size = 0x8000;
 pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
+pcc->lpcr_pm = LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_PECE2 |
+   LPCR_P8_PECE3 | LPCR_P8_PECE4;
 }
 
 #ifdef CONFIG_SOFTMMU
@@ -8898,11 +8901,13 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
 pcc->l1_dcache_size = 0x8000;
 pcc->l1_icache_size = 0x8000;
 pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
+pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE;
 }
 
 #if !defined(CONFIG_USER_ONLY)
 void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp)
 {
+PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 CPUPPCState *env = >env;
 ppc_spr_t *lpcr = >spr_cb[SPR_LPCR];
 ppc_spr_t *amor = >spr_cb[SPR_AMOR];
@@ -8932,8 +8937,7 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, 
PPCVirtualHypervisor *vhyp)
 lpcr->default_value &= ~LPCR_RMLS;
 lpcr->default_value |= 1ull << LPCR_RMLS_SHIFT;
 
-switch (env->mmu_model) {
-case POWERPC_MMU_3_00:
+if (env->mmu_model == POWERPC_MMU_3_00) {
 /* By default we choose legacy mode and switch to new hash or radix
  * when a register process table hcall is made. So disable process
  * tables and guest translation shootdown by default
@@ -8947,18 +8951,13 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, 
PPCVirtualHypervisor *vhyp)
 } else {
 lpcr->default_value &= ~(LPCR_UPRT | LPCR_GTSE);
 }
-lpcr->default_value |= LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE |
-   LPCR_OEE;
-break;
-default:
-/* P7 and P8 has slightly different PECE bits, mostly because P8 adds
- * bit 47 and 48 which are reserved on P7. Here we set them all, which
- * will work as expected for both implementations
- */
-lpcr->default_value |= LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_PECE2 |
-   LPCR_P8_PECE3 | LPCR_P8_PECE4;
 }
 
+/* Also set the power-saving mode bits which depend on the CPU
+ * family
+ */
+lpcr->default_value |= pcc->lpcr_pm;
+
 /* We should be followed by a CPU reset but update the active value
  * just in case...
  */
-- 
2.14.3




[Qemu-devel] [PULL 13/24] ppc/xics: introduce an icp_create() helper

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

The sPAPR and the PowerNV core objects create the interrupt presenter
object of the CPUs in a very similar way. Let's provide a common
routine in which we use the presenter 'type' as a child identifier.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Reviewed-by: Greg Kurz 
Signed-off-by: David Gibson 
---
 hw/intc/xics.c  | 21 +
 hw/ppc/pnv_core.c   | 10 +-
 hw/ppc/spapr_cpu_core.c | 13 ++---
 include/hw/ppc/xics.h   |  3 +++
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index a1cc0e420c..bfc6b5bb23 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -384,6 +384,27 @@ static const TypeInfo icp_info = {
 .class_size = sizeof(ICPStateClass),
 };
 
+Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
+{
+Error *local_err = NULL;
+Object *obj;
+
+obj = object_new(type);
+object_property_add_child(cpu, type, obj, _abort);
+object_unref(obj);
+object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi),
+   _abort);
+object_property_add_const_link(obj, ICP_PROP_CPU, cpu, _abort);
+object_property_set_bool(obj, true, "realized", _err);
+if (local_err) {
+object_unparent(obj);
+error_propagate(errp, local_err);
+obj = NULL;
+}
+
+return obj;
+}
+
 /*
  * ICS: Source layer
  */
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 82ff440b33..8d966e0802 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -126,7 +126,6 @@ static void pnv_core_realize_child(Object *child, 
XICSFabric *xi, Error **errp)
 Error *local_err = NULL;
 CPUState *cs = CPU(child);
 PowerPCCPU *cpu = POWERPC_CPU(cs);
-Object *obj;
 
 object_property_set_bool(child, true, "realized", _err);
 if (local_err) {
@@ -134,13 +133,7 @@ static void pnv_core_realize_child(Object *child, 
XICSFabric *xi, Error **errp)
 return;
 }
 
-obj = object_new(TYPE_PNV_ICP);
-object_property_add_child(child, "icp", obj, NULL);
-object_unref(obj);
-object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi),
-   _abort);
-object_property_add_const_link(obj, ICP_PROP_CPU, child, _abort);
-object_property_set_bool(obj, true, "realized", _err);
+icp_create(child, TYPE_PNV_ICP, xi, _err);
 if (local_err) {
 error_propagate(errp, local_err);
 return;
@@ -148,7 +141,6 @@ static void pnv_core_realize_child(Object *child, 
XICSFabric *xi, Error **errp)
 
 powernv_cpu_init(cpu, _err);
 if (local_err) {
-object_unparent(obj);
 error_propagate(errp, local_err);
 return;
 }
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 1ea0e295dd..70e757f808 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -110,7 +110,6 @@ static void spapr_cpu_core_realize_child(Object *child,
 Error *local_err = NULL;
 CPUState *cs = CPU(child);
 PowerPCCPU *cpu = POWERPC_CPU(cs);
-Object *obj;
 
 object_property_set_bool(child, true, "realized", _err);
 if (local_err) {
@@ -122,21 +121,13 @@ static void spapr_cpu_core_realize_child(Object *child,
 goto error;
 }
 
-obj = object_new(spapr->icp_type);
-object_property_add_child(child, "icp", obj, _abort);
-object_unref(obj);
-object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr),
-   _abort);
-object_property_add_const_link(obj, ICP_PROP_CPU, child, _abort);
-object_property_set_bool(obj, true, "realized", _err);
+icp_create(child, spapr->icp_type, XICS_FABRIC(spapr), _err);
 if (local_err) {
-goto free_icp;
+goto error;
 }
 
 return;
 
-free_icp:
-object_unparent(obj);
 error:
 error_propagate(errp, local_err);
 }
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 2df99be111..2ba8b12208 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -212,4 +212,7 @@ typedef struct sPAPRMachineState sPAPRMachineState;
 int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
 void xics_spapr_init(sPAPRMachineState *spapr);
 
+Object *icp_create(Object *cpu, const char *type, XICSFabric *xi,
+   Error **errp);
+
 #endif /* XICS_H */
-- 
2.14.3




[Qemu-devel] [PULL 06/24] nvram: add AT24Cx i2c eeprom

2017-12-14 Thread David Gibson
From: Michael Davidsaver 

Signed-off-by: Michael Davidsaver 
Signed-off-by: David Gibson 
---
 hw/nvram/Makefile.objs  |   1 +
 hw/nvram/eeprom_at24c.c | 205 
 2 files changed, 206 insertions(+)
 create mode 100644 hw/nvram/eeprom_at24c.c

diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs
index c018f6b2ff..0f4ee71dcb 100644
--- a/hw/nvram/Makefile.objs
+++ b/hw/nvram/Makefile.objs
@@ -1,5 +1,6 @@
 common-obj-$(CONFIG_DS1225Y) += ds1225y.o
 common-obj-y += eeprom93xx.o
+common-obj-y += eeprom_at24c.o
 common-obj-y += fw_cfg.o
 common-obj-y += chrp_nvram.o
 common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
new file mode 100644
index 00..efa3621ac6
--- /dev/null
+++ b/hw/nvram/eeprom_at24c.c
@@ -0,0 +1,205 @@
+/*
+ * *AT24C* series I2C EEPROM
+ *
+ * Copyright (c) 2015 Michael Davidsaver
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the LICENSE file in the top-level directory.
+ */
+
+#include 
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/hw.h"
+#include "hw/i2c/i2c.h"
+#include "sysemu/block-backend.h"
+
+/* #define DEBUG_AT24C */
+
+#ifdef DEBUG_AT24C
+#define DPRINTK(FMT, ...) printf(TYPE_AT24C_EE " : " FMT, ## __VA_ARGS__)
+#else
+#define DPRINTK(FMT, ...) do {} while (0)
+#endif
+
+#define ERR(FMT, ...) fprintf(stderr, TYPE_AT24C_EE " : " FMT, \
+## __VA_ARGS__)
+
+#define TYPE_AT24C_EE "at24c-eeprom"
+#define AT24C_EE(obj) OBJECT_CHECK(EEPROMState, (obj), TYPE_AT24C_EE)
+
+typedef struct EEPROMState {
+I2CSlave parent_obj;
+
+/* address counter */
+uint16_t cur;
+/* total size in bytes */
+uint32_t rsize;
+bool writable;
+/* cells changed since last START? */
+bool changed;
+/* during WRITE, # of address bytes transfered */
+uint8_t haveaddr;
+
+uint8_t *mem;
+
+BlockBackend *blk;
+} EEPROMState;
+
+static
+int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
+{
+EEPROMState *ee = container_of(s, EEPROMState, parent_obj);
+
+switch (event) {
+case I2C_START_SEND:
+case I2C_START_RECV:
+case I2C_FINISH:
+ee->haveaddr = 0;
+DPRINTK("clear\n");
+if (ee->blk && ee->changed) {
+int len = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
+if (len != ee->rsize) {
+ERR(TYPE_AT24C_EE
+" : failed to write backing file\n");
+}
+DPRINTK("Wrote to backing file\n");
+}
+ee->changed = false;
+break;
+case I2C_NACK:
+break;
+}
+return 0;
+}
+
+static
+int at24c_eeprom_recv(I2CSlave *s)
+{
+EEPROMState *ee = AT24C_EE(s);
+int ret;
+
+ret = ee->mem[ee->cur];
+
+ee->cur = (ee->cur + 1u) % ee->rsize;
+DPRINTK("Recv %02x %c\n", ret, ret);
+
+return ret;
+}
+
+static
+int at24c_eeprom_send(I2CSlave *s, uint8_t data)
+{
+EEPROMState *ee = AT24C_EE(s);
+
+if (ee->haveaddr < 2) {
+ee->cur <<= 8;
+ee->cur |= data;
+ee->haveaddr++;
+if (ee->haveaddr == 2) {
+ee->cur %= ee->rsize;
+DPRINTK("Set pointer %04x\n", ee->cur);
+}
+
+} else {
+if (ee->writable) {
+DPRINTK("Send %02x\n", data);
+ee->mem[ee->cur] = data;
+ee->changed = true;
+} else {
+DPRINTK("Send error %02x read-only\n", data);
+}
+ee->cur = (ee->cur + 1u) % ee->rsize;
+
+}
+
+return 0;
+}
+
+static
+int at24c_eeprom_init(I2CSlave *i2c)
+{
+EEPROMState *ee = AT24C_EE(i2c);
+
+ee->mem = g_malloc0(ee->rsize);
+
+if (ee->blk) {
+int64_t len = blk_getlength(ee->blk);
+
+if (len != ee->rsize) {
+ERR(TYPE_AT24C_EE " : Backing file size %lu != %u\n",
+(unsigned long)len, (unsigned)ee->rsize);
+exit(1);
+}
+
+if (blk_set_perm(ee->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
+ BLK_PERM_ALL, _fatal) < 0)
+{
+ERR(TYPE_AT24C_EE
+" : Backing file incorrect permission\n");
+exit(1);
+}
+}
+return 0;
+}
+
+static
+void at24c_eeprom_reset(DeviceState *state)
+{
+EEPROMState *ee = AT24C_EE(state);
+
+ee->changed = false;
+ee->cur = 0;
+ee->haveaddr = 0;
+
+memset(ee->mem, 0, ee->rsize);
+
+if (ee->blk) {
+int len = blk_pread(ee->blk, 0, ee->mem, ee->rsize);
+
+if (len != ee->rsize) {
+ERR(TYPE_AT24C_EE
+" : Failed initial sync with backing file\n");
+}
+DPRINTK("Reset read backing file\n");
+}
+}
+
+static Property at24c_eeprom_props[] = {
+DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0),
+

[Qemu-devel] [PULL 16/24] spapr: introduce a spapr_irq_set_lsi() helper

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

It will make synchronisation easier with the XIVE interrupt mode when
available. The 'irq' parameter refers to the global IRQ number space.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 53c2c58a25..02cc7ffd4d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3582,6 +3582,14 @@ static int ics_find_free_block(ICSState *ics, int num, 
int alignnum)
 return -1;
 }
 
+/*
+ * Allocate the IRQ number and set the IRQ type, LSI or MSI
+ */
+static void spapr_irq_set_lsi(sPAPRMachineState *spapr, int irq, bool lsi)
+{
+ics_set_irq_type(spapr->ics, irq - spapr->ics->offset, lsi);
+}
+
 int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi,
 Error **errp)
 {
@@ -3606,7 +3614,7 @@ int spapr_irq_alloc(sPAPRMachineState *spapr, int 
irq_hint, bool lsi,
 irq += ics->offset;
 }
 
-ics_set_irq_type(ics, irq - ics->offset, lsi);
+spapr_irq_set_lsi(spapr, irq, lsi);
 trace_spapr_irq_alloc(irq);
 
 return irq;
@@ -3645,10 +3653,10 @@ int spapr_irq_alloc_block(sPAPRMachineState *spapr, int 
num, bool lsi,
 return -1;
 }
 
+first += ics->offset;
 for (i = first; i < first + num; ++i) {
-ics_set_irq_type(ics, i, lsi);
+spapr_irq_set_lsi(spapr, i, lsi);
 }
-first += ics->offset;
 
 trace_spapr_irq_alloc_block(first, num, lsi, align);
 
-- 
2.14.3




[Qemu-devel] [PULL 01/24] target/ppc: Use tcg_gen_lookup_and_goto_ptr

2017-12-14 Thread David Gibson
From: Richard Henderson 

Signed-off-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: David Gibson 
---
 target/ppc/translate.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 998fbed848..4075fc8589 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -3419,7 +3419,7 @@ static inline bool use_goto_tb(DisasContext *ctx, 
target_ulong dest)
 }
 
 /***Branch ***/
-static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
+static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
 {
 if (NARROW_MODE(ctx)) {
 dest = (uint32_t) dest;
@@ -3441,7 +3441,7 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, 
target_ulong dest)
 gen_debug_exception(ctx);
 }
 }
-tcg_gen_exit_tb(0);
+tcg_gen_lookup_and_goto_ptr();
 }
 }
 
@@ -3479,7 +3479,7 @@ static void gen_b(DisasContext *ctx)
 #define BCOND_CTR 2
 #define BCOND_TAR 3
 
-static inline void gen_bcond(DisasContext *ctx, int type)
+static void gen_bcond(DisasContext *ctx, int type)
 {
 uint32_t bo = BO(ctx->opcode);
 TCGLabel *l1;
@@ -3543,26 +3543,19 @@ static inline void gen_bcond(DisasContext *ctx, int 
type)
 } else {
 gen_goto_tb(ctx, 0, li);
 }
-if ((bo & 0x14) != 0x14) {
-gen_set_label(l1);
-gen_goto_tb(ctx, 1, ctx->nip);
-}
 } else {
 if (NARROW_MODE(ctx)) {
 tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
 } else {
 tcg_gen_andi_tl(cpu_nip, target, ~3);
 }
-tcg_gen_exit_tb(0);
-if ((bo & 0x14) != 0x14) {
-gen_set_label(l1);
-gen_update_nip(ctx, ctx->nip);
-tcg_gen_exit_tb(0);
-}
-}
-if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
+tcg_gen_lookup_and_goto_ptr();
 tcg_temp_free(target);
 }
+if ((bo & 0x14) != 0x14) {
+gen_set_label(l1);
+gen_goto_tb(ctx, 1, ctx->nip);
+}
 }
 
 static void gen_bc(DisasContext *ctx)
-- 
2.14.3




[Qemu-devel] [PULL 02/24] ppc/xics: remove useless if condition

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

The previous code section uses a 'first < 0' test and returns. Therefore,
there is no need to test the 'first' variable against '>= 0' afterwards.

Signed-off-by: Cédric Le Goater 
Reviewed-by: Greg Kurz 
Signed-off-by: David Gibson 
---
 hw/intc/xics_spapr.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index d98ea8b130..e8c0a1b3e9 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -329,10 +329,8 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi,
 return -1;
 }
 
-if (first >= 0) {
-for (i = first; i < first + num; ++i) {
-ics_set_irq_type(ics, i, lsi);
-}
+for (i = first; i < first + num; ++i) {
+ics_set_irq_type(ics, i, lsi);
 }
 first += ics->offset;
 
-- 
2.14.3




[Qemu-devel] [PULL 12/24] spapr/rtas: do not reset the MSR in stop-self command

2017-12-14 Thread David Gibson
From: Cédric Le Goater 

When a CPU is stopped with the 'stop-self' RTAS call, its state
'halted' is switched to 1 and, in this case, the MSR is not taken into
account anymore in the cpu_has_work() routine. Only the pending
hardware interrupts are checked with their LPCR:PECE* enablement bit.

The CPU is now also protected from the decrementer interrupt by the
LPCR:PECE* bits which are disabled in the 'stop-self' RTAS
call. Reseting the MSR is pointless.

Signed-off-by: Cédric Le Goater 
Reviewed-by: David Gibson 
Signed-off-by: David Gibson 
---
 hw/ppc/spapr_rtas.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 858adb1bf3..4bb939d3d1 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -206,16 +206,6 @@ static void rtas_stop_self(PowerPCCPU *cpu, 
sPAPRMachineState *spapr,
 
 cs->halted = 1;
 qemu_cpu_kick(cs);
-/*
- * While stopping a CPU, the guest calls H_CPPR which
- * effectively disables interrupts on XICS level.
- * However decrementer interrupts in TCG can still
- * wake the CPU up so here we disable interrupts in MSR
- * as well.
- * As rtas_start_cpu() resets the whole MSR anyway, there is
- * no need to bother with specific bits, we just clear it.
- */
-env->msr = 0;
 
 /* Disable Power-saving mode Exit Cause exceptions for the CPU.
  * This could deliver an interrupt on a dying CPU and crash the
-- 
2.14.3




[Qemu-devel] [PULL 03/24] spapr: Add pseries-2.12 machine type

2017-12-14 Thread David Gibson
While we're at it fix a couple of small errors in the 2.11 and 2.10 models
(they didn't have any real effect, but don't quite match the template).

Signed-off-by: David Gibson 
---
 hw/ppc/spapr.c  | 26 +++---
 include/hw/compat.h |  2 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1ac7eb0f8c..8881f2f1e8 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3713,28 +3713,48 @@ static const TypeInfo spapr_machine_info = {
 }\
 type_init(spapr_machine_register_##suffix)
 
+/*
+ * pseries-2.12
+ */
+static void spapr_machine_2_12_instance_options(MachineState *machine)
+{
+}
+
+static void spapr_machine_2_12_class_options(MachineClass *mc)
+{
+/* Defaults for the latest behaviour inherited from the base class */
+}
+
+DEFINE_SPAPR_MACHINE(2_12, "2.12", true);
+
 /*
  * pseries-2.11
  */
+#define SPAPR_COMPAT_2_11  \
+HW_COMPAT_2_11
+
 static void spapr_machine_2_11_instance_options(MachineState *machine)
 {
+spapr_machine_2_12_instance_options(machine);
 }
 
 static void spapr_machine_2_11_class_options(MachineClass *mc)
 {
-/* Defaults for the latest behaviour inherited from the base class */
+spapr_machine_2_12_class_options(mc);
+SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11);
 }
 
-DEFINE_SPAPR_MACHINE(2_11, "2.11", true);
+DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
 
 /*
  * pseries-2.10
  */
 #define SPAPR_COMPAT_2_10  \
-HW_COMPAT_2_10 \
+HW_COMPAT_2_10
 
 static void spapr_machine_2_10_instance_options(MachineState *machine)
 {
+spapr_machine_2_11_instance_options(machine);
 }
 
 static void spapr_machine_2_10_class_options(MachineClass *mc)
diff --git a/include/hw/compat.h b/include/hw/compat.h
index cf389b4e85..0d2a6ac468 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,8 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
+#define HW_COMPAT_2_11
+
 #define HW_COMPAT_2_10 \
 {\
 .driver   = "virtio-mouse-device",\
-- 
2.14.3




[Qemu-devel] [PULL 00/24] ppc-for-2.12 queue 20171215

2017-12-14 Thread David Gibson
The following changes since commit 0ef0583d5adceb9138bdb47494dabd1549ac5b6d:

  Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20171214' into 
staging (2017-12-14 15:32:32 +)

are available in the Git repository at:

  git://github.com/dgibson/qemu.git tags/ppc-for-2.12-20171215

for you to fetch changes up to 1481fe5fcfeb7fcf3c1ebb9d8c0432e3e0188ccf:

  spapr: don't initialize PATB entry if max-cpu-compat < power9 (2017-12-15 
09:50:29 +1100)


ppc patch queue 2017-12-15

First pull request for qemu-2.12.  This has quite a bit of stuff
accumulated while 2.11 was finalizing.  Highlights are:

  * Some preliminary work towards implementing the "XIVE" POWER9
interrupt controller
  * Some fixes for problems during reboot with MTTCG
  * A substantial TCG performance improvement via
tcg_get_lookup_and_goto_ptr
  * Numerous assorted cleanups and bugfixes that weren't urgent enough
for 2.11


Cédric Le Goater (11):
  ppc/xics: remove useless if condition
  pcc: define the Power-saving mode Exit Cause Enable bits in 
PowerPCCPUClass
  spapr/rtas: disable the decrementer interrupt when a CPU is unplugged
  spapr/rtas: fix reboot of a a SMP TCG guest
  spapr/rtas: do not reset the MSR in stop-self command
  ppc/xics: introduce an icp_create() helper
  ppc/xics: assign of the CPU 'intc' pointer under the core
  spapr: move the IRQ allocation routines under the machine
  spapr: introduce a spapr_irq_set_lsi() helper
  spapr: introduce a spapr_qirq() helper
  target/ppc: introduce the PPC_BIT() macro

David Gibson (3):
  spapr: Add pseries-2.12 machine type
  spapr: Rename machine init functions for clarity
  spapr: Assume msi_nonbroken

Greg Kurz (3):
  spapr_cpu_core: instantiate CPUs separately
  spapr: fix LSI interrupt specifiers in the device tree
  spapr_events: drop bogus cell from "interrupt-ranges" property

Igor Mammedov (1):
  spapr: replace numa_get_node() with lookup in pc-dimm list

Laurent Vivier (1):
  spapr: don't initialize PATB entry if max-cpu-compat < power9

Michael Davidsaver (4):
  e500: name openpic and pci host bridge
  nvram: add AT24Cx i2c eeprom
  openpic: debug w/ info_report()
  e500: fix pci host bridge class/type

Richard Henderson (1):
  target/ppc: Use tcg_gen_lookup_and_goto_ptr

 hw/intc/openpic.c   | 102 +-
 hw/intc/trace-events|   4 -
 hw/intc/xics.c  |  34 +++---
 hw/intc/xics_spapr.c| 116 -
 hw/mem/pc-dimm.c|   2 -
 hw/nvram/Makefile.objs  |   1 +
 hw/nvram/eeprom_at24c.c | 205 +
 hw/pci-host/ppce500.c   |   5 -
 hw/ppc/e500.c   |   4 +
 hw/ppc/pnv_core.c   |  10 +-
 hw/ppc/spapr.c  | 222 +++-
 hw/ppc/spapr_cpu_core.c |  41 
 hw/ppc/spapr_events.c   |  22 ++--
 hw/ppc/spapr_pci.c  |  13 ++-
 hw/ppc/spapr_rtas.c |  21 ++--
 hw/ppc/spapr_vio.c  |   5 +-
 hw/ppc/trace-events |   4 +
 include/hw/compat.h |   2 +
 include/hw/pci-host/spapr.h |   2 +-
 include/hw/ppc/spapr.h  |  17 +++
 include/hw/ppc/spapr_cpu_core.h |   2 +-
 include/hw/ppc/spapr_vio.h  |   2 +-
 include/hw/ppc/xics.h   |   8 +-
 include/sysemu/numa.h   |  10 --
 numa.c  |  94 -
 target/ppc/cpu-qom.h|   1 +
 target/ppc/cpu.h| 105 ++-
 target/ppc/translate.c  |  23 ++---
 target/ppc/translate_init.c |  26 ++---
 29 files changed, 636 insertions(+), 467 deletions(-)
 create mode 100644 hw/nvram/eeprom_at24c.c



Re: [Qemu-devel] [PATCH qemu] RFC: vfio-pci: Allow mmap of MSIX BAR

2017-12-14 Thread David Gibson
On Tue, Dec 12, 2017 at 09:05:25AM -0700, Alex Williamson wrote:
> On Tue, 12 Dec 2017 18:01:40 +1100
> Alexey Kardashevskiy  wrote:
> 
> > On 12/12/17 17:06, Alexey Kardashevskiy wrote:
> > > On 12/12/17 16:54, Alex Williamson wrote:  
> > >> On Tue, 12 Dec 2017 16:21:31 +1100
> > >> Alexey Kardashevskiy  wrote:
> > >>  
> > >>> This makes use of a new VFIO_REGION_INFO_CAP_MSIX_MAPPABLE capability
> > >>> which tells that a region with MSIX data can be mapped entirely, i.e.
> > >>> the VFIO PCI driver won't prevent MSIX vectors area from being mapped.
> > >>>
> > >>> This adds a "msix-no-mmap" property to the vfio-pci device, it is "true"
> > >>> by default and "false" for pseries-2.12+ machines.
> > >>>
> > >>> This requites kernel's "vfio-pci: Allow mapping MSIX BAR"
> > >>> https://www.spinics.net/lists/kvm/msg160282.html
> > >>>
> > >>> Signed-off-by: Alexey Kardashevskiy 
> > >>> ---
> > >>>
> > >>> This is an RFC as it requires kernel headers update which is not there 
> > >>> yet.
> > >>>
> > >>> I'd like to make it "msix-mmap" (without "no") but could not find a way
> > >>> of enabling a device property for machine versions newer than some 
> > >>> value.
> > >>>
> > >>> I changed 2.11 machine just for the demonstration purpose.
> > >>>
> > >>>
> > >>> ---
> > >>>  hw/vfio/pci.h |  1 +
> > >>>  include/hw/vfio/vfio-common.h |  1 +
> > >>>  linux-headers/linux/vfio.h|  5 +
> > >>>  hw/ppc/spapr.c| 10 +-
> > >>>  hw/vfio/common.c  | 15 +++
> > >>>  hw/vfio/pci.c | 11 +++
> > >>>  6 files changed, 42 insertions(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> > >>> index a8fb3b3..53912ef 100644
> > >>> --- a/hw/vfio/pci.h
> > >>> +++ b/hw/vfio/pci.h
> > >>> @@ -142,6 +142,7 @@ typedef struct VFIOPCIDevice {
> > >>>  bool no_kvm_intx;
> > >>>  bool no_kvm_msi;
> > >>>  bool no_kvm_msix;
> > >>> +bool msix_no_mmap;
> > >>>  } VFIOPCIDevice;
> > >>>  
> > >>>  uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
> > >>> diff --git a/include/hw/vfio/vfio-common.h 
> > >>> b/include/hw/vfio/vfio-common.h
> > >>> index f3a2ac9..927d600 100644
> > >>> --- a/include/hw/vfio/vfio-common.h
> > >>> +++ b/include/hw/vfio/vfio-common.h
> > >>> @@ -171,6 +171,7 @@ int vfio_get_region_info(VFIODevice *vbasedev, int 
> > >>> index,
> > >>>   struct vfio_region_info **info);
> > >>>  int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
> > >>>   uint32_t subtype, struct vfio_region_info 
> > >>> **info);
> > >>> +bool vfio_is_cap_present(VFIODevice *vbasedev, uint16_t cap_type, int 
> > >>> region);
> > >>>  #endif
> > >>>  extern const MemoryListener vfio_prereg_listener;
> > >>>  
> > >>> diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
> > >>> index 4e7ab4c..bce9baf 100644
> > >>> --- a/linux-headers/linux/vfio.h
> > >>> +++ b/linux-headers/linux/vfio.h
> > >>> @@ -300,6 +300,11 @@ struct vfio_region_info_cap_type {
> > >>>  #define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
> > >>>  #define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG  (3)
> > >>>  
> > >>> +/*
> > >>> + * The MSIX mappable capability informs that MSIX data of a BAR can be 
> > >>> mmapped.
> > >>> + */
> > >>> +#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3
> > >>> +
> > >>>  /**
> > >>>   * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
> > >>>   * struct vfio_irq_info)
> > >>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > >>> index 9de63f0..1dfc386 100644
> > >>> --- a/hw/ppc/spapr.c
> > >>> +++ b/hw/ppc/spapr.c
> > >>> @@ -3742,13 +3742,21 @@ static const TypeInfo spapr_machine_info = {
> > >>>  /*
> > >>>   * pseries-2.11
> > >>>   */
> > >>> +#define SPAPR_COMPAT_2_11 \
> > >>> +HW_COMPAT_2_10\
> > >>> +{ \
> > >>> +.driver = "vfio-pci", \
> > >>> +.property = "msix-no-mmap",   \
> > >>> +.value= "on", \
> > >>> +},\
> > >>> +
> > >>>  static void spapr_machine_2_11_instance_options(MachineState *machine)
> > >>>  {
> > >>>  }
> > >>>  
> > >>>  static void spapr_machine_2_11_class_options(MachineClass *mc)
> > >>>  {
> > >>> -/* Defaults for the latest behaviour inherited from the base class 
> > >>> */
> > >>> +SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11);
> > >>>  }
> > >>>  
> > >>>  DEFINE_SPAPR_MACHINE(2_11, "2.11", true);
> > >>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > >>> index ed7717d..593514c 100644
> > >>> 

Re: [Qemu-devel] [PATCH qemu] RFC: vfio-pci: Allow mmap of MSIX BAR

2017-12-14 Thread David Gibson
On Tue, Dec 12, 2017 at 04:21:31PM +1100, Alexey Kardashevskiy wrote:
> This makes use of a new VFIO_REGION_INFO_CAP_MSIX_MAPPABLE capability
> which tells that a region with MSIX data can be mapped entirely, i.e.
> the VFIO PCI driver won't prevent MSIX vectors area from being mapped.
> 
> This adds a "msix-no-mmap" property to the vfio-pci device, it is "true"
> by default and "false" for pseries-2.12+ machines.
> 
> This requites kernel's "vfio-pci: Allow mapping MSIX BAR"
> https://www.spinics.net/lists/kvm/msg160282.html
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
> 
> This is an RFC as it requires kernel headers update which is not there yet.
> 
> I'd like to make it "msix-mmap" (without "no") but could not find a way
> of enabling a device property for machine versions newer than some value.
> 
> I changed 2.11 machine just for the demonstration purpose.

As Alex says, the mmap()ability of the MSI-X BAR isn't really the
point.  The point is whether we need to intercept guest MMIOs to the
MSI-X region.  Still, the logic's basically right, just rename your
property to, say, "intercept_msix_mmio".  It would be true by default,
set to false by the pseries machine type.

I don't think you actually need to make it vary depending on the
version of the pseries machine type: whether the BAR is mmap()ed or
qemu emulated shouldn't be a guest visible change.  No PAPR guest
should have been directly poking the MSI-X region (ever), so we
shouldn't need to intercept the region even for old versions.

> 
> 
> ---
>  hw/vfio/pci.h |  1 +
>  include/hw/vfio/vfio-common.h |  1 +
>  linux-headers/linux/vfio.h|  5 +
>  hw/ppc/spapr.c| 10 +-
>  hw/vfio/common.c  | 15 +++
>  hw/vfio/pci.c | 11 +++
>  6 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index a8fb3b3..53912ef 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -142,6 +142,7 @@ typedef struct VFIOPCIDevice {
>  bool no_kvm_intx;
>  bool no_kvm_msi;
>  bool no_kvm_msix;
> +bool msix_no_mmap;
>  } VFIOPCIDevice;
>  
>  uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index f3a2ac9..927d600 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -171,6 +171,7 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index,
>   struct vfio_region_info **info);
>  int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
>   uint32_t subtype, struct vfio_region_info 
> **info);
> +bool vfio_is_cap_present(VFIODevice *vbasedev, uint16_t cap_type, int 
> region);
>  #endif
>  extern const MemoryListener vfio_prereg_listener;
>  
> diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
> index 4e7ab4c..bce9baf 100644
> --- a/linux-headers/linux/vfio.h
> +++ b/linux-headers/linux/vfio.h
> @@ -300,6 +300,11 @@ struct vfio_region_info_cap_type {
>  #define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG   (2)
>  #define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG(3)
>  
> +/*
> + * The MSIX mappable capability informs that MSIX data of a BAR can be 
> mmapped.
> + */
> +#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE   3
> +
>  /**
>   * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
>   *   struct vfio_irq_info)
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 9de63f0..1dfc386 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3742,13 +3742,21 @@ static const TypeInfo spapr_machine_info = {
>  /*
>   * pseries-2.11
>   */
> +#define SPAPR_COMPAT_2_11 \
> +HW_COMPAT_2_10\
> +{ \
> +.driver = "vfio-pci", \
> +.property = "msix-no-mmap",   \
> +.value= "on", \
> +},\
> +
>  static void spapr_machine_2_11_instance_options(MachineState *machine)
>  {
>  }
>  
>  static void spapr_machine_2_11_class_options(MachineClass *mc)
>  {
> -/* Defaults for the latest behaviour inherited from the base class */
> +SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11);
>  }
>  
>  DEFINE_SPAPR_MACHINE(2_11, "2.11", true);
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index ed7717d..593514c 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1408,6 +1408,21 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, 
> uint32_t type,
>  return -ENODEV;
>  }
>  
> +bool vfio_is_cap_present(VFIODevice *vbasedev, uint16_t cap_type, int region)
> +{
> +struct 

[Qemu-devel] [PATCH qemu v2] kvm: Add kvm_set_user_memory tracepoint

2017-12-14 Thread Alexey Kardashevskiy
This adds a tracepoint to trace the KVM_SET_USER_MEMORY_REGION ioctl
parameters which is quite useful for debugging VFIO memory regions
being actually registered with KVM.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v2:
* added forgotten change to trace-events
---
 accel/kvm/kvm-all.c| 6 +-
 accel/kvm/trace-events | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f290f48..b91fcb7 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -235,6 +235,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener 
*kml, KVMSlot *slot)
 {
 KVMState *s = kvm_state;
 struct kvm_userspace_memory_region mem;
+int ret;
 
 mem.slot = slot->slot | (kml->as_id << 16);
 mem.guest_phys_addr = slot->start_addr;
@@ -248,7 +249,10 @@ static int kvm_set_user_memory_region(KVMMemoryListener 
*kml, KVMSlot *slot)
 kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, );
 }
 mem.memory_size = slot->memory_size;
-return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, );
+ret = kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, );
+trace_kvm_set_user_memory(mem.slot, mem.flags, mem.guest_phys_addr,
+  mem.memory_size, mem.userspace_addr, ret);
+return ret;
 }
 
 int kvm_destroy_vcpu(CPUState *cpu)
diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events
index f89ba55..58e98ef 100644
--- a/accel/kvm/trace-events
+++ b/accel/kvm/trace-events
@@ -12,4 +12,5 @@ kvm_irqchip_commit_routes(void) ""
 kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d 
virq %d"
 kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d"
 kvm_irqchip_release_virq(int virq) "virq %d"
+kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_addr, 
uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags=0x%x 
gpa=0x%"PRIx64 " size=0x%"PRIx64 " ua=0x%"PRIx64 " ret=%d"
 
-- 
2.11.0




Re: [Qemu-devel] [PATCH v4 00/43] remove i386/pc dependency from non-PC world (part 1)

2017-12-14 Thread no-reply
Hi,

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

Subject: [Qemu-devel] [PATCH v4 00/43] remove i386/pc dependency from non-PC 
world (part 1)
Type: series
Message-id: 20171215033015.738-1-f4...@amsat.org

=== 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 ==="
INSTALL=$PWD/install
BUILD=$PWD/build
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --prefix=$INSTALL
make -j100
# XXX: we need reliable clean up
# make check -j100 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  patchew/20171215031547.31006-1-f4...@amsat.org -> 
patchew/20171215031547.31006-1-f4...@amsat.org
 * [new tag] patchew/20171215033015.738-1-f4...@amsat.org -> 
patchew/20171215033015.738-1-f4...@amsat.org
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Submodule 'pixman' (git://anongit.freedesktop.org/pixman) registered for path 
'pixman'
Submodule 'roms/SLOF' (git://git.qemu-project.org/SLOF.git) registered for path 
'roms/SLOF'
Submodule 'roms/ipxe' (git://git.qemu-project.org/ipxe.git) registered for path 
'roms/ipxe'
Submodule 'roms/openbios' (git://git.qemu-project.org/openbios.git) registered 
for path 'roms/openbios'
Submodule 'roms/openhackware' (git://git.qemu-project.org/openhackware.git) 
registered for path 'roms/openhackware'
Submodule 'roms/qemu-palcode' (git://github.com/rth7680/qemu-palcode.git) 
registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (git://git.qemu-project.org/seabios.git/) registered 
for path 'roms/seabios'
Submodule 'roms/sgabios' (git://git.qemu-project.org/sgabios.git) registered 
for path 'roms/sgabios'
Submodule 'roms/u-boot' (git://git.qemu-project.org/u-boot.git) registered for 
path 'roms/u-boot'
Submodule 'roms/vgabios' (git://git.qemu-project.org/vgabios.git/) registered 
for path 'roms/vgabios'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf'
Cloning into 'pixman'...
Submodule path 'pixman': checked out '87eea99e443b389c978cf37efc52788bf03a0ee0'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 
'e3d05727a074619fc12d0a67f05cf2c42c875cce'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 
'04186319181298083ef28695a8309028b26fe83c'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 
'e79bca64838c96ec44fd7acd508879c5284233dd'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 
'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 
'c87a92639b28ac42bc8f6c67443543b405dc479b'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 
'e2fc41e24ee0ada60fc511d60b15a41b294538be'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 
'23d474943dcd55d0550a3d20b3d30e9040a4f15b'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 
'2072e7262965bb48d7fffb1e283101e6ed8b21a8'
Cloning into 'roms/vgabios'...
Submodule path 'roms/vgabios': checked out 
'19ea12c230ded95928ecaef0db47a82231c2e485'
warning: unable to rmdir pixman: Directory not empty
Switched to a new branch 'test'
M   dtc
M   roms/SLOF
M   roms/ipxe
M   roms/openbios
M   roms/qemu-palcode
M   roms/seabios
M   roms/sgabios
M   roms/u-boot
6a29db1 misc: drop old i386 dependency
35444d6 hw/i386/vmport: replace fprintf() by trace events
e65fbcc i386/pc: move vmmouse.c to hw/i386/
493c91e i386/pc: move vmport.c to hw/i386/
25bfbe5 hw/misc/pvpanic: extract public API from i386/pc to "hw/misc/pvpanic.h"
c823bc5 hw/net/ne2000: extract ne2k-isa code from i386/pc to ne2000-isa.c
df0727a hw/display/vga: extract public API from i386/pc to "hw/display/vga.h"
7fc9e96 hw/display/vga: "vga_int.h" requires "ui/console.h"
3056602 hw/display/vga: "vga.h" only contains registers defs, rename it 
"vga_regs.h"
c5a7978 hw/acpi/ich9: extract ACPI_PM_PROP_TCO_ENABLED from i386/pc
e7927f7 hw/acpi: ACPI_PM_* defines are not restricted to i386 arch
3330abb hw/timer/mc146818: rename rtc_init() -> mc146818_rtc_init()
2b81d31 hw/timer/i8254: rename pit_init() -> i8254_pit_init()
18f1373 hw/unicore32: restrict hw addr defines to source file
15669da hw/virtio-balloon: remove old i386 dependency
b9991ae hw/tpm: remove old i386 dependency
4aeb5ab hw/i2c: remove old i386 dependency
5a5656c hw/ipmi: remove old i386 dependency
d21d4b3 hw/ide: remove old i386 dependency
9015c6c misc: remove old i386 dependency
1fc8b51 amd_iommu: avoid needless includes in header file
947e55d hw/ssi/aspeed_smc: remove unused #include
1e8a047 hw/misc/pvpanic: remove unused #include
1d64a75 

Re: [Qemu-devel] [PATCH 0/2] vhost: two fixes

2017-12-14 Thread Zhoujian (jay)
Hi Michael,

> -Original Message-
> From: Michael S. Tsirkin [mailto:m...@redhat.com]
> Sent: Friday, December 15, 2017 12:36 PM
> To: Zhoujian (jay) 
> Cc: Dr. David Alan Gilbert ; qemu-devel@nongnu.org;
> Huangweidong (C) ; Gonglei (Arei)
> ; wangxin (U) ;
> Liuzhe (Cloud Open Labs, NFV) ; Igor Mammedov
> 
> Subject: Re: [PATCH 0/2] vhost: two fixes
> 
> On Fri, Dec 15, 2017 at 02:38:35AM +, Zhoujian (jay) wrote:
> > Hi Dave,
> >
> > > -Original Message-
> > > From: Dr. David Alan Gilbert [mailto:dgilb...@redhat.com]
> > > Sent: Friday, December 15, 2017 3:49 AM
> > > To: Michael S. Tsirkin 
> > > Cc: Zhoujian (jay) ; qemu-devel@nongnu.org;
> > > Huangweidong (C) ; Gonglei (Arei)
> > > ; wangxin (U) ;
> > > Liuzhe (Cloud Open Labs, NFV) ; Igor
> > > Mammedov 
> > > Subject: Re: [PATCH 0/2] vhost: two fixes
> > >
> > > * Michael S. Tsirkin (m...@redhat.com) wrote:
> > > > On Fri, Dec 15, 2017 at 12:36:30AM +0800, Jay Zhou wrote:
> > > > > Jay Zhou (2):
> > > > >   vhost: add used memslot number for vhost-user
> > > > >   vhost: double check memslot number
> > > > >
> > > > >  hw/virtio/vhost-user.c| 31 +
> > > > >  hw/virtio/vhost.c | 49
> > > ++-
> > > > >  include/hw/virtio/vhost-backend.h |  4 
> > > > >  3 files changed, 78 insertions(+), 6 deletions(-)
> > > >
> > > > Cc two developers working on these files right now.
> > >
> > > I have to admit to not understanding the 'used_memslots' variable.
> > >
> > > * It's a global in vhost.c
> > > * but set by vhost_set_memory that's called from the listener
> associated
> > >   with each individual vhost
> > > * While they're probably always the same, the merging code calls
> > >   the vhost_backend_can_merge method for each device, so the number
> > >   of regions can be different.
> > >
> >
> > Your mean for some devices the new added MemoryRegionSection can be
> > merged, but for others it can not be merged? IIUC the vhost_mem for
> > each vhost_dev is the same.
> >
> > Meanwhile, I think it is more reasonable to add globals in
> > vhost-backend.c and vhost-user.c respectively instead of
> > 'used_memslots'. The reason is explained in patch 1. What do you think?
> >
> > Regards,
> > Jay
> 
> I'd rather avoid globals completely if possible.
> 

It is possible, we could add a 'used_memslots' variable in struct vhost_dev
for per device. I will try to do it in v2.

Regards,
Jay



Re: [Qemu-devel] [PATCH qemu v2] machine: Polish -machine xxx,help

2017-12-14 Thread Alexey Kardashevskiy
On 26/10/17 12:41, Alexey Kardashevskiy wrote:
> The "-machine xxx,help" prints kernel-irqchip possible values as
> "OnOffSplit", this adds separators to the printed line.
> 
> Also, since only lower case letters are specified in qapi/common.json,
> this changes the letter cases too.
> 
> Signed-off-by: Alexey Kardashevskiy 

ping?


> ---
> 
> aik@fstn1-p1:~$ ./qemu-system-ppc64 -machine pseries,help 2>&1 | grep 
> kernel-irqchip
> 
> Was:
> pseries-2.11.kernel-irqchip=OnOffSplit (Configure KVM in-kernel irqchip)
> 
> Now:
> pseries-2.11.kernel-irqchip=on|off|split (Configure KVM in-kernel irqchip)
> ---
>  hw/core/machine.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 36c2fb069c..bd3db14e12 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -506,7 +506,7 @@ static void machine_class_init(ObjectClass *oc, void 
> *data)
>  object_class_property_set_description(oc, "accel",
>  "Accelerator list", _abort);
>  
> -object_class_property_add(oc, "kernel-irqchip", "OnOffSplit",
> +object_class_property_add(oc, "kernel-irqchip", "on|off|split",
>  NULL, machine_set_kernel_irqchip,
>  NULL, NULL, _abort);
>  object_class_property_set_description(oc, "kernel-irqchip",
> 


-- 
Alexey



Re: [Qemu-devel] [PATCH 06/14] sdhci: refactor same sysbus/pci properties into a common one

2017-12-14 Thread Kevin O'Connor
On Thu, Dec 14, 2017 at 03:40:17PM -0300, Philippe Mathieu-Daudé wrote:
> >>  /* Capabilities registers provide information on supported features of 
> >> this
> >>   * specific host controller implementation */
> >> -static Property sdhci_pci_properties[] = {
> >> +static Property sdhci_properties[] = {
> >>  DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
> >>  SDHC_CAPAB_REG_DEFAULT),
> >>  DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
> >> +DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, 
> >> pending_insert_quirk,
> >> + false),
> >
> > I like the reduction of code in this patch, but aren't we now going to
> > have device properties that aren't actually connected to anything?
> 
> I'm not sure I understand, ar you worried about the PCI_SDHCI will now
> have this property but not use it?
> 
> I couldn't find any machine using SDHCI via PCI and was tempted to
> just remove this code,

I'm not sure if you are suggesting the removal of PCI SDHCI support or
removal of some of the properties.

I do find qemu's PCI SDHCI support useful for testing.  SeaBIOS can
launch an OS from PCI SDHCI (qemu-system-x86_64 -device sdhci-pci
-device sd-card,drive=drive0 -drive id=drive0,if=none,file=dos-drivec)
and linux has drivers for it as well.  A number of the Chromebooks
ship with PCI SDHCI devices on them, so it's not an unheard of
configuration.

I've never manually set any of the PCI properites, however.

-Kevin



Re: [Qemu-devel] [PATCH 0/2] vhost: two fixes

2017-12-14 Thread Michael S. Tsirkin
On Fri, Dec 15, 2017 at 02:38:35AM +, Zhoujian (jay) wrote:
> Hi Dave,
> 
> > -Original Message-
> > From: Dr. David Alan Gilbert [mailto:dgilb...@redhat.com]
> > Sent: Friday, December 15, 2017 3:49 AM
> > To: Michael S. Tsirkin 
> > Cc: Zhoujian (jay) ; qemu-devel@nongnu.org;
> > Huangweidong (C) ; Gonglei (Arei)
> > ; wangxin (U) ;
> > Liuzhe (Cloud Open Labs, NFV) ; Igor Mammedov
> > 
> > Subject: Re: [PATCH 0/2] vhost: two fixes
> > 
> > * Michael S. Tsirkin (m...@redhat.com) wrote:
> > > On Fri, Dec 15, 2017 at 12:36:30AM +0800, Jay Zhou wrote:
> > > > Jay Zhou (2):
> > > >   vhost: add used memslot number for vhost-user
> > > >   vhost: double check memslot number
> > > >
> > > >  hw/virtio/vhost-user.c| 31 +
> > > >  hw/virtio/vhost.c | 49
> > ++-
> > > >  include/hw/virtio/vhost-backend.h |  4 
> > > >  3 files changed, 78 insertions(+), 6 deletions(-)
> > >
> > > Cc two developers working on these files right now.
> > 
> > I have to admit to not understanding the 'used_memslots' variable.
> > 
> > * It's a global in vhost.c
> > * but set by vhost_set_memory that's called from the listener associated
> >   with each individual vhost
> > * While they're probably always the same, the merging code calls
> >   the vhost_backend_can_merge method for each device, so the number
> >   of regions can be different.
> > 
> 
> Your mean for some devices the new added MemoryRegionSection can be merged,
> but for others it can not be merged? IIUC the vhost_mem for each vhost_dev
> is the same.
> 
> Meanwhile, I think it is more reasonable to add globals in vhost-backend.c
> and vhost-user.c respectively instead of 'used_memslots'. The reason
> is explained in patch 1. What do you think?
> 
> Regards,
> Jay

I'd rather avoid globals completely if possible.

-- 
MST



[Qemu-devel] [Bug 1701808] Re: stack smashing in or after recvmsg system call in aarch64 user mode

2017-12-14 Thread Bruno Haible
The behaviour in qemu-2.11 is the same as in qemu-2.9.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1701808

Title:
  stack smashing in or after recvmsg system call in aarch64 user mode

Status in QEMU:
  New

Bug description:
  A program that invokes recvmsg aborts with "*** stack smashing
  detected ***" when run in qemu-aarch64 (user mode), but works fine
  when running on native aarch64 hardware.

  How to reproduce:
  $ aarch64-linux-gnu-gcc-5 -O -Wall 
/media/develdata/devel/qemu-bug/testpassfd.c -static -DEXTRA_SPACE=0
  $ QEMU_LD_PREFIX=/usr/aarch64-linux-gnu ~/inst-qemu/2.9.0/bin/qemu-aarch64 
./a.out
  *** stack smashing detected ***: ./a.out terminated
  qemu: uncaught target signal 6 (Aborted) - core dumped

  On native aarch64 hardware:
  $ ./a.out 
  $ echo $?
  0

  The parameter EXTRA_SPACE can be used to add additional space to the
  array that receives the recvmsg data. With -DEXTRA_SPACE=9 (or
  larger), the program runs fine. Which suggests that recvmsg is storing
  up to 9 bytes more than allowed in memory.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1701808/+subscriptions



[Qemu-devel] [PATCH v5 2/2] misc: drop old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/char/debugcon.c  | 1 -
 hw/intc/lm32_pic.c  | 1 -
 hw/moxie/moxiesim.c | 1 -
 hw/sparc/sun4m.c| 1 -
 hw/watchdog/wdt_ib700.c | 1 -
 5 files changed, 5 deletions(-)

diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
index 95ccec6f8b..e2abc61b04 100644
--- a/hw/char/debugcon.c
+++ b/hw/char/debugcon.c
@@ -29,7 +29,6 @@
 #include "hw/hw.h"
 #include "chardev/char-fe.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
 #define ISA_DEBUGCON_DEVICE(obj) \
diff --git a/hw/intc/lm32_pic.c b/hw/intc/lm32_pic.c
index 09e15115fb..db6c7afc2f 100644
--- a/hw/intc/lm32_pic.c
+++ b/hw/intc/lm32_pic.c
@@ -20,7 +20,6 @@
 #include "qemu/osdep.h"
 
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "monitor/monitor.h"
 #include "hw/sysbus.h"
 #include "trace.h"
diff --git a/hw/moxie/moxiesim.c b/hw/moxie/moxiesim.c
index 3ba58481d0..3c3ba9d8c5 100644
--- a/hw/moxie/moxiesim.c
+++ b/hw/moxie/moxiesim.c
@@ -30,7 +30,6 @@
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 24c2b8a555..e71648404c 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -36,7 +36,6 @@
 #include "net/net.h"
 #include "hw/boards.h"
 #include "hw/scsi/esp.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "hw/nvram/sun_nvram.h"
 #include "hw/nvram/chrp_nvram.h"
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
index 532afe89e7..d045032bf4 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -25,7 +25,6 @@
 #include "sysemu/watchdog.h"
 #include "hw/hw.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 /*#define IB700_DEBUG 1*/
 
-- 
2.15.1




[Qemu-devel] [PATCH v5 0/2] remove i386/pc dependency from non-PC world (part 1) fix

2017-12-14 Thread Philippe Mathieu-Daudé
Fix patch 42 from previous series (v4) so patchew can build, and if a maintainer
is willing to take the previous series with the last 2 patches, I don't need to
respam a v6.

Regards,

Phil.

Based-on: 20171215033015.738-42-f4...@amsat.org
  (remove i386/pc dependency from non-PC world v4)

Philippe Mathieu-Daudé (2):
  hw/i386/vmport: replace fprintf() by trace events
  misc: drop old i386 dependency

 hw/char/debugcon.c  | 1 -
 hw/i386/vmport.c| 8 +++-
 hw/intc/lm32_pic.c  | 1 -
 hw/moxie/moxiesim.c | 1 -
 hw/sparc/sun4m.c| 1 -
 hw/watchdog/wdt_ib700.c | 1 -
 hw/i386/trace-events| 4 
 7 files changed, 7 insertions(+), 10 deletions(-)

-- 
2.15.1




Re: [Qemu-devel] [PATCH v4 42/43] hw/i386/vmport: replace fprintf() by trace events

2017-12-14 Thread Philippe Mathieu-Daudé
Oops I sent the wrong file :(

On Fri, Dec 15, 2017 at 12:30 AM, Philippe Mathieu-Daudé
 wrote:
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/i386/vmport.c | 8 +++-
>  hw/i386/trace-events | 4 
>  2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
> index eb880c6def..b5585a009a 100644
> --- a/hw/i386/vmport.c
> +++ b/hw/i386/vmport.c
> @@ -27,8 +27,7 @@
>  #include "hw/i386/pc.h"
>  #include "sysemu/hw_accel.h"
>  #include "hw/qdev.h"
> -
> -/* #define VMPORT_DEBUG */
> +#include "trace.h"
>
>  #define VMPORT_CMD_GETVERSION 0x0a
>  #define VMPORT_CMD_GETRAMSIZE 0x14
> @@ -54,6 +53,7 @@ void vmport_register(unsigned char command, VMPortReadFunc 
> *func, void *opaque)
>  return;
>  }
>
> +trace_vmport_register(command, func, opaque);
>  port_state->func[command] = func;
>  port_state->opaque[command] = opaque;
>  }
> @@ -80,9 +80,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr 
> addr,
>  return eax;
>  }
>  if (!s->func[command]) {
> -#ifdef VMPORT_DEBUG
> -fprintf(stderr, "vmport: unknown command %x\n", command);
> -#endif
> +trace_vmport_ioport_read_unknown_command(command, addr);
>  return eax;
>  }
>
> diff --git a/hw/i386/trace-events b/hw/i386/trace-events
> index d43b4b6cd3..f0522ea5e5 100644
> --- a/hw/i386/trace-events
> +++ b/hw/i386/trace-events
> @@ -113,3 +113,7 @@ amdvi_mode_invalid(uint8_t level, uint64_t addr)"error: 
> translation level 0x%"PR
>  amdvi_page_fault(uint64_t addr) "error: page fault accessing guest physical 
> address 0x%"PRIx64
>  amdvi_iotlb_hit(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, 
> uint64_t txaddr) "hit iotlb devid %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
>  amdvi_translation_result(uint8_t bus, uint8_t slot, uint8_t func, uint64_t 
> addr, uint64_t txaddr) "devid: %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
> +
> +# hw/i386/vmport.c
> +vmport_register(unsigned char command, void *func, void *opaque) "command: 
> 0x%02x func: %p opaque: %p"
> +vmport_ioport_read_unknown_command(unsigned char command, hwaddr addr) 
> "unknown command: 0x%02x addr: 0x" HWADDR_PRIx

a '%' is missing here: 0x%" HWADDR_PRIx

-vmport_ioport_read_unknown_command(unsigned char command, hwaddr
addr) "unknown command: 0x%02x addr: 0x" HWADDR_PRIx
+vmport_ioport_read_unknown_command(unsigned char command, hwaddr
addr) "unknown command: 0x%02x addr: 0x%" HWADDR_PRIx

> --
> 2.15.1
>



[Qemu-devel] [PATCH v4 41/43] i386/pc: move vmmouse.c to hw/i386/

2017-12-14 Thread Philippe Mathieu-Daudé
It's a x86-only device, so it does not make sense to keep it
in the shared misc folder.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/{input => i386}/vmmouse.c | 0
 hw/i386/Makefile.objs| 1 +
 hw/input/Makefile.objs   | 1 -
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename hw/{input => i386}/vmmouse.c (100%)

diff --git a/hw/input/vmmouse.c b/hw/i386/vmmouse.c
similarity index 100%
rename from hw/input/vmmouse.c
rename to hw/i386/vmmouse.c
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 1548ad1ad0..fd279e7584 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -6,6 +6,7 @@ obj-y += x86-iommu.o intel_iommu.o
 obj-y += amd_iommu.o
 obj-$(CONFIG_XEN) += ../xenpv/ xen/
 obj-$(CONFIG_VMPORT) += vmport.o
+obj-$(CONFIG_VMMOUSE) += vmmouse.o
 
 obj-y += kvmvapic.o
 obj-y += acpi-build.o
diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
index 7715d7230d..636f794b6b 100644
--- a/hw/input/Makefile.objs
+++ b/hw/input/Makefile.objs
@@ -6,7 +6,6 @@ common-obj-$(CONFIG_PL050) += pl050.o
 common-obj-y += ps2.o
 common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
 common-obj-$(CONFIG_TSC2005) += tsc2005.o
-common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
 
 common-obj-$(CONFIG_VIRTIO) += virtio-input.o
 common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o
-- 
2.15.1




[Qemu-devel] [PATCH v4 39/43] hw/misc/pvpanic: extract public API from i386/pc to "hw/misc/pvpanic.h"

2017-12-14 Thread Philippe Mathieu-Daudé
and remove the old i386/pc dependency.

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/i386/pc.h  |  3 ---
 include/hw/misc/pvpanic.h | 21 +
 hw/i386/acpi-build.c  |  2 +-
 hw/misc/pvpanic.c |  9 -
 4 files changed, 26 insertions(+), 9 deletions(-)
 create mode 100644 include/hw/misc/pvpanic.h

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ab84e31cce..6f77eb0665 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -306,9 +306,6 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 void pc_system_firmware_init(MemoryRegion *rom_memory,
  bool isapc_ram_fw);
 
-/* pvpanic.c */
-uint16_t pvpanic_port(void);
-
 /* acpi-build.c */
 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
const CPUArchIdList *apic_ids, GArray *entry);
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
new file mode 100644
index 00..36a54e270c
--- /dev/null
+++ b/include/hw/misc/pvpanic.h
@@ -0,0 +1,21 @@
+/*
+ * QEMU simulated pvpanic device.
+ *
+ * Copyright Fujitsu, Corp. 2013
+ *
+ * Authors:
+ * Wen Congyang 
+ * Hu Tao 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#ifndef HW_MISC_PVPANIC_H
+#define HW_MISC_PVPANIC_H
+
+#define TYPE_PVPANIC "pvpanic"
+
+uint16_t pvpanic_port(void);
+
+#endif
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 73519ab3ac..63bbc610eb 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -28,8 +28,8 @@
 #include "qemu/error-report.h"
 #include "hw/pci/pci.h"
 #include "qom/cpu.h"
-#include "hw/i386/pc.h"
 #include "target/i386/cpu.h"
+#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 3a0e4ba828..b26250dec9 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -17,7 +17,7 @@
 #include "qemu/log.h"
 
 #include "hw/nvram/fw_cfg.h"
-#include "hw/i386/pc.h"
+#include "hw/misc/pvpanic.h"
 
 /* The bit of supported pv event */
 #define PVPANIC_F_PANICKED  0
@@ -25,9 +25,8 @@
 /* The pv event value */
 #define PVPANIC_PANICKED(1 << PVPANIC_F_PANICKED)
 
-#define TYPE_ISA_PVPANIC_DEVICE"pvpanic"
 #define ISA_PVPANIC_DEVICE(obj)\
-OBJECT_CHECK(PVPanicState, (obj), TYPE_ISA_PVPANIC_DEVICE)
+OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC)
 
 static void handle_event(int event)
 {
@@ -104,7 +103,7 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error 
**errp)
 
 uint16_t pvpanic_port(void)
 {
-Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL);
+Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
 if (!o) {
 return 0;
 }
@@ -126,7 +125,7 @@ static void pvpanic_isa_class_init(ObjectClass *klass, void 
*data)
 }
 
 static TypeInfo pvpanic_isa_info = {
-.name  = TYPE_ISA_PVPANIC_DEVICE,
+.name  = TYPE_PVPANIC,
 .parent= TYPE_ISA_DEVICE,
 .instance_size = sizeof(PVPanicState),
 .instance_init = pvpanic_isa_initfn,
-- 
2.15.1




[Qemu-devel] [PATCH v4 38/43] hw/net/ne2000: extract ne2k-isa code from i386/pc to ne2000-isa.c

2017-12-14 Thread Philippe Mathieu-Daudé
- add "hw/net/ne2000-isa.h"
- remove the old i386 dependency

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
Acked-by: David Gibson  [PPC]
---
 hw/net/ne2000.h |  3 +++
 include/hw/i386/pc.h| 20 
 include/hw/net/ne2000-isa.h | 33 +
 hw/i386/pc.c|  1 +
 hw/mips/mips_r4k.c  |  1 +
 hw/net/ne2000-isa.c |  6 ++
 hw/net/ne2000.c |  2 --
 hw/ppc/prep.c   |  1 +
 8 files changed, 41 insertions(+), 26 deletions(-)
 create mode 100644 include/hw/net/ne2000-isa.h

diff --git a/hw/net/ne2000.h b/hw/net/ne2000.h
index d213dccae3..adb8021bd1 100644
--- a/hw/net/ne2000.h
+++ b/hw/net/ne2000.h
@@ -1,6 +1,9 @@
 #ifndef HW_NE2000_H
 #define HW_NE2000_H
 
+#include "hw/hw.h"
+#include "net/net.h"
+
 #define NE2000_PMEM_SIZE(32*1024)
 #define NE2000_PMEM_START   (16*1024)
 #define NE2000_PMEM_END (NE2000_PMEM_SIZE+NE2000_PMEM_START)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1d55ba3322..ab84e31cce 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -302,26 +302,6 @@ PCIBus *find_i440fx(void);
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 
-/* ne2000.c */
-static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
-{
-DeviceState *dev;
-ISADevice *isadev;
-
-qemu_check_nic_model(nd, "ne2k_isa");
-
-isadev = isa_try_create(bus, "ne2k_isa");
-if (!isadev) {
-return false;
-}
-dev = DEVICE(isadev);
-qdev_prop_set_uint32(dev, "iobase", base);
-qdev_prop_set_uint32(dev, "irq",irq);
-qdev_set_nic_properties(dev, nd);
-qdev_init_nofail(dev);
-return true;
-}
-
 /* pc_sysfw.c */
 void pc_system_firmware_init(MemoryRegion *rom_memory,
  bool isapc_ram_fw);
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
new file mode 100644
index 00..ff2bed9c95
--- /dev/null
+++ b/include/hw/net/ne2000-isa.h
@@ -0,0 +1,33 @@
+/*
+ * QEMU NE2000 emulation -- isa bus windup
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/hw.h"
+#include "hw/qdev.h"
+#include "hw/isa/isa.h"
+#include "net/net.h"
+
+#define TYPE_ISA_NE2000 "ne2k_isa"
+
+static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq,
+ NICInfo *nd)
+{
+ISADevice *d;
+
+qemu_check_nic_model(nd, "ne2k_isa");
+
+d = isa_try_create(bus, TYPE_ISA_NE2000);
+if (d) {
+DeviceState *dev = DEVICE(d);
+
+qdev_prop_set_uint32(dev, "iobase", base);
+qdev_prop_set_uint32(dev, "irq",irq);
+qdev_set_nic_properties(dev, nd);
+qdev_init_nofail(dev);
+}
+return d;
+}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index fe5e8b53bb..3fcf318a95 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -69,6 +69,7 @@
 #include "qom/cpu.h"
 #include "hw/nmi.h"
 #include "hw/i386/intel_iommu.h"
+#include "hw/net/ne2000-isa.h"
 
 /* debug PC/ISA interrupts */
 //#define DEBUG_IRQ
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 9884ee7e9f..244bd41813 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -18,6 +18,7 @@
 #include "hw/char/serial.h"
 #include "hw/isa/isa.h"
 #include "net/net.h"
+#include "hw/net/ne2000-isa.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
 #include "hw/block/flash.h"
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index f3455339ee..70e5c1d3d4 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -22,17 +22,15 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
+#include "hw/net/ne2000-isa.h"
 #include "hw/qdev.h"
-#include "net/net.h"
 #include "ne2000.h"
+#include "sysemu/sysemu.h"
 #include "exec/address-spaces.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 
-#define TYPE_ISA_NE2000 "ne2k_isa"
 #define ISA_NE2000(obj) OBJECT_CHECK(ISANE2000State, (obj), TYPE_ISA_NE2000)
 
 typedef struct ISANE2000State {
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 3938e6ddd8..6874c8c6b9 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -22,9 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "hw/hw.h"
 #include "hw/pci/pci.h"
-#include "net/net.h"
 #include "ne2000.h"
 #include "hw/loader.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 6f8accc397..af08ac319a 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -42,6 +42,7 @@
 #include "hw/loader.h"
 #include "hw/timer/mc146818rtc.h"
 #include "hw/isa/pc87312.h"
+#include "hw/net/ne2000-isa.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/arch_init.h"
 #include "sysemu/kvm.h"
-- 

[Qemu-devel] [PATCH v4 36/43] hw/display/vga: "vga_int.h" requires "ui/console.h"

2017-12-14 Thread Philippe Mathieu-Daudé
since The VGACommonState struct has a GraphicHwOps *hw_ops member,
then remove the now unnecessary includes.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/display/qxl.h| 1 -
 hw/display/vga_int.h| 3 ++-
 hw/display/cirrus_vga.c | 1 -
 hw/display/vga-isa-mm.c | 1 -
 hw/display/vga-isa.c| 1 -
 hw/display/vga-pci.c| 1 -
 hw/display/vga.c| 1 -
 hw/display/virtio-vga.c | 1 -
 hw/display/vmware_vga.c | 1 -
 9 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index f6556adb73..8668a8e05a 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -3,7 +3,6 @@
 
 #include "qemu-common.h"
 
-#include "ui/console.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "vga_int.h"
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index ad34a1f048..fe23b81442 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -25,8 +25,9 @@
 #ifndef HW_VGA_INT_H
 #define HW_VGA_INT_H
 
-#include "hw/hw.h"
+#include "exec/ioport.h"
 #include "exec/memory.h"
+#include "ui/console.h"
 
 #define ST01_V_RETRACE  0x08
 #define ST01_DISP_ENABLE0x01
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index bc32bf1e39..138ae961b9 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -31,7 +31,6 @@
 #include "trace.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
-#include "ui/console.h"
 #include "ui/pixel_ops.h"
 #include "vga_int.h"
 #include "hw/loader.h"
diff --git a/hw/display/vga-isa-mm.c b/hw/display/vga-isa-mm.c
index 51ccbccc41..68c4d6e23e 100644
--- a/hw/display/vga-isa-mm.c
+++ b/hw/display/vga-isa-mm.c
@@ -23,7 +23,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "ui/console.h"
 #include "hw/i386/pc.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
index 1af95562f2..26f69fd40a 100644
--- a/hw/display/vga-isa.c
+++ b/hw/display/vga-isa.c
@@ -25,7 +25,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "ui/console.h"
 #include "hw/i386/pc.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 7adb89fcb4..1674bd3581 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -25,7 +25,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "ui/console.h"
 #include "hw/pci/pci.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
diff --git a/hw/display/vga.c b/hw/display/vga.c
index ce95b40e5c..4163b532e0 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "ui/console.h"
 #include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "vga_int.h"
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index f9b017d86b..baa74ba82c 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -1,7 +1,6 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
-#include "ui/console.h"
 #include "vga_int.h"
 #include "hw/virtio/virtio-pci.h"
 #include "qapi/error.h"
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 0e6673a911..bd3e8b3586 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -26,7 +26,6 @@
 #include "hw/hw.h"
 #include "hw/loader.h"
 #include "trace.h"
-#include "ui/console.h"
 #include "ui/vnc.h"
 #include "hw/pci/pci.h"
 
-- 
2.15.1




[Qemu-devel] [PATCH v4 35/43] hw/display/vga: "vga.h" only contains registers defs, rename it "vga_regs.h"

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/display/{vga.h => vga_regs.h} | 0
 hw/display/vga.c | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename hw/display/{vga.h => vga_regs.h} (100%)

diff --git a/hw/display/vga.h b/hw/display/vga_regs.h
similarity index 100%
rename from hw/display/vga.h
rename to hw/display/vga_regs.h
diff --git a/hw/display/vga.c b/hw/display/vga.c
index a64a0942da..ce95b40e5c 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -24,11 +24,11 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "vga.h"
 #include "ui/console.h"
 #include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "vga_int.h"
+#include "vga_regs.h"
 #include "ui/pixel_ops.h"
 #include "qemu/timer.h"
 #include "hw/xen/xen.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 32/43] hw/timer/mc146818: rename rtc_init() -> mc146818_rtc_init()

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
Reviewed-by: David Gibson 
---
 include/hw/timer/mc146818rtc.h | 3 ++-
 hw/alpha/dp264.c   | 2 +-
 hw/i386/pc.c   | 2 +-
 hw/isa/i82378.c| 3 ++-
 hw/mips/mips_fulong2e.c| 2 +-
 hw/mips/mips_jazz.c| 2 +-
 hw/mips/mips_malta.c   | 2 +-
 hw/mips/mips_r4k.c | 2 +-
 hw/ppc/pnv.c   | 2 +-
 hw/timer/mc146818rtc.c | 2 +-
 10 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/hw/timer/mc146818rtc.h b/include/hw/timer/mc146818rtc.h
index 7c8e64b203..fe6ed63f71 100644
--- a/include/hw/timer/mc146818rtc.h
+++ b/include/hw/timer/mc146818rtc.h
@@ -6,7 +6,8 @@
 
 #define TYPE_MC146818_RTC "mc146818rtc"
 
-ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq);
+ISADevice *mc146818_rtc_init(ISABus *bus, int base_year,
+ qemu_irq intercept_irq);
 void rtc_set_memory(ISADevice *dev, int addr, int val);
 int rtc_get_memory(ISADevice *dev, int addr);
 
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 887a7401f1..766373eec7 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -78,7 +78,7 @@ static void clipper_init(MachineState *machine)
clipper_pci_map_irq);
 
 /* Since we have an SRM-compatible PALcode, use the SRM epoch.  */
-rtc_init(isa_bus, 1900, rtc_irq);
+mc146818_rtc_init(isa_bus, 1900, rtc_irq);
 
 i8254_pit_init(isa_bus, 0x40, 0, NULL);
 isa_create_simple(isa_bus, "i8042");
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6a6041573f..fe5e8b53bb 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1565,7 +1565,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
 rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
 }
 }
-*rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
+*rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq);
 
 qemu_register_boot_set(pc_boot_set, *rtc_state);
 
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index a9c15f858d..a5d67bc6d7 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -21,6 +21,7 @@
 #include "hw/pci/pci.h"
 #include "hw/i386/pc.h"
 #include "hw/timer/i8254.h"
+#include "hw/timer/mc146818rtc.h"
 #include "hw/audio/pcspk.h"
 
 #define TYPE_I82378 "i82378"
@@ -106,7 +107,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
 isa = isa_create_simple(isabus, "i82374");
 
 /* timer */
-isa_create_simple(isabus, "mc146818rtc");
+isa_create_simple(isabus, TYPE_MC146818_RTC);
 }
 
 static void i82378_init(Object *obj)
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 2a2a09c9de..725e25a134 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -365,7 +365,7 @@ static void mips_fulong2e_init(MachineState *machine)
 /* Super I/O */
 isa_create_simple(isa_bus, "i8042");
 
-rtc_init(isa_bus, 2000, NULL);
+mc146818_rtc_init(isa_bus, 2000, NULL);
 
 serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
 parallel_hds_isa_init(isa_bus, 1);
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 995419344d..22a3d5169c 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -288,7 +288,7 @@ static void mips_jazz_init(MachineState *machine,
 fdctrl_init_sysbus(qdev_get_gpio_in(rc4030, 1), -1, 0x80003000, fds);
 
 /* Real time clock */
-rtc_init(isa_bus, 1980, NULL);
+mc146818_rtc_init(isa_bus, 1980, NULL);
 memory_region_init_io(rtc, NULL, _ops, NULL, "rtc", 0x1000);
 memory_region_add_subregion(address_space, 0x80004000, rtc);
 
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 88b4733743..37f19428d6 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1214,7 +1214,7 @@ void mips_malta_init(MachineState *machine)
 /* Super I/O */
 isa_create_simple(isa_bus, "i8042");
 
-rtc_init(isa_bus, 2000, NULL);
+mc146818_rtc_init(isa_bus, 2000, NULL);
 serial_hds_isa_init(isa_bus, 0, 2);
 parallel_hds_isa_init(isa_bus, 1);
 
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 58d7bac18b..9884ee7e9f 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -270,7 +270,7 @@ void mips_r4k_init(MachineState *machine)
 i8259 = i8259_init(isa_bus, env->irq[2]);
 isa_bus_irqs(isa_bus, i8259);
 
-rtc_init(isa_bus, 2000, NULL);
+mc146818_rtc_init(isa_bus, 2000, NULL);
 
 pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
 
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c35c439d81..94ffc8e137 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -655,7 +655,7 @@ static void ppc_powernv_init(MachineState *machine)
 serial_hds_isa_init(pnv->isa_bus, 0, MAX_SERIAL_PORTS);
 
 /* Create an RTC ISA device too */
-rtc_init(pnv->isa_bus, 2000, NULL);
+mc146818_rtc_init(pnv->isa_bus, 2000, NULL);
 
 /* OpenPOWER systems use a 

[Qemu-devel] [PATCH v4 34/43] hw/acpi/ich9: extract ACPI_PM_PROP_TCO_ENABLED from i386/pc

2017-12-14 Thread Philippe Mathieu-Daudé
enable_tco is specific to i386/pc.

Suggested-by: Paolo Bonzini 
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
---
 include/hw/acpi/ich9.h | 2 ++
 include/hw/i386/pc.h   | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index a352c94fde..59aeb06393 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -63,6 +63,8 @@ typedef struct ICH9LPCPMRegs {
 TCOIORegs tco_regs;
 } ICH9LPCPMRegs;
 
+#define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
+
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
   bool smm_enabled,
   qemu_irq sci_irq);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 252526e600..3794473108 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -151,8 +151,6 @@ struct PCMachineClass {
 #define PC_MACHINE_CLASS(klass) \
 OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
 
-#define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
-
 /* parallel.c */
 
 void parallel_hds_isa_init(ISABus *bus, int n);
-- 
2.15.1




[Qemu-devel] [PATCH v4 29/43] hw/virtio-balloon: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/virtio/virtio-balloon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 37cde38982..14e08d20d0 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -18,7 +18,7 @@
 #include "qemu/timer.h"
 #include "qemu-common.h"
 #include "hw/virtio/virtio.h"
-#include "hw/i386/pc.h"
+#include "hw/mem/pc-dimm.h"
 #include "sysemu/balloon.h"
 #include "hw/virtio/virtio-balloon.h"
 #include "sysemu/kvm.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 31/43] hw/timer/i8254: rename pit_init() -> i8254_pit_init()

2017-12-14 Thread Philippe Mathieu-Daudé
and remove the old i386/pc dependency

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
---
 include/hw/timer/i8254.h  | 5 +++--
 include/hw/timer/i8254_internal.h | 2 +-
 hw/alpha/dp264.c  | 2 +-
 hw/i386/pc.c  | 2 +-
 hw/isa/i82378.c   | 2 +-
 hw/mips/mips_fulong2e.c   | 2 +-
 hw/mips/mips_jazz.c   | 2 +-
 hw/mips/mips_malta.c  | 2 +-
 hw/mips/mips_r4k.c| 2 +-
 hw/timer/i8254.c  | 1 -
 hw/timer/i8254_common.c   | 1 -
 11 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h
index 5adae9fa44..5b12eb918e 100644
--- a/include/hw/timer/i8254.h
+++ b/include/hw/timer/i8254.h
@@ -26,6 +26,7 @@
 #define HW_I8254_H
 
 #include "hw/hw.h"
+#include "hw/qdev.h"
 #include "hw/isa/isa.h"
 
 #define PIT_FREQ 1193182
@@ -48,8 +49,8 @@ typedef struct PITChannelInfo {
 #define TYPE_I8254 "isa-pit"
 #define TYPE_KVM_I8254 "kvm-pit"
 
-static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq,
-  qemu_irq alt_irq)
+static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,
+qemu_irq alt_irq)
 {
 DeviceState *dev;
 ISADevice *d;
diff --git a/include/hw/timer/i8254_internal.h 
b/include/hw/timer/i8254_internal.h
index dc09cc0467..c37a438f82 100644
--- a/include/hw/timer/i8254_internal.h
+++ b/include/hw/timer/i8254_internal.h
@@ -26,8 +26,8 @@
 #define QEMU_I8254_INTERNAL_H
 
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
+#include "qemu/timer.h"
 
 typedef struct PITChannelState {
 int count; /* can be 65536 */
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index babd6ea514..887a7401f1 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -80,7 +80,7 @@ static void clipper_init(MachineState *machine)
 /* Since we have an SRM-compatible PALcode, use the SRM epoch.  */
 rtc_init(isa_bus, 1900, rtc_irq);
 
-pit_init(isa_bus, 0x40, 0, NULL);
+i8254_pit_init(isa_bus, 0x40, 0, NULL);
 isa_create_simple(isa_bus, "i8042");
 
 /* VGA setup.  Don't bother loading the bios.  */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 186545d2a4..6a6041573f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1573,7 +1573,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
 if (kvm_pit_in_kernel()) {
 pit = kvm_pit_init(isa_bus, 0x40);
 } else {
-pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
+pit = i8254_pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
 }
 if (hpet) {
 /* connect PIT to output control line of the HPET */
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index d20ea4c2ee..a9c15f858d 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -97,7 +97,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
 isa_bus_irqs(isabus, s->i8259);
 
 /* 1 82C54 (pit) */
-isa = pit_init(isabus, 0x40, 0, NULL);
+isa = i8254_pit_init(isabus, 0x40, 0, NULL);
 
 /* speaker */
 pcspk_init(isabus, isa);
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 146cf0fccd..2a2a09c9de 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -359,7 +359,7 @@ static void mips_fulong2e_init(MachineState *machine)
 smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd));
 
 /* init other devices */
-pit = pit_init(isa_bus, 0x40, 0, NULL);
+pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
 DMA_init(isa_bus, 0);
 
 /* Super I/O */
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index fe4f17389f..995419344d 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -218,7 +218,7 @@ static void mips_jazz_init(MachineState *machine,
 i8259 = i8259_init(isa_bus, env->irq[4]);
 isa_bus_irqs(isa_bus, i8259);
 DMA_init(isa_bus, 0);
-pit = pit_init(isa_bus, 0x40, 0, NULL);
+pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
 pcspk_init(isa_bus, pit);
 
 /* Video card */
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index ec6af4a277..88b4733743 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1208,7 +1208,7 @@ void mips_malta_init(MachineState *machine)
   isa_get_irq(NULL, 9), NULL, 0, NULL);
 smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
 g_free(smbus_eeprom_buf);
-pit = pit_init(isa_bus, 0x40, 0, NULL);
+pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
 DMA_init(isa_bus, 0);
 
 /* Super I/O */
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 3bbb1827e1..58d7bac18b 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -272,7 +272,7 @@ void mips_r4k_init(MachineState *machine)
 
 rtc_init(isa_bus, 2000, NULL);
 
-pit = pit_init(isa_bus, 

[Qemu-devel] [PATCH v4 27/43] hw/i2c: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/i2c/pm_smbus.c   | 1 -
 hw/i2c/smbus_ich9.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 6fc3923f56..a044dd1b27 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -19,7 +19,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/i2c/pm_smbus.h"
 #include "hw/i2c/smbus.h"
 
diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index e47556c9d8..007cb6701d 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -26,7 +26,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/i2c/pm_smbus.h"
 #include "hw/pci/pci.h"
 #include "sysemu/sysemu.h"
-- 
2.15.1




[Qemu-devel] [PATCH v5 1/2] hw/i386/vmport: replace fprintf() by trace events

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/vmport.c | 8 +++-
 hw/i386/trace-events | 4 
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index eb880c6def..b5585a009a 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -27,8 +27,7 @@
 #include "hw/i386/pc.h"
 #include "sysemu/hw_accel.h"
 #include "hw/qdev.h"
-
-/* #define VMPORT_DEBUG */
+#include "trace.h"
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
@@ -54,6 +53,7 @@ void vmport_register(unsigned char command, VMPortReadFunc 
*func, void *opaque)
 return;
 }
 
+trace_vmport_register(command, func, opaque);
 port_state->func[command] = func;
 port_state->opaque[command] = opaque;
 }
@@ -80,9 +80,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,
 return eax;
 }
 if (!s->func[command]) {
-#ifdef VMPORT_DEBUG
-fprintf(stderr, "vmport: unknown command %x\n", command);
-#endif
+trace_vmport_ioport_read_unknown_command(command, addr);
 return eax;
 }
 
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index d43b4b6cd3..150549c15e 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -113,3 +113,7 @@ amdvi_mode_invalid(uint8_t level, uint64_t addr)"error: 
translation level 0x%"PR
 amdvi_page_fault(uint64_t addr) "error: page fault accessing guest physical 
address 0x%"PRIx64
 amdvi_iotlb_hit(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, 
uint64_t txaddr) "hit iotlb devid %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
 amdvi_translation_result(uint8_t bus, uint8_t slot, uint8_t func, uint64_t 
addr, uint64_t txaddr) "devid: %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
+
+# hw/i386/vmport.c
+vmport_register(unsigned char command, void *func, void *opaque) "command: 
0x%02x func: %p opaque: %p"
+vmport_ioport_read_unknown_command(unsigned char command, hwaddr addr) 
"unknown command: 0x%02x addr: 0x%" HWADDR_PRIx
-- 
2.15.1




[Qemu-devel] [PATCH v4 43/43] misc: drop old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/char/debugcon.c  | 1 -
 hw/intc/lm32_pic.c  | 1 -
 hw/moxie/moxiesim.c | 1 -
 hw/sparc/sun4m.c| 1 -
 hw/watchdog/wdt_ib700.c | 1 -
 5 files changed, 5 deletions(-)

diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
index 95ccec6f8b..e2abc61b04 100644
--- a/hw/char/debugcon.c
+++ b/hw/char/debugcon.c
@@ -29,7 +29,6 @@
 #include "hw/hw.h"
 #include "chardev/char-fe.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
 #define ISA_DEBUGCON_DEVICE(obj) \
diff --git a/hw/intc/lm32_pic.c b/hw/intc/lm32_pic.c
index 09e15115fb..db6c7afc2f 100644
--- a/hw/intc/lm32_pic.c
+++ b/hw/intc/lm32_pic.c
@@ -20,7 +20,6 @@
 #include "qemu/osdep.h"
 
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "monitor/monitor.h"
 #include "hw/sysbus.h"
 #include "trace.h"
diff --git a/hw/moxie/moxiesim.c b/hw/moxie/moxiesim.c
index 3ba58481d0..3c3ba9d8c5 100644
--- a/hw/moxie/moxiesim.c
+++ b/hw/moxie/moxiesim.c
@@ -30,7 +30,6 @@
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 24c2b8a555..e71648404c 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -36,7 +36,6 @@
 #include "net/net.h"
 #include "hw/boards.h"
 #include "hw/scsi/esp.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "hw/nvram/sun_nvram.h"
 #include "hw/nvram/chrp_nvram.h"
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
index 532afe89e7..d045032bf4 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -25,7 +25,6 @@
 #include "sysemu/watchdog.h"
 #include "hw/hw.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 /*#define IB700_DEBUG 1*/
 
-- 
2.15.1




[Qemu-devel] [PATCH v4 28/43] hw/tpm: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Stefan Berger 
---
 hw/tpm/tpm_passthrough.c | 1 -
 hw/tpm/tpm_tis.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index c440aff4b2..d904d8e33f 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -29,7 +29,6 @@
 #include "sysemu/tpm_backend.h"
 #include "tpm_int.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "qapi/clone-visitor.h"
 #include "tpm_util.h"
 
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 42d647d363..3c38fd8b2c 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -29,7 +29,6 @@
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci_ids.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 24/43] misc: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Reviewed-by: Anthony PERARD 
---
 hw/audio/pcspk.c| 1 -
 hw/i386/xen/xen_platform.c  | 1 -
 hw/isa/vt82c686.c   | 1 -
 hw/misc/ivshmem.c   | 1 -
 hw/misc/sga.c   | 1 -
 hw/pci-bridge/pci_expander_bridge.c | 1 -
 monitor.c   | 1 -
 7 files changed, 7 deletions(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 0206f7399b..908696d483 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -24,7 +24,6 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "hw/audio/soundhw.h"
 #include "audio/audio.h"
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 056b87de0b..fc8623c90b 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -26,7 +26,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/ide.h"
 #include "hw/pci/pci.h"
 #include "hw/irq.h"
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index c129985e2a..4084b32be9 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -12,7 +12,6 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/vt82c686.h"
 #include "hw/i2c/i2c.h"
 #include "hw/i2c/smbus.h"
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index a5a46827fe..4919011f38 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -20,7 +20,6 @@
 #include "qapi/error.h"
 #include "qemu/cutils.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "hw/pci/msix.h"
diff --git a/hw/misc/sga.c b/hw/misc/sga.c
index 03b006d6f0..97fd63f176 100644
--- a/hw/misc/sga.c
+++ b/hw/misc/sga.c
@@ -26,7 +26,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/pci/pci.h"
-#include "hw/i386/pc.h"
 #include "hw/loader.h"
 #include "sysemu/sysemu.h"
 
diff --git a/hw/pci-bridge/pci_expander_bridge.c 
b/hw/pci-bridge/pci_expander_bridge.c
index 8c8ac737ad..9e799dc10f 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -16,7 +16,6 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci_host.h"
 #include "hw/pci/pci_bridge.h"
-#include "hw/i386/pc.h"
 #include "qemu/range.h"
 #include "qemu/error-report.h"
 #include "sysemu/numa.h"
diff --git a/monitor.c b/monitor.c
index e36fb5308d..d682eee2d8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -28,7 +28,6 @@
 #include "hw/hw.h"
 #include "monitor/qdev.h"
 #include "hw/usb.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "sysemu/watchdog.h"
 #include "hw/loader.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 26/43] hw/ipmi: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Corey Minyard 
Tested-by: Corey Minyard 
---
 hw/ipmi/isa_ipmi_bt.c  | 1 -
 hw/ipmi/isa_ipmi_kcs.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index 2fcc3d2e7c..e098fd5206 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -26,7 +26,6 @@
 #include "hw/hw.h"
 #include "hw/ipmi/ipmi.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 /* Control register */
 #define IPMI_BT_CLR_WR_BIT 0
diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
index 80444977a0..689587b65d 100644
--- a/hw/ipmi/isa_ipmi_kcs.c
+++ b/hw/ipmi/isa_ipmi_kcs.c
@@ -26,7 +26,6 @@
 #include "hw/hw.h"
 #include "hw/ipmi/ipmi.h"
 #include "hw/isa/isa.h"
-#include "hw/i386/pc.h"
 
 #define IPMI_KCS_OBF_BIT0
 #define IPMI_KCS_IBF_BIT1
-- 
2.15.1




[Qemu-devel] [PATCH v4 22/43] hw/ssi/aspeed_smc: remove unused #include

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 hw/ssi/aspeed_smc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 992617fd3a..5059396bc6 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -27,7 +27,6 @@
 #include "sysemu/sysemu.h"
 #include "qemu/log.h"
 #include "qemu/error-report.h"
-#include "exec/address-spaces.h"
 
 #include "hw/ssi/aspeed_smc.h"
 
-- 
2.15.1





[Qemu-devel] [PATCH v4 33/43] hw/acpi: ACPI_PM_* defines are not restricted to i386 arch

2017-12-14 Thread Philippe Mathieu-Daudé
this allows to remove the old i386/pc dependency on acpi/core.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
---
 include/hw/acpi/acpi.h | 11 +++
 include/hw/i386/pc.h   | 11 ---
 hw/acpi/core.c |  1 -
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index 7b3d93cf0d..39ff512129 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -39,6 +39,17 @@
 #define ACPI_PM2_REGISTER_WIDTH 8
 #define ACPI_PM_TIMER_WIDTH 32
 
+/* PC-style peripherals (also used by other machines).  */
+#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
+#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
+#define ACPI_PM_PROP_S4_VAL "s4_val"
+#define ACPI_PM_PROP_SCI_INT "sci_int"
+#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd"
+#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd"
+#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
+#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
+#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
+
 /* PM Timer ticks per second (HZ) */
 #define PM_TIMER_FREQUENCY  3579545
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ef438bd765..252526e600 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -151,17 +151,6 @@ struct PCMachineClass {
 #define PC_MACHINE_CLASS(klass) \
 OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
 
-/* PC-style peripherals (also used by other machines).  */
-
-#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
-#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
-#define ACPI_PM_PROP_S4_VAL "s4_val"
-#define ACPI_PM_PROP_SCI_INT "sci_int"
-#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd"
-#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd"
-#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
-#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
-#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
 #define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
 
 /* parallel.c */
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index cd0a1d357b..eb9b76f70b 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -21,7 +21,6 @@
 #include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/acpi/acpi.h"
 #include "hw/nvram/fw_cfg.h"
 #include "qemu/config-file.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 42/43] hw/i386/vmport: replace fprintf() by trace events

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/vmport.c | 8 +++-
 hw/i386/trace-events | 4 
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index eb880c6def..b5585a009a 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -27,8 +27,7 @@
 #include "hw/i386/pc.h"
 #include "sysemu/hw_accel.h"
 #include "hw/qdev.h"
-
-/* #define VMPORT_DEBUG */
+#include "trace.h"
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
@@ -54,6 +53,7 @@ void vmport_register(unsigned char command, VMPortReadFunc 
*func, void *opaque)
 return;
 }
 
+trace_vmport_register(command, func, opaque);
 port_state->func[command] = func;
 port_state->opaque[command] = opaque;
 }
@@ -80,9 +80,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,
 return eax;
 }
 if (!s->func[command]) {
-#ifdef VMPORT_DEBUG
-fprintf(stderr, "vmport: unknown command %x\n", command);
-#endif
+trace_vmport_ioport_read_unknown_command(command, addr);
 return eax;
 }
 
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index d43b4b6cd3..f0522ea5e5 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -113,3 +113,7 @@ amdvi_mode_invalid(uint8_t level, uint64_t addr)"error: 
translation level 0x%"PR
 amdvi_page_fault(uint64_t addr) "error: page fault accessing guest physical 
address 0x%"PRIx64
 amdvi_iotlb_hit(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, 
uint64_t txaddr) "hit iotlb devid %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
 amdvi_translation_result(uint8_t bus, uint8_t slot, uint8_t func, uint64_t 
addr, uint64_t txaddr) "devid: %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64
+
+# hw/i386/vmport.c
+vmport_register(unsigned char command, void *func, void *opaque) "command: 
0x%02x func: %p opaque: %p"
+vmport_ioport_read_unknown_command(unsigned char command, hwaddr addr) 
"unknown command: 0x%02x addr: 0x" HWADDR_PRIx
-- 
2.15.1




[Qemu-devel] [PATCH v4 23/43] amd_iommu: avoid needless includes in header file

2017-12-14 Thread Philippe Mathieu-Daudé
instead move them to the source file

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/i386/amd_iommu.h | 5 -
 hw/i386/amd_iommu.c | 5 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index d370ae3549..aeef802364 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -23,11 +23,6 @@
 
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
-#include "hw/pci/msi.h"
-#include "hw/sysbus.h"
-#include "sysemu/dma.h"
-#include "hw/i386/pc.h"
-#include "hw/pci/pci_bus.h"
 #include "hw/i386/x86-iommu.h"
 
 /* Capability registers */
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index ad8155ca4c..eeaf0e0aa8 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -20,7 +20,10 @@
  * Cache implementation inspired by hw/i386/intel_iommu.c
  */
 #include "qemu/osdep.h"
-#include "hw/i386/amd_iommu.h"
+#include "hw/i386/pc.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/pci_bus.h"
+#include "amd_iommu.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "trace.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 18/43] misc: avoid "include/" in include path

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 hw/input/adb.c  | 2 +-
 hw/ssi/aspeed_smc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/input/adb.c b/hw/input/adb.c
index fcca3a8eb9..924a3f9fd5 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -24,8 +24,8 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/input/adb.h"
+#include "hw/input/adb-keys.h"
 #include "ui/console.h"
-#include "include/hw/input/adb-keys.h"
 #include "ui/input.h"
 #include "sysemu/sysemu.h"
 
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index cb515730c5..992617fd3a 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -26,7 +26,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/sysemu.h"
 #include "qemu/log.h"
-#include "include/qemu/error-report.h"
+#include "qemu/error-report.h"
 #include "exec/address-spaces.h"
 
 #include "hw/ssi/aspeed_smc.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 30/43] hw/unicore32: restrict hw addr defines to source file

2017-12-14 Thread Philippe Mathieu-Daudé
and drop unused #includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 include/hw/unicore32/puv3.h | 10 --
 hw/unicore32/puv3.c | 15 ++-
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/include/hw/unicore32/puv3.h b/include/hw/unicore32/puv3.h
index 5a4839f8df..f587a1f622 100644
--- a/include/hw/unicore32/puv3.h
+++ b/include/hw/unicore32/puv3.h
@@ -14,16 +14,6 @@
 
 #define PUV3_REGS_OFFSET(0x1000) /* 4K is reasonable */
 
-/* PKUnity System bus (AHB): 0xc000 - 0xedff (640MB) */
-#define PUV3_DMA_BASE   (0xc020) /* AHB-4 */
-
-/* PKUnity Peripheral bus (APB): 0xee00 - 0xefff (128MB) */
-#define PUV3_GPIO_BASE  (0xee50) /* APB-5 */
-#define PUV3_INTC_BASE  (0xee60) /* APB-6 */
-#define PUV3_OST_BASE   (0xee80) /* APB-8 */
-#define PUV3_PM_BASE(0xeea0) /* APB-10 */
-#define PUV3_PS2_BASE   (0xeeb0) /* APB-11 */
-
 /* Hardware interrupts */
 #define PUV3_IRQS_NR(32)
 
diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
index 1b39cc035b..db26959a1d 100644
--- a/hw/unicore32/puv3.c
+++ b/hw/unicore32/puv3.c
@@ -11,16 +11,11 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qemu-common.h"
 #include "cpu.h"
 #include "ui/console.h"
-#include "elf.h"
-#include "exec/address-spaces.h"
-#include "hw/sysbus.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
 #include "hw/i386/pc.h"
-#include "qemu/error-report.h"
 #include "sysemu/qtest.h"
 
 #undef DEBUG_PUV3
@@ -29,6 +24,16 @@
 #define KERNEL_LOAD_ADDR0x0300
 #define KERNEL_MAX_SIZE 0x0080 /* Just a guess */
 
+/* PKUnity System bus (AHB): 0xc000 - 0xedff (640MB) */
+#define PUV3_DMA_BASE   (0xc020) /* AHB-4 */
+
+/* PKUnity Peripheral bus (APB): 0xee00 - 0xefff (128MB) */
+#define PUV3_GPIO_BASE  (0xee50) /* APB-5 */
+#define PUV3_INTC_BASE  (0xee60) /* APB-6 */
+#define PUV3_OST_BASE   (0xee80) /* APB-8 */
+#define PUV3_PM_BASE(0xeea0) /* APB-10 */
+#define PUV3_PS2_BASE   (0xeeb0) /* APB-11 */
+
 static void puv3_intc_cpu_handler(void *opaque, int irq, int level)
 {
 UniCore32CPU *cpu = opaque;
-- 
2.15.1




[Qemu-devel] [PATCH v4 40/43] i386/pc: move vmport.c to hw/i386/

2017-12-14 Thread Philippe Mathieu-Daudé
It's a x86-only device, so it does not make sense to keep it
in the shared misc folder.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 hw/{misc => i386}/vmport.c | 17 +
 hw/i386/Makefile.objs  |  1 +
 hw/misc/Makefile.objs  |  2 --
 3 files changed, 10 insertions(+), 10 deletions(-)
 rename hw/{misc => i386}/vmport.c (95%)

diff --git a/hw/misc/vmport.c b/hw/i386/vmport.c
similarity index 95%
rename from hw/misc/vmport.c
rename to hw/i386/vmport.c
index 165500223f..eb880c6def 100644
--- a/hw/misc/vmport.c
+++ b/hw/i386/vmport.c
@@ -28,7 +28,7 @@
 #include "sysemu/hw_accel.h"
 #include "hw/qdev.h"
 
-//#define VMPORT_DEBUG
+/* #define VMPORT_DEBUG */
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
@@ -38,8 +38,7 @@
 
 #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
 
-typedef struct VMPortState
-{
+typedef struct VMPortState {
 ISADevice parent_obj;
 
 MemoryRegion io;
@@ -51,8 +50,9 @@ static VMPortState *port_state;
 
 void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque)
 {
-if (command >= VMPORT_ENTRIES)
+if (command >= VMPORT_ENTRIES) {
 return;
+}
 
 port_state->func[command] = func;
 port_state->opaque[command] = opaque;
@@ -71,14 +71,15 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr 
addr,
 cpu_synchronize_state(cs);
 
 eax = env->regs[R_EAX];
-if (eax != VMPORT_MAGIC)
+if (eax != VMPORT_MAGIC) {
 return eax;
+}
 
 command = env->regs[R_ECX];
-if (command >= VMPORT_ENTRIES)
+if (command >= VMPORT_ENTRIES) {
 return eax;
-if (!s->func[command])
-{
+}
+if (!s->func[command]) {
 #ifdef VMPORT_DEBUG
 fprintf(stderr, "vmport: unknown command %x\n", command);
 #endif
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 2e5e1299ad..1548ad1ad0 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o
 obj-y += x86-iommu.o intel_iommu.o
 obj-y += amd_iommu.o
 obj-$(CONFIG_XEN) += ../xenpv/ xen/
+obj-$(CONFIG_VMPORT) += vmport.o
 
 obj-y += kvmvapic.o
 obj-y += acpi-build.o
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index 10c88a84b4..d517f83e81 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -11,8 +11,6 @@ common-obj-$(CONFIG_EDU) += edu.o
 common-obj-y += unimp.o
 common-obj-$(CONFIG_FW_CFG_DMA) += vmcoreinfo.o
 
-obj-$(CONFIG_VMPORT) += vmport.o
-
 # ARM devices
 common-obj-$(CONFIG_PL310) += arm_l2x0.o
 common-obj-$(CONFIG_INTEGRATOR_DEBUG) += arm_integrator_debug.o
-- 
2.15.1




[Qemu-devel] [PATCH v4 19/43] numa: remove unused #include

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 numa.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/numa.c b/numa.c
index 7151b24d1c..20bdb5a4b1 100644
--- a/numa.c
+++ b/numa.c
@@ -29,7 +29,6 @@
 #include "qemu/bitmap.h"
 #include "qom/cpu.h"
 #include "qemu/error-report.h"
-#include "include/exec/cpu-common.h" /* for RAM_ADDR_FMT */
 #include "qapi-visit.h"
 #include "qapi/opts-visitor.h"
 #include "hw/boards.h"
-- 
2.15.1





[Qemu-devel] [PATCH v4 17/43] nios2: remove duplicated includes (in code commented out)

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 target/nios2/cpu.h   | 1 -
 disas/nios2.c| 3 ---
 hw/nios2/boot.c  | 1 -
 target/nios2/helper.c| 5 +
 target/nios2/op_helper.c | 1 +
 target/nios2/translate.c | 1 +
 6 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 9119eee587..88823a6d4d 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -20,7 +20,6 @@
 #ifndef CPU_NIOS2_H
 #define CPU_NIOS2_H
 
-#include "qemu/osdep.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
diff --git a/disas/nios2.c b/disas/nios2.c
index b342936d21..de11f04cc4 100644
--- a/disas/nios2.c
+++ b/disas/nios2.c
@@ -1756,7 +1756,6 @@ extern const int nios2_num_r2_reg_range_mappings;
 #endif /* _NIOS2_H */
 
 /*#include "sysdep.h"
-#include 
 #include "opcode/nios2.h"
 */
 /* Register string table */
@@ -2521,8 +2520,6 @@ const int nios2_num_r2_reg_range_mappings = 8;
 #include "dis-asm.h"
 #include "opcode/nios2.h"
 #include "libiberty.h"
-#include 
-#include 
 */
 /* No symbol table is available when this code runs out in an embedded
system as when it is used for disassembler support in a monitor.  */
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 2b31f5b844..94f436e7fb 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -34,7 +34,6 @@
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
-#include "qemu-common.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
diff --git a/target/nios2/helper.c b/target/nios2/helper.c
index ef9ee05798..9f741a8f19 100644
--- a/target/nios2/helper.c
+++ b/target/nios2/helper.c
@@ -18,12 +18,9 @@
  * 
  */
 
-#include 
-#include 
-#include 
+#include "qemu/osdep.h"
 
 #include "cpu.h"
-#include "qemu/osdep.h"
 #include "qemu/host-utils.h"
 #include "qapi/error.h"
 #include "exec/exec-all.h"
diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c
index efb1c489c9..c853aeae02 100644
--- a/target/nios2/op_helper.c
+++ b/target/nios2/op_helper.c
@@ -18,6 +18,7 @@
  * 
  */
 
+#include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 72329002ac..51a54ff760 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -21,6 +21,7 @@
  * 
  */
 
+#include "qemu/osdep.h"
 #include "cpu.h"
 #include "tcg-op.h"
 #include "exec/exec-all.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 37/43] hw/display/vga: extract public API from i386/pc to "hw/display/vga.h"

2017-12-14 Thread Philippe Mathieu-Daudé
and remove the old i386/pc dependency.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 include/hw/display/vga.h | 25 +
 include/hw/i386/pc.h | 12 
 hw/display/vga-isa-mm.c  |  3 +--
 hw/display/vga-isa.c |  2 +-
 hw/display/vga.c |  2 +-
 hw/mips/mips_jazz.c  |  1 +
 vl.c |  2 +-
 MAINTAINERS  |  1 +
 8 files changed, 31 insertions(+), 17 deletions(-)
 create mode 100644 include/hw/display/vga.h

diff --git a/include/hw/display/vga.h b/include/hw/display/vga.h
new file mode 100644
index 00..0401a3a292
--- /dev/null
+++ b/include/hw/display/vga.h
@@ -0,0 +1,25 @@
+/*
+ * QEMU VGA Emulator.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_HW_DISPLAY_VGA_H
+#define QEMU_HW_DISPLAY_VGA_H
+
+#include "exec/memory.h"
+
+enum vga_retrace_method {
+VGA_RETRACE_DUMB,
+VGA_RETRACE_PRECISE
+};
+
+extern enum vga_retrace_method vga_retrace_method;
+
+int isa_vga_mm_init(hwaddr vram_base,
+hwaddr ctrl_base, int it_shift,
+MemoryRegion *address_space);
+
+#endif
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3794473108..1d55ba3322 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -302,18 +302,6 @@ PCIBus *find_i440fx(void);
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 
-/* vga.c */
-enum vga_retrace_method {
-VGA_RETRACE_DUMB,
-VGA_RETRACE_PRECISE
-};
-
-extern enum vga_retrace_method vga_retrace_method;
-
-int isa_vga_mm_init(hwaddr vram_base,
-hwaddr ctrl_base, int it_shift,
-MemoryRegion *address_space);
-
 /* ne2000.c */
 static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
 {
diff --git a/hw/display/vga-isa-mm.c b/hw/display/vga-isa-mm.c
index 68c4d6e23e..e887b45651 100644
--- a/hw/display/vga-isa-mm.c
+++ b/hw/display/vga-isa-mm.c
@@ -23,10 +23,9 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
+#include "hw/display/vga.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
-#include "qemu/timer.h"
 
 #define VGA_RAM_SIZE (8192 * 1024)
 
diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
index 26f69fd40a..469834add5 100644
--- a/hw/display/vga-isa.c
+++ b/hw/display/vga-isa.c
@@ -25,7 +25,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
+#include "hw/isa/isa.h"
 #include "vga_int.h"
 #include "ui/pixel_ops.h"
 #include "qemu/timer.h"
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 4163b532e0..a0412000a5 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
+#include "hw/display/vga.h"
 #include "hw/pci/pci.h"
 #include "vga_int.h"
 #include "vga_regs.h"
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 22a3d5169c..0d2c0683ba 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -39,6 +39,7 @@
 #include "hw/loader.h"
 #include "hw/timer/mc146818rtc.h"
 #include "hw/timer/i8254.h"
+#include "hw/display/vga.h"
 #include "hw/audio/pcspk.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
diff --git a/vl.c b/vl.c
index c1ba52306a..e9012bb009 100644
--- a/vl.c
+++ b/vl.c
@@ -57,9 +57,9 @@ int main(int argc, char **argv)
 #include "hw/boards.h"
 #include "sysemu/accel.h"
 #include "hw/usb.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "hw/scsi/scsi.h"
+#include "hw/display/vga.h"
 #include "hw/bt.h"
 #include "sysemu/watchdog.h"
 #include "hw/smbios/smbios.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index f299dc2c19..8ae268d772 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -881,6 +881,7 @@ F: hw/timer/hpet*
 F: hw/timer/i8254*
 F: hw/timer/mc146818rtc*
 F: hw/watchdog/wdt_ib700.c
+F: include/hw/display/vga.h
 F: include/hw/i2c/pm_smbus.h
 F: include/hw/isa/i8257.h
 F: include/hw/timer/hpet.h
-- 
2.15.1




[Qemu-devel] [PATCH v4 25/43] hw/ide: remove old i386 dependency

2017-12-14 Thread Philippe Mathieu-Daudé
and remove a duplicated include

Signed-off-by: Philippe Mathieu-Daudé 
Acked-by: John Snow 
---
 hw/ide/ahci.c   | 1 -
 hw/ide/cmd646.c | 1 -
 hw/ide/core.c   | 3 +--
 hw/ide/ich.c| 1 -
 hw/ide/isa.c| 1 -
 hw/ide/microdrive.c | 1 -
 hw/ide/pci.c| 1 -
 hw/ide/piix.c   | 2 +-
 hw/ide/via.c| 1 -
 9 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 373311f91a..451b18b419 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/pci/msi.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 
 #include "qemu/error-report.h"
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 86b2a8f504..65aff518ec 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -24,7 +24,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 471d0c928b..1ea5812b7e 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -24,17 +24,16 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/blockdev.h"
 #include "sysemu/dma.h"
 #include "hw/block/block.h"
 #include "sysemu/block-backend.h"
 #include "qemu/cutils.h"
-#include "qemu/error-report.h"
 
 #include "hw/ide/internal.h"
 #include "trace.h"
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 8dd0ced6b3..c01b24ecbe 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -63,7 +63,6 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/pci/msi.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 40213d662c..9fb24fc92b 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -24,7 +24,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/dma.h"
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 17917c0b30..fde4d4645e 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -24,7 +24,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pcmcia.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/dma.h"
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 25f1d36f3a..1ab0a892d0 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -24,7 +24,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index dfb21f65fa..a3afe1fd29 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -25,11 +25,11 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/blockdev.h"
 #include "sysemu/dma.h"
 
 #include "hw/ide/pci.h"
diff --git a/hw/ide/via.c b/hw/ide/via.c
index 35c3059325..117ac4d95e 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -25,7 +25,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
 #include "sysemu/block-backend.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 11/43] block: remove "qemu/osdep.h" from header file

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 block/dmg.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/dmg.h b/block/dmg.h
index b592d6fa8b..2ecf239ba5 100644
--- a/block/dmg.h
+++ b/block/dmg.h
@@ -26,7 +26,6 @@
 #ifndef BLOCK_DMG_H
 #define BLOCK_DMG_H
 
-#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
 #include 
-- 
2.15.1




[Qemu-devel] [PATCH v4 14/43] ppc: remove duplicated includes

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

not needed since 7ebaf795560

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Acked-by: David Gibson 
---
 hw/ppc/spapr_hcall.c | 1 -
 target/ppc/kvm.c | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index be22a6b289..51eba52e86 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -13,7 +13,6 @@
 #include "trace.h"
 #include "kvm_ppc.h"
 #include "hw/ppc/spapr_ovec.h"
-#include "qemu/error-report.h"
 #include "mmu-book3s-v3.h"
 
 struct SPRSyncState {
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 9d57debf0e..4664a3ce9d 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -47,9 +47,6 @@
 #include "sysemu/hostmem.h"
 #include "qemu/cutils.h"
 #include "qemu/mmap-alloc.h"
-#if defined(TARGET_PPC64)
-#include "hw/ppc/spapr_cpu_core.h"
-#endif
 #include "elf.h"
 #include "sysemu/kvm_int.h"
 
-- 
2.15.1




[Qemu-devel] [PATCH v4 21/43] hw/misc/pvpanic: remove unused #include

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/misc/pvpanic.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 2b1e9a6450..3a0e4ba828 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -13,14 +13,11 @@
  */
 
 #include "qemu/osdep.h"
-#include "qapi/qmp/qobject.h"
-#include "qapi/qmp/qjson.h"
 #include "sysemu/sysemu.h"
 #include "qemu/log.h"
 
 #include "hw/nvram/fw_cfg.h"
 #include "hw/i386/pc.h"
-#include "qapi-event.h"
 
 /* The bit of supported pv event */
 #define PVPANIC_F_PANICKED  0
-- 
2.15.1




[Qemu-devel] [PATCH v4 13/43] misc: remove duplicated includes

2017-12-14 Thread Philippe Mathieu-Daudé
exec: housekeeping (funny since 02d0e095031)

applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Acked-by: Cornelia Huck 
Reviewed-by: Anthony PERARD 
---
 accel/tcg/translate-all.c  | 1 -
 exec.c | 3 ---
 hw/arm/spitz.c | 1 -
 hw/char/xen_console.c  | 1 -
 hw/core/machine.c  | 1 -
 hw/s390x/css.c | 1 -
 target/openrisc/exception_helper.c | 1 -
 tests/vhost-user-test.c| 1 -
 util/qemu-sockets.c| 1 -
 vl.c   | 1 -
 10 files changed, 12 deletions(-)

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index e7f0329a52..22682d3cf1 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -31,7 +31,6 @@
 #include "tcg.h"
 #if defined(CONFIG_USER_ONLY)
 #include "qemu.h"
-#include "exec/exec-all.h"
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include 
 #if __FreeBSD_version >= 700104
diff --git a/exec.c b/exec.c
index 03238a3449..3e7c57e914 100644
--- a/exec.c
+++ b/exec.c
@@ -18,8 +18,6 @@
  */
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#ifndef _WIN32
-#endif
 
 #include "qemu/cutils.h"
 #include "cpu.h"
@@ -51,7 +49,6 @@
 #include "trace-root.h"
 
 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE
-#include 
 #include 
 #endif
 
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index feccdb00d3..ac1e15cbbc 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -29,7 +29,6 @@
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
-#include "sysemu/sysemu.h"
 #include "cpu.h"
 
 #undef REG_FMT
diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c
index 3643dfe067..5e68326c19 100644
--- a/hw/char/xen_console.c
+++ b/hw/char/xen_console.c
@@ -27,7 +27,6 @@
 #include "hw/hw.h"
 #include "chardev/char-fe.h"
 #include "hw/xen/xen_backend.h"
-#include "qapi/error.h"
 
 #include 
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 36c2fb069c..c857f3f934 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -20,7 +20,6 @@
 #include "sysemu/numa.h"
 #include "qemu/error-report.h"
 #include "qemu/cutils.h"
-#include "sysemu/numa.h"
 #include "sysemu/qtest.h"
 
 static char *machine_get_accel(Object *obj, Error **errp)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index f6b5c807cd..e3918db741 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -13,7 +13,6 @@
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "hw/qdev.h"
-#include "qemu/error-report.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
 #include "exec/address-spaces.h"
diff --git a/target/openrisc/exception_helper.c 
b/target/openrisc/exception_helper.c
index a8a5f69b05..6073a5b21c 100644
--- a/target/openrisc/exception_helper.c
+++ b/target/openrisc/exception_helper.c
@@ -21,7 +21,6 @@
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "exec/helper-proto.h"
-#include "exec/exec-all.h"
 #include "exception.h"
 
 void HELPER(exception)(CPUOpenRISCState *env, uint32_t excp)
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 4b98018478..e2c89ed376 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -21,7 +21,6 @@
 #include "libqos/libqos.h"
 #include "libqos/pci-pc.h"
 #include "libqos/virtio-pci.h"
-#include "qapi/error.h"
 
 #include "libqos/malloc-pc.h"
 #include "hw/virtio/virtio-net.h"
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index a1cf47e625..af4f01211a 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -26,7 +26,6 @@
 #include "qapi/error.h"
 #include "qemu/sockets.h"
 #include "qemu/main-loop.h"
-#include "qapi/clone-visitor.h"
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qapi-visit.h"
diff --git a/vl.c b/vl.c
index fc8bd9372f..c1ba52306a 100644
--- a/vl.c
+++ b/vl.c
@@ -95,7 +95,6 @@ int main(int argc, char **argv)
 #include "sysemu/kvm.h"
 #include "sysemu/hax.h"
 #include "qapi/qobject-input-visitor.h"
-#include "qapi/qobject-input-visitor.h"
 #include "qapi-visit.h"
 #include "qapi/qmp/qjson.h"
 #include "qemu/option.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 10/43] hw: remove "qemu/osdep.h" from header files

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Reviewed-by: Corey Minyard 
Tested-by: Corey Minyard 
---
 include/hw/acpi/ipmi.h  | 1 -
 include/hw/cpu/core.h   | 1 -
 include/hw/i2c/ppc4xx_i2c.h | 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h
index ab2bb29048..c38483565c 100644
--- a/include/hw/acpi/ipmi.h
+++ b/include/hw/acpi/ipmi.h
@@ -9,7 +9,6 @@
 #ifndef HW_ACPI_IPMI_H
 #define HW_ACPI_IPMI_H
 
-#include "qemu/osdep.h"
 #include "hw/acpi/aml-build.h"
 
 /*
diff --git a/include/hw/cpu/core.h b/include/hw/cpu/core.h
index 79ac79c29c..b7470644d8 100644
--- a/include/hw/cpu/core.h
+++ b/include/hw/cpu/core.h
@@ -9,7 +9,6 @@
 #ifndef HW_CPU_CORE_H
 #define HW_CPU_CORE_H
 
-#include "qemu/osdep.h"
 #include "hw/qdev.h"
 
 #define TYPE_CPU_CORE "cpu-core"
diff --git a/include/hw/i2c/ppc4xx_i2c.h b/include/hw/i2c/ppc4xx_i2c.h
index e53042f6d4..3450bda577 100644
--- a/include/hw/i2c/ppc4xx_i2c.h
+++ b/include/hw/i2c/ppc4xx_i2c.h
@@ -25,7 +25,6 @@
 #ifndef PPC4XX_I2C_H
 #define PPC4XX_I2C_H
 
-#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "hw/sysbus.h"
 #include "hw/i2c/i2c.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 16/43] i386/hax: remove duplicated include

2017-12-14 Thread Philippe Mathieu-Daudé
this file in include in "target/i386/hax-i386.h":

#ifdef CONFIG_WIN32
#include "target/i386/hax-windows.h"
#endif

which guaranties that sysemu/os-win32.h is previously included (CONFIG_WIN32)

Suggested-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
---
 target/i386/hax-windows.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/i386/hax-windows.h b/target/i386/hax-windows.h
index f7c3e99246..004f867694 100644
--- a/target/i386/hax-windows.h
+++ b/target/i386/hax-windows.h
@@ -20,7 +20,6 @@
 #ifndef TARGET_I386_HAX_WINDOWS_H
 #define TARGET_I386_HAX_WINDOWS_H
 
-#include 
 #include 
 #include 
 #include 
-- 
2.15.1




[Qemu-devel] [PATCH v4 20/43] hw/input/vmmouse: remove unused #include

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/input/vmmouse.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c
index b6d22086f4..65ef55329e 100644
--- a/hw/input/vmmouse.c
+++ b/hw/input/vmmouse.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "ui/console.h"
-#include "hw/input/ps2.h"
 #include "hw/i386/pc.h"
 #include "hw/qdev.h"
 
-- 
2.15.1




[Qemu-devel] [PATCH v4 09/43] hw: use "qemu/osdep.h" as first #include in source files

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Acked-by: David Gibson 
Acked-by: Cornelia Huck 
---
 hw/acpi/ipmi-stub.c | 1 +
 hw/audio/fmopl.c| 1 -
 hw/cpu/core.c   | 1 +
 hw/ppc/spapr_cpu_core.c | 1 +
 hw/smbios/smbios_type_38-stub.c | 1 +
 hw/vfio/ccw.c   | 2 +-
 hw/virtio/vhost-vsock.c | 2 +-
 7 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/acpi/ipmi-stub.c b/hw/acpi/ipmi-stub.c
index 98b6dcee0d..f525f71c2d 100644
--- a/hw/acpi/ipmi-stub.c
+++ b/hw/acpi/ipmi-stub.c
@@ -7,6 +7,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "hw/acpi/ipmi.h"
 
 void build_acpi_ipmi_devices(Aml *table, BusState *bus)
diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
index 5cfb6a96dd..9f50a89b4a 100644
--- a/hw/audio/fmopl.c
+++ b/hw/audio/fmopl.c
@@ -34,7 +34,6 @@
 #include 
 //#include "driver.h"  /* use M.A.M.E. */
 #include "fmopl.h"
-#include "qemu/osdep.h"
 #ifndef PI
 #define PI 3.14159265358979323846
 #endif
diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index bd578ab80c..7e42e2c87a 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include "hw/cpu/core.h"
 #include "qapi/visitor.h"
 #include "qapi/error.h"
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 3a4c174012..8474f9cca8 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "qemu/osdep.h"
 #include "hw/cpu/core.h"
 #include "hw/ppc/spapr_cpu_core.h"
 #include "target/ppc/cpu.h"
diff --git a/hw/smbios/smbios_type_38-stub.c b/hw/smbios/smbios_type_38-stub.c
index 9528c2c28e..5b83c9b1f1 100644
--- a/hw/smbios/smbios_type_38-stub.c
+++ b/hw/smbios/smbios_type_38-stub.c
@@ -7,6 +7,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "hw/smbios/ipmi.h"
 
 void smbios_build_type_38_table(void)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 636729c03d..16713f2c52 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -11,11 +11,11 @@
  * directory.
  */
 
+#include "qemu/osdep.h"
 #include 
 #include 
 #include 
 
-#include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/sysbus.h"
 #include "hw/vfio/vfio.h"
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index 5ec1c6a2a2..aa5af927e1 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -11,8 +11,8 @@
  * top-level directory.
  */
 
-#include 
 #include "qemu/osdep.h"
+#include 
 #include "standard-headers/linux/virtio_vsock.h"
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 08/43] MAINTAINERS: add missing entry for include/hw/net/

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9505c3f90a..f299dc2c19 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1004,6 +1004,7 @@ Network devices
 M: Jason Wang 
 S: Odd Fixes
 F: hw/net/
+F: include/hw/net/
 F: tests/virtio-net-test.c
 T: git git://github.com/jasowang/qemu.git net
 
-- 
2.15.1




[Qemu-devel] [PATCH v4 15/43] i386/hax: remove duplicated includes

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
---
 include/sysemu/hax.h  | 1 -
 target/i386/hax-darwin.h  | 3 ---
 target/i386/hax-windows.h | 2 --
 target/i386/hax-darwin.c  | 6 +-
 4 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
index 232a68ab1b..f252399623 100644
--- a/include/sysemu/hax.h
+++ b/include/sysemu/hax.h
@@ -22,7 +22,6 @@
 #ifndef QEMU_HAX_H
 #define QEMU_HAX_H
 
-#include "config-host.h"
 #include "qemu-common.h"
 
 int hax_sync_vcpus(void);
diff --git a/target/i386/hax-darwin.h b/target/i386/hax-darwin.h
index 0c0968b77d..fb8e25a096 100644
--- a/target/i386/hax-darwin.h
+++ b/target/i386/hax-darwin.h
@@ -15,10 +15,7 @@
 #ifndef TARGET_I386_HAX_DARWIN_H
 #define TARGET_I386_HAX_DARWIN_H
 
-#include 
 #include 
-#include 
-#include 
 
 #define HAX_INVALID_FD  (-1)
 static inline int hax_invalid_fd(hax_fd fd)
diff --git a/target/i386/hax-windows.h b/target/i386/hax-windows.h
index 1d8f68de91..f7c3e99246 100644
--- a/target/i386/hax-windows.h
+++ b/target/i386/hax-windows.h
@@ -24,8 +24,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 #define HAX_INVALID_FD INVALID_HANDLE_VALUE
diff --git a/target/i386/hax-darwin.c b/target/i386/hax-darwin.c
index 1c5bbd0a2d..ee9417454c 100644
--- a/target/i386/hax-darwin.c
+++ b/target/i386/hax-darwin.c
@@ -11,13 +11,9 @@
  */
 
 /* HAX module interface - darwin version */
-#include 
-#include 
-#include 
-#include 
+#include "qemu/osdep.h"
 #include 
 
-#include "qemu/osdep.h"
 #include "target/i386/hax-i386.h"
 
 hax_fd hax_mod_open(void)
-- 
2.15.1




[Qemu-devel] [PATCH v4 05/43] MAINTAINERS: add an entry for watchdog/wdt_ib700

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4618f9b4db..00ce2931d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -877,6 +877,7 @@ F: hw/misc/pc-testdev.c
 F: hw/timer/hpet*
 F: hw/timer/i8254*
 F: hw/timer/mc146818rtc*
+F: hw/watchdog/wdt_ib700.c
 F: include/hw/i2c/pm_smbus.h
 F: include/hw/isa/i8257.h
 F: include/hw/timer/hpet.h
-- 
2.15.1




[Qemu-devel] [PATCH v4 07/43] MAINTAINERS: add entries for timer/m48t59

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 27f190a70a..9505c3f90a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -735,6 +735,8 @@ F: hw/pci-host/prep.[hc]
 F: hw/isa/i82378.c
 F: hw/isa/pc87312.[hc]
 F: hw/dma/i82374.c
+F: hw/timer/m48t59-isa.c
+F: include/hw/timer/m48t59.h
 F: pc-bios/ppc_rom.bin
 
 sPAPR
-- 
2.15.1




[Qemu-devel] [PATCH v4 06/43] MAINTAINERS: add an entry for input/pckbd.c

2017-12-14 Thread Philippe Mathieu-Daudé
and fix a typo in the "PC Chipset" section

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 00ce2931d9..27f190a70a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -863,12 +863,13 @@ F: hw/misc/sga.c
 PC Chipset
 M: Michael S. Tsirkin 
 M: Paolo Bonzini 
-S: Support
+S: Supported
 F: hw/char/debugcon.c
 F: hw/char/parallel.c
 F: hw/char/serial*
 F: hw/dma/i8257*
 F: hw/i2c/pm_smbus.c
+F: hw/input/pckbd.c
 F: hw/intc/apic*
 F: hw/intc/ioapic*
 F: hw/intc/i8259*
-- 
2.15.1




[Qemu-devel] [PATCH v4 12/43] misc: remove headers implicitly included

2017-12-14 Thread Philippe Mathieu-Daudé
applied using ./scripts/clean-includes

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Reviewed-by: Stefan Hajnoczi 
---
 hw/audio/fmopl.h | 1 -
 bsd-user/main.c  | 1 -
 chardev/wctablet.c   | 4 
 hw/scsi/vhost-user-scsi.c| 1 -
 linux-user/main.c| 1 -
 net/colo-compare.c   | 1 -
 tests/test-aio-multithread.c | 1 -
 tests/test-clone-visitor.c   | 1 -
 tests/vmgenid-test.c | 3 ---
 9 files changed, 14 deletions(-)

diff --git a/hw/audio/fmopl.h b/hw/audio/fmopl.h
index f4065f425c..e7e578a48e 100644
--- a/hw/audio/fmopl.h
+++ b/hw/audio/fmopl.h
@@ -1,7 +1,6 @@
 #ifndef FMOPL_H
 #define FMOPL_H
 
-#include 
 
 typedef void (*OPL_TIMERHANDLER)(void *param, int channel, double 
interval_Sec);
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index f1b244b59b..efef5ff8c5 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -32,7 +32,6 @@
 #include "qemu/envlist.h"
 #include "exec/log.h"
 #include "trace/control.h"
-#include "glib-compat.h"
 
 int singlestep;
 unsigned long mmap_min_addr;
diff --git a/chardev/wctablet.c b/chardev/wctablet.c
index 6c13c2c58a..969d014574 100644
--- a/chardev/wctablet.c
+++ b/chardev/wctablet.c
@@ -25,10 +25,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include 
-#include 
-#include 
-#include 
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index f7561e23fa..9389ed48e0 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -18,7 +18,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
-#include "qemu/typedefs.h"
 #include "qom/object.h"
 #include "hw/fw-path-provider.h"
 #include "hw/qdev-core.h"
diff --git a/linux-user/main.c b/linux-user/main.c
index 6286661bd3..2fd2a143ed 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -35,7 +35,6 @@
 #include "elf.h"
 #include "exec/log.h"
 #include "trace/control.h"
-#include "glib-compat.h"
 
 char *exec_path;
 
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 1ce195f877..0ebdec936c 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -23,7 +23,6 @@
 #include "qom/object_interfaces.h"
 #include "qemu/iov.h"
 #include "qom/object.h"
-#include "qemu/typedefs.h"
 #include "net/queue.h"
 #include "chardev/char-fe.h"
 #include "qemu/sockets.h"
diff --git a/tests/test-aio-multithread.c b/tests/test-aio-multithread.c
index d396185972..c8bec81520 100644
--- a/tests/test-aio-multithread.c
+++ b/tests/test-aio-multithread.c
@@ -11,7 +11,6 @@
  */
 
 #include "qemu/osdep.h"
-#include 
 #include "block/aio.h"
 #include "qapi/error.h"
 #include "qemu/coroutine.h"
diff --git a/tests/test-clone-visitor.c b/tests/test-clone-visitor.c
index 96982163e4..ac6afc562e 100644
--- a/tests/test-clone-visitor.c
+++ b/tests/test-clone-visitor.c
@@ -8,7 +8,6 @@
  */
 
 #include "qemu/osdep.h"
-#include 
 
 #include "qemu-common.h"
 #include "qapi/clone-visitor.h"
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index 5a86b40775..68ff954578 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -8,9 +8,6 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include 
-#include 
-#include 
 #include "qemu/osdep.h"
 #include "qemu/bitmap.h"
 #include "qemu/uuid.h"
-- 
2.15.1




[Qemu-devel] [PATCH v4 02/43] MAINTAINERS: add an entry for the i82374 (southbridge)

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Reviewed-by: Hervé Poussineau 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8582c7d6b5..eb1646fbfe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -733,6 +733,7 @@ F: hw/ppc/prep_systemio.c
 F: hw/ppc/rs6000_mc.c
 F: hw/pci-host/prep.[hc]
 F: hw/isa/pc87312.[hc]
+F: hw/dma/i82374.c
 F: pc-bios/ppc_rom.bin
 
 sPAPR
-- 
2.15.1




[Qemu-devel] [PATCH v4 01/43] MAINTAINERS: add entries for i2c/ppc4xx

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Peter Maydell 
Reviewed-by: Corey Minyard 
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 45e2e2009b..8582c7d6b5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -976,7 +976,9 @@ M: Alexander Graf 
 L: qemu-...@nongnu.org
 S: Odd Fixes
 F: hw/ppc/ppc4*.c
+F: hw/i2c/ppc4xx_i2c.c
 F: include/hw/ppc/ppc4xx.h
+F: include/hw/i2c/ppc4xx_i2c.h
 
 ppce500
 M: Alexander Graf 
-- 
2.15.1




[Qemu-devel] [PATCH v4 03/43] MAINTAINERS: add an entry for the i8257 (DMA controller)

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index eb1646fbfe..31c673d60a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -877,6 +877,7 @@ F: hw/timer/hpet*
 F: hw/timer/i8254*
 F: hw/timer/mc146818rtc*
 F: include/hw/i2c/pm_smbus.h
+F: include/hw/isa/i8257.h
 F: include/hw/timer/hpet.h
 F: include/hw/timer/i8254*
 F: include/hw/timer/mc146818rtc*
-- 
2.15.1




[Qemu-devel] [PATCH v2 18/20] sdhci: add a check_capab_baseclock() qtest

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/sdhci-test.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c
index 01373a69df..966bd00499 100644
--- a/tests/sdhci-test.c
+++ b/tests/sdhci-test.c
@@ -7,9 +7,11 @@
  * See the COPYING file in the top-level directory.
  */
 #include "qemu/osdep.h"
+#include "hw/registerfields.h"
 #include "libqtest.h"
 
 #define SDHC_CAPAB  0x40
+FIELD(SDHC_CAPAB, BASECLKFREQ,   8, 8); /* since v2 */
 #define SDHC_HCVER  0xFE
 
 static const struct sdhci_t {
@@ -18,16 +20,17 @@ static const struct sdhci_t {
 struct {
 uintptr_t addr;
 uint8_t version;
+uint8_t baseclock;
 } sdhci;
 } models[] = {
 { "arm","smdkc210",
-{0x1251, 2} },
+{0x1251, 2, 0} },
 { "arm","sabrelite",
-{0x0219, 3} },
+{0x0219, 3, 0} },
 { "arm","raspi2",   /* bcm2835 */
-{0x3f30, 3} },
+{0x3f30, 3, 52} },
 { "arm","xilinx-zynq-a9",   /* exynos4210 */
-{0xe010, 3} },
+{0xe010, 3, 0} },
 };
 
 static uint32_t sdhci_readl(uintptr_t base, uint32_t reg_addr)
@@ -75,6 +78,18 @@ static void check_capab_readonly(uintptr_t addr)
 g_assert_cmpuint(capab1, ==, capab0);
 }
 
+static void check_capab_baseclock(uintptr_t addr, uint8_t expected_freq)
+{
+uint64_t capab, capab_freq;
+
+if (!expected_freq) {
+return;
+}
+capab = sdhci_readq(addr, SDHC_CAPAB);
+capab_freq = FIELD_EX64(capab, SDHC_CAPAB, BASECLKFREQ);
+g_assert_cmpuint(capab_freq, ==, expected_freq);
+}
+
 static void test_machine(const void *data)
 {
 const struct sdhci_t *test = data;
@@ -83,6 +98,7 @@ static void test_machine(const void *data)
 
 check_specs_version(test->sdhci.addr, test->sdhci.version);
 check_capab_readonly(test->sdhci.addr);
+check_capab_baseclock(test->sdhci.addr, test->sdhci.baseclock);
 
 qtest_quit(global_qtest);
 }
-- 
2.15.1




[Qemu-devel] [PATCH v4 04/43] MAINTAINERS: add an entry for the i82378 (superio)

2017-12-14 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Hervé Poussineau 
Reviewed-by: Hervé Poussineau 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 31c673d60a..4618f9b4db 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -732,6 +732,7 @@ F: hw/ppc/prep.c
 F: hw/ppc/prep_systemio.c
 F: hw/ppc/rs6000_mc.c
 F: hw/pci-host/prep.[hc]
+F: hw/isa/i82378.c
 F: hw/isa/pc87312.[hc]
 F: hw/dma/i82374.c
 F: pc-bios/ppc_rom.bin
-- 
2.15.1




[Qemu-devel] [PATCH v4 00/43] remove i386/pc dependency from non-PC world (part 1)

2017-12-14 Thread Philippe Mathieu-Daudé
Quite a bunch of patches and files modified, but the diffstat is not that big.

Which Michael is willing to merge this? :)

Regards,

Phil.

v4:
- added R-b, A-b
- rebased on 2.12
- fixed an english comment (Thomas)
- replace fprintf() by trace events in hw/i386/vmport.c

since v3:
- addressed Thomas & Paolo comments (thanks for your reviews!)
- split/fixed MAINTAINERS entries
- dropped port92 patch
- dropped i8237* patches

I couldn't test the KVM/XEN/HAX part (thanks Corey Minyard for v1 testing!).

since v2:
- added R-b, A-b
- added missing MAINTAINERS entries (as separate patches)
- dma/i82374: avoid multiple creations on the same ISA bus
- i386/pc: extract port92 from pc.c
- i386/pc: move vmport.c/pvpanic.c from hw/misc/ to hw/i386/

v1:
- clean includes (mostly from script)
- code movement (about no logical changes)

001/43:[] [--] 'MAINTAINERS: add entries for i2c/ppc4xx'
002/43:[] [--] 'MAINTAINERS: add an entry for the i82374 (southbridge)'
003/43:[] [--] 'MAINTAINERS: add an entry for the i8257 (DMA controller)'
004/43:[] [--] 'MAINTAINERS: add an entry for the i82378 (superio)'
005/43:[] [--] 'MAINTAINERS: add an entry for watchdog/wdt_ib700'
006/43:[] [--] 'MAINTAINERS: add an entry for input/pckbd.c'
007/43:[] [--] 'MAINTAINERS: add entries for timer/m48t59'
008/43:[] [--] 'MAINTAINERS: add missing entry for include/hw/net/'
009/43:[] [--] 'hw: use "qemu/osdep.h" as first #include in source files'
010/43:[] [--] 'hw: remove "qemu/osdep.h" from header files'
011/43:[] [--] 'block: remove "qemu/osdep.h" from header file'
012/43:[] [--] 'misc: remove headers implicitly included'
013/43:[] [--] 'misc: remove duplicated includes'
014/43:[] [--] 'ppc: remove duplicated includes'
015/43:[] [--] 'i386/hax: remove duplicated includes'
016/43:[0013] [FC] 'i386/hax: remove duplicated include'
017/43:[] [--] 'nios2: remove duplicated includes (in code commented out)'
018/43:[] [--] 'misc: avoid "include/" in include path'
019/43:[] [--] 'numa: remove unused #include'
020/43:[] [--] 'hw/input/vmmouse: remove unused #include'
021/43:[] [--] 'hw/misc/pvpanic: remove unused #include'
022/43:[] [--] 'hw/ssi/aspeed_smc: remove unused #include'
023/43:[] [--] 'amd_iommu: avoid needless includes in header file'
024/43:[0003] [FC] 'misc: remove old i386 dependency'
025/43:[] [--] 'hw/ide: remove old i386 dependency'
026/43:[] [--] 'hw/ipmi: remove old i386 dependency'
027/43:[] [--] 'hw/i2c: remove old i386 dependency'
028/43:[] [-C] 'hw/tpm: remove old i386 dependency'
029/43:[] [--] 'hw/virtio-balloon: remove old i386 dependency'
030/43:[] [--] 'hw/unicore32: restrict hw addr defines to source file'
031/43:[] [--] 'hw/timer/i8254: rename pit_init() -> i8254_pit_init()'
032/43:[] [--] 'hw/timer/mc146818: rename rtc_init() -> mc146818_rtc_init()'
033/43:[] [--] 'hw/acpi: ACPI_PM_* defines are not restricted to i386 arch'
034/43:[] [--] 'hw/acpi/ich9: extract ACPI_PM_PROP_TCO_ENABLED from i386/pc'
035/43:[] [--] 'hw/display/vga: "vga.h" only contains registers defs, 
rename it "vga_regs.h"'
036/43:[] [--] 'hw/display/vga: "vga_int.h" requires "ui/console.h"'
037/43:[] [--] 'hw/display/vga: extract public API from i386/pc to 
"hw/display/vga.h"'
038/43:[] [--] 'hw/net/ne2000: extract ne2k-isa code from i386/pc to 
ne2000-isa.c'
039/43:[] [--] 'hw/misc/pvpanic: extract public API from i386/pc to 
"hw/misc/pvpanic.h"'
040/43:[0017] [FC] 'i386/pc: move vmport.c to hw/i386/'
041/43:[] [--] 'i386/pc: move vmmouse.c to hw/i386/'
042/43:[down] 'hw/i386/vmport: replace fprintf() by trace events'
043/43:[] [--] 'misc: drop old i386 dependency'

Philippe Mathieu-Daudé (43):
  MAINTAINERS: add entries for i2c/ppc4xx
  MAINTAINERS: add an entry for the i82374 (southbridge)
  MAINTAINERS: add an entry for the i8257 (DMA controller)
  MAINTAINERS: add an entry for the i82378 (superio)
  MAINTAINERS: add an entry for watchdog/wdt_ib700
  MAINTAINERS: add an entry for input/pckbd.c
  MAINTAINERS: add entries for timer/m48t59
  MAINTAINERS: add missing entry for include/hw/net/
  hw: use "qemu/osdep.h" as first #include in source files
  hw: remove "qemu/osdep.h" from header files
  block: remove "qemu/osdep.h" from header file
  misc: remove headers implicitly included
  misc: remove duplicated includes
  ppc: remove duplicated includes
  i386/hax: remove duplicated includes
  i386/hax: remove duplicated include
  nios2: remove duplicated includes (in code commented out)
  misc: avoid "include/" in include path
  numa: remove unused #include
  hw/input/vmmouse: remove unused #include
  hw/misc/pvpanic: remove unused #include
  hw/ssi/aspeed_smc: remove unused #include
  amd_iommu: avoid needless includes in header file
  misc: remove old i386 dependency
  hw/ide: remove old i386 dependency
  hw/ipmi: remove old i386 dependency
  hw/i2c: remove old i386 dependency
  hw/tpm: 

  1   2   3   4   5   >