[Qemu-devel] [Bug 1485180] Re: Ctrl Alt G -- Multiple Virtual Machines

2018-10-26 Thread Launchpad Bug Tracker
[Expired for QEMU because there has been no activity for 60 days.]

** Changed in: qemu
   Status: Incomplete => Expired

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

Title:
  Ctrl Alt G -- Multiple Virtual Machines

Status in QEMU:
  Expired

Bug description:
  I'm using Fedora 22.

  Firstly, what works:
  A single VM instance, running Windows. Although, I am keeping this (GTK) 
window focused.

  What really fails:
  If I have two running VM's, WIndows XP and Windows Vista:
  1. I press Ctrl-Alt-G to get the focus.
  2. That works first time.
  3. Then I press Ctrl-Alt-G again.
  4. Then Alt-Tab to the other machine (switching from XP to Vista, or back.)
  5. Then press Ctrl-Alt-G to gain focus:
  - Problem is that now the Ctrl-Alt-G, although showing in the title bar, only 
grabs the mouse, but NOT the keyboard. That is to say, whilst in Ctrl-Alt-G 
mode the second time, pressing Alt-Tab jumps back to the other VM!

  Pressing Alt-F4 quits! Regardless of whether Ctrl-Alt-G mode or 
not!
  But only when running two VM's.

  Thanks
  Misha

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



[Qemu-devel] [Bug 1493033] Re: memory leak/high memory usage with spice webdav feature

2018-10-26 Thread Launchpad Bug Tracker
[Expired for QEMU because there has been no activity for 60 days.]

** Changed in: qemu
   Status: Incomplete => Expired

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

Title:
  memory leak/high memory usage with spice webdav feature

Status in QEMU:
  Expired

Bug description:
  This bug is being open due the comment:
  https://bugs.freedesktop.org/show_bug.cgi?id=91350#c9

  Description of problem:
  When copying big files from client to guest, the memory usage in the host 
grows by about the size of the file. This is partially spice problem due the 
memory pool being able to increase as much as necessary without a limit which 
should be handled by the patches sent in the mailing list [0]

  [0] http://lists.freedesktop.org/archives/spice-
  devel/2015-August/021644.html

  At the same time, massif shows high memory usage by qemu as well [1]
  (output attached)

  [1] (peak)
  ->49.64% (267,580,319B) 0x308B89: malloc_and_trace (vl.c:2724)
  | ->49.38% (266,167,561B) 0x67CE678: g_malloc (gmem.c:97)
  | | ->49.03% (264,241,152B) 0x511D8E: qemu_coroutine_new 
(coroutine-ucontext.c:106)
  | | | ->49.03% (264,241,152B) 0x510E24: qemu_coroutine_create 
(qemu-coroutine.c:74)
  (...)

  The file being shared was a 320M ogv video.

  Version-Release number of selected component (if applicable):
  QEMU emulator version 2.3.93
  SPICE and SPICE-GTK: from git master

  How reproducible:
  100%

  Steps to Reproduce:
  1-) build spice-gtk with --enable-webdav=yes
  2-) enable webdav in your VM by following:
  https://elmarco.fedorapeople.org/manual.html#_folder_sharing
  3-) using remote-viewer with webdav patches, connects to a fedora guest
  4-) Open nautilus, go to 'Browse Network'
  5-) On remote-viewer, enable shared folder by File > Preferences > [X] Share 
folder
  6-) The spice client folder should appear: Double-click to mount it.
  7-) Check the memory of your qemu process
  8-) Copy a big file (let's say, 300 MB) from the shared folder to local VM
  9-) See the memory consumption of qemu grows by a lot;

  Actual results:
  Memory usage grows during copy and is not freed

  Expected results:
  Memory should have an upper limit to grow and should be freed after copy

  Additional info:
  Also reported in Fedora/rawhide: 
https://bugzilla.redhat.com/show_bug.cgi?id=1256376
  SPICE upstream bug: https://bugs.freedesktop.org/show_bug.cgi?id=91350

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



Re: [Qemu-devel] [PATCH 04/10] cputlb: Split large page tracking per mmu_idx

2018-10-26 Thread Emilio G. Cota
On Tue, Oct 23, 2018 at 08:02:47 +0100, Richard Henderson wrote:
> +static void tlb_flush_page_locked(CPUArchState *env, int midx,
> +  target_ulong addr)
> +{
> +target_ulong lp_addr = env->tlb_d[midx].large_page_addr;
> +target_ulong lp_mask = env->tlb_d[midx].large_page_mask;
> +
> +/* Check if we need to flush due to large pages.  */
> +if ((addr & lp_mask) == lp_addr) {
> +tlb_debug("forcing full flush midx %d ("
> +  TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
> +  midx, lp_addr, lp_mask);
> +tlb_flush_one_mmuidx_locked(env, midx);
> +} else {
> +int pidx = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
> +tlb_flush_entry_locked(>tlb_table[midx][pidx], addr);
> +tlb_flush_vtlb_page_locked(env, midx, addr);

Just noticed that we should use tlb_entry here, e.g.:

 } else {
-int pidx = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
-tlb_flush_entry_locked(>tlb_table[midx][pidx], addr);
+CPUTLBEntry *entry = tlb_entry(env, midx, addr);
+
+tlb_flush_entry_locked(entry, addr);
 tlb_flush_vtlb_page_locked(env, midx, addr);
 }

Thanks,

Emilio



Re: [Qemu-devel] [PATCH 2/4] migration: introduce lockless multithreads model

2018-10-26 Thread Emilio G. Cota
On Wed, Oct 17, 2018 at 12:10:15 +0200, Paolo Bonzini wrote:
> On 16/10/2018 13:10, guangrong.x...@gmail.com wrote:

> An idea: the total number of requests is going to be very small, and a
> PtrRing is not the nicest data structure for multiple producer/single
> consumer.  So you could instead:
(snip)
> - now that you have request indices, you can replace the completion
> ptr_ring with a bitmap, and set a bit in the bitmap with set_bit_atomic
> to report completion.  On the writer side you use find_next_bit to find
(snip)
> Emilio, can you review the above ideas?

Sorry it took me a while to go through this.

I like your suggestions. Just one nit; I'm not sure I understood
the use case very well, but I think using a bitmap to signal
completion might be suboptimal, since we'd have several
thread spinning on the same cacheline yet caring about
different bits.

Xiao: a couple of suggestions

- Since you'll be adding a generic module, make its commit and
  description self-contained. That is, mentioning in the
  log that this will be used for migration is fine, but please
  describe the module (and the assumptions it makes about its
  users) in general, so that someone that doesn't know anything
  about migration can still understand this module (and hopefully
  adopt it for other use cases).

- I'd like to see a simple test program (or rather, benchmark)
  that shows how this works. This benchmark would be completely
  unrelated to migration; it should just be a simple test of
  the performance/scalability of this module.
  Having this benchmark would help (1) discuss and quantitately
  evaluate modifications to the module, and (2) help others to
  quickly understand what the module does.
  See tests/qht-bench.c for an example.

Thanks,

Emilio



Re: [Qemu-devel] [PULL 0/3] MIPS queue for October 2018 - part 3

2018-10-26 Thread Peter Maydell
On 25 October 2018 at 21:19, Aleksandar Markovic
 wrote:
> From: Aleksandar Markovic 
>
> The following changes since commit 808ebd66e467f77c0d1f8c6346235f81e9c99cf2:
>
>   Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-sf0' 
> into staging (2018-10-25 17:41:03 +0100)
>
> are available in the git repository at:
>
>   https://github.com/AMarkovic/qemu tags/mips-queue-oct-2018-part-3
>
> for you to fetch changes up to 89a955e8df3dba6f96859cd0339356243b6c996f:
>
>   target/mips: Add disassembler support for nanoMIPS (2018-10-25 22:13:33 
> +0200)
>
> 
> MIPS queue for October 2018 - part 3
>
>   - this pull request contains three assorted nanoMIPS issues
>   - three checkpatch.pl warnings are known and should be ignored
> 
>


Applied, thanks.

-- PMM



[Qemu-devel] template for a script for running an ad-hoc QEMU image

2018-10-26 Thread Peter Maydell
In a conversation this week I mentioned the scripts I use for running
ad-hoc QEMU guest images that I have. The idea here is just that
by making sure that whenever I get a test image I set it up to be
run in the same way, I don't have the problem of trying to remember
how to run the guest if I come back to it after six months.
Here's an example -- I generally just copy-paste-and-edit an older
script when I get a new test image.


#!/bin/sh -e
TESTDIR="$(cd "$(dirname "$0")"; pwd)"
QEMU="$@"

${QEMU} -M lm3s6965evb -kernel "${TESTDIR}"/qs_ek-lm3s6965.bin


I put each guest image in its own directory, and the script is
always named "runme" and is executable. Then any test can be run with
path/to/test/runme path/to/qemu-system-whatever

There's no magic here but there are a couple of nice nuances here:
 * the rune at the top sets TESTDIR to the directory containing the
   script, regardless of what the current working directory is when
   you run the script; references to kernels, disk files, etc should
   then all use $TESTDIR rather than being absolute or relative paths
 * the use of $@ means you can also do

path/to/test/runme gdb --args path/to/qemu-system-whatever
path/to/test/runme valgrind path/to/qemu-system-whatever

and other similar things.

This doesn't fix any of the problems of using ad-hoc human-run
images for testing, but at least it makes them all be runnable in
the same way, reducing the barrier to randomly running one of them.

thanks
-- PMM



Re: [Qemu-devel] [PATCH 0/3] target/mips: Rename MMI-related code elements

2018-10-26 Thread Fredrik Noring
Hi Aleksandar,

> This series renames MMI-related code elements so that they do not
> contain TX79 substring. Tx79 is one of CPUs that support MMI ASE.
> Opcodes and other code elements should be as generic as possible,
> and should not contain CPU name if they are supported by multiple
> CPUs. In cases when there is a single-CPU-specific opcode, an
> anoter special convention should apply, like, for example,
> MMI_OPC__TX79_XXX or MMI_OPC__R5900_YYY. So far these cases were
> not identified, but there will be some in the future. But overall,
> the great MMI opcodes are shared (stay the same) between different
> CPUs that support MMI.
> 
> Aleksandar Markovic (3):
>   target/mips: Rename MMI-related masks
>   target/mips: Rename MMI-related opcodes
>   target/mips: Rename MMI-related functions
> 
>  target/mips/translate.c | 518 
> 
>  1 file changed, 259 insertions(+), 259 deletions(-)

This is interesting. Could you name a few other ISAs, beside the R5900
and the TX79, that have 128-bit GPRs and equivalent MMIs?

Fredrik



Re: [Qemu-devel] [PATCH v1] lsi53c895a: check message length value is valid

2018-10-26 Thread Peter Maydell
On 26 October 2018 at 20:43, P J P  wrote:
> From: Prasad J Pandit 
>
> While writing a message in 'lsi_do_msgin', message length value
> in 'msg_len' could be invalid. Add check to avoid OOB access issue.
>
> Signed-off-by: Prasad J Pandit 
> ---
>  hw/scsi/lsi53c895a.c | 15 ++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> Update v1: add .post_load routine and an assert() call
>   -> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05730.html
>
> diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
> index d1e6534311..3a40e62853 100644
> --- a/hw/scsi/lsi53c895a.c
> +++ b/hw/scsi/lsi53c895a.c
> @@ -861,12 +861,13 @@ static void lsi_do_status(LSIState *s)
>
>  static void lsi_do_msgin(LSIState *s)
>  {
> -int len;
> +uint8_t len;
>  trace_lsi_do_msgin(s->dbc, s->msg_len);
>  s->sfbr = s->msg[0];
>  len = s->msg_len;
>  if (len > s->dbc)
>  len = s->dbc;
> +assert(len <= LSI_MAX_MSGIN_LEN);
>  pci_dma_write(PCI_DEVICE(s), s->dnad, s->msg, len);
>  /* Linux drivers rely on the last byte being in the SIDL.  */
>  s->sidl = s->msg[len - 1];

Is it possible to get here with len == 0 ?

thanks
-- PMM



[Qemu-devel] [PATCH 3/3] target/mips: Rename MMI-related functions

2018-10-26 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Rename MMI-related functions.

Signed-off-by: Aleksandar Markovic 
---
 target/mips/translate.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 4b008d8..155331f 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -24681,7 +24681,7 @@ static void decode_opc_special3_legacy(CPUMIPSState 
*env, DisasContext *ctx)
 }
 }
 
-static void decode_tx79_mmi0(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi0(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI0(ctx->opcode);
 
@@ -24720,7 +24720,7 @@ static void decode_tx79_mmi0(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
-static void decode_tx79_mmi1(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi1(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI1(ctx->opcode);
 
@@ -24752,7 +24752,7 @@ static void decode_tx79_mmi1(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
-static void decode_tx79_mmi2(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI2(ctx->opcode);
 
@@ -24788,7 +24788,7 @@ static void decode_tx79_mmi2(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
-static void decode_tx79_mmi3(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi3(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI3(ctx->opcode);
 
@@ -24815,7 +24815,7 @@ static void decode_tx79_mmi3(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
-static void decode_tx79_mmi(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI(ctx->opcode);
 int rs = extract32(ctx->opcode, 21, 5);
@@ -24824,16 +24824,16 @@ static void decode_tx79_mmi(CPUMIPSState *env, 
DisasContext *ctx)
 
 switch (opc) {
 case MMI_OPC_CLASS_MMI0:
-decode_tx79_mmi0(env, ctx);
+decode_mmi0(env, ctx);
 break;
 case MMI_OPC_CLASS_MMI1:
-decode_tx79_mmi1(env, ctx);
+decode_mmi1(env, ctx);
 break;
 case MMI_OPC_CLASS_MMI2:
-decode_tx79_mmi2(env, ctx);
+decode_mmi2(env, ctx);
 break;
 case MMI_OPC_CLASS_MMI3:
-decode_tx79_mmi3(env, ctx);
+decode_mmi3(env, ctx);
 break;
 case MMI_OPC_MULT1:
 case MMI_OPC_MULTU1:
@@ -24873,12 +24873,12 @@ static void decode_tx79_mmi(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
-static void decode_tx79_lq(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi_lq(CPUMIPSState *env, DisasContext *ctx)
 {
 generate_exception_end(ctx, EXCP_RI);/* TODO: MMI_LQ */
 }
 
-static void gen_tx79_sq(DisasContext *ctx, int base, int rt, int offset)
+static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset)
 {
 generate_exception_end(ctx, EXCP_RI);/* TODO: MMI_SQ */
 }
@@ -24904,7 +24904,7 @@ static void gen_tx79_sq(DisasContext *ctx, int base, 
int rt, int offset)
  * In user mode, QEMU must verify the upper and lower 11 bits to distinguish
  * between SQ and RDHWR, as the Linux kernel does.
  */
-static void decode_tx79_sq(CPUMIPSState *env, DisasContext *ctx)
+static void decode_mmi_sq(CPUMIPSState *env, DisasContext *ctx)
 {
 int base = extract32(ctx->opcode, 21, 5);
 int rt = extract32(ctx->opcode, 16, 5);
@@ -24922,7 +24922,7 @@ static void decode_tx79_sq(CPUMIPSState *env, 
DisasContext *ctx)
 }
 #endif
 
-gen_tx79_sq(ctx, base, rt, offset);
+gen_mmi_sq(ctx, base, rt, offset);
 }
 
 static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
@@ -26231,14 +26231,14 @@ static void decode_opc(CPUMIPSState *env, 
DisasContext *ctx)
 break;
 case OPC_SPECIAL2:
 if ((ctx->insn_flags & INSN_R5900) && (ctx->insn_flags & ASE_MMI)) {
-decode_tx79_mmi(env, ctx);
+decode_mmi(env, ctx);
 } else {
 decode_opc_special2_legacy(env, ctx);
 }
 break;
 case OPC_SPECIAL3:
 if (ctx->insn_flags & INSN_R5900) {
-decode_tx79_sq(env, ctx);/* MMI_SQ */
+decode_mmi_sq(env, ctx);/* MMI_SQ */
 } else {
 decode_opc_special3(env, ctx);
 }
@@ -26902,7 +26902,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext 
*ctx)
 break;
 case OPC_MSA: /* OPC_MDMX */
 if (ctx->insn_flags & INSN_R5900) {
-decode_tx79_lq(env, ctx);/* MMI_LQ */
+decode_mmi_lq(env, ctx);/* MMI_LQ */
 } else {
 /* MDMX: Not implemented. */
 gen_msa(env, ctx);
-- 
2.7.4




[Qemu-devel] [PATCH 0/3] target/mips: Rename MMI-related code elements

2018-10-26 Thread Aleksandar Markovic
From: Aleksandar Markovic 

This series renames MMI-related code elements so that they do not
contain TX79 substring. Tx79 is one of CPUs that support MMI ASE.
Opcodes and other code elements should be as generic as possible,
and should not contain CPU name if they are supported by multiple
CPUs. In cases when there is a single-CPU-specific opcode, an
anoter special convention should apply, like, for example,
MMI_OPC__TX79_XXX or MMI_OPC__R5900_YYY. So far these cases were
not identified, but there will be some in the future. But overall,
the great MMI opcodes are shared (stay the same) between different
CPUs that support MMI.

Aleksandar Markovic (3):
  target/mips: Rename MMI-related masks
  target/mips: Rename MMI-related opcodes
  target/mips: Rename MMI-related functions

 target/mips/translate.c | 518 
 1 file changed, 259 insertions(+), 259 deletions(-)

-- 
2.7.4




[Qemu-devel] [PATCH 1/3] target/mips: Rename MMI-related masks

2018-10-26 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Rename MMI-related masks.

Signed-off-by: Aleksandar Markovic 
---
 target/mips/translate.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 51a5488..e38d50d 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -2159,7 +2159,7 @@ enum {
  *7 111 |   *   |   *   |   *   |   *   | PSLLW |   *   | PSRLW | PSRAW
  */
 
-#define MASK_TX79_MMI(op) (MASK_OP_MAJOR(op) | ((op) & 0x3F))
+#define MASK_MMI(op) (MASK_OP_MAJOR(op) | ((op) & 0x3F))
 enum {
 TX79_MMI_MADD   = 0x00 | TX79_CLASS_MMI, /* Same as OPC_MADD */
 TX79_MMI_MADDU  = 0x01 | TX79_CLASS_MMI, /* Same as OPC_MADDU */
@@ -2210,7 +2210,7 @@ enum {
  *7 111 |   *   |   *   | PEXT5 | PPAC5
  */
 
-#define MASK_TX79_MMI0(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
+#define MASK_MMI0(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
 enum {
 TX79_MMI0_PADDW  = (0x00 << 6) | TX79_MMI_CLASS_MMI0,
 TX79_MMI0_PSUBW  = (0x01 << 6) | TX79_MMI_CLASS_MMI0,
@@ -2261,7 +2261,7 @@ enum {
  *7 111 |   *   |   *   |   *   |   *
  */
 
-#define MASK_TX79_MMI1(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
+#define MASK_MMI1(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
 enum {
 TX79_MMI1_PABSW  = (0x01 << 6) | TX79_MMI_CLASS_MMI1,
 TX79_MMI1_PCEQW  = (0x02 << 6) | TX79_MMI_CLASS_MMI1,
@@ -2305,7 +2305,7 @@ enum {
  *7 111 | PMULTH| PDIVBW| PEXEW | PROT3W
  */
 
-#define MASK_TX79_MMI2(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
+#define MASK_MMI2(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
 enum {
 TX79_MMI2_PMADDW = (0x00 << 6) | TX79_MMI_CLASS_MMI2,
 TX79_MMI2_PSLLVW = (0x02 << 6) | TX79_MMI_CLASS_MMI2,
@@ -2353,7 +2353,7 @@ enum {
  *7 111 |   *   |   *   | PEXCW |   *
  */
 
-#define MASK_TX79_MMI3(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
+#define MASK_MMI3(op) (MASK_OP_MAJOR(op) | ((op) & 0x7FF))
 enum {
 TX79_MMI3_PMADDUW = (0x00 << 6) | TX79_MMI_CLASS_MMI3,
 TX79_MMI3_PSRAVW  = (0x03 << 6) | TX79_MMI_CLASS_MMI3,
@@ -24683,7 +24683,7 @@ static void decode_opc_special3_legacy(CPUMIPSState 
*env, DisasContext *ctx)
 
 static void decode_tx79_mmi0(CPUMIPSState *env, DisasContext *ctx)
 {
-uint32_t opc = MASK_TX79_MMI0(ctx->opcode);
+uint32_t opc = MASK_MMI0(ctx->opcode);
 
 switch (opc) {
 case TX79_MMI0_PADDW: /* TODO: TX79_MMI0_PADDW */
@@ -24722,7 +24722,7 @@ static void decode_tx79_mmi0(CPUMIPSState *env, 
DisasContext *ctx)
 
 static void decode_tx79_mmi1(CPUMIPSState *env, DisasContext *ctx)
 {
-uint32_t opc = MASK_TX79_MMI1(ctx->opcode);
+uint32_t opc = MASK_MMI1(ctx->opcode);
 
 switch (opc) {
 case TX79_MMI1_PABSW: /* TODO: TX79_MMI1_PABSW */
@@ -24754,7 +24754,7 @@ static void decode_tx79_mmi1(CPUMIPSState *env, 
DisasContext *ctx)
 
 static void decode_tx79_mmi2(CPUMIPSState *env, DisasContext *ctx)
 {
-uint32_t opc = MASK_TX79_MMI2(ctx->opcode);
+uint32_t opc = MASK_MMI2(ctx->opcode);
 
 switch (opc) {
 case TX79_MMI2_PMADDW:/* TODO: TX79_MMI2_PMADDW */
@@ -24790,7 +24790,7 @@ static void decode_tx79_mmi2(CPUMIPSState *env, 
DisasContext *ctx)
 
 static void decode_tx79_mmi3(CPUMIPSState *env, DisasContext *ctx)
 {
-uint32_t opc = MASK_TX79_MMI3(ctx->opcode);
+uint32_t opc = MASK_MMI3(ctx->opcode);
 
 switch (opc) {
 case TX79_MMI3_PMADDUW:/* TODO: TX79_MMI3_PMADDUW */
@@ -24817,7 +24817,7 @@ static void decode_tx79_mmi3(CPUMIPSState *env, 
DisasContext *ctx)
 
 static void decode_tx79_mmi(CPUMIPSState *env, DisasContext *ctx)
 {
-uint32_t opc = MASK_TX79_MMI(ctx->opcode);
+uint32_t opc = MASK_MMI(ctx->opcode);
 int rs = extract32(ctx->opcode, 21, 5);
 int rt = extract32(ctx->opcode, 16, 5);
 int rd = extract32(ctx->opcode, 11, 5);
-- 
2.7.4




[Qemu-devel] [PATCH 2/3] target/mips: Rename MMI-related opcodes

2018-10-26 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Rename MMI-related opcodes.

Signed-off-by: Aleksandar Markovic 
---
 target/mips/translate.c | 470 
 1 file changed, 235 insertions(+), 235 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index e38d50d..4b008d8 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -2099,7 +2099,7 @@ enum {
  * The TX79-specific Multimedia Instruction encodings
  * ==
  *
- * TX79 Multimedia Instruction encoding table keys:
+ * MMI Instruction encoding table keys:
  *
  * *   This code is reserved for future use. An attempt to execute it
  * causes a Reserved Instruction exception.
@@ -2110,7 +2110,7 @@ enum {
  * DMULTU, DDIV, DDIVU, LL, LLD, SC, SCD, LWC2 and SWC2. An attempt
  * to execute it causes a Reserved Instruction exception.
  *
- * TX79 Multimedia Instructions encoded by opcode field (MMI, LQ, SQ):
+ * MMI Instructions encoded by opcode field (MMI, LQ, SQ):
  *
  *  31260
  * +++
@@ -2132,13 +2132,13 @@ enum {
  */
 
 enum {
-TX79_CLASS_MMI = 0x1C << 26,/* Same as OPC_SPECIAL2 */
-TX79_LQ= 0x1E << 26,/* Same as OPC_MSA */
-TX79_SQ= 0x1F << 26,/* Same as OPC_SPECIAL3 */
+MMI_CLASS_MMI = 0x1C << 26,/* Same as OPC_SPECIAL2 */
+MMI_LQ= 0x1E << 26,/* Same as OPC_MSA */
+MMI_SQ= 0x1F << 26,/* Same as OPC_SPECIAL3 */
 };
 
 /*
- * TX79 Multimedia Instructions with opcode field = MMI:
+ * MMI Instructions with opcode field = MMI:
  *
  *  3126 5  0
  * ++---++
@@ -2161,35 +2161,35 @@ enum {
 
 #define MASK_MMI(op) (MASK_OP_MAJOR(op) | ((op) & 0x3F))
 enum {
-TX79_MMI_MADD   = 0x00 | TX79_CLASS_MMI, /* Same as OPC_MADD */
-TX79_MMI_MADDU  = 0x01 | TX79_CLASS_MMI, /* Same as OPC_MADDU */
-TX79_MMI_PLZCW  = 0x04 | TX79_CLASS_MMI,
-TX79_MMI_CLASS_MMI0 = 0x08 | TX79_CLASS_MMI,
-TX79_MMI_CLASS_MMI2 = 0x09 | TX79_CLASS_MMI,
-TX79_MMI_MFHI1  = 0x10 | TX79_CLASS_MMI, /* Same minor as OPC_MFHI */
-TX79_MMI_MTHI1  = 0x11 | TX79_CLASS_MMI, /* Same minor as OPC_MTHI */
-TX79_MMI_MFLO1  = 0x12 | TX79_CLASS_MMI, /* Same minor as OPC_MFLO */
-TX79_MMI_MTLO1  = 0x13 | TX79_CLASS_MMI, /* Same minor as OPC_MTLO */
-TX79_MMI_MULT1  = 0x18 | TX79_CLASS_MMI, /* Same minor as OPC_MULT */
-TX79_MMI_MULTU1 = 0x19 | TX79_CLASS_MMI, /* Same minor as OPC_MULTU */
-TX79_MMI_DIV1   = 0x1A | TX79_CLASS_MMI, /* Same minor as OPC_DIV */
-TX79_MMI_DIVU1  = 0x1B | TX79_CLASS_MMI, /* Same minor as OPC_DIVU */
-TX79_MMI_MADD1  = 0x20 | TX79_CLASS_MMI,
-TX79_MMI_MADDU1 = 0x21 | TX79_CLASS_MMI,
-TX79_MMI_CLASS_MMI1 = 0x28 | TX79_CLASS_MMI,
-TX79_MMI_CLASS_MMI3 = 0x29 | TX79_CLASS_MMI,
-TX79_MMI_PMFHL  = 0x30 | TX79_CLASS_MMI,
-TX79_MMI_PMTHL  = 0x31 | TX79_CLASS_MMI,
-TX79_MMI_PSLLH  = 0x34 | TX79_CLASS_MMI,
-TX79_MMI_PSRLH  = 0x36 | TX79_CLASS_MMI,
-TX79_MMI_PSRAH  = 0x37 | TX79_CLASS_MMI,
-TX79_MMI_PSLLW  = 0x3C | TX79_CLASS_MMI,
-TX79_MMI_PSRLW  = 0x3E | TX79_CLASS_MMI,
-TX79_MMI_PSRAW  = 0x3F | TX79_CLASS_MMI,
+MMI_OPC_MADD   = 0x00 | MMI_CLASS_MMI, /* Same as OPC_MADD */
+MMI_OPC_MADDU  = 0x01 | MMI_CLASS_MMI, /* Same as OPC_MADDU */
+MMI_OPC_PLZCW  = 0x04 | MMI_CLASS_MMI,
+MMI_OPC_CLASS_MMI0 = 0x08 | MMI_CLASS_MMI,
+MMI_OPC_CLASS_MMI2 = 0x09 | MMI_CLASS_MMI,
+MMI_OPC_MFHI1  = 0x10 | MMI_CLASS_MMI, /* Same minor as OPC_MFHI */
+MMI_OPC_MTHI1  = 0x11 | MMI_CLASS_MMI, /* Same minor as OPC_MTHI */
+MMI_OPC_MFLO1  = 0x12 | MMI_CLASS_MMI, /* Same minor as OPC_MFLO */
+MMI_OPC_MTLO1  = 0x13 | MMI_CLASS_MMI, /* Same minor as OPC_MTLO */
+MMI_OPC_MULT1  = 0x18 | MMI_CLASS_MMI, /* Same minor as OPC_MULT */
+MMI_OPC_MULTU1 = 0x19 | MMI_CLASS_MMI, /* Same minor as OPC_MULTU */
+MMI_OPC_DIV1   = 0x1A | MMI_CLASS_MMI, /* Same minor as OPC_DIV */
+MMI_OPC_DIVU1  = 0x1B | MMI_CLASS_MMI, /* Same minor as OPC_DIVU */
+MMI_OPC_MADD1  = 0x20 | MMI_CLASS_MMI,
+MMI_OPC_MADDU1 = 0x21 | MMI_CLASS_MMI,
+MMI_OPC_CLASS_MMI1 = 0x28 | MMI_CLASS_MMI,
+MMI_OPC_CLASS_MMI3 = 0x29 | MMI_CLASS_MMI,
+MMI_OPC_PMFHL  = 0x30 | MMI_CLASS_MMI,
+MMI_OPC_PMTHL  = 0x31 | MMI_CLASS_MMI,
+MMI_OPC_PSLLH  = 0x34 | MMI_CLASS_MMI,
+MMI_OPC_PSRLH  = 0x36 | MMI_CLASS_MMI,
+MMI_OPC_PSRAH  = 0x37 | MMI_CLASS_MMI,
+MMI_OPC_PSLLW  = 0x3C | MMI_CLASS_MMI,
+MMI_OPC_PSRLW  = 0x3E | MMI_CLASS_MMI,
+MMI_OPC_PSRAW  = 0x3F | MMI_CLASS_MMI,
 };
 
 /*
- * TX79 Multimedia Instructions with opcode field 

Re: [Qemu-devel] [PATCH v1] bt: use size_t type for length parameters instead of int

2018-10-26 Thread P J P
+-- On Sun, 21 Oct 2018, P J P wrote --+
| The length parameter values are not negative, thus use an unsigned
| type 'size_t' for them. Many routines pass 'len' values to memcpy(3)
| calls. If it was negative, it could lead to memory corruption issues.
| Add check to avoid it.
| 
| Reported-by: Arash TC 
| Signed-off-by: Prasad J Pandit 
| ---
|  bt-host.c  |  8 +++---
|  bt-vhci.c  |  7 +++---
|  hw/bt/core.c   |  2 +-
|  hw/bt/hci-csr.c| 20 +++
|  hw/bt/hci.c| 38 ++--
|  hw/bt/hid.c| 10 
|  hw/bt/l2cap.c  | 56 ++
|  hw/bt/sdp.c|  6 ++---
|  hw/usb/dev-bluetooth.c | 12 -
|  include/hw/bt.h|  8 +++---
|  include/sysemu/bt.h| 10 
|  11 files changed, 90 insertions(+), 87 deletions(-)
| 
| Update v1: add assert check in vhci_host_send. Also check other places wherein
| length is used with fixed size buffers.
|   -> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg03831.html

Ping...!
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F



[Qemu-devel] [PATCH v1] lsi53c895a: check message length value is valid

2018-10-26 Thread P J P
From: Prasad J Pandit 

While writing a message in 'lsi_do_msgin', message length value
in 'msg_len' could be invalid. Add check to avoid OOB access issue.

Signed-off-by: Prasad J Pandit 
---
 hw/scsi/lsi53c895a.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Update v1: add .post_load routine and an assert() call
  -> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05730.html

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index d1e6534311..3a40e62853 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -861,12 +861,13 @@ static void lsi_do_status(LSIState *s)
 
 static void lsi_do_msgin(LSIState *s)
 {
-int len;
+uint8_t len;
 trace_lsi_do_msgin(s->dbc, s->msg_len);
 s->sfbr = s->msg[0];
 len = s->msg_len;
 if (len > s->dbc)
 len = s->dbc;
+assert(len <= LSI_MAX_MSGIN_LEN);
 pci_dma_write(PCI_DEVICE(s), s->dnad, s->msg, len);
 /* Linux drivers rely on the last byte being in the SIDL.  */
 s->sidl = s->msg[len - 1];
@@ -2103,11 +2104,23 @@ static int lsi_pre_save(void *opaque)
 return 0;
 }
 
+static int lsi_post_load(void *opaque, int version_id)
+{
+LSIState *s = opaque;
+
+if (s->msg_len < 0 || s->msg_len > LSI_MAX_MSGIN_LEN) {
+return -EINVAL;
+}
+
+return 0;
+}
+
 static const VMStateDescription vmstate_lsi_scsi = {
 .name = "lsiscsi",
 .version_id = 0,
 .minimum_version_id = 0,
 .pre_save = lsi_pre_save,
+.post_load = lsi_post_load,
 .fields = (VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, LSIState),
 
-- 
2.17.2




Re: [Qemu-devel] [PULL v2 00/28] pci, pc, virtio: fixes, features

2018-10-26 Thread Peter Maydell
On 26 October 2018 at 14:26, Singh, Brijesh  wrote:
>
>
> On 10/25/2018 07:59 PM, Michael S. Tsirkin wrote:
>> On Thu, Oct 25, 2018 at 08:16:44PM +0100, Peter Maydell wrote:
>>> These should presumably all be "ULL". (The "UL" suffix is
>>> usually a bug, as it's either unnecessary or should be ULL.)
>>
>> Yea.  Fixed. Brijesh could you start cleaning up that header generally?
>> It has all kind of weird code like using bitfields for hardware
>> accesses. That isn't portable - switch to full dword fields with shift
>> and | to operate them and proper cpu_to_le APIs or similar please.
>>
>
>
> Noted, I will look into cleaning up this and send patches for reviews.

Thanks. You might like to look at the extract32()/extract64()/
deposit32()/deposit64() functions in bitops.h, which are often (but not
always) cleaner than hand-rolled shifts-and-logical-ops for assembling
and disassembling fields.

thanks
-- PMM



Re: [Qemu-devel] [PULL v2 00/43] Machine queue, 2018-10-25

2018-10-26 Thread Peter Maydell
On 25 October 2018 at 14:32, Eduardo Habkost  wrote:
> Changes v1 -> v2:
> * Fix 'make check' warnings (Igor)
>
>
> The following changes since commit 13399aad4fa87b2878c49d02a5d3bafa6c966ba3:
>
>   Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-10-22' 
> into staging (2018-10-23 17:20:23 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/ehabkost/qemu.git tags/machine-next-pull-request
>
> for you to fetch changes up to 8fa922c241e63f018f5b55c03ac494ae3d5fe594:
>
>   net: xgmac: convert SysBus init method to a realize method (2018-10-24 
> 06:44:59 -0300)
>
> 
> Machine queue, 2018-10-25
>
> * sysbus init/realize cleanups
>   (Cédric Le Goater, Philippe Mathieu-Daudé)
> * memory-device refactoring (David Hildenbrand)
> * -smp: deprecate incorrect CPUs topology (Igor Mammedov)
> * -numa parsing cleanups (Markus Armbruster)
> * Fix hostmem-file memory leak (Zhang Yi)
> * Typo fix (Li Qiang)
>
> 
>
> Queue for Machine Core patches
>

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCH 5/6] Determine the desired FPU mode

2018-10-26 Thread Aleksandar Markovic
> From: Peter Maydell 
> Subject: Re: [Qemu-devel] [PATCH 5/6] Determine the desired FPU mode
> 
> On 26 October 2018 at 15:21, Stefan Markovic  
> wrote:
> > From: Stefan Markovic 
> >
> > Floating-point mode is calculated from MIPS.abiflags FP ABI value
> > (based on kernel implementation). Illegal combinations are rejected.
> >
> > Signed-off-by: Stefan Markovic 
> > ---
> >  linux-user/mips/cpu_loop.c | 75 
> > ++
> >  1 file changed, 75 insertions(+)
> 
> > + if ((info->fp_abi > MAX_FP_ABI && info->fp_abi != MIPS_ABI_FP_UNKNOWN)
> > +|| (info->interp_fp_abi > MAX_FP_ABI &&
> > +info->interp_fp_abi != MIPS_ABI_FP_UNKNOWN)) {
> > +fprintf(stderr, "qemu: Program and interpreter have "
> > +"unexpected FPU modes\n");
> > +exit(137);
> 
> Why are we exit()ing with a funny exit status code here?
> 
> If this is a "can't happen" case, then we should assert(). If
> it is a "can happen if fed an odd binary" case, then we should just
> exit(1) as we do already in this function for an unsupported NaN mode.
> 

Thanks for the review.

This is a "can happen if fed an odd binary" case. Or, in other words, and more 
precisely, an executable compiled with one FP option attempts to load a library 
compiled with another, incompatible, FP option.

Kernel counterpart lines are:

https://elixir.bootlin.com/linux/v4.19/source/arch/mips/kernel/elf.c#L211
https://elixir.bootlin.com/linux/v4.19/source/arch/mips/kernel/elf.c#L263

I think the error code is important for MIPS loader to work as designed in such 
cases. Stefan should be best positioned to explain and analyze the cases, since 
he worked on verifying and fixing involved scenarios, not only from QEMU 
perspective. However, he will be back most likely only on Monday.

Thanks again,
Aleksandar

> > +}
> > +
> > +prog_req = (info->fp_abi == MIPS_ABI_FP_UNKNOWN) ? none_req
> > +: fpu_reqs[info->fp_abi];
> > +interp_req = (info->interp_fp_abi == MIPS_ABI_FP_UNKNOWN) ? none_req
> > +: 
> > fpu_reqs[info->interp_fp_abi];
> > +
> > +prog_req.single &= interp_req.single;
> > +prog_req.soft &= interp_req.soft;
> > +prog_req.fr1 &= interp_req.fr1;
> > +prog_req.frdefault &= interp_req.frdefault;
> > +prog_req.fre &= interp_req.fre;
> > +
> > +bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
> > +  env->insn_flags & ISA_MIPS64R2 ||
> > +  env->insn_flags & ISA_MIPS32R6 ||
> > +  env->insn_flags & ISA_MIPS64R6;
> > +
> > +if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) {
> > +env->CP0_Config5 |= (1 << CP0C5_FRE);
> > +if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) {
> > +env->hflags |= MIPS_HFLAG_FRE;
> > +}
> > +} else if ((prog_req.fr1 && prog_req.frdefault) ||
> > + (prog_req.single && !prog_req.frdefault)) {
> > +if ((env->active_fpu.fcr0 & (1 << FCR0_F64)
> > +&& cpu_has_mips_r2_r6) || prog_req.fr1) {
> > +env->CP0_Status |= (1 << CP0St_FR);
> > +env->hflags |= MIPS_HFLAG_F64;
> > +}
> > +} else  if (!prog_req.fre && !prog_req.frdefault &&
> > +  !prog_req.fr1 && !prog_req.single && !prog_req.soft) {
> > +exit(137);
> > +}
> 
> Ditto here (and we haven't printed any error message here...)
> 
> thanks
> -- PMM
> 


Re: [Qemu-devel] [PATCH] lsi53c895a: check message length value

2018-10-26 Thread P J P
+-- On Fri, 26 Oct 2018, Mark Kanda wrote --+
| Yes, please use that acknowledgement text in lieu of a 'Reported-by' line.

Okay, thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F



Re: [Qemu-devel] [PATCH 3/3] cirrus: mark as deprecated

2018-10-26 Thread P J P
+-- On Fri, 26 Oct 2018, Daniel P. Berrangé wrote --+
| ... 
| One thing we should do, however, is to make it clear which of the
| device models we consider secure, and which we consider only usable
| in a friendly guest environment, as we have very different code
| maintainership & quality standards for different parts of QEMU.
| 
| Essentially virtio devices, and then only a handful of the emulated
| devices are things we consider suitable for usage in secure envs.
| Likewise for machine types probably.

True, +1.

It did come up in another thread. It'll surely be helpful to list these 
professional and friendly components. 'Professional' being production ready 
and thus security relevant. And 'Friendly' being experimental or not suitable 
for production usage. Maybe like staging drivers in the kernel tree. They are 
available for use but not considered production ready and thus are not 
security relevant.

To be clear, irrespective of professional or friendly, we strive to fix every 
single issue that is found and/or reported. Only difference is, professional 
ones are tracked by a CVE ID and friendly ones are fixed as bug fixes, not 
tracked by CVE ID.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F


Re: [Qemu-devel] [PATCH v2] migration: avoid segmentfault when take a snapshot of a VM which being migrated

2018-10-26 Thread Dr. David Alan Gilbert
* Jia Lina (jialin...@baidu.com) wrote:
> During an active background migration, snapshot will trigger a
> segmentfault. As snapshot clears the "current_migration" struct
> and updates "to_dst_file" before it finds out that there is a
> migration task, Migration accesses the null pointer in
> "current_migration" struct and qemu crashes eventually.
> 
> Signed-off-by: Jia Lina 
> Signed-off-by: Chai Wen 
> Signed-off-by: Zhang Yu 

Thanks, that looks better.



Reviewed-by: Dr. David Alan Gilbert 

> ---
>  migration/migration.c |  2 +-
>  migration/migration.h |  2 ++
>  migration/savevm.c| 19 +++
>  3 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index d6ae879dc8..b5e71c7bfc 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -711,7 +711,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error 
> **errp)
>   * Return true if we're already in the middle of a migration
>   * (i.e. any of the active or setup states)
>   */
> -static bool migration_is_setup_or_active(int state)
> +bool migration_is_setup_or_active(int state)
>  {
>  switch (state) {
>  case MIGRATION_STATUS_ACTIVE:
> diff --git a/migration/migration.h b/migration/migration.h
> index f7813f8261..e413d4d8b6 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -241,6 +241,8 @@ void migrate_fd_error(MigrationState *s, const Error 
> *error);
>  
>  void migrate_fd_connect(MigrationState *s, Error *error_in);
>  
> +bool migration_is_setup_or_active(int state);
> +
>  void migrate_init(MigrationState *s);
>  bool migration_is_blocked(Error **errp);
>  /* True if outgoing migration has entered postcopy phase */
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 2d10e45582..eeade8cb92 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1319,21 +1319,25 @@ static int qemu_savevm_state(QEMUFile *f, Error 
> **errp)
>  MigrationState *ms = migrate_get_current();
>  MigrationStatus status;
>  
> -migrate_init(ms);
> -
> -ms->to_dst_file = f;
> +if (migration_is_setup_or_active(ms->state) ||
> +ms->state == MIGRATION_STATUS_CANCELLING ||
> +ms->state == MIGRATION_STATUS_COLO) {
> +error_setg(errp, QERR_MIGRATION_ACTIVE);
> +return -EINVAL;
> +}
>  
>  if (migration_is_blocked(errp)) {
> -ret = -EINVAL;
> -goto done;
> +return -EINVAL;
>  }
>  
>  if (migrate_use_block()) {
>  error_setg(errp, "Block migration and snapshots are incompatible");
> -ret = -EINVAL;
> -goto done;
> +return -EINVAL;
>  }
>  
> +migrate_init(ms);
> +ms->to_dst_file = f;
> +
>  qemu_mutex_unlock_iothread();
>  qemu_savevm_state_header(f);
>  qemu_savevm_state_setup(f);
> @@ -1355,7 +1359,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>  error_setg_errno(errp, -ret, "Error while writing VM state");
>  }
>  
> -done:
>  if (ret != 0) {
>  status = MIGRATION_STATUS_FAILED;
>  } else {
> -- 
> 2.13.2.windows.1
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] [PATCH] lsi53c895a: check message length value

2018-10-26 Thread Mark Kanda

On 10/26/2018 1:37 PM, P J P wrote:

+-- On Fri, 26 Oct 2018, Mark Kanda wrote --+
| Deja vu requested that we include the following text in the commit message:
|
|   Discovered by Deja vu Security. Reported by Oracle.
|
| Would that be acceptable?

Generally an email-id is used/preferred in the commit log message. We could
use above for acknowledgement and avoid Reported-by in the commit log message
if that suits Deja vu team.

Please let me know your/their preference.



Yes, please use that acknowledgement text in lieu of a 'Reported-by' line.

Thanks,

-Mark



Re: [Qemu-devel] [PATCH] lsi53c895a: check message length value

2018-10-26 Thread P J P
+-- On Fri, 26 Oct 2018, Mark Kanda wrote --+
| Deja vu requested that we include the following text in the commit message:
| 
|   Discovered by Deja vu Security. Reported by Oracle.
| 
| Would that be acceptable?

Generally an email-id is used/preferred in the commit log message. We could 
use above for acknowledgement and avoid Reported-by in the commit log message 
if that suits Deja vu team.

Please let me know your/their preference.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F



[Qemu-devel] [PATCH] decodetree: Allow multiple input files

2018-10-26 Thread Richard Henderson
While it would be possible to concatenate input files with make,
passing the original input files to decodetree.py allows us to
generate error messages which allows compilation environments
(read: emacs) to next-error to the correct input file.

Signed-off-by: Richard Henderson 
---

Bastian, I think this makes splitting the decode file even nicer.
No temp file in the build tree, and better error messages.

The makefile fragment now becomes e.g.

target/riscv/decode_insn32.inc.c: $(decode32-y) $(DECODETREE)
$(call quiet-command, \
  $(PYTHON) $(DECODETREE) -o $@ --decode decode_insn32 $(decode32-y), \
  "GEN", $(TARGET_DIR)$@)

Also, I think that the rv64g insns should be in insn32-64.decode,
mirroring insn16-64.decode, and leaving insn64.decode free for an
actual 64-bit instruction word, as aluded to in the "Extending RISC-V"
section of the manual.

I've included this with the other two pending decodetree patches at

  https://github.com/rth7680/qemu.git decodetree


r~

---
 scripts/decodetree.py | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index c0bb447095..f60f1b0ab6 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -177,15 +177,15 @@ decode_function = 'decode'
 re_ident = '[a-zA-Z][a-zA-Z0-9_]*'
 
 
-def error(lineno, *args):
+def error_with_file(file, lineno, *args):
 """Print an error message from file:line and args and exit."""
 global output_file
 global output_fd
 
 if lineno:
-r = '{0}:{1}: error:'.format(input_file, lineno)
+r = '{0}:{1}: error:'.format(file, lineno)
 elif input_file:
-r = '{0}: error:'.format(input_file)
+r = '{0}: error:'.format(file)
 else:
 r = 'error:'
 for a in args:
@@ -197,6 +197,8 @@ def error(lineno, *args):
 os.remove(output_file)
 exit(1)
 
+def error(lineno, *args):
+error_with_file(input_file, lineno, args)
 
 def output(*args):
 global output_fd
@@ -422,6 +424,7 @@ class General:
 """Common code between instruction formats and instruction patterns"""
 def __init__(self, name, lineno, base, fixb, fixm, udfm, fldm, flds):
 self.name = name
+self.file = input_file
 self.lineno = lineno
 self.base = base
 self.fixedbits = fixb
@@ -474,7 +477,7 @@ class Pattern(General):
 global translate_prefix
 ind = str_indent(i)
 arg = self.base.base.name
-output(ind, '/* line ', str(self.lineno), ' */\n')
+output(ind, '/* ', self.file, ':', str(self.lineno), ' */\n')
 if not extracted:
 output(ind, self.base.extract_name(), '(_', arg, ', insn);\n')
 for n, f in self.fields.items():
@@ -922,8 +925,9 @@ def build_tree(pats, outerbits, outermask):
 if innermask == 0:
 pnames = []
 for p in pats:
-pnames.append(p.name + ':' + str(p.lineno))
-error(pats[0].lineno, 'overlapping patterns:', pnames)
+pnames.append(p.name + ':' + p.file + ':' + str(p.lineno))
+error_with_file(pats[0].file, pats[0].lineno,
+'overlapping patterns:', pnames)
 
 fullmask = outermask | innermask
 
@@ -1014,10 +1018,11 @@ def main():
 
 if len(args) < 1:
 error(0, 'missing input file')
-input_file = args[0]
-f = open(input_file, 'r')
-parse_file(f)
-f.close()
+for filename in args:
+input_file = filename
+f = open(filename, 'r')
+parse_file(f)
+f.close()
 
 t = build_tree(patterns, 0, 0)
 prop_format(t)
-- 
2.17.2




Re: [Qemu-devel] [PATCH] target/riscv/pmp.c: pmpcfg_csr_read returns bogus value on RV64

2018-10-26 Thread Dayeol Lee
Hi,

I submitted the patch, but just found this has been already fixed by
Michael Clark
and pushed to riscv/riscv-qemu https://github.com/riscv/riscv-qemu/pull/166
but not in the upstream.

Do we still need this patch?

Thanks,

Dayeol

On Fri, Oct 26, 2018 at 11:04 AM Dayeol Lee  wrote:

> pmp_read_cfg() returns 8-bit value, which is combined together to form a
> single pmpcfg CSR.
> The default promotion rules will result in an integer here ("i*8" is
> integer, which
> flows through) resulting in a 32-bit signed value on most hosts.
> That's bogus on RV64I, with the high bits of the CSR being wrong.
>
> Signed-off-by: Dayeol Lee 
> Reviewed-by: Palmer Dabbelt 
> ---
>  target/riscv/pmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
> index c828950..3d3906a 100644
> --- a/target/riscv/pmp.c
> +++ b/target/riscv/pmp.c
> @@ -330,7 +330,7 @@ target_ulong pmpcfg_csr_read(CPURISCVState *env,
> uint32_t reg_index)
>  {
>  int i;
>  target_ulong cfg_val = 0;
> -uint8_t val = 0;
> +target_ulong val = 0;
>
>  if(sizeof(target_ulong) == 8)
>  reg_index /= 2;
> --
> 2.7.4
>
>


Re: [Qemu-devel] [PATCH 5/6] Determine the desired FPU mode

2018-10-26 Thread Peter Maydell
On 26 October 2018 at 15:21, Stefan Markovic  wrote:
> From: Stefan Markovic 
>
> Floating-point mode is calculated from MIPS.abiflags FP ABI value
> (based on kernel implementation). Illegal combinations are rejected.
>
> Signed-off-by: Stefan Markovic 
> ---
>  linux-user/mips/cpu_loop.c | 75 
> ++
>  1 file changed, 75 insertions(+)

> + if ((info->fp_abi > MAX_FP_ABI && info->fp_abi != MIPS_ABI_FP_UNKNOWN)
> +|| (info->interp_fp_abi > MAX_FP_ABI &&
> +info->interp_fp_abi != MIPS_ABI_FP_UNKNOWN)) {
> +fprintf(stderr, "qemu: Program and interpreter have "
> +"unexpected FPU modes\n");
> +exit(137);

Why are we exit()ing with a funny exit status code here?

If this is a "can't happen" case, then we should assert(). If
it is a "can happen if fed an odd binary" case, then we should just
exit(1) as we do already in this function for an unsupported NaN mode.

> +}
> +
> +prog_req = (info->fp_abi == MIPS_ABI_FP_UNKNOWN) ? none_req
> +: fpu_reqs[info->fp_abi];
> +interp_req = (info->interp_fp_abi == MIPS_ABI_FP_UNKNOWN) ? none_req
> +: fpu_reqs[info->interp_fp_abi];
> +
> +prog_req.single &= interp_req.single;
> +prog_req.soft &= interp_req.soft;
> +prog_req.fr1 &= interp_req.fr1;
> +prog_req.frdefault &= interp_req.frdefault;
> +prog_req.fre &= interp_req.fre;
> +
> +bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
> +  env->insn_flags & ISA_MIPS64R2 ||
> +  env->insn_flags & ISA_MIPS32R6 ||
> +  env->insn_flags & ISA_MIPS64R6;
> +
> +if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) {
> +env->CP0_Config5 |= (1 << CP0C5_FRE);
> +if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) {
> +env->hflags |= MIPS_HFLAG_FRE;
> +}
> +} else if ((prog_req.fr1 && prog_req.frdefault) ||
> + (prog_req.single && !prog_req.frdefault)) {
> +if ((env->active_fpu.fcr0 & (1 << FCR0_F64)
> +&& cpu_has_mips_r2_r6) || prog_req.fr1) {
> +env->CP0_Status |= (1 << CP0St_FR);
> +env->hflags |= MIPS_HFLAG_F64;
> +}
> +} else  if (!prog_req.fre && !prog_req.frdefault &&
> +  !prog_req.fr1 && !prog_req.single && !prog_req.soft) {
> +exit(137);
> +}

Ditto here (and we haven't printed any error message here...)

thanks
-- PMM



[Qemu-devel] [PATCH] target/riscv/pmp.c: pmpcfg_csr_read returns bogus value on RV64

2018-10-26 Thread Dayeol Lee
pmp_read_cfg() returns 8-bit value, which is combined together to form a single 
pmpcfg CSR. 
The default promotion rules will result in an integer here ("i*8" is integer, 
which
flows through) resulting in a 32-bit signed value on most hosts.
That's bogus on RV64I, with the high bits of the CSR being wrong.

Signed-off-by: Dayeol Lee 
Reviewed-by: Palmer Dabbelt 
---
 target/riscv/pmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index c828950..3d3906a 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -330,7 +330,7 @@ target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t 
reg_index)
 {
 int i;
 target_ulong cfg_val = 0;
-uint8_t val = 0;
+target_ulong val = 0;
 
 if(sizeof(target_ulong) == 8)
 reg_index /= 2;
-- 
2.7.4




Re: [Qemu-devel] [PATCH 0/6] target/mips: Add support for prctl() PR_GET_FP_MODE and PR_SET_FP_MODE

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 0/6] target/mips: Add support for prctl() PR_GET_FP_MODE and 
> PR_SET_FP_MODE
> 
> From: Stefan Markovic 
> 
> This series includes support for prctl() PR_GET_FP_MODE and PR_SET_FP_MODE.
> This requires extracting MIPS.abiflags section from ELF file and fp_abi value 
> handling.
> 
> Stefan Markovic (6):
>   Define MIPS_ABI_FP_UNKNOWN macro
>   Extend image_info struct with MIPS specific fp_abi and interp_fp_abi fields
>   Extract MIPS abiflags from ELF file
>   Read and set FP ABI value from MIPS abiflags
>   Determine the desired FPU mode
>   Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE implementations
> 
>  include/elf.h  |  2 +
>  linux-user/elfload.c   | 37 +++
>  linux-user/mips/cpu_loop.c | 75 
> ++
>  linux-user/mips/target_syscall.h   |  2 +
>  linux-user/mips64/target_syscall.h |  2 +
>  linux-user/qemu.h  |  4 ++
>  linux-user/syscall.c   | 62 +--
>  7 files changed, 180 insertions(+), 4 deletions(-)
> 
> --
> 1.9.1
> 


Hi, Laurent,

Here is a mini-series about a MIPS-specific linux-user feature. Its code is 
almost entirely either in MIPS-specific files or under "#ifdef MIPS" 
directives. I think it makes sense that I should be able to integrate them via 
MIPS queue. Please let me know if you object to this.

You probably wonder why so much code for such obscure feature. The answer is 
that the solution needs to follow and mimic corresponding solution in 
MIPS-specific parts of the kernel, and its complexity is determined by that.

Thanks,
Aleksandar



Re: [Qemu-devel] [PATCH v2] ppc/pnv: check size before data buffer access

2018-10-26 Thread Cédric Le Goater
On 10/26/18 2:33 PM, P J P wrote:
> From: Prasad J Pandit 
> 
> While performing PowerNV memory r/w operations, the access length
> 'sz' could exceed the data[4] buffer size. Add check to avoid OOB
> access.
> 
> Reported-by: Moguofang 
> Signed-off-by: Prasad J Pandit 

Reviewed-by: Cédric Le Goater 

Thanks,

C.


> ---
>  hw/ppc/pnv_lpc.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> Update v2: add error log message
>   -> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05750.html
> 
> diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
> index d7721320a2..172a915cfc 100644
> --- a/hw/ppc/pnv_lpc.c
> +++ b/hw/ppc/pnv_lpc.c
> @@ -155,9 +155,15 @@ static void pnv_lpc_do_eccb(PnvLpcController *lpc, 
> uint64_t cmd)
>  /* XXX Check for magic bits at the top, addr size etc... */
>  unsigned int sz = (cmd & ECCB_CTL_SZ_MASK) >> ECCB_CTL_SZ_LSH;
>  uint32_t opb_addr = cmd & ECCB_CTL_ADDR_MASK;
> -uint8_t data[4];
> +uint8_t data[8];
>  bool success;
>  
> +if (sz > sizeof(data)) {
> +qemu_log_mask(LOG_GUEST_ERROR,
> +"ECCB: invalid operation at @0x%08x size %d\n", opb_addr, sz);
> +return;
> +}
> +
>  if (cmd & ECCB_CTL_READ) {
>  success = opb_read(lpc, opb_addr, data, sz);
>  if (success) {
> 




Re: [Qemu-devel] [PATCH 1/6] Define MIPS_ABI_FP_UNKNOWN macro

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 1/6] Define MIPS_ABI_FP_UNKNOWN macro
> 
> From: Stefan Markovic 
> 
> Signed-off-by: Stefan Markovic 
> ---

A brief commit message is needed. From what kernel or glibc header is this 
constant copied? Other than that:

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [PATCH 2/6] Extend image_info struct with MIPS specific fp_abi and interp_fp_abi fields

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 2/6] Extend image_info struct with MIPS specific fp_abi and 
> interp_fp_abi fields
> 
> From: Stefan Markovic 
> 
> Signed-off-by: Stefan Markovic 
> ---

A brief commit message is needed. Perhaps with the description of the 
role/purpose of two fields introduced in this patch. Other than that:

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [PATCH 3/6] Extract MIPS abiflags from ELF file

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 3/6] Extract MIPS abiflags from ELF file
> 
> From: Stefan Markovic 
> 
> Signed-off-by: Stefan Markovic 
> ---

A brief commit message is needed. Other than that:

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [RFC v4 70/71] cpus-common: move exclusive_idle higher in the file

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> This will simplify the following commit's diff.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  cpus-common.c | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [RFC v4 36/71] arm: convert to cpu_interrupt_request

2018-10-26 Thread Emilio G. Cota
On Fri, Oct 26, 2018 at 14:39:21 +0100, Alex Bennée wrote:
> 
> Emilio G. Cota  writes:
> 
> > Cc: Peter Maydell 
> 
> This will need to catch-up in the next re-base as there is a merge conflict.

Yep, this series is so long that I decided to keep the same
baseline as in v3, so that I could just git diff the two
branches to track the delta.

I'll rebase on master in the next iteration.

Thanks,

Emilio



Re: [Qemu-devel] [RFC v4 68/71] cpu: add async_run_on_cpu_no_bql

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Some async jobs do not need the BQL.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h | 14 ++
>  cpus-common.c | 39 ++-
>  2 files changed, 48 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [PATCH 4/6] Read and set FP ABI value from MIPS abiflags

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 4/6] Read and set FP ABI value from MIPS abiflags
>
> From: Stefan Markovic 
> 
> Signed-off-by: Stefan Markovic 
> ---

A short commit message is needed. Other than that:

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [RFC v4 65/71] xtensa: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: Max Filippov 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/xtensa/cpu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [PATCH 5/6] Determine the desired FPU mode

2018-10-26 Thread Aleksandar Markovic
> Subject: [PATCH 5/6] Determine the desired FPU mode
> 
> From: Stefan Markovic 
> 
> Floating-point mode is calculated from MIPS.abiflags FP ABI value
> (based on kernel implementation). Illegal combinations are rejected.
> 
> Signed-off-by: Stefan Markovic 
> ---

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [RFC v4 67/71] cpus-common: release BQL earlier in run_on_cpu

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> After completing the conversion to per-CPU locks, there is no need
> to release the BQL after having called cpu_kick.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  cpus-common.c | 20 +---
>  1 file changed, 5 insertions(+), 15 deletions(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [PATCH 6/6] Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE implementations

2018-10-26 Thread Aleksandar Markovic
> From: Stefan Markovic 
> Subject: [PATCH 6/6] Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE 
> implementations
> 
> From: Stefan Markovic 
> 
> Signed-off-by: Stefan Markovic 

>  #define TARGET_PR_SET_FP_MODE  45
>  #define TARGET_PR_GET_FP_MODE  46
> +#define TARGET_PR_FP_MODE_FR  (1 << 0)
> +#define TARGET_PR_FP_MODE_FRE (1 << 1)

There should be one space more to the left of (1 << 0) and (1 << 1) to achieve 
nicer alignment.

A short commit message is needed too. Other than that:

Reviewed-by: Aleksandar Markovic 



Re: [Qemu-devel] [RFC v4 58/71] cpu: call .cpu_has_work with the CPU lock held

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [RFC v4 64/71] sparc: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: Mark Cave-Ayland 
> Cc: Artyom Tarasenko 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/sparc/cpu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [RFC v4 63/71] riscv: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: Michael Clark 
> Cc: Palmer Dabbelt 
> Cc: Sagar Karandikar 
> Cc: Bastian Koppelmann 
> Reviewed-by: Palmer Dabbelt 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/riscv/cpu.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 11/20] cpu.h: fix a typo in comment

2018-10-26 Thread Laurent Vivier
From: Li Qiang 

Found by reading the code.

Signed-off-by: Li Qiang 
Message-Id: <1536150548-2797-1-git-send-email-liq...@gmail.com>
Signed-off-by: Laurent Vivier 
---
 include/qom/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 4e238b0d9f..def0c64308 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -852,7 +852,7 @@ extern CPUInterruptHandler cpu_interrupt_handler;
 /**
  * cpu_interrupt:
  * @cpu: The CPU to set an interrupt on.
- * @mask: The interupts to set.
+ * @mask: The interrupts to set.
  *
  * Invokes the interrupt handler.
  */
-- 
2.17.2




Re: [Qemu-devel] [RFC v4 62/71] s390x: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: Cornelia Huck 
> Cc: Alexander Graf 
> Cc: David Hildenbrand 
> Cc: qemu-s3...@nongnu.org
> Signed-off-by: Emilio G. Cota 
> ---
>  target/s390x/cpu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~





Re: [Qemu-devel] [RFC v4 61/71] mips: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: Aurelien Jarno 
> Cc: Aleksandar Markovic 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/mips/cpu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 07/20] scripts/decodetree.py: remove unused imports

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

Signed-off-by: Cleber Rosa 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181004161852.11673-8-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 scripts/decodetree.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index 277f9a9bba..457cffea90 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -149,12 +149,10 @@
 #   trans_addl_i(ctx, _opi, insn)
 #
 
-import io
 import os
 import re
 import sys
 import getopt
-import pdb
 
 insnwidth = 32
 insnmask = 0x
-- 
2.17.2




[Qemu-devel] [PULL 05/20] qemu-iotests: fix filename containing checks

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

Commit cce293a2945 moved some functions from common.config to
common.rc, but the error messages still reference the old file
location.

Signed-off-by: Cleber Rosa 
Reviewed-by: Max Reitz 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181004161852.11673-5-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 tests/qemu-iotests/common.rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 44bee16a5e..70ca65b49b 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -170,7 +170,7 @@ if [ ! -e "$TEST_DIR" ]; then
 fi
 
 if [ ! -d "$TEST_DIR" ]; then
-echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
+echo "common.rc: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
 exit 1
 fi
 
@@ -179,7 +179,7 @@ if [ -z "$REMOTE_TEST_DIR" ]; then
 fi
 
 if [ ! -d "$SAMPLE_IMG_DIR" ]; then
-echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a 
directory"
+echo "common.rc: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a 
directory"
 exit 1
 fi
 
-- 
2.17.2




Re: [Qemu-devel] [RFC v4 60/71] ppc: convert to cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Soon we will call cpu_has_work without the BQL.
> 
> Cc: David Gibson 
> Cc: Alexander Graf 
> Cc: qemu-...@nongnu.org
> Signed-off-by: Emilio G. Cota 
> ---
>  target/ppc/translate_init.inc.c | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 06/20] docs/devel/testing.rst: add missing newlines after code block

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

The line immediate following a ".. code::" block is considered
to contains arguments to the "code directive".  The lack of a
new line gives me during at parse time:

   testing.rst:63: (ERROR/3) Error in "code" directive:
   maximum 1 argument(s) allowed, 3 supplied.

   .. code::
 make check-unit V=1

   testing.rst:120: (ERROR/3) Error in "code" directive:
   maximum 1 argument(s) allowed, 3 supplied.

   .. code::
 make check-qtest V=1

Let's add the missing newlines, both for consistency and to
avoid the parsing errors.

Signed-off-by: Cleber Rosa 
Reviewed-by: John Snow 
Message-Id: <20181004161852.11673-6-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 docs/devel/testing.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index fcfad87614..a227754f86 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -59,6 +59,7 @@ variable (which affects memory reclamation and catches 
invalid pointers better)
 and gtester options. If necessary, you can run
 
 .. code::
+
   make check-unit V=1
 
 and copy the actual command line which executes the unit test, then run
@@ -116,6 +117,7 @@ and using gdb on the test is still simple to do: find out 
the actual command
 from the output of
 
 .. code::
+
   make check-qtest V=1
 
 which you can run manually.
-- 
2.17.2




[Qemu-devel] [PULL 19/20] milkymist-minimac2: Use qemu_log_mask(GUEST_ERROR) instead of error_report

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

qemu_log_mask(GUEST_ERROR) is more appropriate:

  $ qemu -d help
  Log items (comma separated):
  guest_errorslog when the guest OS does something invalid (eg accessing a 
non-existent register)

Signed-off-by: Philippe Mathieu-Daudé 
Acked-by: Michael Walle 
Message-Id: <20180702014022.12395-1-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 hw/net/milkymist-minimac2.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c
index 3eaa19dfde..322fb77e46 100644
--- a/hw/net/milkymist-minimac2.c
+++ b/hw/net/milkymist-minimac2.c
@@ -30,6 +30,7 @@
 #include "hw/sysbus.h"
 #include "trace.h"
 #include "net/net.h"
+#include "qemu/log.h"
 #include "qemu/error-report.h"
 
 #include 
@@ -214,7 +215,8 @@ static size_t assemble_frame(uint8_t *buf, size_t size,
 uint32_t crc;
 
 if (size < payload_size + 12) {
-error_report("milkymist_minimac2: received too big ethernet frame");
+qemu_log_mask(LOG_GUEST_ERROR, "milkymist_minimac2: frame too big "
+  "(%zd bytes)\n", payload_size);
 return 0;
 }
 
@@ -347,8 +349,9 @@ minimac2_read(void *opaque, hwaddr addr, unsigned size)
 break;
 
 default:
-error_report("milkymist_minimac2: read access to unknown register 0x"
-TARGET_FMT_plx, addr << 2);
+qemu_log_mask(LOG_GUEST_ERROR,
+  "milkymist_minimac2_rd%d: 0x%" HWADDR_PRIx "\n",
+  size, addr << 2);
 break;
 }
 
@@ -413,8 +416,9 @@ minimac2_write(void *opaque, hwaddr addr, uint64_t value,
 break;
 
 default:
-error_report("milkymist_minimac2: write access to unknown register 0x"
-TARGET_FMT_plx, addr << 2);
+qemu_log_mask(LOG_GUEST_ERROR,
+  "milkymist_minimac2_wr%d: 0x%" HWADDR_PRIx " = 0x%lx\n",
+  size, addr << 2, value);
 break;
 }
 }
-- 
2.17.2




Re: [Qemu-devel] [RFC v4 59/71] cpu: introduce cpu_has_work_with_iothread_lock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> It will gain some users soon.
> 
> Suggested-by: Paolo Bonzini 
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h | 36 +---
>  1 file changed, 33 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 00/20] Trivial patches patches

2018-10-26 Thread Laurent Vivier
The following changes since commit 808ebd66e467f77c0d1f8c6346235f81e9c99cf2:

  Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-sf0' 
into staging (2018-10-25 17:41:03 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/trivial-patches-pull-request

for you to fetch changes up to 4b03da6e87c34793137a231b558231fd406c05e8:

  ppc: move at24c to its own CONFIG_ symbol (2018-10-26 17:17:32 +0200)


QEMU trivial patches collected between June and October 2018
(Thank you to Thomas Huth)



Cleber Rosa (6):
  tests/tcg/README: fix location for lm32 tests
  qemu-iotests: fix filename containing checks
  docs/devel/testing.rst: add missing newlines after code block
  scripts/decodetree.py: remove unused imports
  scripts/qemu.py: remove trailing quotes on docstring
  qemu-iotests: make 218 executable

Emilio G. Cota (1):
  linux-user: fix comment s/atomic_write/atomic_set/

Li Qiang (2):
  memory.h: fix typos in comments
  cpu.h: fix a typo in comment

Paolo Bonzini (1):
  ppc: move at24c to its own CONFIG_ symbol

Philippe Mathieu-Daudé (6):
  qobject: Catch another straggler for use of qdict_put_str()
  xen: Use the PCI_DEVICE macro
  tests/bios-tables-test: Remove an useless cast
  hw/pci-host: Remove useless parenthesis around DIV_ROUND_UP macro
  hw/intc/gicv3: Remove useless parenthesis around DIV_ROUND_UP macro
  milkymist-minimac2: Use qemu_log_mask(GUEST_ERROR) instead of
error_report

Stefan Weil (2):
  tests: Fix typos in comments and help message (found by codespell)
  configure: Support pkg-config for zlib

Thomas Huth (1):
  configs/alpha: Remove unused CONFIG_PARALLEL_ISA switch

yuchenlin (1):
  vga_int: remove unused function protype

 configure | 40 +++
 default-configs/alpha-softmmu.mak |  1 -
 default-configs/ppc-softmmu.mak   |  1 +
 docs/devel/testing.rst|  2 ++
 hw/display/vga_int.h  |  1 -
 hw/net/milkymist-minimac2.c   | 14 ++
 hw/nvram/Makefile.objs|  2 +-
 hw/pci-host/piix.c|  2 +-
 hw/pci-host/q35.c |  2 +-
 hw/xen/xen_pt_config_init.c   |  8 +++---
 include/exec/memory.h |  6 ++--
 include/hw/intc/arm_gicv3_common.h|  2 +-
 include/qom/cpu.h |  2 +-
 linux-user/qemu.h |  2 +-
 qobject/block-qdict.c |  2 +-
 scripts/decodetree.py |  2 --
 scripts/qemu.py   |  2 +-
 tests/bios-tables-test.c  |  4 +--
 tests/docker/Makefile.include |  2 +-
 tests/docker/docker.py|  4 +--
 tests/guest-debug/test-gdbstub.py |  2 +-
 tests/qemu-iotests/218|  0
 tests/qemu-iotests/common.qemu|  2 +-
 tests/qemu-iotests/common.rc  |  4 +--
 tests/tcg/Makefile.include|  2 +-
 tests/tcg/Makefile.probe  |  2 +-
 tests/tcg/README  |  2 +-
 tests/tcg/mips/mips64-dsp/subq_s_pw.c |  2 +-
 28 files changed, 63 insertions(+), 54 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218

-- 
2.17.2




[Qemu-devel] [PULL 20/20] ppc: move at24c to its own CONFIG_ symbol

2018-10-26 Thread Laurent Vivier
From: Paolo Bonzini 

AT24c EEPROM is currently gated by CONFIG_I2C, and as such it is
being included in all emulators that use I2C, even if they do not
really need it.  Separate it and, since it was added for the e500
machines, add it to qemu-system-ppc and qemu-system-ppc64.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Message-Id: <20180522191743.12872-1-pbonz...@redhat.com>
[lv: rebase]
Signed-off-by: Laurent Vivier 
---
 default-configs/ppc-softmmu.mak | 1 +
 hw/nvram/Makefile.objs  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index 3181bbf163..23d871fb3e 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -28,6 +28,7 @@ CONFIG_SM501=y
 CONFIG_DDC=y
 CONFIG_IDE_SII3112=y
 CONFIG_I2C=y
+CONFIG_AT24C=y
 CONFIG_BITBANG_I2C=y
 CONFIG_M41T80=y
 CONFIG_VGA_CIRRUS=y
diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs
index a912d25391..b318e53a43 100644
--- a/hw/nvram/Makefile.objs
+++ b/hw/nvram/Makefile.objs
@@ -1,6 +1,6 @@
 common-obj-$(CONFIG_DS1225Y) += ds1225y.o
 common-obj-y += eeprom93xx.o
-common-obj-$(CONFIG_I2C) += eeprom_at24c.o
+common-obj-$(CONFIG_AT24C) += eeprom_at24c.o
 common-obj-y += fw_cfg.o
 common-obj-y += chrp_nvram.o
 common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o
-- 
2.17.2




Re: [Qemu-devel] [RFC v4 57/71] accel/tcg: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  accel/tcg/cpu-exec.c  | 15 ---
>  accel/tcg/tcg-all.c   | 12 +---
>  accel/tcg/translate-all.c |  2 +-
>  3 files changed, 18 insertions(+), 11 deletions(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 04/20] tests/tcg/README: fix location for lm32 tests

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

Point to the right and obvious location for lm32 tests.

Signed-off-by: Cleber Rosa 
Reviewed-by: Thomas Huth 
Acked-by: Alex Bennée 
Message-Id: <20181004161852.11673-3-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 tests/tcg/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tcg/README b/tests/tcg/README
index a5643d33e7..2a58f9a058 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -10,6 +10,6 @@ with "make test-cris".
 
 LM32
 
-The testsuite for LM32 is in tests/tcg/cris.  You can run it
+The testsuite for LM32 is in tests/tcg/lm32.  You can run it
 with "make test-lm32".
 
-- 
2.17.2




[Qemu-devel] [PULL 03/20] memory.h: fix typos in comments

2018-10-26 Thread Laurent Vivier
From: Li Qiang 

Signed-off-by: Li Qiang 
Reviewed-by: Peter Maydell 
Message-Id: <1539080467-2976-1-git-send-email-liq...@gmail.com>
[lv: s/types/typos/]
Signed-off-by: Laurent Vivier 
---
 include/exec/memory.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 667466b8f3..d0c7f0d9e9 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -935,7 +935,7 @@ uint64_t memory_region_size(MemoryRegion *mr);
 /**
  * memory_region_is_ram: check whether a memory region is random access
  *
- * Returns %true is a memory region is random access.
+ * Returns %true if a memory region is random access.
  *
  * @mr: the memory region being queried
  */
@@ -947,7 +947,7 @@ static inline bool memory_region_is_ram(MemoryRegion *mr)
 /**
  * memory_region_is_ram_device: check whether a memory region is a ram device
  *
- * Returns %true is a memory region is a device backed ram region
+ * Returns %true if a memory region is a device backed ram region
  *
  * @mr: the memory region being queried
  */
@@ -1161,7 +1161,7 @@ uint8_t memory_region_get_dirty_log_mask(MemoryRegion 
*mr);
 /**
  * memory_region_is_rom: check whether a memory region is ROM
  *
- * Returns %true is a memory region is read-only memory.
+ * Returns %true if a memory region is read-only memory.
  *
  * @mr: the memory region being queried
  */
-- 
2.17.2




[Qemu-devel] [PULL 08/20] scripts/qemu.py: remove trailing quotes on docstring

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

Signed-off-by: Cleber Rosa 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181004161852.11673-11-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index f099ce7278..b0b2f12ce6 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -87,7 +87,7 @@ class QEMUMachine(object):
 @param name: prefix for socket and log file names (default: qemu-PID)
 @param test_dir: where to create socket and log file
 @param monitor_address: address for QMP monitor
-@param socket_scm_helper: helper program, required for send_fd_scm()"
+@param socket_scm_helper: helper program, required for send_fd_scm()
 @note: Qemu process is not started until launch() is used.
 '''
 if args is None:
-- 
2.17.2




[Qemu-devel] [PULL 14/20] qobject: Catch another straggler for use of qdict_put_str()

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h \
--dir . --in-place

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Markus Armbruster 
Acked-by: Michael S. Tsirkin 
Message-Id: <20180705155811.20366-2-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 42054cc274..1487cc5dd8 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -577,7 +577,7 @@ static QObject *qdict_crumple_for_keyval_qiv(QDict *src, 
Error **errp)
 if (!tmp) {
 tmp = qdict_clone_shallow(src);
 }
-qdict_put(tmp, ent->key, qstring_from_str(s));
+qdict_put_str(tmp, ent->key, s);
 g_free(buf);
 }
 
-- 
2.17.2




[Qemu-devel] [PULL 01/20] configs/alpha: Remove unused CONFIG_PARALLEL_ISA switch

2018-10-26 Thread Laurent Vivier
From: Thomas Huth 

We don't use CONFIG_PARALLEL_ISA in any of our Makefiles, so this
is just a dead config option which can be removed.

Fixes: a4cb773928e047b137c6998209cf2eec857fac6b
Signed-off-by: Thomas Huth 
Acked-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <1540376314-5727-1-git-send-email-th...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 default-configs/alpha-softmmu.mak | 1 -
 1 file changed, 1 deletion(-)

diff --git a/default-configs/alpha-softmmu.mak 
b/default-configs/alpha-softmmu.mak
index eb58b40254..4d654eaa0b 100644
--- a/default-configs/alpha-softmmu.mak
+++ b/default-configs/alpha-softmmu.mak
@@ -8,7 +8,6 @@ CONFIG_I82374=y
 CONFIG_I8254=y
 CONFIG_I8257=y
 CONFIG_PARALLEL=y
-CONFIG_PARALLEL_ISA=y
 CONFIG_FDC=y
 CONFIG_PCKBD=y
 CONFIG_VGA_CIRRUS=y
-- 
2.17.2




[Qemu-devel] [PULL 10/20] linux-user: fix comment s/atomic_write/atomic_set/

2018-10-26 Thread Laurent Vivier
From: "Emilio G. Cota" 

Signed-off-by: Emilio G. Cota 
Message-Id: <20180811211011.6277-1-c...@braap.org>
Signed-off-by: Laurent Vivier 
---
 linux-user/qemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 1beb6a2cfc..dde3f26f5a 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -143,7 +143,7 @@ typedef struct TaskState {
 /* Nonzero if process_pending_signals() needs to do something (either
  * handle a pending signal or unblock signals).
  * This flag is written from a signal handler so should be accessed via
- * the atomic_read() and atomic_write() functions. (It is not accessed
+ * the atomic_read() and atomic_set() functions. (It is not accessed
  * from multiple threads.)
  */
 int signal_pending;
-- 
2.17.2




[Qemu-devel] [PULL 09/20] qemu-iotests: make 218 executable

2018-10-26 Thread Laurent Vivier
From: Cleber Rosa 

Commit 990dc39c made all tests executable at the time, but 218 came in
later, and missing those permissions.

Signed-off-by: Cleber Rosa 
Message-Id: <20181004161852.11673-4-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 tests/qemu-iotests/218 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218

diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
old mode 100644
new mode 100755
-- 
2.17.2




[Qemu-devel] [PULL 15/20] xen: Use the PCI_DEVICE macro

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

TYPE_XEN_PT_DEVICE is a subclass of TYPE_PCI_DEVICE, the clean way
to access the PCIDevice pointer is using the PCI_DEVICE() macro.

Suggested-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Markus Armbruster 
Acked-by: Anthony PERARD 
Acked-by: Michael S. Tsirkin 
Message-Id: <20180705155811.20366-4-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 hw/xen/xen_pt_config_init.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index aee31c62bb..47f9010c75 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -358,7 +358,7 @@ static uint64_t xen_pt_get_bar_size(PCIIORegion *r)
 static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
  int index)
 {
-PCIDevice *d = >dev;
+PCIDevice *d = PCI_DEVICE(s);
 XenPTRegion *region = NULL;
 PCIIORegion *r;
 
@@ -469,7 +469,7 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, 
XenPTReg *cfg_entry,
 {
 XenPTRegInfo *reg = cfg_entry->reg;
 XenPTRegion *base = NULL;
-PCIDevice *d = >dev;
+PCIDevice *d = PCI_DEVICE(s);
 const PCIIORegion *r;
 uint32_t writable_mask = 0;
 uint32_t bar_emu_mask = 0;
@@ -543,7 +543,7 @@ static int 
xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
 {
 XenPTRegInfo *reg = cfg_entry->reg;
 XenPTRegion *base = NULL;
-PCIDevice *d = (PCIDevice *)>dev;
+PCIDevice *d = PCI_DEVICE(s);
 uint32_t writable_mask = 0;
 uint32_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
 pcibus_t r_size = 0;
@@ -1587,7 +1587,7 @@ static int xen_pt_pcie_size_init(XenPCIPassthroughState 
*s,
  const XenPTRegGroupInfo *grp_reg,
  uint32_t base_offset, uint8_t *size)
 {
-PCIDevice *d = >dev;
+PCIDevice *d = PCI_DEVICE(s);
 uint8_t version = get_capability_version(s, base_offset);
 uint8_t type = get_device_type(s, base_offset);
 uint8_t pcie_size = 0;
-- 
2.17.2




Re: [Qemu-devel] [RFC v4 48/71] mips: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Cc: Aurelien Jarno 
> Cc: Aleksandar Markovic 
> Cc: James Hogan 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/mips/cpu.c | 7 ---
>  target/mips/kvm.c | 2 +-
>  2 files changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson 

r~





[Qemu-devel] [PULL 17/20] hw/pci-host: Remove useless parenthesis around DIV_ROUND_UP macro

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/round.cocci \
--macro-file scripts/cocci-macro-file.h \
--dir . --in-place

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Markus Armbruster 
Acked-by: Michael S. Tsirkin 
Message-Id: <20180705155811.20366-7-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 hw/pci-host/piix.c | 2 +-
 hw/pci-host/q35.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index da73743fa2..47293a3915 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -144,7 +144,7 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)
 memory_region_transaction_begin();
 for (i = 0; i < 13; i++) {
 pam_update(>pam_regions[i], i,
-   pd->config[I440FX_PAM + (DIV_ROUND_UP(i, 2))]);
+   pd->config[I440FX_PAM + DIV_ROUND_UP(i, 2)]);
 }
 memory_region_set_enabled(>smram_region,
   !(pd->config[I440FX_SMRAM] & SMRAM_D_OPEN));
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 8ce1e09932..966a7cf92d 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -356,7 +356,7 @@ static void mch_update_pam(MCHPCIState *mch)
 memory_region_transaction_begin();
 for (i = 0; i < 13; i++) {
 pam_update(>pam_regions[i], i,
-   pd->config[MCH_HOST_BRIDGE_PAM0 + (DIV_ROUND_UP(i, 2))]);
+   pd->config[MCH_HOST_BRIDGE_PAM0 + DIV_ROUND_UP(i, 2)]);
 }
 memory_region_transaction_commit();
 }
-- 
2.17.2




[Qemu-devel] [PULL 13/20] configure: Support pkg-config for zlib

2018-10-26 Thread Laurent Vivier
From: Stefan Weil 

This is needed for builds with the mingw64-* packages from Cygwin,
but also works for Linux.

Move the zlib test also more to the end because users should
get information on the really important missing packages
(which also require zlib) first.

Signed-off-by: Stefan Weil 
Reviewed-by: Stefan Hajnoczi 
Message-Id: <20180712192603.11599-1...@weilnetz.de>
Signed-off-by: Laurent Vivier 
---
 configure | 40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/configure b/configure
index 1ee09bd112..a02df30dde 100755
--- a/configure
+++ b/configure
@@ -2151,23 +2151,6 @@ EOF
   fi
 fi
 
-#
-# zlib check
-
-if test "$zlib" != "no" ; then
-cat > $TMPC << EOF
-#include 
-int main(void) { zlibVersion(); return 0; }
-EOF
-if compile_prog "" "-lz" ; then
-:
-else
-error_exit "zlib check failed" \
-"Make sure to have the zlib libs and headers installed."
-fi
-fi
-LIBS="$LIBS -lz"
-
 ##
 # lzo check
 
@@ -3479,6 +3462,29 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; 
then
 fi
 fi
 
+#
+# zlib check
+
+if test "$zlib" != "no" ; then
+if $pkg_config --exists zlib; then
+zlib_cflags=$($pkg_config --cflags zlib)
+zlib_libs=$($pkg_config --libs zlib)
+QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
+LIBS="$zlib_libs $LIBS"
+else
+cat > $TMPC << EOF
+#include 
+int main(void) { zlibVersion(); return 0; }
+EOF
+if compile_prog "" "-lz" ; then
+LIBS="$LIBS -lz"
+else
+error_exit "zlib check failed" \
+"Make sure to have the zlib libs and headers installed."
+fi
+fi
+fi
+
 ##
 # SHA command probe for modules
 if test "$modules" = yes; then
-- 
2.17.2




[Qemu-devel] [PULL 18/20] hw/intc/gicv3: Remove useless parenthesis around DIV_ROUND_UP macro

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/round.cocci \
--macro-file scripts/cocci-macro-file.h \
--dir . --in-place

Signed-off-by: Philippe Mathieu-Daudé 
Acked-by: Michael S. Tsirkin 
Message-Id: <20180705155811.20366-8-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 include/hw/intc/arm_gicv3_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/intc/arm_gicv3_common.h 
b/include/hw/intc/arm_gicv3_common.h
index b798486ecf..31ec9a1ae4 100644
--- a/include/hw/intc/arm_gicv3_common.h
+++ b/include/hw/intc/arm_gicv3_common.h
@@ -62,7 +62,7 @@
  * avoids bugs where we forget to subtract GIC_INTERNAL from an
  * interrupt number.
  */
-#define GICV3_BMP_SIZE (DIV_ROUND_UP(GICV3_MAXIRQ, 32))
+#define GICV3_BMP_SIZE DIV_ROUND_UP(GICV3_MAXIRQ, 32)
 
 #define GIC_DECLARE_BITMAP(name) \
 uint32_t name[GICV3_BMP_SIZE]
-- 
2.17.2




[Qemu-devel] [PULL 02/20] vga_int: remove unused function protype

2018-10-26 Thread Laurent Vivier
From: yuchenlin 

Signed-off-by: yuchenlin 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181022080053.9379-1-yuchen...@synology.com>
Signed-off-by: Laurent Vivier 
---
 hw/display/vga_int.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 6e4fa48a79..55c418eab5 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -166,7 +166,6 @@ MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,
   const MemoryRegionPortio **vbe_ports);
 void vga_common_reset(VGACommonState *s);
 
-void vga_sync_dirty_bitmap(VGACommonState *s);
 void vga_dirty_log_start(VGACommonState *s);
 void vga_dirty_log_stop(VGACommonState *s);
 
-- 
2.17.2




[Qemu-devel] [PULL 16/20] tests/bios-tables-test: Remove an useless cast

2018-10-26 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/typecast.cocci \
--macro-file scripts/cocci-macro-file.h \
--dir . --in-place

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Markus Armbruster 
Acked-by: Michael S. Tsirkin 
Message-Id: <20180705155811.20366-5-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 tests/bios-tables-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index af4b1fb6bd..02e77ec811 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -319,7 +319,7 @@ static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
 ret = g_spawn_command_line_sync(command_line->str, , _err, NULL, 
);
 g_assert_no_error(error);
 if (ret) {
-ret = g_file_get_contents(sdt->asl_file, (gchar **)>asl,
+ret = g_file_get_contents(sdt->asl_file, >asl,
   >asl_len, );
 g_assert(ret);
 g_assert_no_error(error);
-- 
2.17.2




Re: [Qemu-devel] [PATCH 1/1] hostmem-file: remove the invalid pmem object id.

2018-10-26 Thread Eduardo Habkost
On Wed, Oct 24, 2018 at 10:14:56PM +0800, Zhang Yi wrote:
> We will never get the canonical path from the object
> before object_property_add_child.
> 
> Signed-off-by: Zhang Yi 

Thanks.  I'm queueing it on machine-next, after rewriting the
subject line as:

  hostmem-file: remove object id from pmem error message

-- 
Eduardo



Re: [Qemu-devel] [RFC v4 42/71] ppc: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Cc: David Gibson 
> Cc: Alexander Graf 
> Cc: qemu-...@nongnu.org
> Signed-off-by: Emilio G. Cota 
> ---
>  hw/ppc/ppc.c|  2 +-
>  target/ppc/excp_helper.c|  2 +-
>  target/ppc/kvm.c|  4 ++--
>  target/ppc/translate_init.inc.c | 14 +++---
>  4 files changed, 11 insertions(+), 11 deletions(-)

Reviewed-by: Richard Henderson 

r~




[Qemu-devel] [PULL 12/20] tests: Fix typos in comments and help message (found by codespell)

2018-10-26 Thread Laurent Vivier
From: Stefan Weil 

Fix also a grammar issue.

Signed-off-by: Stefan Weil 
Reviewed-by: Alex Bennée 
Message-Id: <20180713054755.23323-1...@weilnetz.de>
Signed-off-by: Laurent Vivier 
---
 tests/bios-tables-test.c  | 2 +-
 tests/docker/Makefile.include | 2 +-
 tests/docker/docker.py| 4 ++--
 tests/guest-debug/test-gdbstub.py | 2 +-
 tests/qemu-iotests/common.qemu| 2 +-
 tests/tcg/Makefile.include| 2 +-
 tests/tcg/Makefile.probe  | 2 +-
 tests/tcg/mips/mips64-dsp/subq_s_pw.c | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 4e24930c4b..af4b1fb6bd 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -390,7 +390,7 @@ try_again:
 if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
 exp_sdt.aml_file = aml_file;
 } else if (*ext != '\0') {
-/* try fallback to generic (extention less) expected file */
+/* try fallback to generic (extension less) expected file */
 ext = "";
 g_free(aml_file);
 goto try_again;
diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 6e03235ab9..9467e9d088 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -41,7 +41,7 @@ docker-qemu-src: $(DOCKER_SRC_COPY)
 docker-image: ${DOCKER_TARGETS}
 
 # General rule for building docker images. If we are a sub-make
-# invoked with SKIP_DOCKER_BUILD we still check the image is upto date
+# invoked with SKIP_DOCKER_BUILD we still check the image is up to date
 # though
 ifdef SKIP_DOCKER_BUILD
 docker-image-%: $(DOCKER_FILES_DIR)/%.docker
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 44d5f7493b..02d8a83847 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -97,7 +97,7 @@ def _get_so_libs(executable):
 return libs
 
 def _copy_binary_with_libs(src, dest_dir):
-"""Copy a binary executable and all its dependant libraries.
+"""Copy a binary executable and all its dependent libraries.
 
 This does rely on the host file-system being fairly multi-arch
 aware so the file don't clash with the guests layout."""
@@ -284,7 +284,7 @@ class SubCommand(object):
 name = None # Subcommand name
 def shared_args(self, parser):
 parser.add_argument("--quiet", action="store_true",
-help="Run quietly unless an error occured")
+help="Run quietly unless an error occurred")
 
 def args(self, parser):
 """Setup argument parser"""
diff --git a/tests/guest-debug/test-gdbstub.py 
b/tests/guest-debug/test-gdbstub.py
index 474d2c5c65..0e4ac01426 100644
--- a/tests/guest-debug/test-gdbstub.py
+++ b/tests/guest-debug/test-gdbstub.py
@@ -122,7 +122,7 @@ class CatchBreakpoint(gdb.Breakpoint):
 
 
 def run_test():
-"Run throught the tests one by one"
+"Run through the tests one by one"
 
 print ("Checking we can step the first few instructions")
 step_ok = 0
diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu
index f285484951..dadde2a266 100644
--- a/tests/qemu-iotests/common.qemu
+++ b/tests/qemu-iotests/common.qemu
@@ -257,7 +257,7 @@ function _launch_qemu()
 }
 
 
-# Silenty kills the QEMU process
+# Silently kills the QEMU process
 #
 # If $wait is set to anything other than the empty string, the process will not
 # be killed but only waited for, and any output will be forwarded to stdout. If
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
index 57470b2a2c..c581bd6ffc 100644
--- a/tests/tcg/Makefile.include
+++ b/tests/tcg/Makefile.include
@@ -2,7 +2,7 @@
 #
 # TCG tests (per-target rules)
 #
-# This Makefile fragement is included from the per-target
+# This Makefile fragment is included from the per-target
 # Makefile.target so will be invoked for each linux-user program we
 # build. We have two options for compiling, either using a configured
 # guest compiler or calling one of our docker images to do it for us.
diff --git a/tests/tcg/Makefile.probe b/tests/tcg/Makefile.probe
index 15c0412657..9dc654663d 100644
--- a/tests/tcg/Makefile.probe
+++ b/tests/tcg/Makefile.probe
@@ -2,7 +2,7 @@
 #
 # TCG Compiler Probe
 #
-# This Makefile fragement is included multiple times in the main make
+# This Makefile fragment is included multiple times in the main make
 # script to probe for available compilers. This is used to build up a
 # selection of required docker targets before we invoke a sub-make for
 # each target.
diff --git a/tests/tcg/mips/mips64-dsp/subq_s_pw.c 
b/tests/tcg/mips/mips64-dsp/subq_s_pw.c
index e8e0b0567e..4c080b785a 100644
--- a/tests/tcg/mips/mips64-dsp/subq_s_pw.c
+++ b/tests/tcg/mips/mips64-dsp/subq_s_pw.c
@@ -24,7 +24,7 @@ int main(void)
 rt = 0x123456789ABCDEF1;
 rs = 0x123456789ABCDEF2;
 result =  0x0001;
-/* This time we do 

Re: [Qemu-devel] [PATCH v2 02/29] targer/riscv: Activate decodetree and implemnt LUI & AUIPC

2018-10-26 Thread Palmer Dabbelt

On Fri, 26 Oct 2018 07:53:17 PDT (-0700), Bastian Koppelmann wrote:


On 10/26/18 3:58 PM, Richard Henderson wrote:

On 10/26/18 11:49 AM, Bastian Koppelmann wrote:

I think you can pick up everything up to the RVC conversion which still needs
the work suggested by Richard. Thanks, for picking it up :)

Even then I thought we were talking about splitting the RV64 insns
into a separate file, reducing the ifdefs, and renaming the arg-sets
to match the instruction formats described in the riscv spec.



Yes, you are right I forgot that.


OK, so I think I'll hold off for a v3, then.



Re: [Qemu-devel] [PATCH 00/10] Trivial fixes and clean ups

2018-10-26 Thread Eduardo Habkost
On Thu, Oct 04, 2018 at 12:18:42PM -0400, Cleber Rosa wrote:
> Just a collection of trivial fixes and clean ups that have been lying
> around here for some time.

I'm queueing patches 07-10 on python-next.  I'm aware that
Laurent already queued some of them (thanks!), but I want to
avoid conflicts in case other patches touching these modules are
queued on python-next.

-- 
Eduardo



Re: [Qemu-devel] [Qemu-block] [PATCH 09/10] scripts/qemu.py: use a more consistent docstring style

2018-10-26 Thread Eduardo Habkost
On Mon, Oct 08, 2018 at 03:44:14PM -0400, John Snow wrote:
> 
> 
> On 10/04/2018 12:18 PM, Cleber Rosa wrote:
> > Signed-off-by: Cleber Rosa 
> > ---
> >  dtc |  2 +-
> >  scripts/qemu.py | 65 +++--
> >  2 files changed, 42 insertions(+), 25 deletions(-)
> > 
> > diff --git a/dtc b/dtc
> > index 88f18909db..e54388015a 16
> > --- a/dtc
> > +++ b/dtc
> > @@ -1 +1 @@
> > -Subproject commit 88f18909db731a627456f26d779445f84e449536
> > +Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
> > diff --git a/scripts/qemu.py b/scripts/qemu.py
> > index f099ce7278..7abe26de69 100644
> > --- a/scripts/qemu.py
> > +++ b/scripts/qemu.py
> > @@ -53,9 +53,9 @@ class QEMUMachineAddDeviceError(QEMUMachineError):
> >  """
> >  
> >  class MonitorResponseError(qmp.qmp.QMPError):
> > -'''
> > +"""
> >  Represents erroneous QMP monitor reply
> > -'''
> > +"""
> 
> This seems obviously correct, as per the Python Dogma Handbook ...
> 
[...]
> >  def add_fd(self, fd, fdset, opaque, opts=''):
> > -'''Pass a file descriptor to the VM'''
> > +"""
> > +Pass a file descriptor to the VM
> > +"""
> 
> However, is it established practice among ne'er-do-wells to format
> one-line docstrings as three-liners? (And without punctuation to boot --
> for shame!)
> 
> PEP257 suggests that one-liners are allowed, but doesn't seem to
> necessitate their usage. Does this kind of change have any kind of benefit?

I don't mind having one-line docstrings.  But if we're already
touching multiple docstrings, consistency with the rest of the
module code sounds nice.

I'm queueing this on python-next.

-- 
Eduardo



Re: [Qemu-devel] [PATCH RFC 0/2] Fix migration issues

2018-10-26 Thread Dr. David Alan Gilbert
* Peter Xu (pet...@redhat.com) wrote:
> On Fri, Oct 26, 2018 at 09:10:19PM +0800, Fei Li wrote:
> > 
> > 
> > On 10/25/2018 08:58 PM, Peter Xu wrote:
> > > On Thu, Oct 25, 2018 at 05:04:00PM +0800, Fei Li wrote:
> > > 
> > > [...]
> > > 
> > > > @@ -1325,22 +1325,24 @@ bool multifd_recv_all_channels_created(void)
> > > >   /* Return true if multifd is ready for the migration, otherwise false 
> > > > */
> > > >   bool multifd_recv_new_channel(QIOChannel *ioc)
> > > >   {
> > > > +    MigrationIncomingState *mis = migration_incoming_get_current();
> > > >   MultiFDRecvParams *p;
> > > >   Error *local_err = NULL;
> > > >   int id;
> > > > 
> > > >   id = multifd_recv_initial_packet(ioc, _err);
> > > >   if (id < 0) {
> > > > -    multifd_recv_terminate_threads(local_err);
> > > > -    return false;
> > > > +    error_reportf_err(local_err,
> > > > +  "failed to receive packet via multifd 
> > > > channel %x:
> > > > ",
> > > > +  multifd_recv_state->count);
> > > > +    goto fail;
> > > >   }
> > > > 
> > > >   p = _recv_state->params[id];
> > > >   if (p->c != NULL) {
> > > >   error_setg(_err, "multifd: received id '%d' already 
> > > > setup'",
> > > >      id);
> > > > -    multifd_recv_terminate_threads(local_err);
> > > > -    return false;
> > > > +    goto fail;
> > > >   }
> > > >   p->c = ioc;
> > > >   object_ref(OBJECT(ioc));
> > > > @@ -1352,6 +1354,11 @@ bool multifd_recv_new_channel(QIOChannel *ioc)
> > > >      QEMU_THREAD_JOINABLE);
> > > >   atomic_inc(_recv_state->count);
> > > >   return multifd_recv_state->count == migrate_multifd_channels();
> > > > +fail:
> > > > +    multifd_recv_terminate_threads(local_err);
> > > > +    qemu_fclose(mis->from_src_file);
> > > > +    mis->from_src_file = NULL;
> > > > +    exit(EXIT_FAILURE);
> > > >   }
> > > Yeah I think it makes sense to at least report some details when error
> > > happens, but I'm not sure whether it's good to explicitly exit() here.
> > > IMHO you can add an Error** in multifd_recv_new_channel() parameter
> > > list to do that, and even through migration_ioc_process_incoming().
> > > What do you think?
> > > 
> > > Regards,
> > > 
> > You mean exit() in migration_ioc_process_incoming(), or further
> > caller migration_channel_process_incoming()? Actually either is
> > ok for me. :) But today I find if using postcopy and multifd together
> > to do live migration, it seems the hang still occurs even with the
> > above codes, so sad about that. I will keep debugging and see
> > how to fix this.
> 
> Maybe you can move the error_report_err() in
> migration_channel_process_incoming() out of the TLS path so we can
> report the error if either TLS or non-TLS case got something wrong.
> 
> And I don't even know whether multifd could work with postcopy...

Nope, it's not expected to work yet.

Dave

> Regards,
> 
> -- 
> Peter Xu
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] [PATCH v7 0/3] Bootstrap Python venv and acceptance/functional tests

2018-10-26 Thread Eduardo Habkost
On Thu, Oct 18, 2018 at 11:31:31AM -0400, Cleber Rosa wrote:
> TL;DR
> =
> 
> Allow acceptance tests to be run with `make check-acceptance`.

Queued on python-next, thanks!

-- 
Eduardo



Re: [Qemu-devel] [RFC v4 41/71] i386/hvf: convert to cpu_request_interrupt

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/i386/hvf/hvf.c|  8 +---
>  target/i386/hvf/x86hvf.c | 26 +++---
>  2 files changed, 20 insertions(+), 14 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [PATCH 1/9] qom/user-creatable: add a few helper macros

2018-10-26 Thread Eduardo Habkost
On Mon, Oct 22, 2018 at 03:33:30PM +0100, Igor Mammedov wrote:
> On Wed, 12 Sep 2018 16:55:23 +0400
> Marc-André Lureau  wrote:
> 
> > Improve a bit code readability.
> > 
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  include/qom/object_interfaces.h | 4 
> >  qom/object.c| 4 ++--
> >  qom/object_interfaces.c | 9 +++--
> >  3 files changed, 9 insertions(+), 8 deletions(-)
> > 
> > diff --git a/include/qom/object_interfaces.h 
> > b/include/qom/object_interfaces.h
> > index 4d513fb329..46b0861457 100644
> > --- a/include/qom/object_interfaces.h
> > +++ b/include/qom/object_interfaces.h
> > @@ -9,9 +9,13 @@
> >  #define USER_CREATABLE_CLASS(klass) \
> >   OBJECT_CLASS_CHECK(UserCreatableClass, (klass), \
> >  TYPE_USER_CREATABLE)
> > +#define IS_USER_CREATABLE_CLASS(klass) \
> > +object_class_dynamic_cast(OBJECT_CLASS(oc), TYPE_USER_CREATABLE)
> >  #define USER_CREATABLE_GET_CLASS(obj) \
> >   OBJECT_GET_CLASS(UserCreatableClass, (obj), \
> >TYPE_USER_CREATABLE)
> > +#define IS_USER_CREATABLE(obj) \
> > +object_dynamic_cast(OBJECT(obj), TYPE_USER_CREATABLE)
> >  #define USER_CREATABLE(obj) \
> >   INTERFACE_CHECK(UserCreatable, (obj), \
> >   TYPE_USER_CREATABLE)
> > diff --git a/qom/object.c b/qom/object.c
> > index 75d1d48944..0703e8e4ff 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -424,7 +424,7 @@ void object_initialize_childv(Object *parentobj, const 
> > char *propname,
> >  goto out;
> >  }
> >  
> > -if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> > +if (IS_USER_CREATABLE(obj)) {
> >  user_creatable_complete(obj, _err);
> >  if (local_err) {
> >  object_unparent(obj);
> > @@ -605,7 +605,7 @@ Object *object_new_with_propv(const char *typename,
> >  goto error;
> >  }
> >  
> > -if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> > +if (IS_USER_CREATABLE(obj)) {
> >  user_creatable_complete(obj, _err);
> >  if (local_err) {
> >  object_unparent(obj);
> > diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> > index 72b97a8bed..e3084bc04a 100644
> > --- a/qom/object_interfaces.c
> > +++ b/qom/object_interfaces.c
> > @@ -10,18 +10,15 @@
> >  
> >  void user_creatable_complete(Object *obj, Error **errp)
> >  {
> > -
> >  UserCreatableClass *ucc;
> > -UserCreatable *uc =
> > -(UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> >  
> > -if (!uc) {
> > +if (!IS_USER_CREATABLE(obj)) {
> >  return;
> >  }
> >  
> > -ucc = USER_CREATABLE_GET_CLASS(uc);
> > +ucc = USER_CREATABLE_GET_CLASS(obj);
> >  if (ucc->complete) {
> > -ucc->complete(uc, errp);
> > +ucc->complete(USER_CREATABLE(obj), errp);
>  ^^^
> even though function becomes more concise,
> this will call expensive dynamic cast 2nd time (IS_USER_CREATABLE was the 1st 
> and discarded)
> so I'm not sure is a good idea to regress startup time for readability. 

(INTERFACE_CHECK is a nop if CONFIG_QOM_CAST_DEBUG is not
enabled, so I don't understand how it would regress startup time.

-- 
Eduardo



Re: [Qemu-devel] [RFC v4 40/71] i386/whpx-all: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/i386/whpx-all.c | 41 -
>  1 file changed, 24 insertions(+), 17 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 39/71] i386/hax-all: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/i386/hax-all.c | 30 +-
>  1 file changed, 17 insertions(+), 13 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 38/71] i386/kvm: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/i386/kvm.c | 54 +++
>  1 file changed, 31 insertions(+), 23 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 32/71] exec: use cpu_reset_interrupt

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  exec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 37/71] i386: convert to cpu_interrupt_request

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/i386/cpu.c| 2 +-
>  target/i386/helper.c | 4 ++--
>  target/i386/svm_helper.c | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 30/71] cpu: define cpu_interrupt_request helpers

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Add a comment about how atomic_read works here. The comment refers to
> a "BQL-less CPU loop", which will materialize toward the end
> of this series.
> 
> Note that the modifications to cpu_reset_interrupt are there to
> avoid deadlock during the CPU lock transition; once that is complete,
> cpu_interrupt_request will be simple again.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h | 37 +
>  qom/cpu.c | 27 +--
>  2 files changed, 58 insertions(+), 6 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 23/71] riscv: convert to cpu_halted

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Cc: Michael Clark 
> Cc: Palmer Dabbelt 
> Cc: Sagar Karandikar 
> Cc: Bastian Koppelmann 
> Cc: Alistair Francis 
> Reviewed-by: Palmer Dabbelt 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/riscv/op_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 29/71] cpu-exec: convert to cpu_halted

2018-10-26 Thread Richard Henderson
On 10/25/18 3:46 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  accel/tcg/cpu-exec.c | 24 
>  1 file changed, 20 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 13/71] microblaze: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Cc: "Edgar E. Iglesias" 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/microblaze/translate.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 15/71] tcg-runtime: convert to cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  accel/tcg/tcg-runtime.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 17/71] ppc: convert to cpu_halted

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> In ppce500_spin.c, acquire the lock just once to update
> both cpu->halted and cpu->stopped.
> 
> In hw/ppc/spapr_hcall.c, acquire the lock just once to
> update cpu->halted and call cpu_has_work, since later
> in the series we'll acquire the BQL (if not already held)
> from cpu_has_work.
> 
> Cc: David Gibson 
> Cc: Alexander Graf 
> Cc: qemu-...@nongnu.org
> Signed-off-by: Emilio G. Cota 
> ---

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 11/71] m68k: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Cc: Laurent Vivier 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/m68k/translate.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson 

r~



Re: [Qemu-devel] [RFC v4 12/71] alpha: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/alpha/translate.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson 

r~




Re: [Qemu-devel] [RFC v4 10/71] hppa: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota 
> ---
>  target/hppa/translate.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson 

r~



Re: [Qemu-devel] [RFC v4 08/71] ppc: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> Cc: David Gibson 
> Cc: Alexander Graf 
> Cc: qemu-...@nongnu.org
> Signed-off-by: Emilio G. Cota 
> ---
>  target/ppc/translate.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson 


r~



Re: [Qemu-devel] [RFC v4 09/71] cris: convert to helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> And fix the temp leak along the way.
> 
> Cc: "Edgar E. Iglesias" 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/cris/translate.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson 


r~



Re: [Qemu-devel] [RFC v4 07/71] tcg-runtime: define helper_cpu_halted_set

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> +void HELPER(cpu_halted_set)(CPUArchState *env, uint32_t val)
> +{
> +CPUState *cpu = ENV_GET_CPU(env);
> +
> +cpu->halted = val;
> +}

I suppose this is fine as a first step.  I'd like to clean up all of the
targets to also use a helper like this to also raise EXCP_HALTED.  They all
perform the same actions, even though this isn't obvious (many of them
reuse helpers that also raise target-specific exceptions).

That said,
Reviewed-by: Richard Henderson 

r~



Re: [Qemu-devel] [PATCH v2 02/29] targer/riscv: Activate decodetree and implemnt LUI & AUIPC

2018-10-26 Thread Bastian Koppelmann



On 10/26/18 3:58 PM, Richard Henderson wrote:

On 10/26/18 11:49 AM, Bastian Koppelmann wrote:

I think you can pick up everything up to the RVC conversion which still needs
the work suggested by Richard. Thanks, for picking it up :)

Even then I thought we were talking about splitting the RV64 insns
into a separate file, reducing the ifdefs, and renaming the arg-sets
to match the instruction formats described in the riscv spec.



Yes, you are right I forgot that.

Cheers,

Bastian




Re: [Qemu-devel] [RFC v4 04/71] cpu: make qemu_work_cond per-cpu

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> This eliminates the need to use the BQL to queue CPU work.
> 
> While at it, give the per-cpu field a generic name ("cond") since
> it will soon be used for more than just queueing CPU work.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h |  6 ++--
>  cpus-common.c | 72 ++-
>  cpus.c|  2 +-
>  qom/cpu.c |  1 +
>  4 files changed, 63 insertions(+), 18 deletions(-)

Reviewed-by: Richard Henderson 


r~




Re: [Qemu-devel] [RFC v4 03/71] cpu: introduce cpu_mutex_lock/unlock

2018-10-26 Thread Richard Henderson
On 10/25/18 3:45 PM, Emilio G. Cota wrote:
> The few direct users of >lock will be converted soon.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  include/qom/cpu.h   | 33 +++
>  cpus.c  | 48 +++--
>  stubs/cpu-lock.c| 20 +++
>  stubs/Makefile.objs |  1 +
>  4 files changed, 100 insertions(+), 2 deletions(-)
>  create mode 100644 stubs/cpu-lock.c

Reviewed-by: Richard Henderson 


r~



[Qemu-devel] [PATCH 1/6] Define MIPS_ABI_FP_UNKNOWN macro

2018-10-26 Thread Stefan Markovic
From: Stefan Markovic 

Signed-off-by: Stefan Markovic 
---
 include/elf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/elf.h b/include/elf.h
index 5f45f9b..c151164 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -87,6 +87,8 @@ typedef int64_t  Elf64_Sxword;
 #define EF_MIPS_MACH_LS3A 0x00a2  /* ST Microelectronics Loongson 3A */
 #define EF_MIPS_MACH  0x00ff  /* EF_MIPS_MACH_xxx selection mask */
 
+#define MIPS_ABI_FP_UNKNOWN   (-1)/* Unknown FP ABI (internal)   */
+
 #define MIPS_ABI_FP_ANY   0x0 /* FP ABI doesn't matter   */
 #define MIPS_ABI_FP_DOUBLE0x1 /* -mdouble-float  */
 #define MIPS_ABI_FP_SINGLE0x2 /* -msingle-float  */
-- 
1.9.1




[Qemu-devel] [PATCH 6/6] Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE implementations

2018-10-26 Thread Stefan Markovic
From: Stefan Markovic 

Signed-off-by: Stefan Markovic 
---
 linux-user/mips/target_syscall.h   |  2 ++
 linux-user/mips64/target_syscall.h |  2 ++
 linux-user/syscall.c   | 62 +++---
 3 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/linux-user/mips/target_syscall.h b/linux-user/mips/target_syscall.h
index 33177af..fa075c9 100644
--- a/linux-user/mips/target_syscall.h
+++ b/linux-user/mips/target_syscall.h
@@ -247,5 +247,7 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env)
 /* MIPS-specific prctl() options */
 #define TARGET_PR_SET_FP_MODE  45
 #define TARGET_PR_GET_FP_MODE  46
+#define TARGET_PR_FP_MODE_FR  (1 << 0)
+#define TARGET_PR_FP_MODE_FRE (1 << 1)
 
 #endif /* MIPS_TARGET_SYSCALL_H */
diff --git a/linux-user/mips64/target_syscall.h 
b/linux-user/mips64/target_syscall.h
index c1160e6..c8a9027 100644
--- a/linux-user/mips64/target_syscall.h
+++ b/linux-user/mips64/target_syscall.h
@@ -244,5 +244,7 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env)
 /* MIPS-specific prctl() options */
 #define TARGET_PR_SET_FP_MODE  45
 #define TARGET_PR_GET_FP_MODE  46
+#define TARGET_PR_FP_MODE_FR  (1 << 0)
+#define TARGET_PR_FP_MODE_FRE (1 << 1)
 
 #endif /* MIPS64_TARGET_SYSCALL_H */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 15b03e1..810a58b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9529,11 +9529,65 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
 #endif
 #ifdef TARGET_MIPS
 case TARGET_PR_GET_FP_MODE:
-/* TODO: Implement TARGET_PR_SET_FP_MODE handling.*/
-return -TARGET_EINVAL;
+{
+CPUMIPSState *env = ((CPUMIPSState *)cpu_env);
+ret = 0;
+if (env->CP0_Status & (1 << CP0St_FR)) {
+ret |= TARGET_PR_FP_MODE_FR;
+}
+if (env->CP0_Config5 & (1 << CP0C5_FRE)) {
+ret |= TARGET_PR_FP_MODE_FRE;
+}
+return ret;
+}
 case TARGET_PR_SET_FP_MODE:
-/* TODO: Implement TARGET_PR_GET_FP_MODE handling.*/
-return -TARGET_EINVAL;
+{
+CPUMIPSState *env = ((CPUMIPSState *)cpu_env);
+bool old_fr = env->CP0_Status & (1 << CP0St_FR);
+bool new_fr = arg2 & TARGET_PR_FP_MODE_FR;
+bool new_fre = arg2 & TARGET_PR_FP_MODE_FRE;
+
+if (new_fr && !(env->active_fpu.fcr0 & (1 << FCR0_F64))) {
+/* FR1 is not supported */
+return -TARGET_EOPNOTSUPP;
+}
+if (!new_fr && (env->active_fpu.fcr0 & (1 << FCR0_F64))
+&& !(env->CP0_Status_rw_bitmask & (1 << CP0St_FR))) {
+/* cannot set FR=0 */
+return -TARGET_EOPNOTSUPP;
+}
+if (new_fre && !(env->active_fpu.fcr0 & (1 << FCR0_FREP))) {
+/* Cannot set FRE=1 */
+return -TARGET_EOPNOTSUPP;
+}
+
+int i;
+fpr_t *fpr = env->active_fpu.fpr;
+for (i = 0; i < 32 ; i += 2) {
+if (!old_fr && new_fr) {
+fpr[i].w[!FP_ENDIAN_IDX] = fpr[i + 1].w[FP_ENDIAN_IDX];
+} else if (old_fr && !new_fr) {
+fpr[i + 1].w[FP_ENDIAN_IDX] = fpr[i].w[!FP_ENDIAN_IDX];
+}
+}
+
+if (new_fr) {
+env->CP0_Status |= (1 << CP0St_FR);
+env->hflags |= MIPS_HFLAG_F64;
+} else {
+env->CP0_Status &= ~(1 << CP0St_FR);
+}
+if (new_fre) {
+env->CP0_Config5 |= (1 << CP0C5_FRE);
+if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) {
+env->hflags |= MIPS_HFLAG_FRE;
+}
+} else {
+env->CP0_Config5 &= ~(1 << CP0C5_FRE);
+}
+
+return 0;
+}
 #endif /* MIPS */
 #ifdef TARGET_AARCH64
 case TARGET_PR_SVE_SET_VL:
-- 
1.9.1




  1   2   3   >